Skip to content

Commit

Permalink
linter: Simplify lintPubspecSource
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
srawlins authored and Commit Queue committed Nov 13, 2024
1 parent d3de4d9 commit 9ea9386
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pkg/linter/lib/src/test_utilities/test_linter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,17 @@ class TestLinter implements AnalysisErrorListener {
var errors = <AnalysisErrorInfo>[];
var lintDriver = LintDriver(options, _resourceProvider);
errors.addAll(await lintDriver.analyze(files.where(isDartFile)));
files.where(isPubspecFile).forEach((file) {
var errorsForFile = lintPubspecSource(
for (var file in files.where(isPubspecFile)) {
lintPubspecSource(
contents: file.readAsStringSync(),
sourcePath: _resourceProvider.pathContext.normalize(file.absolute.path),
);
errors.addAll(errorsForFile);
});
}
return errors;
}

@visibleForTesting
Iterable<AnalysisErrorInfo> lintPubspecSource(
{required String contents, String? sourcePath}) {
var results = <AnalysisErrorInfo>[];
void lintPubspecSource({required String contents, String? sourcePath}) {
var sourceUrl = sourcePath == null ? null : path.toUri(sourcePath);
var spec = Pubspec.parse(contents, sourceUrl: sourceUrl);

Expand All @@ -78,8 +75,6 @@ class TestLinter implements AnalysisErrorListener {
}
}
}

return results;
}

@override
Expand Down

0 comments on commit 9ea9386

Please sign in to comment.