OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:io'; | 5 import 'dart:io'; |
6 import 'dart:math' as math; | 6 import 'dart:math' as math; |
7 | 7 |
8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
9 import 'package:analyzer/src/generated/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 quiet: options['quiet']); | 167 quiet: options['quiet']); |
168 reporter.write(); | 168 reporter.write(); |
169 } catch (err, stack) { | 169 } catch (err, stack) { |
170 errorSink.writeln('''An error occurred while linting | 170 errorSink.writeln('''An error occurred while linting |
171 Please report it at: github.com/dart-lang/linter/issues | 171 Please report it at: github.com/dart-lang/linter/issues |
172 $err | 172 $err |
173 $stack'''); | 173 $stack'''); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
| 177 Iterable<AnalysisError> _filtered( |
| 178 List<AnalysisError> errors, LintFilter filter) => |
| 179 (filter == null) |
| 180 ? errors |
| 181 : errors.where((AnalysisError e) => !filter.filter(e)); |
| 182 |
177 int _maxSeverity(List<AnalysisErrorInfo> errors, LintFilter filter) { | 183 int _maxSeverity(List<AnalysisErrorInfo> errors, LintFilter filter) { |
178 int max = 0; | 184 int max = 0; |
179 for (AnalysisErrorInfo info in errors) { | 185 for (AnalysisErrorInfo info in errors) { |
180 info.errors | 186 _filtered(info.errors, filter).forEach((AnalysisError e) { |
181 .where((AnalysisError e) => !filter.filter(e)) | |
182 .forEach((AnalysisError e) { | |
183 max = math.max(max, e.errorCode.errorSeverity.ordinal); | 187 max = math.max(max, e.errorCode.errorSeverity.ordinal); |
184 }); | 188 }); |
185 } | 189 } |
186 return max; | 190 return max; |
187 } | 191 } |
OLD | NEW |