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

Unified Diff: lib/src/validator/dependency.dart

Issue 2079303003: Track Source objects in PackageNames. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/system_cache.dart ('k') | test/lock_file_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/validator/dependency.dart
diff --git a/lib/src/validator/dependency.dart b/lib/src/validator/dependency.dart
index e00879ca9ebbc3fccc5008a1ab88a3f6bd234d02..9d14476f9239dca9ca45bc47a7adff8a679a88d5 100644
--- a/lib/src/validator/dependency.dart
+++ b/lib/src/validator/dependency.dart
@@ -9,6 +9,8 @@ import 'package:pub_semver/pub_semver.dart';
import '../entrypoint.dart';
import '../log.dart' as log;
import '../package.dart';
+import '../source/hosted.dart';
+import '../source/path.dart';
import '../validator.dart';
/// The range of all pub versions that don't support `^` version constraints.
@@ -37,7 +39,7 @@ class DependencyValidator extends Validator {
var caretDeps = [];
for (var dependency in entrypoint.root.pubspec.dependencies) {
- if (dependency.source != "hosted") {
+ if (dependency.source is! HostedSource) {
await _warnAboutSource(dependency);
} else if (dependency.constraint.isAny) {
_warnAboutNoConstraint(dependency);
@@ -84,10 +86,7 @@ class DependencyValidator extends Validator {
}
// Path sources are errors. Other sources are just warnings.
- var messages = warnings;
- if (dep.source == "path") {
- messages = errors;
- }
+ var messages = dep.source is PathSource ? errors : warnings;
messages.add('Don\'t depend on "${dep.name}" from the ${dep.source} '
'source. Use the hosted source instead. For example:\n'
« no previous file with comments | « lib/src/system_cache.dart ('k') | test/lock_file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698