Commit 0290622b authored by Ian Hickson's avatar Ian Hickson

Analyzer improvements

- strengthen analyzer against error messages that point past the
  bottom of the file.

- ignore any errors in intl's auto-generated files.
parent 2b47efc9
...@@ -256,9 +256,9 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -256,9 +256,9 @@ class AnalyzeCommand extends FlutterCommand {
]; ];
RegExp generalPattern = new RegExp(r'^\[(error|warning|hint|lint)\] (.+) \(([^(),]+), line ([0-9]+), col ([0-9]+)\)$'); RegExp generalPattern = new RegExp(r'^\[(error|warning|hint|lint)\] (.+) \(([^(),]+), line ([0-9]+), col ([0-9]+)\)$');
RegExp ignorePattern = new RegExp(r'// analyzer says "([^"]+)"'); RegExp allowedIdentifiersPattern = new RegExp(r'_?([A-Z]|_+)\b');
RegExp constructorTearOffsPattern = new RegExp('.+#.+// analyzer doesn\'t like constructor tear-offs'); RegExp constructorTearOffsPattern = new RegExp('.+#.+// analyzer doesn\'t like constructor tear-offs');
RegExp allowedIdentifiers = new RegExp(r'_?([A-Z]|_+)\b'); RegExp ignorePattern = new RegExp(r'// analyzer says "([^"]+)"');
List<String> errorLines = output.toString().split('\n'); List<String> errorLines = output.toString().split('\n');
for (String errorLine in errorLines) { for (String errorLine in errorLines) {
...@@ -272,12 +272,16 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -272,12 +272,16 @@ class AnalyzeCommand extends FlutterCommand {
int colNumber = int.parse(groups[5]); int colNumber = int.parse(groups[5]);
File source = new File(filename); File source = new File(filename);
List<String> sourceLines = source.readAsLinesSync(); List<String> sourceLines = source.readAsLinesSync();
String sourceLine = sourceLines[lineNumber-1]; String sourceLine = (lineNumber < sourceLines.length) ? sourceLines[lineNumber-1] : '';
bool shouldIgnore = false; bool shouldIgnore = false;
if (filename.endsWith('.mojom.dart')) { if (filename.endsWith('.mojom.dart')) {
// autogenerated code - TODO(ianh): Fix the Dart mojom compiler
shouldIgnore = true;
} else if ((sourceLines[0] == '/**') && (' * DO NOT EDIT. This is code generated'.matchAsPrefix(sourceLines[1]) != null)) {
// autogenerated code - TODO(ianh): Fix the intl package resource generator
shouldIgnore = true; shouldIgnore = true;
} else if (level == 'lint' && errorMessage == 'Name non-constant identifiers using lowerCamelCase.') { } else if (level == 'lint' && errorMessage == 'Name non-constant identifiers using lowerCamelCase.') {
if (allowedIdentifiers.matchAsPrefix(sourceLine, colNumber-1) != null) if (allowedIdentifiersPattern.matchAsPrefix(sourceLine, colNumber-1) != null)
shouldIgnore = true; shouldIgnore = true;
} else if (constructorTearOffsPattern.allMatches(sourceLine).isNotEmpty) { } else if (constructorTearOffsPattern.allMatches(sourceLine).isNotEmpty) {
shouldIgnore = true; shouldIgnore = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment