mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 07:40:42 +07:00
Java inspection: Fixed catch finally in "Move return to computation" (IDEA-121153)
This commit is contained in:
+1
-1
@@ -4,6 +4,6 @@ class T {
|
||||
int n = 0;
|
||||
if (b) System.out.println("yes");
|
||||
else return 2;
|
||||
return 0;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,6 +4,6 @@ class T {
|
||||
int n = 0;
|
||||
if (b) return 1;
|
||||
else System.out.println("no");
|
||||
return 0;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,6 +7,6 @@ class T {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,6 +3,6 @@ class T {
|
||||
int f(boolean b) {
|
||||
int n = 0;
|
||||
if (b) return 1;
|
||||
return 0;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,6 +3,6 @@ class T {
|
||||
int f(boolean b, int d) {
|
||||
int n = d;
|
||||
if (b) return 1;
|
||||
return d;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ class T {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return r;
|
||||
}
|
||||
|
||||
boolean hasNext() {
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
return n;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 3;
|
||||
}
|
||||
finally {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
return n;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 3;
|
||||
}
|
||||
finally {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
return n;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 3;
|
||||
}
|
||||
finally {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c, boolean d) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
return n;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 3;
|
||||
}
|
||||
finally {
|
||||
if(d) return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
n = 2;
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 3;
|
||||
}
|
||||
finally {
|
||||
System.out.println();
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
n = 3;
|
||||
}
|
||||
finally {
|
||||
System.out.println();
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "false"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
n = 3;
|
||||
}
|
||||
finally {
|
||||
n = 4;
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "false"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
n = 3;
|
||||
}
|
||||
finally {
|
||||
System.out.println(n);
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
n = 3;
|
||||
}
|
||||
finally {
|
||||
return 4;
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class T {
|
||||
int f(boolean b, boolean c, boolean d) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) throw new IOException();
|
||||
n = 2;
|
||||
if (c) throw new RuntimeException();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
n = 3;
|
||||
}
|
||||
finally {
|
||||
if(d) return 4;
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Move 'return' to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
int f(boolean b) {
|
||||
int n = -1;
|
||||
try {
|
||||
n = 1;
|
||||
if (b) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return 2;
|
||||
}
|
||||
re<caret>turn n;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user