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

Unified Diff: pkg/analyzer_cli/lib/src/error_formatter.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/driver.dart ('k') | pkg/analyzer_cli/lib/src/error_severity.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_formatter.dart
diff --git a/pkg/analyzer_cli/lib/src/error_formatter.dart b/pkg/analyzer_cli/lib/src/error_formatter.dart
index 086edfc52198b2e9f5af0d98d673b0745b35fcbf..e431778c1940b0cd2061dd2d361501e58a47a954 100644
--- a/pkg/analyzer_cli/lib/src/error_formatter.dart
+++ b/pkg/analyzer_cli/lib/src/error_formatter.dart
@@ -12,14 +12,14 @@ import 'package:analyzer_cli/src/options.dart';
import 'package:path/path.dart' as path;
/// Returns the given error's severity.
-ProcessedSeverity _severityIdentity(AnalysisError error) =>
- new ProcessedSeverity(error.errorCode.errorSeverity);
+ErrorSeverity _severityIdentity(AnalysisError error) =>
+ error.errorCode.errorSeverity;
String _pluralize(String word, int count) => count == 1 ? word : word + "s";
/// Returns desired severity for the given [error] (or `null` if it's to be
/// suppressed).
-typedef ProcessedSeverity SeverityProcessor(AnalysisError error);
+typedef ErrorSeverity SeverityProcessor(AnalysisError error);
/// Analysis statistics counter.
class AnalysisStats {
@@ -107,7 +107,7 @@ abstract class ErrorFormatter {
/// Compute the severity for this [error] or `null` if this error should be
/// filtered.
ErrorSeverity _computeSeverity(AnalysisError error) =>
- _severityProcessor(error)?.severity;
+ _severityProcessor(error);
void formatErrors(List<AnalysisErrorInfo> errorInfos) {
stats.unfilteredCount += errorInfos.length;
@@ -153,24 +153,12 @@ class MachineErrorFormatter extends ErrorFormatter {
LineInfo_Location location = errorToLine[error].getLocation(error.offset);
int length = error.length;
- ProcessedSeverity processedSeverity = _severityProcessor(error);
- ErrorSeverity severity = processedSeverity.severity;
-
- if (!processedSeverity.overridden) {
- if (severity == ErrorSeverity.WARNING && options.warningsAreFatal) {
- severity = ErrorSeverity.ERROR;
- }
- }
+ ErrorSeverity severity = _severityProcessor(error);
if (severity == ErrorSeverity.ERROR) {
stats.errorCount++;
} else if (severity == ErrorSeverity.WARNING) {
- // Only treat a warning as an error if it's not been set by a processor.
- if (!processedSeverity.overridden && options.warningsAreFatal) {
- stats.errorCount++;
- } else {
- stats.warnCount++;
- }
+ stats.warnCount++;
} else if (error.errorCode.type == ErrorType.HINT) {
stats.hintCount++;
} else if (error.errorCode.type == ErrorType.LINT) {
@@ -233,8 +221,7 @@ class HumanErrorFormatter extends ErrorFormatter {
Source source = error.source;
LineInfo_Location location = errorToLine[error].getLocation(error.offset);
- ProcessedSeverity processedSeverity = _severityProcessor(error);
- ErrorSeverity severity = processedSeverity.severity;
+ ErrorSeverity severity = _severityProcessor(error);
// Get display name; translate INFOs into LINTS and HINTS.
String errorType = severity.displayName;
@@ -382,13 +369,6 @@ class CLIError implements Comparable<CLIError> {
}
}
-/// A severity with awareness of whether it was overridden by a processor.
-class ProcessedSeverity {
- final ErrorSeverity severity;
- final bool overridden;
- ProcessedSeverity(this.severity, [this.overridden = false]);
-}
-
/// Given an absolute path, return a relative path if the file is contained in
/// the current directory; return the original path otherwise.
String _relative(String file) {
« no previous file with comments | « pkg/analyzer_cli/lib/src/driver.dart ('k') | pkg/analyzer_cli/lib/src/error_severity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698