Skip to content

Commit

Permalink
Issue checkstyle#12327: Resolve Switch case mutation for ParenPad
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin222004 committed Oct 22, 2022
1 parent aad6891 commit 801423e
Show file tree
Hide file tree
Showing 3 changed files with 32 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_7</mutator>
<description>RemoveSwitch 7 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>SeparatorWrapCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck</mutatedClass>
Expand Down
Expand Up @@ -523,6 +523,14 @@ public void testParenPadForSynchronized() throws Exception {
getPath("InputParenPadForSynchronized.java"), expected);
}

@Test
public void testParenPadForEnum() throws Exception {

final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
verifyWithInlineConfigParser(
getPath("InputParenPadForEnum.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,24 @@
/*
ParenPad
option = (default)nospace
tokens = ENUM_CONSTANT_DEF, CTOR_DEF, CTOR_CALL
*/

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

public class InputParenPadForEnum extends RuntimeException {

private static final long serialVersionUID = 1L;

public enum ErrorType {
ROOM_ALREADY_EXISTS,
USER_ALREADY_EXISTS,
NO_SUCH_ROOM_EXISTS
}

public InputParenPadForEnum(String description, ErrorType type) { // ok
super(description); // ok
}
}

0 comments on commit 801423e

Please sign in to comment.