e0b193959f
Fixes https://github.com/dart-lang/sdk/issues/50887 Change-Id: I770b56b908d76f728f58b96e57928c412eebbafd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278370 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
41 lines
1.6 KiB
Dart
41 lines
1.6 KiB
Dart
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:analyzer/error/error.dart';
|
|
import 'package:analyzer/source/error_processor.dart';
|
|
import 'package:analyzer/src/generated/engine.dart';
|
|
import 'package:analyzer_cli/src/options.dart';
|
|
|
|
/// 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.lintsAreFatal] is true, escalate lints to errors.
|
|
ErrorSeverity? computeSeverity(
|
|
AnalysisError error,
|
|
CommandLineOptions commandLineOptions,
|
|
AnalysisOptions analysisOptions,
|
|
) {
|
|
var processor = ErrorProcessor.getProcessor(analysisOptions, error);
|
|
// If there is a processor for this error, defer to it.
|
|
if (processor != null) {
|
|
return processor.severity;
|
|
}
|
|
|
|
return error.errorCode.errorSeverity;
|
|
}
|
|
|
|
/// Check various configuration options to get a desired severity for this
|
|
/// [error] (or `null` if it's to be suppressed).
|
|
ErrorSeverity? determineProcessedSeverity(AnalysisError error,
|
|
CommandLineOptions commandLineOptions, AnalysisOptions analysisOptions) {
|
|
var 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;
|
|
}
|
|
|
|
return severity;
|
|
}
|