Skip to content

Commit bad3760

Browse files
RohitSailyCommit Queue
authored andcommitted
flutter_style_todos: allow leading space, add and edit tests
Closes #61466 GitOrigin-RevId: 09a34ed Change-Id: I6c1a933f3b400bcd87400e59cc27a1c06e41e92b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448884 Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]>
1 parent 7dadd9f commit bad3760

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

pkg/analysis_server/test/src/services/correction/fix/convert_to_flutter_style_todo_test.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void g() { }
3636
void f() {
3737
// TODO(user): msg.
3838
}
39-
// TODO(user): msg.
39+
//TODO(user): msg.
4040
void g() { }
4141
''');
4242
}
@@ -143,10 +143,7 @@ void f() {}
143143
//TODO(user): msg.
144144
void f() {}
145145
''');
146-
await assertHasFix('''
147-
// TODO(user): msg.
148-
void f() {}
149-
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
146+
await assertNoFix();
150147
}
151148

152149
Future<void> test_unwantedSpaceBeforeUser() async {

pkg/linter/lib/src/rules/flutter_style_todos.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FlutterStyleTodos extends LintRule {
1919
static final _todoRegExp = RegExp(r'//+\s*TODO\b', caseSensitive: false);
2020

2121
static final RegExp _todoExpectedRegExp = RegExp(
22-
r'// TODO\([a-zA-Z0-9][-a-zA-Z0-9\.]*\): ',
22+
r'//\s*TODO\([a-zA-Z0-9][-a-zA-Z0-9\.]*\): ',
2323
);
2424

2525
FlutterStyleTodos()

pkg/linter/test/rules/flutter_style_todos_test.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ class FlutterStyleTodosTest extends LintRuleTest {
1717
@override
1818
String get lintRule => LintNames.flutter_style_todos;
1919

20-
// TODO(srawlins): This test is called, "bad patterns", contains 10 TODO-like
21-
// comment lines, but then only expects 9 lints. Why?
20+
// TODO(srawlins): line "// TODO(somebody): something,
21+
// github.com/flutter/flutter" currently isn't recognized as a
22+
// bad pattern, should the URI part be validated or should this
23+
// be an acceptable case
2224
test_badPatterns() async {
2325
await assertDiagnostics(
2426
r'''
@@ -78,6 +80,13 @@ class FlutterStyleTodosTest extends LintRuleTest {
7880
''');
7981
}
8082

83+
test_goodPatterns_noLeadingSpace() async {
84+
await assertNoDiagnostics(r'''
85+
//TODO(somebody): something
86+
//TODO(somebody): something, https://github.com/flutter/flutter
87+
''');
88+
}
89+
8190
test_justTodo() async {
8291
await assertDiagnostics(r'// TODO', [lint(0, 7)]);
8392
}
@@ -90,6 +99,16 @@ class FlutterStyleTodosTest extends LintRuleTest {
9099
await assertDiagnostics(r'// TODO(user) bla', [lint(0, 17)]);
91100
}
92101

102+
test_missingMessage() async {
103+
await assertDiagnostics(
104+
r'''
105+
//TODO(somebody):
106+
// TODO(somebody):
107+
''',
108+
[lint(0, 17), lint(18, 18)],
109+
);
110+
}
111+
93112
test_missingParens() async {
94113
await assertDiagnostics(r'// TODO: bla', [lint(0, 12)]);
95114
}

0 commit comments

Comments
 (0)