Skip to content

Issue #13109: Kill mutation for ReturnCountCheck#13138

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

Issue #13109: Kill mutation for ReturnCountCheck#13138
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:RC1

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 2, 2023

Issue #13109: Kill mutation for ReturnCountCheck


Check :-

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


Mutation Covered

<mutation unstable="false">
<sourceFile>ReturnCountCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ReturnCountCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to java/lang/Object::toString</description>
<lineContent>throw new IllegalStateException(ast.toString());</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ReturnCountCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ReturnCountCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to java/lang/Object::toString</description>
<lineContent>throw new IllegalStateException(ast.toString());</lineContent>
</mutation>


Explaination

1) Test cases
Here in this check, we have an acceptable token

public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.LAMBDA,
TokenTypes.LITERAL_RETURN,
};

and in visitToken and Leave Token all the acceptable tokens have their own case.
so without pure unit testing not possible to create such kind of scenario to cover default.

2) Removal of code
Here in this check, we have an acceptable token

public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.LAMBDA,
TokenTypes.LITERAL_RETURN,
};

and in visitToken and Leave Token all the acceptable tokens have their own case so Removal of default won't make any issue.
Regression are also clean

Currently applied 1) Test cases

@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 Kevin222004 force-pushed the RC1 branch 2 times, most recently from 47c2eb8 to 1fc218f Compare June 5, 2023 19:50
@Kevin222004 Kevin222004 marked this pull request as ready for review June 5, 2023 19:50
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.

Items

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.

Minors:

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.

.

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

@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

@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 12, 2023
@romani romani merged commit 8576b0c into checkstyle:master Jun 12, 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