| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 services.src.linter; | 5 library services.src.linter; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/plugin/options.dart'; | 8 import 'package:analyzer/plugin/options.dart'; |
| 9 import 'package:linter/src/rules.dart'; | 9 import 'package:linter/src/rules.dart'; |
| 10 import 'package:yaml/yaml.dart'; | 10 import 'package:yaml/yaml.dart'; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 validateRules(rules, reporter); | 33 validateRules(rules, reporter); |
| 34 } | 34 } |
| 35 return errors; | 35 return errors; |
| 36 } | 36 } |
| 37 | 37 |
| 38 validateRules(dynamic rules, ErrorReporter reporter) { | 38 validateRules(dynamic rules, ErrorReporter reporter) { |
| 39 if (rules is YamlList) { | 39 if (rules is YamlList) { |
| 40 //TODO(pq): migrate this to a proper API once there is one. | 40 //TODO(pq): migrate this to a proper API once there is one. |
| 41 Iterable<String> registeredLints = ruleRegistry.map((r) => r.name); | 41 Iterable<String> registeredLints = ruleRegistry.map((r) => r.name); |
| 42 rules.nodes.forEach((YamlNode ruleNode) { | 42 rules.nodes.forEach((YamlNode ruleNode) { |
| 43 if (!registeredLints.contains(ruleNode.value)) { | 43 Object value = ruleNode.value; |
| 44 if (value != null && !registeredLints.contains(value)) { |
| 44 reporter.reportErrorForSpan( | 45 reporter.reportErrorForSpan( |
| 45 UNDEFINED_LINT_WARNING, ruleNode.span, [ruleNode.value]); | 46 UNDEFINED_LINT_WARNING, ruleNode.span, [value]); |
| 46 } | 47 } |
| 47 }); | 48 }); |
| 48 } | 49 } |
| 49 } | 50 } |
| 50 } | 51 } |
| OLD | NEW |