Java inspection: Don't look for assignment chains in 'switch' and loop statements in "Move return to computation" inspection (IDEA-121153)

This commit is contained in:
Pavel Dolgov
2016-09-07 18:48:46 +03:00
parent bed73576d5
commit f3d22142cd
3 changed files with 57 additions and 1 deletions
@@ -0,0 +1,23 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
switch (a) {
case 0:
case 1:
case 2:
return n;
case 10:
case 20:
return n + 1;
case 30:
case 40:
case 50:
return 2;
case 90:
return 3;
default:
throw new IllegalArgumentException();
}
}
}
@@ -0,0 +1,27 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
switch (a) {
case 0:
case 1:
case 2:
break;
case 10:
case 20:
n = n + 1;
break;
case 30:
case 40:
case 50:
n = 2;
break;
case 90:
n = 3;
break;
default:
throw new IllegalArgumentException();
}
r<caret>eturn n;
}
}