Skip to content

Issue #13109: Kill mutation for UnusedLocalVariableCheck 6#13149

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:ul6
Jun 12, 2023
Merged

Issue #13109: Kill mutation for UnusedLocalVariableCheck 6#13149
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:ul6

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 3, 2023

Issue #13109: Kill mutation for UnusedLocalVariableCheck 6


Checks

https://checkstyle.org/config_coding.html#UnusedLocalVariable


Mutation covered

<mutation unstable="false">
<sourceFile>UnusedLocalVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheck</mutatedClass>
<mutatedMethod>getBlockContainingLocalAnonInnerClass</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/api/DetailAST::getParent with receiver</description>
<lineContent>DetailAST parentAst = literalNewAst.getParent();</lineContent>
</mutation>


Explaination

hence it is not possible to create a such test that kills mutation. instead of starting the loop with literalNewAst.getParent() if we start from literalnewAst at the end of the first iteration in the loop it will become literalNewAst.getParent. loops run one time more then it was running previously.
hence while as per my changes currentAST go in loop it never be in array of CONTAINERS_FOR_ANON_INNERS

private static final int[] CONTAINERS_FOR_ANON_INNERS = {
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.STATIC_INIT,
TokenTypes.INSTANCE_INIT,
TokenTypes.COMPACT_CTOR_DEF,
};

because it always be TokenTypes.Literal_NEW. same for if statment in it
currentAST never be TokenTypes.lambda so it will not execute
so removal will not make any effect


Diff Regression config: https://gist.githubusercontent.com/Kevin222004/0dbdfb487f8e9a050ed0e6356f1a35b4/raw/31f7927f400e11e4285e86fd086b373095227848/unusedLocal.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/9600f179b602d4c971bdb0a050099005/raw/360a95ed7bb60d7a0956e531199d484c4d6f6617/test-projects.properties
Report label: Regression-2

@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

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@Kevin222004 Kevin222004 marked this pull request as ready for review June 8, 2023 06:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 8, 2023

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

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.
Please add this to issue of bad side effects, as example that pitest is heavily against performance improvements, as much improvement is not possible to enforce by test.

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!

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