Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1809)

Unified Diff: utils/pub/validator/name.dart

Issue 11519049: Validate that a single library has the same name as the package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.');
}
});
}
« no previous file with comments | « no previous file | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698