bulk fix for prefer_const_declarations

Change-Id: I5ee65d901d8777df032f447b8a56bf1d654b98f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161824
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
pq
2020-09-03 23:57:35 +00:00
committed by commit-bot@chromium.org
parent 8e85c1e7c6
commit 5b956bd8a0
3 changed files with 35 additions and 0 deletions
@@ -40,6 +40,7 @@ import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_
import 'package:analysis_server/src/services/correction/dart/rename_to_camel_case.dart';
import 'package:analysis_server/src/services/correction/dart/replace_cascade_with_dot.dart';
import 'package:analysis_server/src/services/correction/dart/replace_colon_with_equals.dart';
import 'package:analysis_server/src/services/correction/dart/replace_final_with_const.dart';
import 'package:analysis_server/src/services/correction/dart/replace_null_with_closure.dart';
import 'package:analysis_server/src/services/correction/dart/replace_with_conditional_assignment.dart';
import 'package:analysis_server/src/services/correction/dart/replace_with_is_empty.dart';
@@ -87,6 +88,7 @@ class BulkFixProcessor {
LintNames.prefer_adjacent_string_concatenation: RemoveOperator.newInstance,
LintNames.prefer_conditional_assignment:
ReplaceWithConditionalAssignment.newInstance,
LintNames.prefer_const_declarations: ReplaceFinalWithConst.newInstance,
LintNames.prefer_contains: ConvertToContains.newInstance,
LintNames.prefer_equal_for_default_values:
ReplaceColonWithEquals.newInstance,
@@ -0,0 +1,31 @@
// Copyright (c) 2020, 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.
import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'bulk_fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(ReplaceFinalWithConstTest);
});
}
@reflectiveTest
class ReplaceFinalWithConstTest extends BulkFixProcessorTest {
@override
String get lintCode => LintNames.prefer_const_declarations;
Future<void> test_singleFile() async {
await resolveTestUnit('''
final int a = 1;
final b = 1;
''');
await assertHasFix('''
const int a = 1;
const b = 1;
''');
}
}
@@ -41,6 +41,7 @@ import 'remove_unnecessary_const_test.dart' as remove_unnecessary_const;
import 'remove_unnecessary_new_test.dart' as remove_unnecessary_new;
import 'rename_to_camel_case_test.dart' as rename_to_camel_case;
import 'replace_colon_with_equals_test.dart' as replace_colon_with_equals;
import 'replace_final_with_const_test.dart' as replace_final_with_const;
import 'replace_null_with_closure_test.dart' as replace_null_with_closure;
import 'replace_with_conditional_assignment_test.dart'
as replace_with_conditional_assignment;
@@ -87,6 +88,7 @@ void main() {
rename_to_camel_case.main();
replace_with_conditional_assignment.main();
replace_colon_with_equals.main();
replace_final_with_const.main();
replace_null_with_closure.main();
replace_with_is_empty.main();
replace_with_tear_off.main();