Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ Below is a list of rules that are not enabled by default together with the reaso
| [`unnecessary_await_in_return`](https://dart.dev/tools/linter-rules/unnecessary_await_in_return) | Deprecated |
| [`unnecessary_const_in_enum_constructor`](https://dart.dev/tools/linter-rules/unnecessary_const_in_enum_constructor) | Not specified |
| [`unnecessary_final`](https://dart.dev/tools/linter-rules/unnecessary_final) | Incompatible with [prefer_final_locals](https://dart.dev/tools/linter-rules/prefer_final_locals) |
| [`unnecessary_primary_constructor_body`](https://dart.dev/tools/linter-rules/unnecessary_primary_constructor_body) | Not specified |
| [`unnecessary_type_name_in_constructor`](https://dart.dev/tools/linter-rules/unnecessary_type_name_in_constructor) | Not specified |
| [`unreachable_from_main`](https://dart.dev/tools/linter-rules/unreachable_from_main) | Not specified |
| [`unsafe_variance`](https://dart.dev/tools/linter-rules/unsafe_variance) | Experimental |
Expand Down
1 change: 1 addition & 0 deletions lib/analysis_options.11.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ linter:
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_primary_constructor_body
- unnecessary_raw_strings
- unnecessary_statements
- unnecessary_string_escapes
Expand Down
30 changes: 7 additions & 23 deletions tool/linter_rules/bin/remove_deprecated_rules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import 'package:yaml_edit/yaml_edit.dart';
/// It will create a new version of the analysis options file and update the
/// exclusion reasons file and the table of excluded rules in the README.md
/// file.
Future<void> main({
void Function(String) log = print,
}) async {
Future<void> main({void Function(String) log = print}) async {
const basePath = '../../';
final deprecatedRules = await allLinterRules(
state: LinterRuleState.deprecated,
Expand All @@ -30,21 +28,15 @@ Future<void> main({
log('Latest Very Good Analysis version: $latestVersion');
log('');

final latestVgaRules = await allVeryGoodAnalysisRules(
version: latestVersion,
);
final latestVgaRules = await allVeryGoodAnalysisRules(version: latestVersion);
log('Fetched ${latestVgaRules.length} Very Good Analysis linter rules');
log('');

final deprecatedVgaRules = latestVgaRules
.where(
(rule) => deprecatedRules.any((dartRule) => dartRule.name == rule),
)
.where((rule) => deprecatedRules.any((dartRule) => dartRule.name == rule))
.toList();
final deprecatedVgaRulesCount = deprecatedVgaRules.length;
log(
'Found $deprecatedVgaRulesCount deprecated Very Good Analysis rules:',
);
log('Found $deprecatedVgaRulesCount deprecated Very Good Analysis rules:');

if (deprecatedVgaRulesCount == 0) {
log('No deprecated Very Good Analysis rules found.');
Expand All @@ -59,9 +51,7 @@ Future<void> main({
//// Update the exclusion reasons file.
final currentExclusionReasons = await readExclusionReasons();
final newExclusionReasons = currentExclusionReasons
..addAll({
for (final rule in deprecatedVgaRules) rule: 'Deprecated',
});
..addAll({for (final rule in deprecatedVgaRules) rule: 'Deprecated'});
await writeExclusionReasons(newExclusionReasons);
log('''Updated the exclusion reasons file.''');
log('');
Expand All @@ -70,21 +60,15 @@ Future<void> main({
final parts = latestVersion.split('.');
// Increment the minor version.
final newVersion = '${parts[0]}.${int.parse(parts[1]) + 1}.0';
bumpVersion(
newVersion,
basePath: basePath,
);
bumpVersion(newVersion, basePath: basePath);
log('Bumped Very Good Analysis version to $newVersion');
log('');

//// Remove deprecated rules from the analysis options file.
final analysisOptionsFile = File(
'$basePath/lib/analysis_options.$newVersion.yaml',
);
_removeLinterRules(
analysisOptionsFile.path,
deprecatedVgaRules,
);
_removeLinterRules(analysisOptionsFile.path, deprecatedVgaRules);

//// Update the table of excluded rules in the README.md file.
final readme = Readme();
Expand Down
1 change: 0 additions & 1 deletion tool/linter_rules/exclusion_reasons.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"unnecessary_await_in_return": "Deprecated",
"unnecessary_const_in_enum_constructor": "Not specified",
"unnecessary_final": "Incompatible with [prefer_final_locals](https://dart.dev/tools/linter-rules/prefer_final_locals)",
"unnecessary_primary_constructor_body": "Not specified",
"unnecessary_type_name_in_constructor": "Not specified",
"unreachable_from_main": "Not specified",
"unsafe_variance": "Experimental",
Expand Down
14 changes: 4 additions & 10 deletions tool/linter_rules/test/src/all_linter_rules_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,8 @@ void main() {
group('allLinterRules', () {
test('returns all linter rules non-removed or wip', () async {
final linterRules = await allLinterRules(
get: (url, {headers}) async => Response(
minimalFixture,
200,
headers: headers ?? {},
),
get: (url, {headers}) async =>
Response(minimalFixture, 200, headers: headers ?? {}),
);

expect(linterRules.length, 2);
Expand All @@ -76,11 +73,8 @@ void main() {
test('filters rules correctly', () async {
final linterRules = await allLinterRules(
state: LinterRuleState.deprecated,
get: (url, {headers}) async => Response(
minimalFixture,
200,
headers: headers ?? {},
),
get: (url, {headers}) async =>
Response(minimalFixture, 200, headers: headers ?? {}),
);

expect(linterRules.length, 1);
Expand Down
21 changes: 9 additions & 12 deletions tool/linter_rules/test/src/latest_vga_version_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ void main() {
);
});

test(
'throws $ArgumentError if the version is not found in '
'the given file path',
() {
expect(
() => latestVgaVersion(
filePath: 'test/test_data/corrupted_analysis_options.yaml',
),
throwsA(isA<ArgumentError>()),
);
},
);
test('throws $ArgumentError if the version is not found in '
'the given file path', () {
expect(
() => latestVgaVersion(
filePath: 'test/test_data/corrupted_analysis_options.yaml',
),
throwsA(isA<ArgumentError>()),
);
});
});
}