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 #12251: Resolve Pitest suppression for AbstractParenPadCheck #12258

Merged
merged 1 commit into from Oct 6, 2022

Conversation

Kevin222004
Copy link
Collaborator

Issue #12251: Resolve Pitest suppression for AbstractParenPadCheck

@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Oct 6, 2022

  1. pitest report
    https://kevin222004.github.io/BeforeChanges/com.puppycrawl.tools.checkstyle.checks.whitespace/AbstractParenPadCheck.java.html
    Surviving Mutation: java/lang/String::trim with receiver → SURVIVED at line 80

  2. Mutated code
    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 ```SPACE`` to option

Now we can't remove or make any changes to this Method

  1. Analysis

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

now to kill this mutation i have create the test file with
\tSPACE so it will appear to code as SPACE
as know the usage of trim come so the muattion will be killed

https://kevin222004.github.io/AfterChanges/com.puppycrawl.tools.checkstyle.checks.whitespace/AbstractParenPadCheck.java.html

@rnveach
Copy link
Member

rnveach commented Oct 6, 2022

  1. Mutated code

You do not show what the mutated code looks like. I wish to confirm you understand the mutation by seeing the actual code representation, so please provide this.

For example, assume the original code is a = b + c and the mutation says "replaced b with zero". I would expect to see you tell me the mutated code looks like a = 0 + c (or some form of a = c).

I am not saying what you provided for this PR is not correct, I just want to verify you understand what pitest is doing as there will be more like this.

  1. Analysis
  2. How to kill this

Just nitpicking, but you say there is two 3s and neither one connect with the number 3 in the thought process issue but you provided your own way that it makes sense to me what your doing.

3 in the thought process is about running actual regression on external projects ( https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#checkstyle-pitest-regression ) . 4 is about what to do for what regression reported back.

Since you provided a PR, and the PR looks like it is passing, I am fine skipping the regression.

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.

CI will show if mutation is resolved, so it is passing proves that.

1 minor item asked for above, and just 1 minor change requested.

@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Oct 6, 2022

You do not show what the mutated code looks like. I wish to confirm you understand the mutation by seeing the actual code representation, so please provide this.

For example, assume the original code is a = b + c and the mutation says "replaced b with zero". I would expect to see you tell me the mutated code looks like a = 0 + c (or some form of a = c).

I am not saying what you provided for this PR is not correct, I just want to verify you understand what pitest is doing as there will be more like this.

Ok I have understood what you are exactly asking for
The function trim is coming from the java.lang.String package and as of the current testing code the function is returning nothing or it is empty according to pitest documentation we can Replace it with ‘empty’ . so if trim() is not used any more we can remove it

@nrmancuso nrmancuso self-requested a review October 6, 2022 20:22
@rnveach rnveach self-assigned this Oct 6, 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.

Awesome hack in config

@rnveach rnveach assigned nrmancuso and unassigned rnveach Oct 6, 2022
Copy link
Member

@nrmancuso nrmancuso left a comment

Choose a reason for hiding this comment

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

@Kevin222004 it might be a good idea to search pitest suppressions for trim and see if we can do similar hack in other check properties.

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

4 participants