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

fix: make avoid-redundant-async correctly handle nullable return values #1009

Merged
merged 2 commits into from Sep 24, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## 4.19.1

* fix: make [`avoid-redundant-async`](https://dartcodemetrics.dev/docs/rules/common/avoid-redundant-async) correctly handle nullable return values.
* fix: make [`avoid-wrapping-in-padding`](https://dartcodemetrics.dev/docs/rules/flutter/avoid-wrapping-in-padding) trigger only on Container widget.

## 4.19.0
Expand Down
Expand Up @@ -3,6 +3,7 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';

import '../../../../../utils/node_utils.dart';
import '../../../lint_utils.dart';
Expand Down
Expand Up @@ -53,7 +53,9 @@ class _AsyncVisitor extends RecursiveAstVisitor<void> {

final type = node.expression?.staticType;

if (type == null || !type.isDartAsyncFuture) {
if (type == null ||
!type.isDartAsyncFuture ||
type.nullabilitySuffix == NullabilitySuffix.question) {
hasValidAsync = true;
}
}
Expand Down
Expand Up @@ -30,4 +30,8 @@ class SomeClass {

print(records);
}

Future<void> returnNullable(SomeClass? instance) async {
return instance?.report([]);
}
}