Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: pkg/analyzer_cli/lib/src/driver.dart

Issue 2857203002: Make the exit code for dartanalyzer more deterministic. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_cli/lib/src/build_mode.dart ('k') | pkg/analyzer_cli/lib/src/error_formatter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/driver.dart
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart
index 5c34be4c25570b7071d0f595db5fc77ef1b8cafb..fd19cdb23f02f647fb47b409202ada948e31f80d 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -130,8 +130,8 @@ class Driver implements CommandLineStarter {
// Do analysis.
if (options.buildMode) {
ErrorSeverity severity = _buildModeAnalyze(options);
- // In case of error propagate exit code.
- if (severity == ErrorSeverity.ERROR) {
+ // Propagate issues to the exit code.
+ if (_shouldBeFatal(severity, options)) {
io.exitCode = severity.ordinal;
}
} else if (options.shouldBatch) {
@@ -142,8 +142,8 @@ class Driver implements CommandLineStarter {
});
} else {
ErrorSeverity severity = await _analyzeAll(options);
- // In case of error propagate exit code.
- if (severity == ErrorSeverity.ERROR) {
+ // Propagate issues to the exit code.
+ if (_shouldBeFatal(severity, options)) {
io.exitCode = severity.ordinal;
}
}
@@ -713,19 +713,12 @@ class Driver implements CommandLineStarter {
}
/// Analyze a single source.
- Future<ErrorSeverity> _runAnalyzer(Source source, CommandLineOptions options,
- ErrorFormatter formatter) async {
+ Future<ErrorSeverity> _runAnalyzer(
+ Source source, CommandLineOptions options, ErrorFormatter formatter) {
int startTime = currentTimeMillis;
AnalyzerImpl analyzer = new AnalyzerImpl(_context.analysisOptions, _context,
analysisDriver, source, options, stats, startTime);
- ErrorSeverity errorSeverity = await analyzer.analyze(formatter);
- if (errorSeverity == ErrorSeverity.ERROR) {
- io.exitCode = errorSeverity.ordinal;
- }
- if (options.warningsAreFatal && errorSeverity == ErrorSeverity.WARNING) {
- io.exitCode = errorSeverity.ordinal;
- }
- return errorSeverity;
+ return analyzer.analyze(formatter);
}
void _setupSdk(CommandLineOptions options, bool useSummaries,
@@ -851,6 +844,19 @@ class Driver implements CommandLineStarter {
/// Convert [sourcePath] into an absolute path.
static String _normalizeSourcePath(String sourcePath) =>
path.normalize(new io.File(sourcePath).absolute.path);
+
+ bool _shouldBeFatal(ErrorSeverity severity, CommandLineOptions options) {
+ if (severity == ErrorSeverity.ERROR) {
+ return true;
+ } else if (severity == ErrorSeverity.WARNING &&
+ (options.warningsAreFatal || options.hintsAreFatal)) {
+ return true;
+ } else if (severity == ErrorSeverity.INFO && options.hintsAreFatal) {
+ return true;
+ } else {
+ return false;
+ }
+ }
}
class _DriverError implements Exception {
« no previous file with comments | « pkg/analyzer_cli/lib/src/build_mode.dart ('k') | pkg/analyzer_cli/lib/src/error_formatter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698