OLD | NEW |
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 validator; | 5 library validator; |
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 Entrypoint entrypoint) { | 46 Entrypoint entrypoint) { |
47 var validators = [ | 47 var validators = [ |
48 new LibValidator(entrypoint), | 48 new LibValidator(entrypoint), |
49 new LicenseValidator(entrypoint), | 49 new LicenseValidator(entrypoint), |
50 new NameValidator(entrypoint), | 50 new NameValidator(entrypoint), |
51 new PubspecFieldValidator(entrypoint), | 51 new PubspecFieldValidator(entrypoint), |
52 new DependencyValidator(entrypoint), | 52 new DependencyValidator(entrypoint), |
53 new DirectoryValidator(entrypoint) | 53 new DirectoryValidator(entrypoint) |
54 ]; | 54 ]; |
55 | 55 |
56 return Future.wait(validators.mappedBy((validator) => validator.validate())) | 56 return Future.wait(validators.map((validator) => validator.validate())) |
57 .then((_) { | 57 .then((_) { |
58 var errors = | 58 var errors = |
59 flatten(validators.mappedBy((validator) => validator.errors)); | 59 flatten(validators.map((validator) => validator.errors)); |
60 var warnings = | 60 var warnings = |
61 flatten(validators.mappedBy((validator) => validator.warnings)); | 61 flatten(validators.map((validator) => validator.warnings)); |
62 | 62 |
63 if (!errors.isEmpty) { | 63 if (!errors.isEmpty) { |
64 log.error("Missing requirements:"); | 64 log.error("Missing requirements:"); |
65 for (var error in errors) { | 65 for (var error in errors) { |
66 log.error("* ${Strings.join(error.split('\n'), '\n ')}"); | 66 log.error("* ${Strings.join(error.split('\n'), '\n ')}"); |
67 } | 67 } |
68 log.error(""); | 68 log.error(""); |
69 } | 69 } |
70 | 70 |
71 if (!warnings.isEmpty) { | 71 if (!warnings.isEmpty) { |
72 log.warning("Suggestions:"); | 72 log.warning("Suggestions:"); |
73 for (var warning in warnings) { | 73 for (var warning in warnings) { |
74 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); | 74 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); |
75 } | 75 } |
76 log.warning(""); | 76 log.warning(""); |
77 } | 77 } |
78 | 78 |
79 return new Pair<List<String>, List<String>>(errors, warnings); | 79 return new Pair<List<String>, List<String>>(errors, warnings); |
80 }); | 80 }); |
81 } | 81 } |
82 } | 82 } |
OLD | NEW |