Detected at checkstyle/checkstyle#13928
code:
public Set<String> getExternalResourceLocations() {
return Stream.concat(filters.stream(),
Stream.concat(ordinaryChecks.stream(), commentChecks.stream()))
.filter(ExternalResourceHolder.class::isInstance)
.map(ExternalResourceHolder.class::cast)
.flatMap(resource -> resource.getExternalResourceLocations().stream())
.collect(Collectors.toSet());
}
mutation is:
org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator
replaced call to java/util/stream/Stream::map with receiver
on line .map(ExternalResourceHolder.class::cast)
Workaround to avoid mutation is usage of old style cast in lambda:
public Set<String> getExternalResourceLocations() {
return Stream.concat(filters.stream(),
Stream.concat(ordinaryChecks.stream(), commentChecks.stream()))
.filter(ExternalResourceHolder.class::isInstance)
.flatMap(resource -> {
return ((ExternalResourceHolder) resource)
.getExternalResourceLocations().stream();
})
.collect(Collectors.toSet());
}
but code does not looks good in this case.
We do know that pitest operates on bytecode so cast chain method is actually not required especially in code where it is close to impossible to put wrong type in collection.
Is it possible to improve pitest to skip such mutations ?
Detected at checkstyle/checkstyle#13928
code:
mutation is:
org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator
replaced call to java/util/stream/Stream::map with receiver
on line
.map(ExternalResourceHolder.class::cast)Workaround to avoid mutation is usage of old style cast in lambda:
but code does not looks good in this case.
We do know that pitest operates on bytecode so cast chain method is actually not required especially in code where it is close to impossible to put wrong type in collection.
Is it possible to improve pitest to skip such mutations ?