Skip to content

Commit

Permalink
Issue #12282: Resolve Pitest suppression for ParenPad
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin222004 authored and rnveach committed Oct 22, 2022
1 parent f249e37 commit 4c7c3cc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
9 changes: 0 additions & 9 deletions .ci/pitest-suppressions/pitest-whitespace-suppressions.xml
Expand Up @@ -81,15 +81,6 @@
<lineContent>processLeft(ast.findFirstToken(TokenTypes.LPAREN));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>ParenPadCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_3</mutator>
<description>RemoveSwitch 3 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>ParenPadCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck</mutatedClass>
Expand Down
Expand Up @@ -513,6 +513,16 @@ public void testParenPadCheckEmoji() throws Exception {
getPath("InputParenPadCheckEmoji.java"), expected);
}

@Test
public void testParenPadForSynchronized() throws Exception {

final String[] expected = {
"18:29: " + getCheckMessage(MSG_WS_PRECEDED, ")"),
};
verifyWithInlineConfigParser(
getPath("InputParenPadForSynchronized.java"), expected);
}

/**
* Pitest requires us to specify more concrete lower bound for condition for
* ParenPadCheck#isAcceptableToken as nodes of first several types like CTOR_DEF,
Expand Down
@@ -0,0 +1,23 @@
/*
ParenPad
option = (default)nospace
tokens = LITERAL_SYNCHRONIZED, CTOR_DEF, CTOR_CALL, LITERAL_IF
*/

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

class InputParenPadForSynchronized {

private static InputParenPadForSynchronized instance = null;
private InputParenPadForSynchronized() {
}

public synchronized static InputParenPadForSynchronized getInstance() {
if(instance == null ) { // violation
instance = new InputParenPadForSynchronized();
}
return instance;
}
}

0 comments on commit 4c7c3cc

Please sign in to comment.