[messages] Use lower case diagnostic names in linter.

Changes the logic in `pkg/linter` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.

This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` and `DiagnosticCode.uniqueName` getters.

Change-Id: I6a6a69645dc1b417c168a3d26ead9e76704ce0d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466131
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry
2025-12-09 07:53:23 -08:00
committed by Commit Queue
parent fe20f87e18
commit 33f4b692ae
4 changed files with 16 additions and 10 deletions
+2 -2
View File
@@ -17,9 +17,9 @@ class LinterLintCode extends LintCodeWithExpectedTypes {
@override
String get url {
if (hasPublishedDocs) {
return 'https://dart.dev/diagnostics/$name';
return 'https://dart.dev/diagnostics/$lowerCaseName';
}
return 'https://dart.dev/lints/$name';
return 'https://dart.dev/lints/$lowerCaseName';
}
}
+4 -2
View File
@@ -13,14 +13,16 @@ void main() {
test('without published diagnostic docs', () {
expect(
_customCode.url,
equals('https://dart.dev/lints/${_customCode.name}'),
equals('https://dart.dev/lints/${_customCode.lowerCaseName}'),
);
});
test('with published diagnostic docs', () {
expect(
_customCodeWithDocs.url,
equals('https://dart.dev/diagnostics/${_customCodeWithDocs.name}'),
equals(
'https://dart.dev/diagnostics/${_customCodeWithDocs.lowerCaseName}',
),
);
});
});
@@ -19,18 +19,18 @@ void main() {
@reflectiveTest
class AnalyzerPublicApiTest extends LintRuleTest {
static String get badPartDirective =>
diag.analyzerPublicApiBadPartDirective.name;
diag.analyzerPublicApiBadPartDirective.lowerCaseName;
static String get badType => diag.analyzerPublicApiBadType.name;
static String get badType => diag.analyzerPublicApiBadType.lowerCaseName;
static String get experimentalInconsistency =>
diag.analyzerPublicApiExperimentalInconsistency.name;
diag.analyzerPublicApiExperimentalInconsistency.lowerCaseName;
static String get exportsNonPublicName =>
diag.analyzerPublicApiExportsNonPublicName.name;
diag.analyzerPublicApiExportsNonPublicName.lowerCaseName;
static String get implInPublicApi =>
diag.analyzerPublicApiImplInPublicApi.name;
diag.analyzerPublicApiImplInPublicApi.lowerCaseName;
String get libFile => '$testPackageRootPath/lib/file.dart';
+5 -1
View File
@@ -70,7 +70,11 @@ Future<String> getMachineListing(
'incompatible': rule.incompatibleRules,
'sets': const [],
'fixStatus':
fixStatusMap[rule.diagnosticCodes.first.uniqueName.suffix] ??
fixStatusMap[rule
.diagnosticCodes
.first
.lowerCaseUniqueName
.suffix] ??
'unregistered',
'details': info.deprecatedDetails,
'sinceDartSdk': _versionToString(info.states.first.since),