MoveConditionToLoopInspection inspection created: IDEA-117791

This commit is contained in:
Roman Ivanov
2018-01-11 17:34:22 +07:00
parent 0363a6f4a9
commit 52ffac3745
16 changed files with 354 additions and 1 deletions
@@ -0,0 +1,9 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
while (i < 12) {
i++;
}
}
}
@@ -0,0 +1,9 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
do {
i++;
} while (i < 12);
}
}
@@ -0,0 +1,10 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
// negative i is invalid - stop here
do {
i++;
} while (i >= 0);
}
}
@@ -0,0 +1,15 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
/*1*/
/*2*/
/*3*/
/*7*/
/*8*/
while (i < 12) {
/*4*/
i =/*5*/ i + 1;/*6*/
}
}
}
@@ -0,0 +1,10 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
for<caret>(;;) {
if(i >= 12) break;
i++;
}
}
}
@@ -0,0 +1,10 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
while<caret>(true) {
i++;
if(i >= 12) break;
}
}
}
@@ -0,0 +1,13 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
while<caret>(true) {
i++;
if(i < 0) {
// negative i is invalid - stop here
break;
}
}
}
}
@@ -0,0 +1,11 @@
// "Move condition to loop" "false"
class Main {
public static void main(String[] args) {
int i = 0;
while<caret>((true) {
i++;
if(i == 4) continue;
if(i >= 12) break;
}
}
}
@@ -0,0 +1,11 @@
// "Move condition to loop" "false"
class Main {
public static void main(String[] args) {
int i = 0;
while<caret>(true) {
i++;
int j = i;
if(j >= 12) break;
}
}
}
@@ -0,0 +1,11 @@
// "Move condition to loop" "true"
class Main {
public static void main(String[] args) {
int i = 0;
while<caret>(true/*7*/) /*8*/ {
if(i >= 12/*1*/)/*2*/ break;/*3*/
/*4*/
i =/*5*/ i + 1;/*6*/
}
}
}