Files
sdk/pkg/linter/tool/generate_lints.dart
Paul Berry 67d3a2c7a6 [messages] Use all lower case in lint_names.g.dart.
Now that lint name matching is case insensitive
(https://dart-review.googlesource.com/c/sdk/+/465964), it is no longer
necessary for the lint names `no_runtimeType_toString`,
`prefer_for_elements_to_map_fromIterable`, and
`prefer_iterable_whereType` to be in mixed case in
`lint_names.g.dart`.

This change adjusts them to all lower case, and renames the
corresponding declarations too. This paves the way for a follow-up CL
that will change the case conventions in `pkg/linter/messages.yaml`.

Change-Id: I6a6a6964381f9573dd735bde0ae8dfb103eef174
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465991
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-04 11:01:59 -08:00

53 lines
1.7 KiB
Dart

// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// Generation logic for `LintNames` and `LinterLintCode` based on
/// the entries in `pkg/linter/messages.yaml`.
library;
import 'package:analyzer_testing/package_root.dart' as pkg_root;
import 'package:analyzer_utilities/tools.dart';
import 'messages_info.dart';
void main() async {
await GeneratedContent.generateAll(pkg_root.packageRoot, [
generatedNamesFile,
]);
}
const String generatedNamesPath = 'linter/lib/src/lint_names.g.dart';
GeneratedFile get generatedNamesFile =>
GeneratedFile(generatedNamesPath, (pkgRoot) async {
var out = StringBuffer('''
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// THIS FILE IS GENERATED. DO NOT EDIT.
//
// Instead modify 'pkg/linter/messages.yaml' and run
// 'dart run pkg/linter/tool/generate_lints.dart' to update.
// We allow some snake_case and SCREAMING_SNAKE_CASE identifiers in generated
// code, as they match names declared in the source configuration files.
// ignore_for_file: constant_identifier_names
// An enumeration of the names of the analyzer's built-in lint rules.
abstract final class LintNames {
''');
for (var lintName in messagesRuleInfo.keys) {
var lintNameLowerCase = lintName.toLowerCase();
out.writeln(
" static const String $lintNameLowerCase = '$lintNameLowerCase';",
);
out.writeln();
}
out.writeln('}');
return out.toString();
});