allow todos in user code to show in IDEs (#23303)
diff --git a/packages/flutter/lib/analysis_options_user.yaml b/packages/flutter/lib/analysis_options_user.yaml
index e558021..01c274a 100644
--- a/packages/flutter/lib/analysis_options_user.yaml
+++ b/packages/flutter/lib/analysis_options_user.yaml
@@ -24,8 +24,6 @@
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
- # allow having TODOs in the code
- todo: ignore
linter:
rules:
diff --git a/packages/flutter_tools/lib/src/commands/analyze_once.dart b/packages/flutter_tools/lib/src/commands/analyze_once.dart
index faadddc..3a536e5 100644
--- a/packages/flutter_tools/lib/src/commands/analyze_once.dart
+++ b/packages/flutter_tools/lib/src/commands/analyze_once.dart
@@ -87,7 +87,8 @@
}
});
server.onErrors.listen((FileAnalysisErrors fileErrors) {
- errors.addAll(fileErrors.errors);
+ // Record the issues found (but filter out to do comments).
+ errors.addAll(fileErrors.errors.where((AnalysisError error) => error.type != 'TODO'));
});
await server.start();
diff --git a/packages/flutter_tools/test/commands/analyze_once_test.dart b/packages/flutter_tools/test/commands/analyze_once_test.dart
index 1166a6e..1525f2d 100644
--- a/packages/flutter_tools/test/commands/analyze_once_test.dart
+++ b/packages/flutter_tools/test/commands/analyze_once_test.dart
@@ -178,6 +178,24 @@
tryToDelete(tempDir);
}
});
+
+ testUsingContext('returns no issues for todo comments', () async {
+ const String contents = '''
+// TODO(foobar):
+StringBuffer bar = StringBuffer('baz');
+''';
+ final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_4.');
+ tempDir.childFile('main.dart').writeAsStringSync(contents);
+ try {
+ await runCommand(
+ command: AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
+ arguments: <String>['analyze'],
+ statusTextContains: <String>['No issues found!'],
+ );
+ } finally {
+ tryToDelete(tempDir);
+ }
+ });
});
}