Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 96099d0

Browse files
committed
Fix for default filter (#228).
The rub is that when I added awareness of filters to max error calculation, I forgot to account for the case where there was none set. This should address that, with a test added. BUG= [email protected] Review URL: https://codereview.chromium.org//1918933002 .
1 parent a8fda45 commit 96099d0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

bin/linter.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,16 @@ $stack''');
174174
}
175175
}
176176

177+
Iterable<AnalysisError> _filtered(
178+
List<AnalysisError> errors, LintFilter filter) =>
179+
(filter == null)
180+
? errors
181+
: errors.where((AnalysisError e) => !filter.filter(e));
182+
177183
int _maxSeverity(List<AnalysisErrorInfo> errors, LintFilter filter) {
178184
int max = 0;
179185
for (AnalysisErrorInfo info in errors) {
180-
info.errors
181-
.where((AnalysisError e) => !filter.filter(e))
182-
.forEach((AnalysisError e) {
186+
_filtered(info.errors, filter).forEach((AnalysisError e) {
183187
max = math.max(max, e.errorCode.errorSeverity.ordinal);
184188
});
185189
}

test/integration_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ defineTests() {
5353
expect(collectingOut.trim(),
5454
stringContainsInOrder(['4 files analyzed, 0 issues found, in']));
5555
});
56+
test('default', () {
57+
dartlint.main(['test/_data/p2']);
58+
expect(exitCode, 1);
59+
expect(collectingOut.trim(),
60+
stringContainsInOrder(['4 files analyzed, 3 issues found, in']));
61+
});
5662
});
5763
});
5864
group('p3', () {

0 commit comments

Comments
 (0)