11// ignore_for_file: unused_local_variable, newline_before_return, no_empty_block
22
3- /// Test the dont_create_a_return_var .
3+ /// Test the avoid_unnecessary_return_variable .
44/// Good code, trivial case.
55int returnVarTestGoodTrivial () {
66 return 1 ;
77}
88
9- /// Test the dont_create_a_return_var .
9+ /// Test the avoid_unnecessary_return_variable .
1010/// Returning mutable variable should not trigger the lint.
1111int returnVarTestReturnMutable () {
1212 var a = 1 ;
@@ -19,7 +19,7 @@ int returnVarTestReturnParameter(int param) {
1919 return param;
2020}
2121
22- /// Test the dont_create_a_return_var .
22+ /// Test the avoid_unnecessary_return_variable .
2323/// Caching mutable variable value.
2424/// Unpredictable: may be useful to cache value
2525/// before operation can change it.
@@ -31,7 +31,7 @@ int returnVarTestCachedMutable() {
3131 return result;
3232}
3333
34- /// Test the dont_create_a_return_var .
34+ /// Test the avoid_unnecessary_return_variable .
3535/// Caching mutable variable value, but return goes
3636/// right after declaration, which makes it bad.
3737int returnVarTestReturnFollowsDeclaration () {
@@ -40,11 +40,11 @@ int returnVarTestReturnFollowsDeclaration() {
4040
4141 //Some comment here
4242
43- //expect_lint: dont_create_a_return_var
43+ //expect_lint: avoid_unnecessary_return_variable
4444 return result;
4545}
4646
47- /// Test the dont_create_a_return_var .
47+ /// Test the avoid_unnecessary_return_variable .
4848/// Caching another method result.
4949/// Unpredictable: may be useful to cache value
5050/// before operation can change it.
@@ -56,7 +56,7 @@ int returnVarTestCachedAnotherMethodResult() {
5656 return result;
5757}
5858
59- /// Test the dont_create_a_return_var .
59+ /// Test the avoid_unnecessary_return_variable .
6060/// Caching value of object's field.
6161/// Unpredictable: may be useful to cache value
6262/// before operation can change it.
@@ -68,7 +68,7 @@ int returnVarTestCachedObjectField() {
6868 return result;
6969}
7070
71- /// Test the dont_create_a_return_var .
71+ /// Test the avoid_unnecessary_return_variable .
7272/// Good: variable is created not only for return
7373/// but is used in following expressions as well.
7474int returnVarTestUsedVariable () {
@@ -79,16 +79,16 @@ int returnVarTestUsedVariable() {
7979 return result;
8080}
8181
82- /// Test the dont_create_a_return_var .
82+ /// Test the avoid_unnecessary_return_variable .
8383/// Bad code, trivial example.
8484int returnVarTestBadTrivial () {
8585 final result = 1 ;
8686
87- //expect_lint: dont_create_a_return_var
87+ //expect_lint: avoid_unnecessary_return_variable
8888 return result;
8989}
9090
91- /// Test the dont_create_a_return_var .
91+ /// Test the avoid_unnecessary_return_variable .
9292/// Bad code: result expression is immutable,
9393/// so can be written in return statement directly.
9494int returnVarTestBadImmutableExpression () {
@@ -103,7 +103,7 @@ int returnVarTestBadImmutableExpression() {
103103 testObj.finalField;
104104 _doNothing ();
105105
106- //expect_lint: dont_create_a_return_var
106+ //expect_lint: avoid_unnecessary_return_variable
107107 return result;
108108}
109109
0 commit comments