Skip to content

Commit 4d72ed3

Browse files
pqcommit-bot@chromium.org
authored andcommitted
bulk fix for prefer_final_locals
Change-Id: I9076dbf40aea9f261fe0374aa624bb64e6ec5a8b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162246 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent bf80bb2 commit 4d72ed3

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class BulkFixProcessor {
9696
LintNames.prefer_equal_for_default_values:
9797
ReplaceColonWithEquals.newInstance,
9898
LintNames.prefer_final_fields: MakeFinal.newInstance,
99+
LintNames.prefer_final_locals: MakeFinal.newInstance,
99100
LintNames.prefer_for_elements_to_map_fromIterable:
100101
ConvertMapFromIterableToForLiteral.newInstance,
101102
LintNames.prefer_generic_function_type_aliases:

pkg/analysis_server/test/src/services/correction/fix/bulk/make_final_test.dart

+22
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'bulk_fix_processor.dart';
1010
void main() {
1111
defineReflectiveSuite(() {
1212
defineReflectiveTests(PreferFinalFieldsTest);
13+
defineReflectiveTests(PreferFinalLocalsTest);
1314
});
1415
}
1516

@@ -37,3 +38,24 @@ class C {
3738
''');
3839
}
3940
}
41+
42+
@reflectiveTest
43+
class PreferFinalLocalsTest extends BulkFixProcessorTest {
44+
@override
45+
String get lintCode => LintNames.prefer_final_locals;
46+
47+
Future<void> test_singleFile() async {
48+
await resolveTestUnit('''
49+
f() {
50+
var x = 0;
51+
var y = x;
52+
}
53+
''');
54+
await assertHasFix('''
55+
f() {
56+
final x = 0;
57+
final y = x;
58+
}
59+
''');
60+
}
61+
}

0 commit comments

Comments
 (0)