Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #12261: Resolve Pitest suppression for EmptyForIteratorPadCheck #12263

Merged
merged 1 commit into from Oct 7, 2022

Conversation

Kevin222004
Copy link
Collaborator

Issue #12261: Resolve Pitest suppression for EmptyForIteratorPadCheck

killed two surviving mutation

<description>replaced call to java/lang/String::toUpperCase with receiver</description>

and
<description>replaced call to java/lang/String::trim with receiver</description>

@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Oct 7, 2022

  1. pitest report
    https://kevin222004.github.io/AfterChanges/com.puppycrawl.tools.checkstyle.checks.whitespace/EmptyForIteratorPadCheck.java.html
    Surviving Mutation: java/lang/String::trim with receiver → SURVIVED
    and
    Surviving Mutation: java/lang/String::toUpperCase with receiver → SURVIVED

  2. Mutated code

  1. trim --> our Surviving mutation is java/lang/String::trim with receiver → SURVIVED
    this trim function will remove the extra space added before or after
    while setting the property SPACEto option
    if we see the without mutation the code looks like.
    option = PadOption.valueOf(optionString.toUpperCase(Locale.ENGLISH));

  2. toUppercase --> our Surviving mutation is java/lang/String::toUpperCase with receiver → SURVIVED
    this toUpperCase function will change the string as --> SPACE
    while setting the property space to option
    if we see the without mutation the code looks like.
    option = PadOption.valueOf(optionStr.trim());

but we can't remove or make any changes to this Method bcs enum has set to be like
SPACE so all the letter we set to option is must be in Uppercase

  1. Analysis

a) the toUpperCase function and trim function will work here as like

<property name="option" value="  space"/>

as the output of this code we will get only SPACE which is good

b) if we remove the toUpperCase function and then try to set the property

<property name="option" value="space"/>

it will give us the error like

com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker
 - cannot initialize module ParenPad - Cannot set property 'option' to 'space'
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:481)
error continue...

and similarly
if we remove the trim function the and set the property

<property name="option" value=" space "/>

it will give us the error like

com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker
 - cannot initialize module ParenPad - Cannot set property 'option' to ' space '
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:481)
error continue...
  1. How to kill this

a) currently in our testing case all the test case which are available
that all have set the property directly SPACE the usage of toUpperCase function
and trimfunction is nothing in all the condition thats why it is Mutated

now to kill this mutation i have create the test file with
space and SPACE so it will appear to code as SPACE
as know the usage of toUpperCase and trim come so the muattion will be killed
https://kevin222004.github.io/EmptyforIteratorPad/com.puppycrawl.tools.checkstyle.checks.whitespace/EmptyForIteratorPadCheck.java.html

@rnveach rnveach merged commit dab7ef8 into checkstyle:master Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants