Skip to content

Issue #13109: Kill mutation for EqualsAvoidNullCheck 3#13126

Closed
Kevin222004 wants to merge 1 commit intocheckstyle:masterfrom
Kevin222004:Ev3
Closed

Issue #13109: Kill mutation for EqualsAvoidNullCheck 3#13126
Kevin222004 wants to merge 1 commit intocheckstyle:masterfrom
Kevin222004:Ev3

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 1, 2023

Issue #13109: Kill mutation for EqualsAvoidNullCheck 3

1 check :- https://checkstyle.org/config_coding.html#EqualsAvoidNull

2covering :-

<mutation unstable="false">
<sourceFile>EqualsAvoidNullCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck$FieldFrame</mutatedClass>
<mutatedMethod>getChildren</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to java/util/Collections::unmodifiableSet with argument</description>
<lineContent>return Collections.unmodifiableSet(children);</lineContent>
</mutation>

3 Explaination
getChildren method is used only at

private void traverseFieldFrameTree(FieldFrame frame) {

ok so as per https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Set.html#unmodifiable:~:text=They%20are%20unmodifiable.%20Elements%20cannot%20be%20added%20or%20removed. we cannot modify children

in above method we are not mdifiying the children in any way,
so removal of it is not creating any issue.

|https://kevin222004.github.io/reports/Ev3/2023-06-01-T-23-12-41/test-report/index.html

@Kevin222004
Copy link
Copy Markdown
Contributor Author

GitHub, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 1, 2023

Report generation failed on phase "make_report",
step "Generate report".
Link: https://github.com/checkstyle/checkstyle/actions/runs/5141568905

@nrmancuso
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@Kevin222004 Kevin222004 marked this pull request as draft June 2, 2023 05:01
@Kevin222004 Kevin222004 marked this pull request as ready for review June 2, 2023 08:38
Copy link
Copy Markdown
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:

*/
public Set<FieldFrame> getChildren() {
return Collections.unmodifiableSet(children);
return new HashSet<>(children);
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 asked this question somewhere.

How ca we instruct pitest to not mutate Collections.unmodifiableSet better to keep code restrictive on mutability, even nobody even tried to change this collection.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

closing this covered at #13127

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.

3 participants