Java inspection: Highlight the whole return statement in "Move return to computation", removed duplicate test cases, changed inspection's level to INFO (IDEA-121153)

This commit is contained in:
Pavel Dolgov
2016-09-07 17:15:45 +03:00
parent 7883184f5a
commit 0b10403b20
38 changed files with 105 additions and 489 deletions
@@ -0,0 +1,16 @@
// "Move 'return' closer to computation of the value of 'raw'" "true"
import java.util.*;
class T {
List<String> f(boolean b) {
List raw = null;
if (b) {
return g();
}
return raw;
}
List<String> g() {
return Collections.singletonList("");
}
}
@@ -0,0 +1,15 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int f(int[][] a) {
int n = -1;
myLabel:
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
if (a[i][j] == 0) {
return j;
}
}
}
return n;
}
}
@@ -0,0 +1,17 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int f(int[][] a) {
int n = -1;
myLabel:
for (int i = 0; i < a.length; i++) {
if (a[i].length == 0) {
return -i - 1;
}
for(int j = 0; j < a[i].length; j++) {
n = j;
if (a[i][j] == 0) return n;
}
}
return n;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' closer to computation of the value of 'raw'" "true"
import java.util.*;
class T {
List<String> f(boolean b) {
List raw = null;
if (b) {
raw = g();
}
re<caret>turn raw;
}
List<String> g() {
return Collections.singletonList("");
}
}
@@ -0,0 +1,16 @@
// "Move 'return' closer to computation of the value of 'raw'" "false"
import java.util.*;
class T {
List<Object> f(boolean b) {
List raw = null;
if (b) {
raw = g();
}
re<caret>turn raw;
}
List<String> g() {
return Collections.singletonList("");
}
}
@@ -0,0 +1,16 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int f(int[][] a) {
int n = -1;
myLabel:
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
if (a[i][j] == 0) {
n = j;
break myLabel;
}
}
}
re<caret>turn n;
}
}
@@ -0,0 +1,18 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int f(int[][] a) {
int n = -1;
myLabel:
for (int i = 0; i < a.length; i++) {
if (a[i].length == 0) {
n = -i - 1;
break myLabel;
}
for(int j = 0; j < a[i].length; j++) {
n = j;
if (a[i][j] == 0) break myLabel;
}
}
re<caret>turn n;
}
}
@@ -0,0 +1,10 @@
// "Move 'return' closer to computation of the value of 'r'" "false"
class T {
int[] f(boolean b) {
int[] r = new int[]{-1};
if (b) {
r[0] = 1;
}
re<caret>turn r;
}
}