allow todos in user code to show in IDEs (#23303)

This commit is contained in:
Devon Carew 2018-10-19 14:10:54 -07:00 committed by GitHub
parent de9f18d288
commit 48fe65c236
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View file

@ -24,8 +24,6 @@ analyzer:
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:

View file

@ -87,7 +87,8 @@ class AnalyzeOnce extends AnalyzeBase {
}
});
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();

View file

@ -178,6 +178,24 @@ StringBuffer bar = StringBuffer('baz');
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);
}
});
});
}