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

fix: ignore override methods for avoid-redundant-async #1060

Merged
merged 1 commit into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* feat: **Breaking change** cleanup public API.
* chore: restrict `analyzer` version to `>=5.1.0 <5.3.0`.
* feat: add `print-config` option to all commands.
* fix: ignore `@override` methods for [`avoid-redundant-async`](https://dartcodemetrics.dev/docs/rules/common/avoid-redundant-async).

## 4.21.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ class _Visitor extends RecursiveAstVisitor<void> {
void visitMethodDeclaration(MethodDeclaration node) {
super.visitMethodDeclaration(node);

if (_hasRedundantAsync(node.body)) {
final isOverride = node.metadata.any(
(node) =>
node.name.name == 'override' && node.atSign.type == TokenType.AT,
);

if (!isOverride && _hasRedundantAsync(node.body)) {
_declarations.add(node);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class SomeClass {
// LINT
Future<String> anotherAsyncMethod() async => Future.value('value');

@override
Future<String> overrideMethod() async => Future.value('value');

Future<String> someAsyncMethod(Future<String> later) => later;

Future<void> report(Iterable<String> records) async {
Expand Down