forked from checkstyle/checkstyle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#12333: Resolve pitest for profile metrics
- Loading branch information
1 parent
d3a5f9a
commit 251c6d1
Showing
3 changed files
with
131 additions
and
45 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
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
120 changes: 120 additions & 0 deletions
120
...com/puppycrawl/tools/checkstyle/checks/metrics/javancss/InputJavaNCSSResolveMutation.java
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,120 @@ | ||
/* | ||
JavaNCSS | ||
methodMaximum = (default)50 | ||
classMaximum = 80 | ||
fileMaximum = (default)2000 | ||
recordMaximum = (default)150 | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.metrics.javancss; | ||
|
||
public class InputJavaNCSSResolveMutation { | ||
// violation above 'NCSS for this class is 84 (max allowed is 80)' | ||
|
||
public static class Some // violation 'NCSS for this class is 83 (max allowed is 80)' | ||
{ | ||
static class SomeClass { | ||
boolean flag = true; | ||
|
||
static boolean test(boolean k) { | ||
return k; | ||
} | ||
} | ||
|
||
private int foo() { | ||
if (SomeClass.test(true)) return 4; | ||
return 0; | ||
} | ||
|
||
private int foo1() { | ||
return 4; | ||
} | ||
|
||
private int foo2() { | ||
if (SomeClass.test(true)) | ||
return 4; | ||
return 0; | ||
} | ||
|
||
private int foo3() { | ||
if (SomeClass.test(true)) if (true) return 4; | ||
return 0; | ||
} | ||
|
||
private void foo(Object o) { | ||
if (o != null) this.notify(); | ||
} | ||
|
||
private void foo2(Object o) { | ||
if (o != null) | ||
this.notify(); | ||
} | ||
|
||
private void loopTest(Object o) { | ||
while (o != null) { | ||
this.notify(); | ||
} | ||
while (o != null) | ||
this.notify(); | ||
while (o != null) this.notify(); | ||
do { | ||
this.notify(); | ||
} while (o != null); | ||
do this.notify(); while (o != null); | ||
do | ||
this.notify(); | ||
while (o != null); | ||
for (; ; ) | ||
break; | ||
for (; ; ) break; | ||
for (int i = 0; i < 10; i++) { | ||
this.notify(); | ||
} | ||
for (int i = 0; i < 10; i++) | ||
this.notify(); | ||
for (int i = 0; ; ) this.notify(); | ||
} | ||
|
||
private int getSmth(int num) { | ||
int counter = 0; | ||
switch (num) { | ||
case 1: | ||
counter++; | ||
break; | ||
case 2: // ok | ||
counter += 2; | ||
break; | ||
case 3: // ok | ||
counter += 3; | ||
break; | ||
case 6: | ||
counter += 10; | ||
break; | ||
default: | ||
counter = 100; | ||
break; | ||
} | ||
return counter; | ||
} | ||
|
||
private void testElse(int k) { | ||
if (k == 4) System.identityHashCode("yes"); | ||
else System.identityHashCode("no"); | ||
for (; ; ) ; | ||
} | ||
|
||
void enhancedForLoop(int[] array) { | ||
for (int value : array) return; | ||
} | ||
|
||
private void forEachLoop() { | ||
for (String s : new String[]{""}) break; | ||
for (String s : new String[]{""}) | ||
break; | ||
for (; ; ) | ||
; | ||
} | ||
} | ||
} |