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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/validator/dependency.dart

Issue 344493003: Update doc comments to follow style guide. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
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 pub.validator.dependency; 5 library pub.validator.dependency;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../entrypoint.dart'; 9 import '../entrypoint.dart';
10 import '../log.dart' as log; 10 import '../log.dart' as log;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 message = '$message For example:\n' 83 message = '$message For example:\n'
84 '\n' 84 '\n'
85 'dependencies:\n' 85 'dependencies:\n'
86 ' ${dep.name}: ${_constraintForVersion(locked.version)}\n'; 86 ' ${dep.name}: ${_constraintForVersion(locked.version)}\n';
87 } 87 }
88 warnings.add("$message\n" 88 warnings.add("$message\n"
89 'Without a constraint, you\'re promising to support ${log.bold("all")} ' 89 'Without a constraint, you\'re promising to support ${log.bold("all")} '
90 'future versions of "${dep.name}".'); 90 'future versions of "${dep.name}".');
91 } 91 }
92 92
93 // Warn that dependencies should allow more than a single version. 93 /// Warn that dependencies should allow more than a single version.
94 void _warnAboutSingleVersionConstraint(PackageDep dep) { 94 void _warnAboutSingleVersionConstraint(PackageDep dep) {
95 warnings.add( 95 warnings.add(
96 'Your dependency on "${dep.name}" should allow more than one version. ' 96 'Your dependency on "${dep.name}" should allow more than one version. '
97 'For example:\n' 97 'For example:\n'
98 '\n' 98 '\n'
99 'dependencies:\n' 99 'dependencies:\n'
100 ' ${dep.name}: ${_constraintForVersion(dep.constraint)}\n' 100 ' ${dep.name}: ${_constraintForVersion(dep.constraint)}\n'
101 '\n' 101 '\n'
102 'Constraints that are too tight will make it difficult for people to ' 102 'Constraints that are too tight will make it difficult for people to '
103 'use your package\n' 103 'use your package\n'
104 'along with other packages that also depend on "${dep.name}".'); 104 'along with other packages that also depend on "${dep.name}".');
105 } 105 }
106 106
107 // Warn that dependencies should have lower bounds on their constraints. 107 /// Warn that dependencies should have lower bounds on their constraints.
108 void _warnAboutNoConstraintLowerBound(PackageDep dep) { 108 void _warnAboutNoConstraintLowerBound(PackageDep dep) {
109 var message = 'Your dependency on "${dep.name}" should have a lower bound.'; 109 var message = 'Your dependency on "${dep.name}" should have a lower bound.';
110 var locked = entrypoint.loadLockFile().packages[dep.name]; 110 var locked = entrypoint.loadLockFile().packages[dep.name];
111 if (locked != null) { 111 if (locked != null) {
112 var constraint; 112 var constraint;
113 if (locked.version == (dep.constraint as VersionRange).max) { 113 if (locked.version == (dep.constraint as VersionRange).max) {
114 constraint = _constraintForVersion(locked.version); 114 constraint = _constraintForVersion(locked.version);
115 } else { 115 } else {
116 constraint = '">=${locked.version} ${dep.constraint}"'; 116 constraint = '">=${locked.version} ${dep.constraint}"';
117 } 117 }
118 118
119 message = '$message For example:\n' 119 message = '$message For example:\n'
120 '\n' 120 '\n'
121 'dependencies:\n' 121 'dependencies:\n'
122 ' ${dep.name}: $constraint\n'; 122 ' ${dep.name}: $constraint\n';
123 } 123 }
124 warnings.add("$message\n" 124 warnings.add("$message\n"
125 'Without a constraint, you\'re promising to support ${log.bold("all")} ' 125 'Without a constraint, you\'re promising to support ${log.bold("all")} '
126 'previous versions of "${dep.name}".'); 126 'previous versions of "${dep.name}".');
127 } 127 }
128 128
129 // Warn that dependencies should have upper bounds on their constraints. 129 /// Warn that dependencies should have upper bounds on their constraints.
130 void _warnAboutNoConstraintUpperBound(PackageDep dep) { 130 void _warnAboutNoConstraintUpperBound(PackageDep dep) {
131 warnings.add( 131 warnings.add(
132 'Your dependency on "${dep.name}" should have an upper bound. For ' 132 'Your dependency on "${dep.name}" should have an upper bound. For '
133 'example:\n' 133 'example:\n'
134 '\n' 134 '\n'
135 'dependencies:\n' 135 'dependencies:\n'
136 ' ${dep.name}: "${dep.constraint} ' 136 ' ${dep.name}: "${dep.constraint} '
137 '${_upperBoundForVersion((dep.constraint as VersionRange).min)}"\n' 137 '${_upperBoundForVersion((dep.constraint as VersionRange).min)}"\n'
138 '\n' 138 '\n'
139 'Without an upper bound, you\'re promising to support ' 139 'Without an upper bound, you\'re promising to support '
140 '${log.bold("all")} future versions of ${dep.name}.'); 140 '${log.bold("all")} future versions of ${dep.name}.');
141 } 141 }
142 142
143 /// Returns the suggested version constraint for a dependency that was tested 143 /// Returns the suggested version constraint for a dependency that was tested
144 /// against [version]. 144 /// against [version].
145 String _constraintForVersion(Version version) => 145 String _constraintForVersion(Version version) =>
146 '">=$version ${_upperBoundForVersion(version)}"'; 146 '">=$version ${_upperBoundForVersion(version)}"';
147 147
148 /// Returns the suggested upper bound for a dependency that was tested against 148 /// Returns the suggested upper bound for a dependency that was tested against
149 /// [version]. 149 /// [version].
150 String _upperBoundForVersion(Version version) { 150 String _upperBoundForVersion(Version version) {
151 if (version.major != 0) return '<${version.major + 1}.0.0'; 151 if (version.major != 0) return '<${version.major + 1}.0.0';
152 return '<${version.major}.${version.minor + 1}.0'; 152 return '<${version.major}.${version.minor + 1}.0';
153 } 153 }
154 } 154 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/validator.dart ('k') | sdk/lib/_internal/pub/lib/src/version.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698