Chromium Code Reviews| Index: utils/pub/validator/name.dart |
| diff --git a/utils/pub/validator/name.dart b/utils/pub/validator/name.dart |
| index 687cfc72ca1e8c0fba028a6553d05df22ee80eb1..be9e6ce80cf52aaedaa56432c0617602ba18c68b 100644 |
| --- a/utils/pub/validator/name.dart |
| +++ b/utils/pub/validator/name.dart |
| @@ -31,12 +31,23 @@ class NameValidator extends Validator { |
| if (!libDirExists) return new Future.immediate([]); |
| return listDir(libDir, recursive: true); |
| }).transform((files) { |
| - for (var file in files) { |
| - file = relativeTo(file, libDir); |
| - if (splitPath(file).contains("src")) continue; |
| - if (path.extension(file) != '.dart') continue; |
| - var libName = path.basenameWithoutExtension(file); |
| - _checkName(libName, 'The name of "$file", "$libName",'); |
| + var libraries = files.map((file) => relativeTo(file, dirname(libDir))) |
| + .filter((file) { |
| + return !splitPath(file).contains("src") && |
| + path.extension(file) == '.dart'; |
| + }); |
|
Bob Nystrom
2012/12/13 19:52:32
How about splitting this out into a separate funct
|
| + |
| + for (var library in libraries) { |
| + var libName = path.basenameWithoutExtension(library); |
| + _checkName(libName, 'The name of "$library", "$libName",'); |
| + } |
| + |
| + if (libraries.length == 1) { |
| + var libName = path.basenameWithoutExtension(libraries[0]); |
| + if (libName == entrypoint.root.name) return; |
| + warnings.add('The name of "$libraries[0]", "$libName", should match ' |
| + 'the name of the package, "${entrypoint.root.name}".\n' |
| + 'This helps users know what library to import.'); |
| } |
| }); |
| } |