mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Java inspection: More tests for "Move return to computation" (IDEA-121153)
This commit is contained in:
-13
@@ -1,13 +0,0 @@
|
||||
class T {
|
||||
int f(int[] a) {
|
||||
int n = -1;
|
||||
myLabel:
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[0] == 0) {
|
||||
n = i;
|
||||
break myLabel;
|
||||
}
|
||||
}
|
||||
<warning descr="Return separated from computation of value of 'n'">return n;</warning>
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
class T {
|
||||
int f(int[] a) {
|
||||
int n = -1;
|
||||
myLabel:
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
n = i;
|
||||
if (a[0] == 0) break myLabel;
|
||||
}
|
||||
<warning descr="Return separated from computation of value of 'n'">return n;</warning>
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = 0;
|
||||
myLabel:
|
||||
if (b) n = 1;
|
||||
else break myLabel;
|
||||
<warning descr="Return separated from computation of value of 'n'">return n;</warning>
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class T {
|
||||
int f() {
|
||||
int n;
|
||||
{
|
||||
n = 1;
|
||||
}
|
||||
<warning descr="Return separated from computation of value of 'n'">return n;</warning>
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
class T {
|
||||
int f() {
|
||||
int n;
|
||||
{
|
||||
n = 1;
|
||||
System.out.println();
|
||||
}
|
||||
<warning descr="Return separated from computation of value of 'n'">return n;</warning>
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) {
|
||||
n = 1;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) n = 1;
|
||||
else n = 2;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) n = 1;
|
||||
}
|
||||
else n = 2;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
private static String getString() throws IOException {
|
||||
String s;
|
||||
try (BufferedReader r = open()) {
|
||||
s = r.readLine();
|
||||
}
|
||||
<warning descr="Return separated from computation of value of 's'">return s;</warning>
|
||||
}
|
||||
|
||||
private static BufferedReader open() throws FileNotFoundException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
class T {
|
||||
String f(String a) {
|
||||
String r = "";
|
||||
int i = 0;
|
||||
do {
|
||||
int j = a.indexOf(",", i);
|
||||
String s = j > i ? a.substring(i, j) : a.substring(i);
|
||||
if (s.startsWith("@")) {
|
||||
r = s;
|
||||
break;
|
||||
}
|
||||
i = j + 1;
|
||||
}
|
||||
while (i >= 0);
|
||||
<warning descr="Return separated from computation of value of 'r'">return r;</warning>
|
||||
}
|
||||
|
||||
boolean hasNext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
String next() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
class T {
|
||||
String f(String[] a) {
|
||||
String r = "";
|
||||
for (String s : a) {
|
||||
if (s != null && s.contains("@")) {
|
||||
r = s + ":" + s.length();
|
||||
break;
|
||||
}
|
||||
}
|
||||
<warning descr="Return separated from computation of value of 'r'">return r;</warning>
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Move 'return' 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[0] == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Move 'return' 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++) {
|
||||
n = i;
|
||||
if (a[0] == 0) return n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = 0;
|
||||
myLabel:
|
||||
if (b) return 1;
|
||||
else return n;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f() {
|
||||
int n;
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f() {
|
||||
int n;
|
||||
{
|
||||
n = 1;
|
||||
System.out.println();
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) return 1;
|
||||
else return 2;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) return 1;
|
||||
}
|
||||
else return 2;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
private static String getString() throws IOException {
|
||||
String s;
|
||||
try (BufferedReader r = open()) {
|
||||
return r.readLine();
|
||||
}
|
||||
}
|
||||
|
||||
private static BufferedReader open() throws FileNotFoundException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// "Move 'return' to computation of the value of 'r'" "true"
|
||||
class T {
|
||||
String f(String a) {
|
||||
String r = "";
|
||||
int i = 0;
|
||||
do {
|
||||
int j = a.indexOf(",", i);
|
||||
String s = j > i ? a.substring(i, j) : a.substring(i);
|
||||
if (s.startsWith("@")) {
|
||||
return s;
|
||||
}
|
||||
i = j + 1;
|
||||
}
|
||||
while (i >= 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
boolean hasNext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
String next() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
String f(String[] a) {
|
||||
String r = "";
|
||||
for (String s : a) {
|
||||
if (s != null && s.contains("@")) {
|
||||
return s + ":" + s.length();
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// "Move 'return' to computation of the value of 'r'" "true"
|
||||
class T {
|
||||
String f(String p) {
|
||||
String r = null;
|
||||
try {
|
||||
while (true) {
|
||||
String n = next();
|
||||
if (n != null) {
|
||||
String t = n.toLowerCase();
|
||||
if (t.equals(p)) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
String next() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'r'" "true"
|
||||
class T {
|
||||
String f(String p) {
|
||||
String r = null;
|
||||
try {
|
||||
while (true) {
|
||||
String n = next();
|
||||
if (n != null) return r;
|
||||
if ("@".eqals(n)) {
|
||||
String t = n.toLowerCase();
|
||||
if (t.equals(p)) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
String next() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Move 'return' 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[0] == 0) {
|
||||
n = i;
|
||||
break myLabel;
|
||||
}
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Move 'return' 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++) {
|
||||
n = i;
|
||||
if (a[0] == 0) break myLabel;
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = 0;
|
||||
myLabel:
|
||||
if (b) n = 1;
|
||||
else break myLabel;
|
||||
ret<caret>urn n;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f() {
|
||||
int n;
|
||||
{
|
||||
n = 1;
|
||||
}
|
||||
ret<caret>urn n;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f() {
|
||||
int n;
|
||||
{
|
||||
n = 1;
|
||||
System.out.println();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) {
|
||||
n = 1;
|
||||
}
|
||||
}
|
||||
ret<caret>urn n;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) n = 1;
|
||||
else n = 2;
|
||||
}
|
||||
r<return>eturn n;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean a, boolean b) {
|
||||
int n = -1;
|
||||
if (a) {
|
||||
if (b) n = 1;
|
||||
}
|
||||
else n = 2;
|
||||
re<before>turn n;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
private static String getString() throws IOException {
|
||||
String s;
|
||||
try (BufferedReader r = open()) {
|
||||
s = r.readLine();
|
||||
}
|
||||
re<return>turn s;
|
||||
}
|
||||
|
||||
private static BufferedReader open() throws FileNotFoundException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// "Move 'return' to computation of the value of 'r'" "true"
|
||||
class T {
|
||||
String f(String a) {
|
||||
String r = "";
|
||||
int i = 0;
|
||||
do {
|
||||
int j = a.indexOf(",", i);
|
||||
String s = j > i ? a.substring(i, j) : a.substring(i);
|
||||
if (s.startsWith("@")) {
|
||||
r = s;
|
||||
break;
|
||||
}
|
||||
i = j + 1;
|
||||
}
|
||||
while (i >= 0);
|
||||
retu<caret>rn r;
|
||||
}
|
||||
|
||||
boolean hasNext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
String next() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
String f(String[] a) {
|
||||
String r = "";
|
||||
for (String s : a) {
|
||||
if (s != null && s.contains("@")) {
|
||||
r = s + ":" + s.length();
|
||||
break;
|
||||
}
|
||||
}
|
||||
r<caret>eturn r;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// "Move 'return' to computation of the value of 'r'" "true"
|
||||
class T {
|
||||
String f(String p) {
|
||||
String r = null;
|
||||
try {
|
||||
while (true) {
|
||||
String n = next();
|
||||
if (n != null) {
|
||||
String t = n.toLowerCase();
|
||||
if (t.equals(p)) {
|
||||
r = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
System.out.println();
|
||||
}
|
||||
re<caret>turn r;
|
||||
}
|
||||
|
||||
String next() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// "Move 'return' to computation of the value of 'r'" "true"
|
||||
class T {
|
||||
String f(String p) {
|
||||
String r = null;
|
||||
try {
|
||||
while (true) {
|
||||
String n = next();
|
||||
if (n != null) break;
|
||||
if ("@".eqals(n)) {
|
||||
String t = n.toLowerCase();
|
||||
if (t.equals(p)) {
|
||||
r = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
System.out.println();
|
||||
}
|
||||
re<caret>turn r;
|
||||
}
|
||||
|
||||
String next() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user