Skip to content

Commit 1c12bbb

Browse files
committed
Issue #92: added test case where return var defined from mutable, but return goes just after (bad practice, not valid caching case)
1 parent 0e11f8f commit 1c12bbb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lint_test/dont_create_a_return_var_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ int returnVarTestCachedMutable() {
3131
return result;
3232
}
3333

34+
/// Test the dont_create_a_return_var.
35+
/// Caching mutable variable value, but return goes
36+
/// right after declaration, which makes it bad.
37+
int returnVarTestReturnFollowsDeclaration() {
38+
var a = 1;
39+
final result = a;
40+
41+
//Some comment here
42+
43+
//expect_lint: dont_create_a_return_var
44+
return result;
45+
}
46+
3447
/// Test the dont_create_a_return_var.
3548
/// Caching another method result.
3649
/// Unpredictable: may be useful to cache value

0 commit comments

Comments
 (0)