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 #12260: Resolve Pitest suppression for AbstractParenPadCheck - 2 #12262

Merged
merged 1 commit into from Oct 7, 2022

Conversation

Kevin222004
Copy link
Collaborator

Issue #12260: Resolve Pitest suppression for AbstractParenPadCheck - 2

killing mutation

<description>replaced call to java/lang/String::toUpperCase 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/AbstractParenPadCheck.java.html
    Surviving Mutation: java/lang/String::toUpperCase with receiver → SURVIVED at line 80

  2. Mutated code
    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 without mutation the code looks like.
    option = PadOption.valueOf(optionStr.trim());

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

  1. Analysis

a) the toUpperCase 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...
  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 so the usage of toUpperCase function
is nothing in all the condition thats why it is Mutated

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

Copy link
Member

@rnveach rnveach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 minor change

final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
verifyWithInlineConfigParser(
getPath("InputParenPadToCheckUpperCaseFunctionInOptionProperty.java"),
expected);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this in this PR and previous. expected is indented 1 less then where it should.

Please ensure they line up. Please fix previous test in this same PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@rnveach rnveach self-assigned this Oct 7, 2022
Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Items

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to merge

@rnveach rnveach merged commit 5ebdef4 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

3 participants