diff --git a/.ci/pitest-suppressions/pitest-naming-suppressions.xml b/.ci/pitest-suppressions/pitest-naming-suppressions.xml index 31c0d0a6a6e..c07806dfd9b 100644 --- a/.ci/pitest-suppressions/pitest-naming-suppressions.xml +++ b/.ci/pitest-suppressions/pitest-naming-suppressions.xml @@ -9,15 +9,6 @@ curNode = curNode.getNextSibling(); - - AccessModifierOption.java - com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption - getInstance - org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator - replaced call to java/lang/String::trim with receiver - return valueOf(AccessModifierOption.class, modifierName.trim().toUpperCase(Locale.ENGLISH)); - - ParameterNameCheck.java com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AccessModifierOptionTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AccessModifierOptionTest.java index 0aefea7089c..e55dfbc4a3d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AccessModifierOptionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AccessModifierOptionTest.java @@ -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() { @@ -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); + + } + } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/accessmodifieroption/InputAccessModifierOption.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/accessmodifieroption/InputAccessModifierOption.java new file mode 100644 index 00000000000..a717c411f70 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/accessmodifieroption/InputAccessModifierOption.java @@ -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; + } + +} \ No newline at end of file