Skip to content

Commit a913c61

Browse files
srawlinsCommit Queue
authored andcommitted
linter: Use new DiagnosticCode name
Work towards #60635 Change-Id: I3f53e1c7db21047665e1a286673d624c2d48c834 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425684 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 4201a37 commit a913c61

21 files changed

+35
-33
lines changed

pkg/linter/lib/src/rules/always_specify_types.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,28 +196,28 @@ class _Visitor extends SimpleAstVisitor<void> {
196196
var singleType = types.length == 1;
197197

198198
List<Object> arguments;
199-
ErrorCode errorCode;
199+
DiagnosticCode lintCode;
200200
if (types.isEmpty) {
201201
arguments = [];
202-
errorCode = LinterLintCode.always_specify_types_add_type;
202+
lintCode = LinterLintCode.always_specify_types_add_type;
203203
} else if (keyword.type == Keyword.VAR) {
204204
if (singleType) {
205205
arguments = [keyword.lexeme, types.first];
206-
errorCode = LinterLintCode.always_specify_types_replace_keyword;
206+
lintCode = LinterLintCode.always_specify_types_replace_keyword;
207207
} else {
208208
arguments = [];
209-
errorCode = LinterLintCode.always_specify_types_split_to_types;
209+
lintCode = LinterLintCode.always_specify_types_split_to_types;
210210
}
211211
} else {
212212
if (singleType) {
213213
arguments = [types.first];
214-
errorCode = LinterLintCode.always_specify_types_specify_type;
214+
lintCode = LinterLintCode.always_specify_types_specify_type;
215215
} else {
216216
arguments = [];
217-
errorCode = LinterLintCode.always_specify_types_add_type;
217+
lintCode = LinterLintCode.always_specify_types_add_type;
218218
}
219219
}
220-
rule.reportAtToken(keyword, arguments: arguments, errorCode: errorCode);
220+
rule.reportAtToken(keyword, arguments: arguments, errorCode: lintCode);
221221
}
222222
}
223223

pkg/linter/test/formatter_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void defineTests() {
3434

3535
var type = MockDiagnosticType()..displayName = 'test';
3636

37-
var code = TestErrorCode('mock_code', 'MSG')..type = type;
37+
var code = TestDiagnosticCode('mock_code', 'MSG')..type = type;
3838

3939
await d.dir('project', [
4040
d.file('foo.dart', '''

pkg/linter/test/mocks.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ class MockSource extends BasicSource {
8080
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
8181
}
8282

83-
class TestErrorCode extends ErrorCode {
83+
class TestDiagnosticCode extends DiagnosticCode {
8484
@override
8585
late ErrorSeverity errorSeverity;
8686

8787
@override
8888
late DiagnosticType type;
8989

90-
TestErrorCode(String name, String message)
90+
TestDiagnosticCode(String name, String message)
9191
: super(
9292
problemMessage: message,
9393
name: name,

pkg/linter/test/rule_test_support.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
3535
export 'package:linter/src/lint_names.dart';
3636

3737
ExpectedDiagnostic error(
38-
ErrorCode code,
38+
DiagnosticCode code,
3939
int offset,
4040
int length, {
4141
Pattern? messageContains,
@@ -518,7 +518,9 @@ abstract class _ContextResolutionTest
518518
late ResolvedUnitResult result;
519519

520520
/// Error codes that by default should be ignored in test expectations.
521-
List<ErrorCode> get ignoredErrorCodes => [WarningCode.UNUSED_LOCAL_VARIABLE];
521+
List<DiagnosticCode> get ignoredErrorCodes => [
522+
WarningCode.UNUSED_LOCAL_VARIABLE,
523+
];
522524

523525
/// The path to the root of the external packages.
524526
@override
@@ -609,7 +611,7 @@ abstract class _ContextResolutionTest
609611

610612
/// A description of an expected error.
611613
final class _ExpectedError extends ExpectedDiagnostic {
612-
final ErrorCode _code;
614+
final DiagnosticCode _code;
613615

614616
_ExpectedError(this._code, int offset, int length, {Pattern? messageContains})
615617
: super(

pkg/linter/test/rules/always_put_control_body_on_new_line_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
@reflectiveTest
1717
class AlwaysPutControlBodyOnNewLineTest extends LintRuleTest {
1818
@override
19-
List<ErrorCode> get ignoredErrorCodes => [
19+
List<DiagnosticCode> get ignoredErrorCodes => [
2020
WarningCode.DEAD_CODE,
2121
WarningCode.UNUSED_LOCAL_VARIABLE,
2222
];

pkg/linter/test/rules/avoid_catches_without_on_clauses_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AvoidCatchesWithoutOnClausesTest extends LintRuleTest {
1919
bool get addFlutterPackageDep => true;
2020

2121
@override
22-
List<ErrorCode> get ignoredErrorCodes => [
22+
List<DiagnosticCode> get ignoredErrorCodes => [
2323
WarningCode.UNUSED_ELEMENT,
2424
WarningCode.UNUSED_LOCAL_VARIABLE,
2525
];

pkg/linter/test/rules/avoid_private_typedef_functions_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
@reflectiveTest
1717
class AvoidPrivateTypedefFunctionsTest extends LintRuleTest {
1818
@override
19-
List<ErrorCode> get ignoredErrorCodes => [
19+
List<DiagnosticCode> get ignoredErrorCodes => [
2020
WarningCode.UNUSED_ELEMENT,
2121
WarningCode.UNUSED_FIELD,
2222
WarningCode.UNUSED_LOCAL_VARIABLE,

pkg/linter/test/rules/avoid_returning_null_for_void_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
@reflectiveTest
1717
class AvoidReturningNullForVoidTest extends LintRuleTest {
1818
@override
19-
List<ErrorCode> get ignoredErrorCodes => [
19+
List<DiagnosticCode> get ignoredErrorCodes => [
2020
WarningCode.UNUSED_ELEMENT,
2121
WarningCode.UNUSED_LOCAL_VARIABLE,
2222
];

pkg/linter/test/rules/avoid_shadowing_type_parameters_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
@reflectiveTest
1717
class AvoidShadowingTypeParametersTest extends LintRuleTest {
1818
@override
19-
List<ErrorCode> get ignoredErrorCodes => [
19+
List<DiagnosticCode> get ignoredErrorCodes => [
2020
WarningCode.UNUSED_ELEMENT,
2121
WarningCode.UNUSED_LOCAL_VARIABLE,
2222
];

pkg/linter/test/rules/combinators_ordering_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
@reflectiveTest
1717
class CombinatorsOrderingTest extends LintRuleTest {
1818
@override
19-
List<ErrorCode> get ignoredErrorCodes => [WarningCode.UNUSED_IMPORT];
19+
List<DiagnosticCode> get ignoredErrorCodes => [WarningCode.UNUSED_IMPORT];
2020

2121
@override
2222
String get lintRule => LintNames.combinators_ordering;

0 commit comments

Comments
 (0)