From 4c7c3cc832a2b6ddefa529a816008880a9db9255 Mon Sep 17 00:00:00 2001 From: Kevin222004 Date: Sat, 22 Oct 2022 18:56:16 +0530 Subject: [PATCH] Issue #12282: Resolve Pitest suppression for ParenPad --- .../pitest-whitespace-suppressions.xml | 9 -------- .../checks/whitespace/ParenPadCheckTest.java | 10 ++++++++ .../InputParenPadForSynchronized.java | 23 +++++++++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/parenpad/InputParenPadForSynchronized.java diff --git a/.ci/pitest-suppressions/pitest-whitespace-suppressions.xml b/.ci/pitest-suppressions/pitest-whitespace-suppressions.xml index 31965f6faef..1101a9bcdc4 100644 --- a/.ci/pitest-suppressions/pitest-whitespace-suppressions.xml +++ b/.ci/pitest-suppressions/pitest-whitespace-suppressions.xml @@ -81,15 +81,6 @@ processLeft(ast.findFirstToken(TokenTypes.LPAREN)); - - ParenPadCheck.java - com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck - visitToken - org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_3 - RemoveSwitch 3 mutation - switch (ast.getType()) { - - ParenPadCheck.java com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java index 4318ca3a7c4..f85a7c25a97 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java @@ -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, diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/parenpad/InputParenPadForSynchronized.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/parenpad/InputParenPadForSynchronized.java new file mode 100644 index 00000000000..2911bcec1de --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/parenpad/InputParenPadForSynchronized.java @@ -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; + } +}