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

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: Code review changes 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') | no next file with comments »
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';
11 import '../utils.dart'; 11 import '../utils.dart';
12 import '../validator.dart'; 12 import '../validator.dart';
13 import '../version.dart'; 13 import '../version.dart';
14 14
15 /// A validator that validates a package's dependencies. 15 /// A validator that validates a package's dependencies.
16 class DependencyValidator extends Validator { 16 class DependencyValidator extends Validator {
17 DependencyValidator(Entrypoint entrypoint) 17 DependencyValidator(Entrypoint entrypoint)
18 : super(entrypoint); 18 : super(entrypoint);
19 19
20 Future validate() { 20 Future validate() {
21 return Futures.forEach(entrypoint.root.pubspec.dependencies, (dependency) { 21 return Futures.forEach(entrypoint.root.pubspec.dependencies, (dependency) {
22 if (dependency.source is! HostedSource) { 22 if (dependency.source is! HostedSource) {
23 return _warnAboutSource(dependency); 23 return _warnAboutSource(dependency);
24 } 24 }
25 25
26 if (dependency.name == entrypoint.root.name) {
27 warnings.add('You don\'t need to explicitly depend on your own '
28 'package.\n'
29 'Pub enables "package:${entrypoint.root.name}" imports '
30 'implicitly.');
31 return new Future.immediate(null);
32 }
33
26 if (dependency.constraint.isAny && 34 if (dependency.constraint.isAny &&
27 // TODO(nweiz): once we have development dependencies (issue 5358), we 35 // TODO(nweiz): once we have development dependencies (issue 5358), we
28 // should warn about unittest. Until then, it's reasonable not to put 36 // should warn about unittest. Until then, it's reasonable not to put
29 // a constraint on it. 37 // a constraint on it.
30 dependency.name != 'unittest') { 38 dependency.name != 'unittest') {
31 return _warnAboutConstraint(dependency); 39 return _warnAboutConstraint(dependency);
32 } 40 }
33 41
34 return new Future.immediate(null); 42 return new Future.immediate(null);
35 }); 43 });
(...skipping 46 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698