From aedef5139bb611d5654f35b80b2c48718a201cd2 Mon Sep 17 00:00:00 2001 From: pq Date: Fri, 11 Mar 2016 10:35:17 -0800 Subject: [PATCH 1/2] Analyze command cleanup. Removing some special-casing in pursuit of aligning `flutter analyze` output with that provided by server/IDEs. Specifically: * strong-hints (stale, no longer supported) * "analyzer says" comment handling in favor of `//ignore`s * `conflictingNamePattern` --- no longer needed Next up some of the error filter regexps... --- .../flutter_tools/lib/src/commands/analyze.dart | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index b1ced5da30f..06227fca04b 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -289,7 +289,6 @@ class AnalyzeCommand extends FlutterCommand { '--strong', '--package-warnings', '--fatal-warnings', - '--strong-hints', '--fatal-hints', // defines lints '--options', optionsFile.path, @@ -340,8 +339,6 @@ class AnalyzeCommand extends FlutterCommand { RegExp generalPattern = new RegExp(r'^\[(error|warning|hint|lint)\] (.+) \(([^(),]+), line ([0-9]+), col ([0-9]+)\)$'); RegExp allowedIdentifiersPattern = new RegExp(r'_?([A-Z]|_+)\b'); RegExp constructorTearOffsPattern = new RegExp('.+#.+// analyzer doesn\'t like constructor tear-offs'); - RegExp ignorePattern = new RegExp(r'// analyzer says "([^"]+)"'); - RegExp conflictingNamesPattern = new RegExp('^The imported libraries \'([^\']+)\' and \'([^\']+)\' cannot have the same name \'([^\']+)\'\$'); RegExp missingFilePattern = new RegExp('^Target of URI does not exist: \'([^\')]+)\'\$'); Set changedFiles = new Set(); // files about which we've complained that they changed @@ -374,11 +371,8 @@ class AnalyzeCommand extends FlutterCommand { } bool shouldIgnore = false; if (filename == mainFile.path) { - Match libs = conflictingNamesPattern.firstMatch(errorMessage); Match missing = missingFilePattern.firstMatch(errorMessage); - if (libs != null) { - errorLine = '[$level] $errorMessage (${dartFiles[lineNumber-1]})'; // strip the reference to the generated main.dart - } else if (missing != null) { + if (missing != null) { errorLine = '[$level] File does not exist (${missing[1]})'; } else { errorLine += ' (Please file a bug on the "flutter analyze" command saying that you saw this message.)'; @@ -394,14 +388,6 @@ class AnalyzeCommand extends FlutterCommand { shouldIgnore = true; } else if (constructorTearOffsPattern.allMatches(sourceLine).isNotEmpty) { shouldIgnore = true; - } else { - Iterable ignoreGroups = ignorePattern.allMatches(sourceLine); - for (Match ignoreGroup in ignoreGroups) { - if (errorMessage.contains(ignoreGroup[1])) { - shouldIgnore = true; - break; - } - } } if (shouldIgnore) continue; From a2dac85f8737e81257260ac292fb3a5e7a406004 Mon Sep 17 00:00:00 2001 From: pq Date: Fri, 11 Mar 2016 13:12:07 -0800 Subject: [PATCH 2/2] Re-added conflictingNamesPattern. --- packages/flutter_tools/lib/src/commands/analyze.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 06227fca04b..99062a35eb3 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -339,6 +339,7 @@ class AnalyzeCommand extends FlutterCommand { RegExp generalPattern = new RegExp(r'^\[(error|warning|hint|lint)\] (.+) \(([^(),]+), line ([0-9]+), col ([0-9]+)\)$'); RegExp allowedIdentifiersPattern = new RegExp(r'_?([A-Z]|_+)\b'); RegExp constructorTearOffsPattern = new RegExp('.+#.+// analyzer doesn\'t like constructor tear-offs'); + RegExp conflictingNamesPattern = new RegExp('^The imported libraries \'([^\']+)\' and \'([^\']+)\' cannot have the same name \'([^\']+)\'\$'); RegExp missingFilePattern = new RegExp('^Target of URI does not exist: \'([^\')]+)\'\$'); Set changedFiles = new Set(); // files about which we've complained that they changed @@ -371,8 +372,11 @@ class AnalyzeCommand extends FlutterCommand { } bool shouldIgnore = false; if (filename == mainFile.path) { + Match libs = conflictingNamesPattern.firstMatch(errorMessage); Match missing = missingFilePattern.firstMatch(errorMessage); - if (missing != null) { + if (libs != null) { + errorLine = '[$level] $errorMessage (${dartFiles[lineNumber-1]})'; // strip the reference to the generated main.dart + } else if (missing != null) { errorLine = '[$level] File does not exist (${missing[1]})'; } else { errorLine += ' (Please file a bug on the "flutter analyze" command saying that you saw this message.)';