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

Side by Side Diff: bin/linter.dart

Issue 1918933002: Fix for default filter (#228). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/integration_test.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) 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
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 }
OLDNEW
« no previous file with comments | « no previous file | test/integration_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698