Files
sdk/pkg/analyzer_cli/lib/src/error_severity.dart
T
Paul Berry ce0c219753 [analyzer_cli] Remove unused CommandLineOptions.
Removes the field `AnalyzerImpl.options`, the `options` parameter of
the method `Driver._runAnalyzer`, and the `commandLineOptions`
parameters of the functions `computeSeverity` and
`determineProcessedSeverity`. None of these were used.

Change-Id: I6a6a6964617cecb81f0d1c6570be1d78fb599af4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463085
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 15:17:59 -08:00

42 lines
1.5 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/diagnostic/diagnostic.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/source/error_processor.dart';
import 'package:analyzer/src/generated/engine.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 [DiagnosticSeverity.INFO].
/// - if `options.lintsAreFatal` is true, escalate lints to errors.
DiagnosticSeverity? computeSeverity(
Diagnostic diagnostic,
AnalysisOptions analysisOptions,
) {
var processor = ErrorProcessor.getProcessor(analysisOptions, diagnostic);
// If there is a processor for this error, defer to it.
if (processor != null) {
return processor.severity;
}
return diagnostic.diagnosticCode.severity;
}
/// Check various configuration options to get a desired severity for this
/// [diagnostic] (or `null` if it's to be suppressed).
DiagnosticSeverity? determineProcessedSeverity(
Diagnostic diagnostic,
AnalysisOptions analysisOptions,
) {
var severity = computeSeverity(diagnostic, analysisOptions);
// Skip TODOs categorically unless escalated to ERROR or HINT (#26215).
if (diagnostic.diagnosticCode.type == DiagnosticType.TODO &&
severity == DiagnosticSeverity.INFO) {
return null;
}
return severity;
}