Skip to content

Commit 3981c33

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Hardcode IgnoreValidator.enableUnignorableIgnore flag.
This flag existed to allow the `unignorable_ignore` diagnostic to be easily disabled in case it caused problems in Flutter. This CL removes the flag, hardcoding the behavior that the diagnostic is enabled. Change-Id: I6a6a696462e893244917f17ff694ddd2c862a880 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463641 Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
1 parent c4fcd14 commit 3981c33

File tree

2 files changed

+10
-39
lines changed

2 files changed

+10
-39
lines changed

pkg/analyzer/lib/src/error/ignore_validator.dart

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:analyzer/source/line_info.dart';
99
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
1010
import 'package:analyzer/src/ignore_comments/ignore_info.dart';
1111
import 'package:analyzer/src/lint/registry.dart';
12-
import 'package:meta/meta.dart';
1312

1413
/// Used to validate the ignore comments in a single file.
1514
class IgnoreValidator {
@@ -28,20 +27,6 @@ class IgnoreValidator {
2827
static late DiagnosticCode unnecessaryIgnoreNameLocationLintCode;
2928
static late DiagnosticCode unnecessaryIgnoreNameFileLintCode;
3029

31-
/// Whether to report `unignorable_ignore` warnings.
32-
///
33-
/// `unignorable_ignore` warnings were introduced in
34-
/// https://dart-review.googlesource.com/c/sdk/+/156402 but not enabled until
35-
/// https://dart-review.googlesource.com/c/sdk/+/463504.
36-
///
37-
/// This flag allows the logic for reporting these warnings to be easily
38-
/// disabled again in case this leads to problems, without interfering with
39-
/// the ability to unit test the functionality.
40-
// TODO(paulberry): remove this flag once sufficient time has elapsed after
41-
// rolling https://dart-review.googlesource.com/c/sdk/+/463504 into Flutter.
42-
@visibleForTesting
43-
static bool enableUnignorableIgnore = true;
44-
4530
/// The diagnostic reporter to which diagnostics are to be reported.
4631
final DiagnosticReporter _diagnosticReporter;
4732

@@ -169,18 +154,16 @@ class IgnoreValidator {
169154
List<IgnoredElement> duplicated,
170155
List<IgnoredElement> list,
171156
) {
172-
if (enableUnignorableIgnore) {
173-
for (var unignorableName in unignorable) {
174-
if (unignorableName is IgnoredDiagnosticName) {
175-
var name = unignorableName.name;
176-
_diagnosticReporter.atOffset(
177-
diagnosticCode: diag.unignorableIgnore,
178-
offset: unignorableName.offset,
179-
length: name.length,
180-
arguments: [name],
181-
);
182-
list.remove(unignorableName);
183-
}
157+
for (var unignorableName in unignorable) {
158+
if (unignorableName is IgnoredDiagnosticName) {
159+
var name = unignorableName.name;
160+
_diagnosticReporter.atOffset(
161+
diagnosticCode: diag.unignorableIgnore,
162+
offset: unignorableName.offset,
163+
length: name.length,
164+
arguments: [name],
165+
);
166+
list.remove(unignorableName);
184167
}
185168
}
186169
for (var ignoredElement in duplicated) {

pkg/analyzer/test/src/diagnostics/unignorable_ignore_test.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import 'package:analyzer/dart/ast/ast.dart';
99
import 'package:analyzer/dart/ast/visitor.dart';
1010
import 'package:analyzer/error/error.dart';
1111
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
12-
import 'package:analyzer/src/error/ignore_validator.dart';
1312
import 'package:analyzer/src/test_utilities/lint_registration_mixin.dart';
1413
import 'package:analyzer_testing/utilities/utilities.dart';
15-
import 'package:test/test.dart';
1614
import 'package:test_reflective_loader/test_reflective_loader.dart';
1715

1816
import '../dart/resolution/context_collection_resolution.dart';
@@ -26,16 +24,6 @@ main() {
2624
@reflectiveTest
2725
class UnignorableIgnoreTest extends PubPackageResolutionTest
2826
with LintRegistrationMixin {
29-
@override
30-
void setUp() {
31-
var enableUnignorableIgnore = IgnoreValidator.enableUnignorableIgnore;
32-
addTearDown(() {
33-
IgnoreValidator.enableUnignorableIgnore = enableUnignorableIgnore;
34-
});
35-
IgnoreValidator.enableUnignorableIgnore = true;
36-
super.setUp();
37-
}
38-
3927
@override
4028
Future<void> tearDown() {
4129
unregisterLintRules();

0 commit comments

Comments
 (0)