Skip to content
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 #13809: Kill mutation in XpathUtil #13944

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

Kevin222004
Copy link
Contributor

Issue #13809: Kill mutation in XpathUtil

<mutation unstable="false">
<sourceFile>XpathUtil.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.utils.XpathUtil</mutatedClass>
<mutatedMethod>getXpathItems</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/util/stream/Stream::map with receiver</description>
<lineContent>.map(NodeInfo.class::cast)</lineContent>
</mutation>

Copy link
Member

@nrmancuso nrmancuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to understand how pitest is actually mutating this code before we make changes like this. The code proposed by this PR is objectively less clear and concise than what we have now. We should not allow pitest to decrease our code quality, especially if we don’t even understand what it is doing under the hood.

Copy link
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
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.

@Vyom-Yadav , please share your opinion on cast problem, looks like this becomes hot topic.

@romani
Copy link
Member

romani commented Oct 26, 2023

@Kevin222004 , please rebase to resolve conflict

@Kevin222004 Kevin222004 force-pushed the XpathUtil branch 2 times, most recently from 19ce261 to 8ca3e77 Compare October 28, 2023 07:26
@romani
Copy link
Member

romani commented Oct 28, 2023

@Kevin222004 , please address Checker

Copy link
Contributor

@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

@Kevin222004 please resolve checker errors

Copy link
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! Please fix CI errors.

@Vyom-Yadav Vyom-Yadav assigned nrmancuso and unassigned Vyom-Yadav Oct 29, 2023
Copy link
Member

@nrmancuso nrmancuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Item:

Comment on lines +77 to +81
public static <S, T> List<T> unmodifiableList(Collection<S> items, Class<T> elementType) {
return items.stream()
.map(elementType::cast)
.collect(Collectors.toUnmodifiableList());
}
Copy link
Member

@nrmancuso nrmancuso Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we make this about collections, when the issue is with the calls to Class#cast? If we want to make some hack to bypass pitest, why not just have a util method to cast the stream as an intermediate operation?

Pseudocode:

<R, T> Stream<T> castedStreamOf(Stream<R> s, Class<T> c) {
  return stream.map(c::cast)
}

Then we can collect or perform subsequent stream operations elsewhere more readily.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has unmodified collection, that pitest will complain about, not sure why it is not doing it now.

And current implementation is easier, and we don't want to make it highly reusable, at least for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it a public method in a utility class if we don't want it to be reusable?

Copy link
Member

@romani romani Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pitest limitation to allow easy exclude from mutation by class name .

Whole code of this class is excluded from mutation at all. And class of exist until pitest improve. We did not report issue yet, but we collecting unfortunate cases in our issue

Copy link
Member

@nrmancuso nrmancuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here don't add up for me. In order to remove one pitest suppression (that should just be permanent IMO), we have added:

  • 2 checker suppressions (tech debt)
  • avoidCallsTo suppression in pom.xml (tech debt)
  • yet another specialized utility method that won't get used anywhere else (tech debt)
  • Production code (the reason why we are really here) that is much less clear than before

At this point, we are shuffling tech debt around. I won't block this, but I cannot approve either.

@nrmancuso nrmancuso assigned romani and unassigned nrmancuso Oct 30, 2023
@nrmancuso
Copy link
Member

@romani let’s just merge this and move on. We have already spent too much time and resources on this PR.

@romani romani merged commit 8e506dc into checkstyle:master Oct 30, 2023
112 checks passed
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.

None yet

5 participants