Skip to content

Issue #13501: Kill mutation for UnusedLocalVariableCheck 9 #13152

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:ul9
Aug 8, 2023
Merged

Issue #13501: Kill mutation for UnusedLocalVariableCheck 9 #13152
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:ul9

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 3, 2023

Issue #13501: Kill mutation for UnusedLocalVariableCheck 9


Check :-

https://checkstyle.org/checks/coding/unusedlocalvariable.html#UnusedLocalVariable


Mutation

<mutation unstable="false">
<sourceFile>UnusedLocalVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheck</mutatedClass>
<mutatedMethod>isInsideLocalAnonInnerClass</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>if (TokenUtil.isTypeDeclaration(currentAst.getParent().getType())) {</lineContent>
</mutation>


Explaination

TokenUtil.isTypeDeclaration check if the ast is of type
class, enum, record or interface.

know in this all type of the last child is alwyas objBlock token. so the parent of SList never going to be
from isTypeDeclaration so either of checking currentASt Parent if the loops run 1 time more and currentast would be change then ultimately in
result = currentAst.getType() == TokenTypes.SLIST; it will make affect but result will not change.


Regression :-

Report-1 ; https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/5346d57_2023074741/reports/diff/index.html

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


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-Aug-5-2

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 4, 2023

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 8, 2023

@Kevin222004 Kevin222004 changed the title Issue #13109: Kill mutation for UnusedLocalVariableCheck 9 Issue #13328: Kill mutation for UnusedLocalVariableCheck 9 Jul 1, 2023
@Kevin222004 Kevin222004 marked this pull request as ready for review July 1, 2023 04:33
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

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Please ignore pitest it will cover at #13151

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.

Restarted circleci, it's green now.

lgtm

@rdiachenko rdiachenko assigned Vyom-Yadav and unassigned rdiachenko Jul 1, 2023
@romani
Copy link
Copy Markdown
Member

romani commented Jul 1, 2023

I restarted pitest failure.
@Kevin222004 , please recheck its state in 1 hour

@Kevin222004
Copy link
Copy Markdown
Contributor Author

This failure is covered #13151

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Kevin222004 The surviving mutation is different from the one in #13151.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

#13152 (comment) ohh yes you are right, my misunderstanding

I think I have to evaluate whole loop again

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Kevin222004 Please mention if you require any help with this PR.

@romani romani self-requested a review August 3, 2023 00:54
@Kevin222004 Kevin222004 changed the title Issue #13328: Kill mutation for UnusedLocalVariableCheck 9 Issue #13501: Kill mutation for UnusedLocalVariableCheck 9 Aug 5, 2023
@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 5, 2023

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@romani
Copy link
Copy Markdown
Member

romani commented Aug 5, 2023

@Vyom-Yadav , please finish review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 5, 2023

Comment on lines -406 to -412
while (currentAst.getType() != TokenTypes.SLIST) {
if (TokenUtil.isTypeDeclaration(currentAst.getParent().getType())) {
while (!TokenUtil.isTypeDeclaration(currentAst.getType())) {
if (currentAst.getType() == TokenTypes.SLIST) {
result = true;
break;
}
currentAst = currentAst.getParent();
}
result = currentAst.getType() == TokenTypes.SLIST;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nicee, simplified the logic.

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!

@Vyom-Yadav Vyom-Yadav assigned romani and unassigned Vyom-Yadav Aug 8, 2023
@romani romani merged commit a174e6e into checkstyle:master Aug 8, 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