Skip to content

Commit

Permalink
Issue checkstyle#12266: Resolve Pitest suppression for OperatorWrapCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin222004 committed Oct 7, 2022
1 parent 5ebdef4 commit 1b59d03
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
18 changes: 0 additions & 18 deletions .ci/pitest-suppressions/pitest-whitespace-suppressions.xml
Expand Up @@ -108,24 +108,6 @@
<lineContent>option = PadOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>OperatorWrapCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck</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 = WrapOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>OperatorWrapCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck</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 = WrapOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

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

@Test
public void testTrimOptionProperty() throws Exception {
final String[] expected = {
"18:21: " + getCheckMessage(MSG_LINE_PREVIOUS, ":"),
"19:21: " + getCheckMessage(MSG_LINE_PREVIOUS, "?"),
};
verifyWithInlineConfigParser(
getPath("InputOperatorWrapWithTrimOptionProperty.java"), expected);
}
}
@@ -1,6 +1,6 @@
/*
OperatorWrap
option = EOL
option = eol
tokens = ASSIGN,COLON,LAND,LOR,STAR,QUESTION
Expand Down
@@ -0,0 +1,21 @@
/*
OperatorWrap
option = \tEOL
tokens = QUESTION, COLON, EQUAL, NOT_EQUAL, DIV, PLUS, MINUS, STAR, MOD, \
SR, BSR, GE, GT, SL, LE, LT, BXOR, BOR, LOR, BAND, LAND, TYPE_EXTENSION_AND, \
LITERAL_INSTANCEOF
*/

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

public class InputOperatorWrapWithTrimOptionProperty {

int x = (1 < 2) ? // ok
false ? "".substring(0,
0).length()
: false // violation '':' should be on the previous line.'
? 2 : 3 : 4; // violation ''?' should be on the previous line.'

}

0 comments on commit 1b59d03

Please sign in to comment.