-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #13038: handled inner class method definition in VariableDeclarationUsageDistanceCheck #14635
base: master
Are you sure you want to change the base?
Conversation
GitHub, generate report |
I've read the pitest wiki and the pitest mutation overview. I understand |
I am fairly certain this means that now the ONLY tokens that are passed to this method are in these conditions, so we might as well return true from the isZeroDistanceToken method, which means that where ever this method is used could probably be mutated to just |
0425b43
to
d762894
Compare
Thanks. I've tried to return true or false in the isZeroDistanceToken method and remove it completely, but some of the tests we have failed after that. Still can't figure out why. |
as a hack, please make method as public and write junit test for this method to clearly show that survival can gone if we do have explicit test. |
Thanks. The method is very straightforward containing several or operator as follows |
If this is true, then we are missing tests from the pitest profile in pom.xml for this check. Please push up your changes and show this failure so that we can help debug. |
…ableDeclarationUsageDistanceCheck
I've pushed the changes I made. If the method just return true directly, the failed tests are shown as in the file below. It looks like the pom file includes the target class and target test of this check correctly. I'd really appreciate it if you could help me debug. I guess I might make some mistakes where I'm not aware of right now. |
There is definitely something weird going on here. I've checked this code out locally, and tried to hardcode the mutation in a number of ways, but the tests are always failing. The only thing I can think of is that the bytecode inlines this method and the actual mutation isn't what is shown in the suppression. I suggest that you check the bytecode for this file, you can see how to do this at https://github.com/checkstyle/checkstyle/wiki/How-to-Generate-and-Analyze-Pitest-Reports#decompiler-usage-to-see-bytecode. @Vyom-Yadav have you seen anything like this before? |
@@ -22,8 +22,7 @@ void mm() { | |||
<T> void xx(List<T> m){} | |||
} | |||
public void method9() { | |||
// until https://github.com/checkstyle/checkstyle/issues/13011 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First I would confirm that these 2 issues are exactly the same and explain it so we understand. I find it odd that a method issue would fix a class issue, but maybe no one noticed the cases were extremely similar.
Also, apparently you reported both issues. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oo right they r almost the same.
@@ -784,7 +787,8 @@ private static boolean isZeroDistanceToken(int type) { | |||
|| type == TokenTypes.MODIFIERS | |||
|| type == TokenTypes.RESOURCE | |||
|| type == TokenTypes.EXTENDS_CLAUSE | |||
|| type == TokenTypes.IMPLEMENTS_CLAUSE; | |||
|| type == TokenTypes.IMPLEMENTS_CLAUSE | |||
|| type == TokenTypes.CLASS_DEF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed conditional - replaced equality check with true
This is my local when I run the profile.
I removed one of these lines completely, or something similar to changing || type == TokenTypes.EXTENDS_CLAUSE
to || false
, and all the tests passed. This shows the mutation. The mutation in this case is reversed from the text that says true.
At a glance this sort of makes sense. extends
and implements
both have class
as a parent.
So now we must identify how to kill these mutations, or understand why they can't be killed. I would look over https://github.com/checkstyle/checkstyle/wiki/How-to-Generate-and-Analyze-Pitest-Reports#how-to-find-java-code-that-can-kill-mutation and https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#checkstyle-pitest-regression for the next steps. You can also look over other pitest issues that describe the more complex process. We do not normally accept new code with new surviving mutations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a glance this sort of makes sense. extends and implements both have class as a parent.
Yes, this sounds like what is happening here. We should probably add some test cases for local enums, records, and interfaces as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank u so much!!! I see. Trying to solve it.
Issue: #13038
Diff Regression config: https://gist.githubusercontent.com/jxr98/8f42477fea778a2b62873c9af6ad8493/raw/b6b8b98a74810181a66fc2cdb04dfc7f45109f85/VariableDeclarationUsageDistance.xml