-
Notifications
You must be signed in to change notification settings - Fork 354
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
cannot use avoidCallsTo to protect *calls* to certain methods from mutation #404
Comments
same issue here! |
+1 There should be a an option to exclude a specific method call from mutations. |
+1 since moving from Java8 to Java11 I have a situation where I'm getting surviving mutations from lines not in the source, but in the bytecode. For example:
becomes
this results in surviving mutations on 'Objects.requireNonNull'. Note- only an issue with method references, without the method reference the compiler doesn't add 'requiresNonNull' It would be really useful to be able to use 'avoidCallsTo' specifically for that method. I obviously don't want to avoid calls to the whole of Objects.class. (I think the issue would have originally become apparent with JDK9, my project just happens to have gone from 8-11) |
@nicwaters96 hit the same issue as well, any workarounds or potential fixes? |
I haven't found a workaround - we just make engineers aware of mutations from bytecode being an issue when they're reviewing reports. It's a bit tedious because we use a Pitest plugin with Sonar and I'm always marking these as false positives:) |
Thanks! For now I'll be avoiding method references when this occurs |
it's a bit of a no-win because one either avoids false positive mutations or avoids the IDE highlighting places where a method reference should/could be used:) |
I agree, it's a hacky workaround, the other alternative is ignoring calls to |
@nicwaters96 @svalchinov Not had chance to look at the more general issue of filtering specific calls, but the next release will filter out mutations to calls to Objects.requireNonNull added by the compiler for method references. |
@hcoles great! I'll upgrade asap. it'll save me some time not marking 'requireNonNull's survivals as false positives:) |
I am facing a situation with pitest that is generating false positives in cases of logging messages. It is easier to clarify it with an example. Let's say I have the following code:
What is bugging me is that a mutation is generated for each of the calls to the logging methods, and it is clear that those mutations are not necessary. If, however, I inline the methods, the logging library avoidance defaults seem to kick in, and skip the mutations. The problem is that I'd rather not inline those methods; the logging lines itself are a bit verbose, and keeping them tucked away in methods is much cleaner.
How should I go about avoiding mutations to calls to specific methods? Here's what I already tried:
"log*"
to theavoidCallsTo
configurations (it seems to only takes packages)excludedMethods
to the configuration (it seems to only consider the inside of the method, not calls to it)@DoNotMutate
(introduced in 1.2.2) annotation to the log* methods of my class (it seems to behave likeexcludedMethods
Nothing seems to work. Is this something that is not currently supported? Please advise.
The text was updated successfully, but these errors were encountered: