-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lots of improvements in the WMC metric. Related to #31
- Loading branch information
1 parent
4c776ec
commit 998ce44
Showing
9 changed files
with
608 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package wmc; | ||
|
||
public class CC10 { | ||
|
||
public void m1() { | ||
int a = 10; | ||
int b = 10; | ||
boolean x = true; | ||
|
||
if(a>10) { | ||
if(b > 10) { | ||
if(x) { | ||
if(!x) { | ||
for(;;) { | ||
while(true) { | ||
for(int i = 0; i < 10 && j < 10; i++) { | ||
boolean y = x ? false : true; | ||
boolean yy = a > 10 && !y ? false : true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else a--; | ||
} | ||
|
||
public void m2() { | ||
int a = 10; | ||
int b = 10; | ||
boolean x = true; | ||
|
||
if(a>10) { | ||
if(b > 10) { | ||
if(x) { | ||
if(!x) { | ||
for(;;) { | ||
while(true) { | ||
for(int i = 0; i < 10 && j < 10; i++) { | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else a--; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package wmc; | ||
|
||
public class CC6 { | ||
public boolean m1(int a) { | ||
if (0 <= a && a <= 10) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public boolean m2(int a) { | ||
boolean cond = (0 <= a && a <= 10); | ||
if (cond) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package wmc; | ||
|
||
public class CC7 { | ||
|
||
public void m1(boolean x) { | ||
int a = 0; | ||
|
||
if(x) a++; | ||
else a--; | ||
} | ||
|
||
public void m2(boolean x) { | ||
int a = 0; | ||
|
||
if(x == true) a++; | ||
else a--; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package wmc; | ||
|
||
import java.util.*; | ||
|
||
public class CC8 { | ||
|
||
public void m0() { | ||
|
||
for(int i = 0, j = 20; i < 10 && j < 20; i++, j++ ) { | ||
// do something else | ||
} | ||
} | ||
|
||
public void m1() { | ||
|
||
for(int i = 0; i < 10; i++) { | ||
// do something | ||
} | ||
|
||
for(int i = 0, j = 20; i < 10 && j < 20; i++, j++ ) { | ||
// do something else | ||
} | ||
|
||
for(;;) { | ||
|
||
} | ||
|
||
boolean x = true; | ||
for(int i = 0; x; i++) { | ||
|
||
} | ||
} | ||
|
||
public void m2() { | ||
int i = 0; | ||
int j = 0; | ||
|
||
while(i < 10) { | ||
// do something | ||
} | ||
|
||
while(i < 10 && j < 20) { | ||
// do something else | ||
} | ||
|
||
while(true) { | ||
|
||
} | ||
|
||
boolean x = true; | ||
while(x) { | ||
|
||
} | ||
} | ||
|
||
public void m3() { | ||
int i = 0; | ||
int j = 0; | ||
|
||
do { | ||
|
||
} while(i < 10); | ||
|
||
do { | ||
// do something else | ||
} while ((i < 10 && j < 20)); | ||
|
||
do { | ||
|
||
} while(true); | ||
|
||
boolean x = true; | ||
do { | ||
|
||
} while(x); | ||
} | ||
|
||
public void m4() { | ||
List<String> xs = new ArrayList<String>(); | ||
for(String x : xs) { | ||
|
||
} | ||
} | ||
|
||
public void m5() { | ||
int a = 10; | ||
while(a > 10 ? true : false) { | ||
|
||
} | ||
|
||
do { | ||
|
||
} while(a > 10 ? true : false); | ||
|
||
|
||
} | ||
|
||
public void m6() { | ||
int i = 0; | ||
int j = 0; | ||
boolean y = false; | ||
|
||
while(true && y && !y && y == false || i > 0) { | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package wmc; | ||
|
||
public class CC9 { | ||
|
||
public void m0() { | ||
int a = 10; | ||
} | ||
|
||
public void m1() { | ||
int a = 0; | ||
int b = 0; | ||
int c = 0; | ||
|
||
if(a > 0) { | ||
|
||
} | ||
|
||
} | ||
|
||
public void m2() { | ||
int a = 0; | ||
int b = 0; | ||
int c = 0; | ||
|
||
if(a > 0) { | ||
|
||
} else if(b > 0) { | ||
|
||
} | ||
|
||
} | ||
|
||
public void m3() { | ||
int a = 0; | ||
int b = 0; | ||
int c = 0; | ||
|
||
if(a > 0) { | ||
|
||
} else { | ||
|
||
} | ||
|
||
} | ||
|
||
public void m4() { | ||
int a = 0; | ||
int b = 0; | ||
int c = 0; | ||
|
||
if(a > 0) { | ||
|
||
} else if(b > 0) { | ||
|
||
} else if(c > 0) { | ||
|
||
} else { | ||
|
||
} | ||
} | ||
|
||
public void m5() { | ||
int a = 0; | ||
int b = 0; | ||
int c = 0; | ||
|
||
if(a > 0 && b < 0) { | ||
|
||
} else if(b > 0 || c > 0) { | ||
|
||
} else if((c == 0 || b < 0) & (a != 0)) { | ||
|
||
} else { | ||
|
||
} | ||
} | ||
|
||
public void m6() { | ||
boolean a = true; | ||
boolean b = false; | ||
boolean c = true; | ||
|
||
if(a) { | ||
|
||
} else if (a == true && b) { | ||
|
||
} else if (!b) { | ||
|
||
} else if(!b && c == false) { | ||
|
||
} else if(!c && b) { | ||
|
||
} | ||
} | ||
|
||
public void m7() { | ||
boolean x = returnTrue(); | ||
|
||
if(x) { | ||
|
||
} else if (returnTrue()) { | ||
|
||
} else if (returnTrue() == false) { | ||
|
||
} else if (!returnTrue()) { | ||
|
||
} | ||
} | ||
|
||
public void m8() { | ||
int x = returnInt(); | ||
|
||
if(x > 10) { | ||
|
||
} else if (returnInt() > 20) { | ||
|
||
} else if (returnInt() + 10 < 20) { | ||
|
||
} | ||
} | ||
|
||
public void m9() { | ||
int a = 0; | ||
int b = 0; | ||
|
||
boolean result = a > 10 ? true : false; | ||
boolean result2 = (a > 10 ? (b > 20 ? true : false) : false); | ||
|
||
if(result) { | ||
|
||
} else if ((a > 10 ? true : false)) { | ||
|
||
} else if ((a > 10 ? true : false) && b > 0) { | ||
|
||
} | ||
|
||
} | ||
|
||
public int returnInt() { | ||
return 10; | ||
} | ||
|
||
public boolean returnTrue() { | ||
return true; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.