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

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

Issue 702343002: Fix analyzer warnings in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | sdk/lib/_internal/pub_generated/lib/src/validator/dependency.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 pub.validator.dependency; 5 library pub.validator.dependency;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:pub_semver/pub_semver.dart'; 9 import 'package:pub_semver/pub_semver.dart';
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ' ${dep.name}: $constraint\n'; 147 ' ${dep.name}: $constraint\n';
148 } 148 }
149 warnings.add("$message\n" 149 warnings.add("$message\n"
150 'Without a constraint, you\'re promising to support ${log.bold("all")} ' 150 'Without a constraint, you\'re promising to support ${log.bold("all")} '
151 'previous versions of "${dep.name}".'); 151 'previous versions of "${dep.name}".');
152 } 152 }
153 153
154 /// Warn that dependencies should have upper bounds on their constraints. 154 /// Warn that dependencies should have upper bounds on their constraints.
155 void _warnAboutNoConstraintUpperBound(PackageDep dep) { 155 void _warnAboutNoConstraintUpperBound(PackageDep dep) {
156 var constraint; 156 var constraint;
157 if ((dep.constraint as VersionRange).includeMin) { 157 if ((dep.constraint as VersionRange).includeMin) {
Bob Nystrom 2014/11/06 17:14:20 What if it isn't a range? What if it's just a Vers
nweiz 2014/11/06 21:11:39 We can only get to this method if the constraint d
158 constraint = _constraintForVersion(dep.constraint.min); 158 constraint = _constraintForVersion((dep.constraint as VersionRange).min);
159 } else { 159 } else {
160 constraint = '"${dep.constraint} ' 160 constraint = '"${dep.constraint} '
161 '<${(dep.constraint as VersionRange).min.nextBreaking}"'; 161 '<${(dep.constraint as VersionRange).min.nextBreaking}"';
162 } 162 }
163 163
164 warnings.add( 164 warnings.add(
165 'Your dependency on "${dep.name}" should have an upper bound. For ' 165 'Your dependency on "${dep.name}" should have an upper bound. For '
166 'example:\n' 166 'example:\n'
167 '\n' 167 '\n'
168 'dependencies:\n' 168 'dependencies:\n'
169 ' ${dep.name}: $constraint\n' 169 ' ${dep.name}: $constraint\n'
170 '\n' 170 '\n'
171 'Without an upper bound, you\'re promising to support ' 171 'Without an upper bound, you\'re promising to support '
172 '${log.bold("all")} future versions of ${dep.name}.'); 172 '${log.bold("all")} future versions of ${dep.name}.');
173 } 173 }
174 174
175 /// Emits an error for any version constraints that use `^` without an 175 /// Emits an error for any version constraints that use `^` without an
176 /// appropriate SDK constraint. 176 /// appropriate SDK constraint.
177 void _errorAboutCaretConstraints(List<PackageDeps> caretDeps) { 177 void _errorAboutCaretConstraints(List<PackageDep> caretDeps) {
178 var newSdkConstraint = entrypoint.root.pubspec.environment.sdkVersion 178 var newSdkConstraint = entrypoint.root.pubspec.environment.sdkVersion
179 .intersect(_postCaretPubVersions); 179 .intersect(_postCaretPubVersions);
180 180
181 if (newSdkConstraint.isEmpty) newSdkConstraint = _postCaretPubVersions; 181 if (newSdkConstraint.isEmpty) newSdkConstraint = _postCaretPubVersions;
182 182
183 var buffer = new StringBuffer( 183 var buffer = new StringBuffer(
184 "Older versions of pub don't support ^ version constraints.\n" 184 "Older versions of pub don't support ^ version constraints.\n"
185 "Make sure your SDK constraint excludes those old versions:\n" 185 "Make sure your SDK constraint excludes those old versions:\n"
186 "\n" 186 "\n"
187 "environment:\n" 187 "environment:\n"
(...skipping 18 matching lines...) Expand all
206 errors.add(buffer.toString().trim()); 206 errors.add(buffer.toString().trim());
207 } 207 }
208 208
209 /// Returns the suggested version constraint for a dependency that was tested 209 /// Returns the suggested version constraint for a dependency that was tested
210 /// against [version]. 210 /// against [version].
211 String _constraintForVersion(Version version) { 211 String _constraintForVersion(Version version) {
212 if (_caretAllowed) return "^$version"; 212 if (_caretAllowed) return "^$version";
213 return '">=$version <${version.nextBreaking}"'; 213 return '">=$version <${version.nextBreaking}"';
214 } 214 }
215 } 215 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/pub_generated/lib/src/validator/dependency.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698