Skip to content

Commit 22453ba

Browse files
srawlinsCommit Queue
authored andcommitted
linter: deprecate AnalysisRule.lintCode
Work towards #50986 Change-Id: Iedf1127b9f04aec910647c7f35597f38c6bfe1d2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428846 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent d039e28 commit 22453ba

File tree

245 files changed

+597
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+597
-278
lines changed

pkg/analysis_server/test/shared/shared_code_actions_fixes_tests.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:analysis_server/lsp_protocol/protocol.dart';
88
import 'package:analysis_server/src/lsp/constants.dart';
99
import 'package:analysis_server/src/lsp/extensions/code_action.dart';
1010
import 'package:analysis_server/src/services/correction/fix_internal.dart';
11-
import 'package:analyzer/src/dart/error/lint_codes.dart';
11+
import 'package:analyzer/error/error.dart';
1212
import 'package:analyzer/src/lint/linter.dart';
1313
import 'package:analyzer/src/lint/registry.dart';
1414
import 'package:analyzer/src/test_utilities/test_code_format.dart';
@@ -817,5 +817,5 @@ class _DeprecatedCamelCaseTypes extends LintRule {
817817
);
818818

819819
@override
820-
LintCode get lintCode => code;
820+
DiagnosticCode get diagnosticCode => code;
821821
}

pkg/analysis_server/test/src/services/completion/yaml/analysis_options_generator_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:analysis_server/src/services/completion/yaml/analysis_options_generator.dart';
6-
import 'package:analyzer/src/dart/error/lint_codes.dart';
6+
import 'package:analyzer/error/error.dart';
77
import 'package:analyzer/src/lint/linter.dart';
88
import 'package:analyzer/src/task/options.dart';
99
import 'package:analyzer/src/test_utilities/lint_registration_mixin.dart';
@@ -316,7 +316,7 @@ class InternalRule extends LintRule {
316316
: super(name: 'internal_lint', state: State.internal(), description: '');
317317

318318
@override
319-
LintCode get lintCode => code;
319+
DiagnosticCode get diagnosticCode => code;
320320
}
321321

322322
class _RemovedLint extends LintRule {
@@ -326,5 +326,5 @@ class _RemovedLint extends LintRule {
326326
: super(name: 'removed_lint', state: State.removed(), description: '');
327327

328328
@override
329-
LintCode get lintCode => _code;
329+
DiagnosticCode get diagnosticCode => _code;
330330
}

pkg/analysis_server/test/src/services/correction/fix/analysis_options/remove_lint_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analyzer/src/dart/error/lint_codes.dart';
5+
import 'package:analyzer/error/error.dart';
66
import 'package:analyzer/src/lint/linter.dart';
77
import 'package:analyzer/src/test_utilities/lint_registration_mixin.dart';
88
import 'package:linter/src/rules.dart';
@@ -31,7 +31,7 @@ class DeprecatedRule extends LintRule {
3131
);
3232

3333
@override
34-
LintCode get lintCode => code;
34+
DiagnosticCode get diagnosticCode => code;
3535
}
3636

3737
class RemovedRule extends LintRule {
@@ -45,7 +45,7 @@ class RemovedRule extends LintRule {
4545
: super(name: 'removed_rule', description: '', state: State.removed());
4646

4747
@override
48-
LintCode get lintCode => code;
48+
DiagnosticCode get diagnosticCode => code;
4949
}
5050

5151
@reflectiveTest

pkg/analysis_server_plugin/test/src/lint_rules.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class NoBoolsRule extends AnalysisRule {
1313
NoBoolsRule() : super(name: 'no_bools', description: 'No bools desc');
1414

1515
@override
16-
LintCode get lintCode => code;
16+
DiagnosticCode get diagnosticCode => code;
1717

1818
@override
1919
void registerNodeProcessors(
@@ -30,7 +30,7 @@ class NoDoublesRule extends AnalysisRule {
3030
: super(name: 'no_doubles', description: 'No doubles message');
3131

3232
@override
33-
LintCode get lintCode => code;
33+
DiagnosticCode get diagnosticCode => code;
3434

3535
@override
3636
void registerNodeProcessors(

pkg/analysis_server_plugin/test/src/plugin_server_error_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class _ThrowsAsyncErrorRule extends AnalysisRule {
265265
: super(name: 'no_bools', description: 'No bools desc');
266266

267267
@override
268-
LintCode get lintCode => code;
268+
DiagnosticCode get diagnosticCode => code;
269269

270270
@override
271271
void registerNodeProcessors(
@@ -312,7 +312,7 @@ class _ThrowsSyncErrorRule extends AnalysisRule {
312312
: super(name: 'no_bools', description: 'No bools desc');
313313

314314
@override
315-
LintCode get lintCode => code;
315+
DiagnosticCode get diagnosticCode => code;
316316

317317
@override
318318
void registerNodeProcessors(

pkg/analyzer/lib/src/lint/linter.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ abstract class AnalysisRule extends AbstractAnalysisRule {
161161
AnalysisRule({required super.name, required super.description, super.state});
162162

163163
/// The code to report for a violation.
164-
DiagnosticCode get diagnosticCode => lintCode;
164+
DiagnosticCode get diagnosticCode;
165165

166166
@override
167-
List<DiagnosticCode> get diagnosticCodes => [lintCode];
167+
List<DiagnosticCode> get diagnosticCodes => [diagnosticCode];
168168

169169
/// The code to report for a violation.
170-
// TODO(srawlins): Deprecate this in favor of `diagnosticCode`.
171-
LintCode get lintCode;
170+
@Deprecated("Use 'diagnosticCode' instead.")
171+
DiagnosticCode get lintCode => diagnosticCode;
172172

173173
/// Reports a diagnostic at [node] with message [arguments] and
174174
/// [contextMessages].

pkg/analyzer/test/src/dart/analysis/driver_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:analyzer/dart/analysis/results.dart';
88
import 'package:analyzer/dart/ast/visitor.dart';
99
import 'package:analyzer/dart/element/element.dart';
1010
import 'package:analyzer/diagnostic/diagnostic.dart';
11+
import 'package:analyzer/error/error.dart';
1112
import 'package:analyzer/file_system/file_system.dart';
1213
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
1314
import 'package:analyzer/src/dart/analysis/driver.dart';
@@ -39976,7 +39977,7 @@ class _AlwaysReportedLint extends LintRule {
3997639977
_AlwaysReportedLint() : super(name: 'always_reported_lint', description: '');
3997739978

3997839979
@override
39979-
LintCode get lintCode => code;
39980+
DiagnosticCode get diagnosticCode => code;
3998039981

3998139982
@override
3998239983
void registerNodeProcessors(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RemovedLint extends LintRule {
2525
);
2626

2727
@override
28-
LintCode get lintCode => throw UnimplementedError();
28+
DiagnosticCode get diagnosticCode => throw UnimplementedError();
2929
}
3030

3131
@reflectiveTest

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RemovedLint extends LintRule {
2525
);
2626

2727
@override
28-
LintCode get lintCode => throw UnimplementedError();
28+
DiagnosticCode get diagnosticCode => throw UnimplementedError();
2929
}
3030

3131
@reflectiveTest
@@ -83,5 +83,5 @@ class ReplacingLint extends LintRule {
8383
);
8484

8585
@override
86-
LintCode get lintCode => throw UnimplementedError();
86+
DiagnosticCode get diagnosticCode => throw UnimplementedError();
8787
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/visitor.dart';
7+
import 'package:analyzer/error/error.dart';
78
import 'package:analyzer/src/error/codes.dart';
89
import 'package:analyzer/src/lint/linter.dart';
910
import 'package:analyzer/src/test_utilities/lint_registration_mixin.dart';
@@ -80,7 +81,7 @@ class UnignorableIgnoreTest extends PubPackageResolutionTest
8081
// ignore: avoid_int
8182
int a = 0;
8283
''',
83-
[error(avoidIntRule.lintCode, 21, 3)],
84+
[error(avoidIntRule.diagnosticCode, 21, 3)],
8485
);
8586
}
8687
}
@@ -95,7 +96,7 @@ class _AvoidIntRule extends LintRule {
9596
_AvoidIntRule() : super(name: 'avoid_int', description: '');
9697

9798
@override
98-
LintCode get lintCode => code;
99+
DiagnosticCode get diagnosticCode => code;
99100

100101
@override
101102
void registerNodeProcessors(

0 commit comments

Comments
 (0)