Skip to content

Issue #13095: kill mutation for VariableDeclarationUsageDistanceCheck 3#13099

Merged
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:M3
May 31, 2023
Merged

Issue #13095: kill mutation for VariableDeclarationUsageDistanceCheck 3#13099
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:M3

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented May 29, 2023

1 Issue #13095: kill mutation for VariableDeclarationUsageDistanceCheck 3

2 Link to Check Documentation :-
https://checkstyle.org/config_coding.html#VariableDeclarationUsageDistance

3 covering

<mutation unstable="false">
<sourceFile>VariableDeclarationUsageDistanceCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck</mutatedClass>
<mutatedMethod>getDistToVariableUsageInChildNode</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_1</mutator>
<description>RemoveSwitch 1 (case value 10)</description>
<lineContent>switch (examineNode.getType()) {</lineContent>
</mutation>

4 Logic behind mutation removal
I don't find any test case which can kill this mutation.

https://github.com/Kevin222004/checkstyle/blob/d60bae5293a4221f4e5b28da1300441a90be5d44/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java#L569-L571
whenever the token type is off TokenTypes.VARIABLE_DEF then resultDist++; will increment by 1.

In default case
https://github.com/Kevin222004/checkstyle/blob/d60bae5293a4221f4e5b28da1300441a90be5d44/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java#L589-L595
if (examineNode.findFirstToken(TokenTypes.SLIST) == null) { here if the if statment is been executing then similarly resultDist++; will increment by 1 their is no case possible where SLIST become the child of VARIABLE_DEF so it is always going to be null and every time only if will execute.

5 Reports :-
https://kevin222004.github.io/reports/M3/2023-05-31-T-09-24-56/test-report/index.html

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Kevin222004 commented May 29, 2023

I don't find any test case which can kill this mutation.

https://github.com/Kevin222004/checkstyle/blob/d60bae5293a4221f4e5b28da1300441a90be5d44/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java#L569-L571
whenever the token type is off TokenTypes.VARIABLE_DEF then resultDist++; will increment by 1.

In default case
https://github.com/Kevin222004/checkstyle/blob/d60bae5293a4221f4e5b28da1300441a90be5d44/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java#L589-L595
if (examineNode.findFirstToken(TokenTypes.SLIST) == null) { here if the if statment is been executing then similarly resultDist++; will increment by 1 their is no case possible where SLIST become the child of VARIABLE_DEF so it is always going to be null and every time only if will execute.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

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.

ok to merge.

I think we need to extend even more project set for cases that we can not find code to cover and ready to apply pitest suggestion.
It will be not CI execution, but we can ask @Kevin222004 , to add 20 more HUGE java projects and let hit execute on his local validation and double confirm that nothing is found.

@Kevin222004 , if you agree please do this while we waiting for other mentors to review this PR.

@romani
Copy link
Copy Markdown
Member

romani commented May 29, 2023

@Kevin222004 , conflict again .
please review what we can do to avoid conflicts, we use to did extra spaces in files between blocks to let git not mark them as conflict.

@nrmancuso
Copy link
Copy Markdown
Contributor

to add 20 more HUGE java projects and let hit execute on his local validation and double confirm that nothing is found

@Kevin222004 do not forget about option to fork repo at https://github.com/nrmancuso/nrmancuso.github.io to generate and host lots of reports easily.

@romani
Copy link
Copy Markdown
Member

romani commented May 30, 2023

We probably need to invest more in tool like this, as we will need even during regular feature development, chasing a regression will be always required.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Thanks @nrmancuso I have this in my mind and will do it.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Regression :- https://kevin222004.github.io/Regression/

@romani please look at this report I have chosen some of the projects.

@romani
Copy link
Copy Markdown
Member

romani commented May 30, 2023

I am ok.

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Kevin222004 It is better to create an extended list and keep it on a gist or something. You can add these projects too:

https://github.com/square/retrofit
https://github.com/NationalSecurityAgency/ghidra
https://github.com/apache/dubbo
https://github.com/PhilJay/MPAndroidChart
https://github.com/jeecgboot/jeecg-boot
https://github.com/skylot/jadx
https://github.com/airbnb/lottie-android
https://github.com/dbeaver/dbeaver
https://github.com/netty/netty
https://github.com/zxing/zxing
https://github.com/Blankj/AndroidUtilCode

Please attach a regression report with these projects too.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Kevin222004 Let's follow some pattern for the PR description.

  1. Resolves #XXX or simply issue number if linking to parent issue
  2. Link to Check Documentation
  3. Mutations Killed, permalink from GitHub
  4. Logic behind mutation removal (Can be either of)
    4.1 Whether test cases were extended
    4.2 Whether the code wasn't required with rationale
    4.3 Extra code was added to support the extending code, hence killing the mutation
  5. All reports
  6. Additional Comments

This would make it easier to evaluate PRs throughout the project and easier to refer to them in the future.

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Kevin222004 All the configurations in the diff report don't use allowedDistance property. By default, it is 3 which may hide some violations we weren't expecting.

Please follow the pattern above and generate reports with allowedDistance as 1.

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.

Logically it looks correct to me. SLIST cannot be the first level child of VARIABLE_DEF. Still, let's generate reports for a sanity check.

LGTM if new diff reports are clean.

@romani romani assigned rdiachenko and unassigned Vyom-Yadav May 31, 2023
@romani
Copy link
Copy Markdown
Member

romani commented May 31, 2023

@Vyom-Yadav , as you finish review reassign it to next reviewer, you should have permission to do this now

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Logically it looks correct to me. SLIST cannot be the first level child of VARIABLE_DEF. Still, let's generate reports for a sanity check.

LGTM if new diff reports are clean.

Regression :- https://kevin222004.github.io/reports/M3/2023-05-31-T-09-24-56/test-report/index.html

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@rdiachenko ping

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 ccdc2e0 into checkstyle:master May 31, 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.

5 participants