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

Unified Diff: pkg/analyzer_cli/lib/src/error_severity.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/error_formatter.dart ('k') | pkg/analyzer_cli/lib/src/options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/error_severity.dart
diff --git a/pkg/analyzer_cli/lib/src/error_severity.dart b/pkg/analyzer_cli/lib/src/error_severity.dart
index 17b7fe5f8867b2fe03de84f34d02eff92c06e333..4344bbaaa11142356866b1b150193839df270e83 100644
--- a/pkg/analyzer_cli/lib/src/error_severity.dart
+++ b/pkg/analyzer_cli/lib/src/error_severity.dart
@@ -6,51 +6,39 @@ import 'package:analyzer/error/error.dart';
import 'package:analyzer/source/error_processor.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult;
-import 'package:analyzer_cli/src/error_formatter.dart';
import 'package:analyzer_cli/src/options.dart';
/// Check various configuration options to get a desired severity for this
/// [error] (or `null` if it's to be suppressed).
-ProcessedSeverity determineProcessedSeverity(AnalysisError error,
+ErrorSeverity determineProcessedSeverity(AnalysisError error,
CommandLineOptions commandLineOptions, AnalysisOptions analysisOptions) {
- ErrorSeverity severity = computeSeverity(error, commandLineOptions,
- analysisOptions: analysisOptions);
- bool isOverridden = false;
-
- // Skip TODOs categorically (unless escalated to ERROR or HINT.)
- // https://github.com/dart-lang/sdk/issues/26215
+ ErrorSeverity severity =
+ computeSeverity(error, commandLineOptions, analysisOptions);
+ // Skip TODOs categorically unless escalated to ERROR or HINT (#26215).
if (error.errorCode.type == ErrorType.TODO &&
severity == ErrorSeverity.INFO) {
return null;
}
- // First check for a filter.
- if (severity == null) {
- // Null severity means the error has been explicitly ignored.
- return null;
- } else {
- isOverridden = true;
- }
-
+ // TODO(devoncarew): We should not filter hints here.
// If not overridden, some "natural" severities get globally filtered.
- if (!isOverridden) {
- // Check for global hint filtering.
- if (severity == ErrorSeverity.INFO && commandLineOptions.disableHints) {
- return null;
- }
+ // Check for global hint filtering.
+ if (severity == ErrorSeverity.INFO && commandLineOptions.disableHints) {
+ return null;
}
- return new ProcessedSeverity(severity, isOverridden);
+ return severity;
}
/// Compute the severity of the error; however:
/// - if [options.enableTypeChecks] is false, then de-escalate checked-mode
/// compile time errors to a severity of [ErrorSeverity.INFO].
-/// - if [options.hintsAreFatal] is true, escalate hints to errors.
/// - if [options.lintsAreFatal] is true, escalate lints to errors.
ErrorSeverity computeSeverity(
- AnalysisError error, CommandLineOptions commandLineOptions,
- {AnalysisOptions analysisOptions}) {
+ AnalysisError error,
+ CommandLineOptions commandLineOptions,
+ AnalysisOptions analysisOptions,
+) {
if (analysisOptions != null) {
ErrorProcessor processor =
ErrorProcessor.getProcessor(analysisOptions, error);
@@ -63,10 +51,9 @@ ErrorSeverity computeSeverity(
if (!commandLineOptions.enableTypeChecks &&
error.errorCode.type == ErrorType.CHECKED_MODE_COMPILE_TIME_ERROR) {
return ErrorSeverity.INFO;
- } else if (commandLineOptions.hintsAreFatal && error.errorCode is HintCode) {
- return ErrorSeverity.ERROR;
} else if (commandLineOptions.lintsAreFatal && error.errorCode is LintCode) {
return ErrorSeverity.ERROR;
}
+
return error.errorCode.errorSeverity;
}
« no previous file with comments | « pkg/analyzer_cli/lib/src/error_formatter.dart ('k') | pkg/analyzer_cli/lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698