From 33f4b692aec6e55487ee6df3f2d38b055bb25a38 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 9 Dec 2025 07:53:23 -0800 Subject: [PATCH] [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 Reviewed-by: Brian Wilkerson Commit-Queue: Paul Berry --- pkg/linter/lib/src/lint_codes.dart | 4 ++-- pkg/linter/test/lint_code_test.dart | 6 ++++-- pkg/linter/test/rules/analyzer_public_api_test.dart | 10 +++++----- pkg/linter/tool/machine.dart | 6 +++++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pkg/linter/lib/src/lint_codes.dart b/pkg/linter/lib/src/lint_codes.dart index a2936c57d27..acc5bbe9cd5 100644 --- a/pkg/linter/lib/src/lint_codes.dart +++ b/pkg/linter/lib/src/lint_codes.dart @@ -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'; } } diff --git a/pkg/linter/test/lint_code_test.dart b/pkg/linter/test/lint_code_test.dart index 4e08cf17971..a98353e2090 100644 --- a/pkg/linter/test/lint_code_test.dart +++ b/pkg/linter/test/lint_code_test.dart @@ -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}', + ), ); }); }); diff --git a/pkg/linter/test/rules/analyzer_public_api_test.dart b/pkg/linter/test/rules/analyzer_public_api_test.dart index 668600ad10a..4338638c2fe 100644 --- a/pkg/linter/test/rules/analyzer_public_api_test.dart +++ b/pkg/linter/test/rules/analyzer_public_api_test.dart @@ -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'; diff --git a/pkg/linter/tool/machine.dart b/pkg/linter/tool/machine.dart index 95133b042ed..2873ed7e39a 100644 --- a/pkg/linter/tool/machine.dart +++ b/pkg/linter/tool/machine.dart @@ -70,7 +70,11 @@ Future 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),