From 9ea93866473aec5a4e098788f728cd8808350c80 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Wed, 13 Nov 2024 18:22:29 +0000 Subject: [PATCH] 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 Reviewed-by: Phil Quitslund Commit-Queue: Phil Quitslund --- pkg/linter/lib/src/test_utilities/test_linter.dart | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/linter/lib/src/test_utilities/test_linter.dart b/pkg/linter/lib/src/test_utilities/test_linter.dart index 631b16533ed7..054baa98f83b 100644 --- a/pkg/linter/lib/src/test_utilities/test_linter.dart +++ b/pkg/linter/lib/src/test_utilities/test_linter.dart @@ -44,20 +44,17 @@ class TestLinter implements AnalysisErrorListener { var errors = []; 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 lintPubspecSource( - {required String contents, String? sourcePath}) { - var results = []; + void lintPubspecSource({required String contents, String? sourcePath}) { var sourceUrl = sourcePath == null ? null : path.toUri(sourcePath); var spec = Pubspec.parse(contents, sourceUrl: sourceUrl); @@ -78,8 +75,6 @@ class TestLinter implements AnalysisErrorListener { } } } - - return results; } @override