diff --git a/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/avoid_ignoring_return_values_rule_test.dart b/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/avoid_ignoring_return_values_rule_test.dart index 532426ff3f..b510a3e1f7 100644 --- a/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/avoid_ignoring_return_values_rule_test.dart +++ b/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/avoid_ignoring_return_values_rule_test.dart @@ -27,32 +27,56 @@ void main() { RuleTestHelper.verifyIssues( issues: issues, startOffsets: [ - 256, - 386, - 427, - 480, - 593, - 650, - 922, - 946, - 1010, - 1541, - 1598, + 455, + 585, + 626, + 759, + 916, + 973, + 1245, + 1269, + 1334, + 1360, + 1537, + 1679, + 1872, + 2888, + 2945, ], - startLines: [20, 28, 30, 33, 38, 41, 54, 55, 61, 101, 104], - startColumns: [5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3], + startLines: [ + 22, + 30, + 32, + 37, + 43, + 46, + 59, + 60, + 66, + 68, + 73, + 77, + 82, + 144, + 147, + ], + startColumns: [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3], endOffsets: [ - 271, - 413, - 442, - 501, - 610, - 673, + 470, + 612, + 641, + 780, 933, - 957, - 1022, - 1552, - 1625, + 996, + 1256, + 1281, + 1346, + 1386, + 1569, + 1709, + 1908, + 2899, + 2972, ], locationTexts: [ 'list.remove(1);', @@ -62,8 +86,12 @@ void main() { 'futureOrMethod();', 'await futureOrMethod();', 'props.name;', - 'props.name;', + 'props.value;', 'props.field;', + 'props.futureMixinMethod();', + 'await props.futureMixinMethod();', + 'props.futureExtensionMethod();', + 'await props.futureExtensionMethod();', 'function();', 'SomeService.staticMethod();', ], @@ -79,6 +107,10 @@ void main() { 'Avoid ignoring return values.', 'Avoid ignoring return values.', 'Avoid ignoring return values.', + 'Avoid ignoring return values.', + 'Avoid ignoring return values.', + 'Avoid ignoring return values.', + 'Avoid ignoring return values.', ], ); }); diff --git a/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/examples/example.dart b/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/examples/example.dart index 9dde787d5f..9ebf2cf37a 100644 --- a/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/examples/example.dart +++ b/test/src/analyzers/lint_analyzer/rules/rules_list/avoid_ignoring_return_values/examples/example.dart @@ -1,3 +1,5 @@ +// ignore_for_file: prefer_expression_function_bodies, unawaited_futures, cascade_invocations, unused_local_variable, unnecessary_statements, prefer_void_to_null, return_without_value + import 'dart:async'; class SomeService { @@ -9,7 +11,7 @@ class SomeService { return 'string'; } - void voidMethod() { + Future voidMethod() async { final list = [ 1, 2, @@ -28,9 +30,12 @@ class SomeService { (list..sort()).contains(1); // LINT futureMethod(); // LINT + futureMethod().then((_) => null); voidFutureMethod(); + voidFutureMethod().then((_) => null); await futureMethod(); // LINT + await futureMethod().then((_) => null); await voidFutureMethod(); final futureResult = await futureMethod(); @@ -52,13 +57,31 @@ class SomeService { final props = ClassWithProps(); props.name; // LINT - props.name; // LINT + props.value; // LINT props ..name ..value; props.field; // LINT + + props.futureMixinMethod(); // LINT + props.futureMixinMethod().then((_) => null); + props.voidFutureMixinMethod(); + props.voidFutureMixinMethod().then((_) => null); + + await props.futureMixinMethod(); // LINT + await props.futureMixinMethod().then((_) => null); + await props.voidFutureMixinMethod(); + + props.futureExtensionMethod(); // LINT + props.futureExtensionMethod().then((_) => null); + props.voidFutureExtensionMethod(); + props.voidFutureExtensionMethod().then((_) => null); + + await props.futureExtensionMethod(); // LINT + await props.futureExtensionMethod().then((_) => null); + await props.voidFutureExtensionMethod(); } Future futureMethod() async { @@ -86,13 +109,33 @@ class SomeService { } } -class ClassWithProps { +class ClassWithProps with MixinWithProp { String get name => 'name'; String get value => 'value'; String field = 'field'; } +mixin MixinWithProp { + Future futureMixinMethod() async { + return 1; + } + + Future voidFutureMixinMethod() async { + return; + } +} + +extension ClassWithPropsExtension on ClassWithProps { + Future futureExtensionMethod() async { + return 1; + } + + Future voidFutureExtensionMethod() async { + return; + } +} + String function() { return 'string'; }