Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore defined_value_getter_type if return Future #100

Merged
merged 1 commit into from
Feb 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class DefinedValueGetterType extends DartLintRule {
final returnType = type.returnType;
if (returnType is VoidType ||
returnType is InvalidType ||
returnType is NeverType) return;
returnType is NeverType ||
returnType.isDartAsyncFuture) return;

reporter.reportErrorForNode(_code, node);
});
Expand Down
17 changes: 14 additions & 3 deletions packages/nilts_test/test/lints/defined_value_getter_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,36 @@ class MainButton extends StatelessWidget {
const MainButton(
void Function() this.onPressed,
// expect_lint: defined_value_getter_type
int Function() this.onReturnPressed, {
int Function() this.onReturnPressed,
Future<int> Function() this.onFutureReturnPressed, {
void Function()? this.onNullablePressed,
void Function(int)? this.onParamPressed,
// expect_lint: defined_value_getter_type
int Function()? this.onNullableReturnPressed,
Future<int> Function()? this.onNullableFutureReturnPressed,
super.key,
});

final void Function() onPressed;
// expect_lint: defined_value_getter_type
final int Function() onReturnPressed;
final Future<int> Function() onFutureReturnPressed;
final void Function()? onNullablePressed;
final void Function(int)? onParamPressed;
// expect_lint: defined_value_getter_type
final int Function()? onNullableReturnPressed;
final Future<int> Function()? onNullableFutureReturnPressed;

void _onPressed(
void Function() onPressed,
// expect_lint: defined_value_getter_type
int Function() onReturnPressed, {
int Function() onReturnPressed,
Future<int> Function() onFutureReturnPressed, {
void Function()? onNullablePressed,
void Function(int)? onParamPressed,
// expect_lint: defined_value_getter_type
int Function()? onNullableReturnPressed,
Future<int> Function()? onNullableFutureReturnPressed,
}) {}

@override
Expand All @@ -44,6 +50,7 @@ class MainButton extends StatelessWidget {
_onPressed(
() {},
() => 0,
() async => 0,
);
onPressed();
},
Expand All @@ -55,17 +62,21 @@ class MainButton extends StatelessWidget {
final void Function() globalFunction = () {};
// expect_lint: defined_value_getter_type
final int Function() globalReturnFunction = () => 0;
final Future<int> Function() globalFutureReturnFunction = () async => 0;
const void Function()? globalNullableFunction = null;
const void Function(int)? globalParamFunction = null;
// expect_lint: defined_value_getter_type
const int Function()? globalNullableReturnFunction = null;
const Future<int> Function()? globalNullableFutureReturnFunction = null;

void _globalFunction(
void Function() onPressed,
// expect_lint: defined_value_getter_type
int Function() onReturnPressed, {
int Function() onReturnPressed,
Future<int> Function() onFutureReturnPressed, {
void Function()? onNullablePressed,
void Function(int)? onParamPressed,
// expect_lint: defined_value_getter_type
int Function()? onNullableReturnPressed,
Future<int> Function()? onNullableFutureReturnPressed,
}) {}
Loading