diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 011ba0bf9c..1155170de0 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -138,6 +138,25 @@ class AnalyzeCommand extends FlutterCommand { return argResults['watch'] ? _analyzeWatch() : _analyzeOnce(); } + List flutterRootComponents; + bool isFlutterLibrary(String filename) { + flutterRootComponents ??= path.normalize(path.absolute(ArtifactStore.flutterRoot)).split(path.separator); + List filenameComponents = path.normalize(path.absolute(filename)).split(path.separator); + if (filenameComponents.length < flutterRootComponents.length + 4) // the 4: 'packages', package_name, 'lib', file_name + return false; + for (int index = 0; index < flutterRootComponents.length; index += 1) { + if (flutterRootComponents[index] != filenameComponents[index]) + return false; + } + if (filenameComponents[flutterRootComponents.length] != 'packages') + return false; + if (filenameComponents[flutterRootComponents.length + 1] == 'flutter_tools') + return false; + if (filenameComponents[flutterRootComponents.length + 2] != 'lib') + return false; + return true; + } + Future _analyzeOnce() async { Stopwatch stopwatch = new Stopwatch()..start(); Set pubSpecDirectories = new HashSet(); @@ -343,6 +362,7 @@ class AnalyzeCommand extends FlutterCommand { 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: \'([^\')]+)\'\$'); + RegExp documentAllMembersPattern = new RegExp('^Document all public memm?bers\$'); Set changedFiles = new Set(); // files about which we've complained that they changed @@ -373,7 +393,11 @@ class AnalyzeCommand extends FlutterCommand { colNumber = 1; } bool shouldIgnore = false; - if (filename == mainFile.path) { + if (documentAllMembersPattern.firstMatch(errorMessage) != null) { + // https://github.com/dart-lang/linter/issues/207 + // https://github.com/dart-lang/linter/issues/208 + shouldIgnore = !isFlutterLibrary(filename); + } else if (filename == mainFile.path) { Match libs = conflictingNamesPattern.firstMatch(errorMessage); Match missing = missingFilePattern.firstMatch(errorMessage); if (libs != null) {