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

Side by Side Diff: utils/pub/validator/dependency.dart

Issue 11737013: Validate that a package doesn't depend on itself. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | utils/tests/pub/validator_test.dart » ('j') | utils/tests/pub/validator_test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dependency_validator; 5 library dependency_validator;
6 6
7 import '../entrypoint.dart'; 7 import '../entrypoint.dart';
8 import '../hosted_source.dart'; 8 import '../hosted_source.dart';
9 import '../http.dart'; 9 import '../http.dart';
10 import '../package.dart'; 10 import '../package.dart';
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 if (dependency.constraint.isAny && 26 if (dependency.constraint.isAny &&
27 // TODO(nweiz): once we have development dependencies (issue 5358), we 27 // TODO(nweiz): once we have development dependencies (issue 5358), we
28 // should warn about unittest. Until then, it's reasonable not to put 28 // should warn about unittest. Until then, it's reasonable not to put
29 // a constraint on it. 29 // a constraint on it.
30 dependency.name != 'unittest') { 30 dependency.name != 'unittest') {
31 return _warnAboutConstraint(dependency); 31 return _warnAboutConstraint(dependency);
32 } 32 }
33 33
34 if (dependency.name == entrypoint.root.name) {
35 warnings.add('You don\'t need to explicitly depend on your own '
36 'package.\n'
37 'Pub will make "package:${entrypoint.root.name}" imports work '
38 'automatically.');
Bob Nystrom 2013/01/03 20:52:45 I find the future tense here a bit confusing. How
nweiz 2013/01/03 21:08:12 Done.
39 return;
40 }
41
34 return new Future.immediate(null); 42 return new Future.immediate(null);
35 }); 43 });
36 } 44 }
37 45
38 /// Warn that dependencies should use the hosted source. 46 /// Warn that dependencies should use the hosted source.
39 Future _warnAboutSource(PackageRef ref) { 47 Future _warnAboutSource(PackageRef ref) {
40 return entrypoint.cache.sources['hosted'] 48 return entrypoint.cache.sources['hosted']
41 .getVersions(ref.name, ref.name) 49 .getVersions(ref.name, ref.name)
42 .transformException((e) => <Version>[]) 50 .transformException((e) => <Version>[])
43 .transform((versions) { 51 .transform((versions) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 90 }
83 91
84 /// Returns the suggested version constraint for a dependency that was tested 92 /// Returns the suggested version constraint for a dependency that was tested
85 /// against [version]. 93 /// against [version].
86 String _constraintForVersion(Version version) { 94 String _constraintForVersion(Version version) {
87 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; 95 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"';
88 return '">=$version <${version.major}.${version.minor}.' 96 return '">=$version <${version.major}.${version.minor}.'
89 '${version.patch + 1}"'; 97 '${version.patch + 1}"';
90 } 98 }
91 } 99 }
OLDNEW
« no previous file with comments | « no previous file | utils/tests/pub/validator_test.dart » ('j') | utils/tests/pub/validator_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698