Skip to content

Issue #13109: Kill mutation for MultipleVariableDeclarationsCheck#13197

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:MultipleVariableDeclarationsCheck
Jun 27, 2023
Merged

Issue #13109: Kill mutation for MultipleVariableDeclarationsCheck#13197
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:MultipleVariableDeclarationsCheck

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 11, 2023

Issue #13109: Kill mutation for MultipleVariableDeclarationsCheck


Check

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


Mutation

<mutation unstable="false">
<sourceFile>MultipleVariableDeclarationsCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck</mutatedClass>
<mutatedMethod>getLastNode</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheck::getLastNode with argument</description>
<lineContent>currentNode = getLastNode(child);</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>MultipleVariableDeclarationsCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/utils/CheckUtil::getFirstNode with argument</description>
<lineContent>final DetailAST firstNextNode = CheckUtil.getFirstNode(nextNode);</lineContent>
</mutation>


Explaination

Test added


Regression

Report-1 :- https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/47e3287_2023184215/reports/diff/index.html

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


Diff Regression config: https://gist.githubusercontent.com/Kevin222004/201dae231798cb048eca902b7b21d6ea/raw/6655ab3c5cff01a88fcbc704e671b6be0c441a98/MultipleVariableDeclarationsCheck.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/21e3934e85f802e2fbd48af06d122364/raw/604256badd733d8568064f371d55657c04b00dfd/test-projects-2.properties
Report label: Latest-Report-2

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 force-pushed the MultipleVariableDeclarationsCheck branch from 57fa60e to 47e3287 Compare June 16, 2023 17:18
@Kevin222004
Copy link
Copy Markdown
Contributor Author

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@Kevin222004 Kevin222004 marked this pull request as ready for review June 16, 2023 17:28
@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 force-pushed the MultipleVariableDeclarationsCheck branch from 47e3287 to fd0a037 Compare June 18, 2023 18:16
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

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Kevin222004 This is not the correct analysis, you missed 2 test cases:

void method4() {                                                                    
    int c = // violation 'Only one variable definition per line allowed.'           
            12; int a = 1;                                                          
                                                                                    
    int cb = 12; java. // violation 'Only one variable definition per line allowed.'
            lang.String                                                             
            asd = "123";                                                            
}                                                                                                                                                  

This is being detected by the code in the master branch, but since you resort to final DetailAST lastNode = ast.getLastChild(); the last child has more children, which are on the next line and nextNode directly instead of final DetailAST firstNextNode = CheckUtil.getFirstNode(nextNode); this is not being detected anymore.


I don't think the current logic is redundant, please use the above-mentioned test cases killing the mutation.

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.

@Kevin222004 Kevin222004 force-pushed the MultipleVariableDeclarationsCheck branch from fd0a037 to b203ae3 Compare June 23, 2023 12:49
@Kevin222004
Copy link
Copy Markdown
Contributor Author

his is being detected by the code in the master branch, but since you resort to final DetailAST lastNode = ast.getLastChild(); the last child has more children, which are on the next line and nextNode directly instead of final DetailAST firstNextNode = CheckUtil.getFirstNode(nextNode); this is not being detected anymore.

Yes you are right I missed this test and my calculation become wrong

@Kevin222004 Kevin222004 force-pushed the MultipleVariableDeclarationsCheck branch 3 times, most recently from bde4677 to c1356b7 Compare June 26, 2023 08:28
@romani
Copy link
Copy Markdown
Member

romani commented Jun 27, 2023

@Kevin222004 , please resolve conflict and and lets finalize review.

@Kevin222004 Kevin222004 force-pushed the MultipleVariableDeclarationsCheck branch from c1356b7 to b6cb59f Compare June 27, 2023 13:26
@romani
Copy link
Copy Markdown
Member

romani commented Jun 27, 2023

Circleci is restarted

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

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

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 Jun 27, 2023
@romani romani merged commit e15fcdb into checkstyle:master Jun 27, 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