Skip to content

Commit

Permalink
Issue #12261: Resolve Pitest suppression for EmptyForIteratorPadCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin222004 authored and rnveach committed Oct 7, 2022
1 parent ba8efc2 commit dab7ef8
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 18 deletions.
18 changes: 0 additions & 18 deletions .ci/pitest-suppressions/pitest-whitespace-suppressions.xml
Expand Up @@ -36,24 +36,6 @@
<lineContent>final DetailAST semi = ast.getNextSibling();</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>EmptyForIteratorPadCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::toUpperCase with receiver</description>
<lineContent>option = PadOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>EmptyForIteratorPadCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::trim with receiver</description>
<lineContent>option = PadOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>EmptyLineSeparatorCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck</mutatedClass>
Expand Down
Expand Up @@ -107,4 +107,25 @@ public void testInvalidOption() throws Exception {
}
}

@Test
public void testTrimOptionProperty() throws Exception {
final String[] expected = {
"20:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"),
};
verifyWithInlineConfigParser(
getPath("InputEmptyForIteratorPadToCheckTrimFunctionInOptionProperty.java"),
expected);

}

@Test
public void testUppercaseOptionProperty() throws Exception {
final String[] expected = {
"20:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"),
};
verifyWithInlineConfigParser(
getPath("InputEmptyForIteratorPadToCheckUppercaseFunctionInOptionProperty.java"),
expected);

}
}
@@ -0,0 +1,28 @@
/*
EmptyForIteratorPad
option = \tSPACE
*/

package com.puppycrawl.tools.checkstyle.checks.whitespace.emptyforiteratorpad;

class InputEmptyForIteratorPadToCheckTrimFunctionInOptionProperty {

void method() {

for (int i = 0; i < 1;i++ ) {
}

for (int i = 0; i < 1; i++ ) {
}

for (int i = 0; i < 1;) { // violation '';' is not followed by whitespace'
i++;
}

for (int i = 0; i < 1; ) { // ok
i++;
}
}
}
@@ -0,0 +1,28 @@
/*
EmptyForIteratorPad
option = space
*/

package com.puppycrawl.tools.checkstyle.checks.whitespace.emptyforiteratorpad;

public class InputEmptyForIteratorPadToCheckUppercaseFunctionInOptionProperty {

void method() {

for (int i = 0; i < 1;i++ ) {
}

for (int i = 0; i < 1; i++ ) {
}

for (int i = 0; i < 1;) { // violation '';' is not followed by whitespace'
i++;
}

for (int i = 0; i < 1; ) { // ok
i++;
}
}
}

0 comments on commit dab7ef8

Please sign in to comment.