Skip to content

Commit 9ea9386

Browse files
srawlinsCommit Queue
authored andcommitted
linter: Simplify lintPubspecSource
A `results` variable was declared in this function, and then just always returned as empty. Since it only ever returned an empty list, we refactor it to just return `void`. Change-Id: Ic785365e3b79666a8a46a595bc656e9b3f1c42e0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394384 Auto-Submit: Samuel Rawlins <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent d3de4d9 commit 9ea9386

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

pkg/linter/lib/src/test_utilities/test_linter.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,17 @@ class TestLinter implements AnalysisErrorListener {
4444
var errors = <AnalysisErrorInfo>[];
4545
var lintDriver = LintDriver(options, _resourceProvider);
4646
errors.addAll(await lintDriver.analyze(files.where(isDartFile)));
47-
files.where(isPubspecFile).forEach((file) {
48-
var errorsForFile = lintPubspecSource(
47+
for (var file in files.where(isPubspecFile)) {
48+
lintPubspecSource(
4949
contents: file.readAsStringSync(),
5050
sourcePath: _resourceProvider.pathContext.normalize(file.absolute.path),
5151
);
52-
errors.addAll(errorsForFile);
53-
});
52+
}
5453
return errors;
5554
}
5655

5756
@visibleForTesting
58-
Iterable<AnalysisErrorInfo> lintPubspecSource(
59-
{required String contents, String? sourcePath}) {
60-
var results = <AnalysisErrorInfo>[];
57+
void lintPubspecSource({required String contents, String? sourcePath}) {
6158
var sourceUrl = sourcePath == null ? null : path.toUri(sourcePath);
6259
var spec = Pubspec.parse(contents, sourceUrl: sourceUrl);
6360

@@ -78,8 +75,6 @@ class TestLinter implements AnalysisErrorListener {
7875
}
7976
}
8077
}
81-
82-
return results;
8378
}
8479

8580
@override

0 commit comments

Comments
 (0)