Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 2eec475

Browse files
authored
fix: make avoid-redundant-async handle yield (#1021)
1 parent ec223c7 commit 2eec475

File tree

3 files changed

+14
-0
lines changed
  • lib/src/analyzers/lint_analyzer/rules/rules_list/avoid_redundant_async
  • test/src/analyzers/lint_analyzer/rules/rules_list/avoid_redundant_async/examples

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* chore: changed min `SDK` version to `2.18.0`.
77
* chore: restrict `analyzer` version to `>=5.1.0 <5.2.0`.
88
* chore: restrict `analyzer_plugin` version to `>=0.11.0 <0.12.0`.
9+
* fix: make [`avoid-redundant-async`](https://dartcodemetrics.dev/docs/rules/common/avoid-redundant-async) correctly handle yield.
910

1011
## 4.19.1
1112

lib/src/analyzers/lint_analyzer/rules/rules_list/avoid_redundant_async/visitor.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,11 @@ class _AsyncVisitor extends RecursiveAstVisitor<void> {
7373

7474
hasValidAsync = true;
7575
}
76+
77+
@override
78+
void visitYieldStatement(YieldStatement node) {
79+
super.visitYieldStatement(node);
80+
81+
hasValidAsync = true;
82+
}
7683
}

test/src/analyzers/lint_analyzer/rules/rules_list/avoid_redundant_async/examples/example.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ class SomeClass {
3434
Future<void> returnNullable(SomeClass? instance) async {
3535
return instance?.report([]);
3636
}
37+
38+
Stream<int> buildStream() async* {
39+
for (int i = 0; i < 10; i++) {
40+
yield i;
41+
}
42+
}
3743
}

0 commit comments

Comments
 (0)