Skip to content

Issue #18028: Resolve Pitest Suppressions - api#18443

Merged
romani merged 1 commit into
checkstyle:masterfrom
Youssefalaa7:issue-18028-Resolve-Pitest-Suppressions-api
Dec 29, 2025
Merged

Issue #18028: Resolve Pitest Suppressions - api#18443
romani merged 1 commit into
checkstyle:masterfrom
Youssefalaa7:issue-18028-Resolve-Pitest-Suppressions-api

Conversation

@Youssefalaa7

Copy link
Copy Markdown
Contributor

Issue #18028: Removed the suppression of the mutation charset = null; in Pitest Suppressions - api

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Items

* @return An unmodifiable view of the provided Charset.
*/
public static Charset unmodifiableCharSet(Charset charset) {
return charset;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code is nonsense.
We need different fix

@Youssefalaa7 Youssefalaa7 Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

what about making two of the constructors in FileText.java to call this method it will be like this

public static Charset unmodifiableCharSet(Charset charset) {
        return Objects.requireNonNullElseGet(charset, Charset::defaultCharset);
    }

is this a good solution?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we need to open issue on pitest.
Removal of this line doesn't make code compile-able, so it is defect of pitest, or there should be some settings to skip such cases, can you create issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you mean that pitest should know that the variable is final and removing its assignment will result in error so it should not remove this assignment am i understanding right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, i will create an issue there

@Youssefalaa7 Youssefalaa7 Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that pitest ignores the compilation it only focuses that when they remove an assignment it results in a difference in the tests that at least one test will fail. And that's why i think checkstyle have mutations only on the assignment to null for final variables but we do not have mutations for assigning to other thing other than null even when it is final as in this case of the previous pr Issue #18033

if (items == null) {
            this.items = null;
    index = -1;
        }
        else {
            this.items = new ArrayList<>(items);
            index = items.size() - 1;
        }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pitest works with bytecode, a lot more can be done on bytecode that is not allowed by compilation, but pitest still can improve.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done I created an issue hcoles/pitest#1440

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@romani
The Pitest maintainer confirmed that EXPERIMENTAL_MEMBER_VARIABLE is disabled by default because it produces low-quality mutations (like the equivalent mutations we're seeing). See their response in the issue.
I tested disabling the EXPERIMENTAL_MEMBER_VARIABLE mutator in our codebase, and it would actually help us remove most of the suppressions we currently have. The mutations it produces are indeed low quality and not providing much value.
Should we proceed with disabling this mutator globally in our Pitest configuration? This would clean up our suppressions significantly.

@Youssefalaa7 Youssefalaa7 force-pushed the issue-18028-Resolve-Pitest-Suppressions-api branch 3 times, most recently from a442625 to bfb1ad2 Compare December 28, 2025 02:13
@Youssefalaa7 Youssefalaa7 requested a review from romani December 28, 2025 02:54

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Items

<sourceFile>FileText.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.FileText</mutatedClass>
<mutatedMethod>&lt;init&gt;</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator</mutator>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's disable mutator at pom.xml with comment until issue in pitest are resolved

@Youssefalaa7 Youssefalaa7 Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will send a PR that comments EXPERIMENTAL_MEMBER_VARIABLE mutator and delete all the suppressions in various pitests related to this mutator

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

only in "api" profile.

@Youssefalaa7 Youssefalaa7 force-pushed the issue-18028-Resolve-Pitest-Suppressions-api branch from bfb1ad2 to c6d7ea5 Compare December 28, 2025 21:49
@Youssefalaa7

Copy link
Copy Markdown
Contributor Author

Done

@Youssefalaa7 Youssefalaa7 requested a review from romani December 28, 2025 22:34

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot

@romani romani merged commit 386684b into checkstyle:master Dec 29, 2025
123 checks passed
@romani

romani commented Dec 29, 2025

Copy link
Copy Markdown
Member

we will wait for pitest project to do update.

@Youssefalaa7

Youssefalaa7 commented Dec 29, 2025

Copy link
Copy Markdown
Contributor Author

Thanks a lot

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.

2 participants