Skip to content

Issue #13109: Kill mutation for EqualsAvoidNullCheck 2#13125

Merged
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:EV2
Jun 4, 2023
Merged

Issue #13109: Kill mutation for EqualsAvoidNullCheck 2#13125
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:EV2

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 1, 2023

Issue #13109: Kill mutation for EqualsAvoidNullCheck 2

1 check :- https://checkstyle.org/config_coding.html#EqualsAvoidNull

2covering :-

<mutation unstable="false">
<sourceFile>EqualsAvoidNullCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck</mutatedClass>
<mutatedMethod>isStringFieldOrVariableFromClass</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheck::getObjectFrame with argument</description>
<lineContent>frame = getObjectFrame(frame.getParent());</lineContent>
</mutation>

3 Explaination
getObjectFrame() method will provide the nearest parent frame of class, enum.

if we remove getObjectFramefrom the FieldFrame frame = getObjectFrame(currentFrame); and frame = getObjectFrame(frame.getParent()); they will go through all the frame instead of directly going to frame which are class or enum.

and as per the condition in loop className.equals(frame.getFrameName())
frameName would always be of class enum as per

/** Name of the class, enum or enum constant declaration. */
private String frameName;

so removal of that not make any issue

https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/c201250_2023104332/reports/diff/index.html

Diff Regression config: https://gist.githubusercontent.com/Kevin222004/c515fe44cd311783e6cbdf0f5788b4d3/raw/15647eeebde66f0c3a366f655442b02b4d55efef/equal.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/21e3934e85f802e2fbd48af06d122364/raw/604256badd733d8568064f371d55657c04b00dfd/test-projects-2.properties
Report label: Project-list-2

@Kevin222004
Copy link
Copy Markdown
Contributor Author

GitHub, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 1, 2023

@Kevin222004 Kevin222004 marked this pull request as draft June 2, 2023 05:02
@Kevin222004 Kevin222004 marked this pull request as ready for review June 2, 2023 06:45
Copy link
Copy Markdown
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.

@romani romani requested review from Vyom-Yadav and rdiachenko June 2, 2023 13:30
@rdiachenko
Copy link
Copy Markdown
Member

@Kevin222004 please resolve the conflict and regenerate report

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 3, 2023

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 3, 2023

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@rdiachenko reports are clean

@Vyom-Yadav
Copy link
Copy Markdown
Member

Issue #13109: Kill mutation for EqualsAvoidNullCheck 2

Check :- https://checkstyle.org/config_coding.html#EqualsAvoidNull


Mutations Covered

<mutation unstable="false">
<sourceFile>EqualsAvoidNullCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck</mutatedClass>
<mutatedMethod>isStringFieldOrVariableFromClass</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheck::getObjectFrame with argument</description>
<lineContent>frame = getObjectFrame(frame.getParent());</lineContent>
</mutation>


Explanation

getObjectFrame() method will provide the nearest parent frame of class, enum.

if we remove getObjectFramefrom the FieldFrame frame = getObjectFrame(currentFrame); and frame = getObjectFrame(frame.getParent()); they will go through all the frame instead of directly going to frame which are class or enum.

and as per the condition in loop className.equals(frame.getFrameName()) frameName would always be of class enum as per

/** Name of the class, enum or enum constant declaration. */
private String frameName;

so removal of that not make any issue


Diff Reports

https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/c201250_2023104332/reports/diff/index.html


Config (You can remove this after you have generated the reports)

Diff Regression config: https://gist.githubusercontent.com/Kevin222004/c515fe44cd311783e6cbdf0f5788b4d3/raw/15647eeebde66f0c3a366f655442b02b4d55efef/equal.xml Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/21e3934e85f802e2fbd48af06d122364/raw/604256badd733d8568064f371d55657c04b00dfd/test-projects-2.properties Report label: Project-list-2


@Kevin222004 slight improvement in formatting makes it look better, you can use --- instead of numbers, it looks cleaner.

Copy link
Copy Markdown
Member

@Vyom-Yadav Vyom-Yadav left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Member

@rdiachenko rdiachenko left a comment

Choose a reason for hiding this comment

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

lgtm

@rdiachenko rdiachenko merged commit 655196e into checkstyle:master Jun 4, 2023
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.

4 participants