Commit b72bd5bf authored by Ian Hickson's avatar Ian Hickson

Merge pull request #2779 from Hixie/analyze-public-members

Only require documentation for libraries.
parents 991b50e4 ce4e9cd6
......@@ -138,6 +138,25 @@ class AnalyzeCommand extends FlutterCommand {
return argResults['watch'] ? _analyzeWatch() : _analyzeOnce();
}
List<String> flutterRootComponents;
bool isFlutterLibrary(String filename) {
flutterRootComponents ??= path.normalize(path.absolute(ArtifactStore.flutterRoot)).split(path.separator);
List<String> 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<int> _analyzeOnce() async {
Stopwatch stopwatch = new Stopwatch()..start();
Set<String> pubSpecDirectories = new HashSet<String>();
......@@ -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<String> changedFiles = new Set<String>(); // 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) {
......
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