Skip to content

Commit

Permalink
Issue checkstyle#12326: Resolve Pitest suppression for AccessModifier…
Browse files Browse the repository at this point in the history
…Option
  • Loading branch information
ThatSneakyCoder committed Nov 20, 2022
1 parent d515c25 commit 856dca1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 10 deletions.
9 changes: 0 additions & 9 deletions .ci/pitest-suppressions/pitest-naming-suppressions.xml
Expand Up @@ -9,15 +9,6 @@
<lineContent>curNode = curNode.getNextSibling();</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>AccessModifierOption.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption</mutatedClass>
<mutatedMethod>getInstance</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::trim with receiver</description>
<lineContent>return valueOf(AccessModifierOption.class, modifierName.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>ParameterNameCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck</mutatedClass>
Expand Down
Expand Up @@ -20,10 +20,19 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.google.common.truth.Truth.assertWithMessage;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_EXPECTED_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_RETURN_EXPECTED;

import org.junit.jupiter.api.Test;

public class AccessModifierOptionTest {
import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;

public class AccessModifierOptionTest extends AbstractModuleTestSupport {

@Override
protected String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/checks/naming/accessmodifieroption";
}

@Test
public void testDefaultCase() {
Expand Down Expand Up @@ -57,4 +66,15 @@ public void testCase() {
.isEqualTo("private");
}

@Test
public void testTrimProperty() throws Exception {
final String[] expected = {
"25: " + getCheckMessage(MSG_RETURN_EXPECTED),
"32: " + getCheckMessage(MSG_RETURN_EXPECTED),
"41:33: " + getCheckMessage(MSG_EXPECTED_TAG,"@throws","Exception"),
};
verifyWithInlineConfigParser(getPath("InputAccessModifierOption.java"),expected);

}

}
@@ -0,0 +1,49 @@
/*
AccessModifierOption
option = \tSPACE
*/

package com.puppycrawl.tools.checkstyle.checks.naming.accessmodifieroption;


public class InputAccessModifierOption {


class classOne {

}

class classTwo {

}

/**
*
*/
public int method1() { // violation , ' @return tag should be present and have description'
return 2;
}

/**
* @return
*/
public String method2() { // violation , ' @return tag should be present and have description'
return "arbitrary_string";
}

/**
*
* @return returns something
* @throws
*/
public int method3() throws Exception { // violation , 'Expected @throws tag for 'Exception''
if(1!=2)
System.out.println("hello world");
else
throw new Exception();
return 1;
}

}

0 comments on commit 856dca1

Please sign in to comment.