Skip to content

Issue #13501: Kill mutation for CodePointUtil#13473

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:cp1
Aug 29, 2023
Merged

Issue #13501: Kill mutation for CodePointUtil#13473
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:cp1

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jul 27, 2023

Issue #13501: Kill mutation for CodePointUtil

Mutation introduction at b862853
@nrmancuso is mandatory reviewer, as we allowed this code in PR year ago.


Mutations

<mutation unstable="false">
<sourceFile>CodePointUtil.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.utils.CodePointUtil</mutatedClass>
<mutatedMethod>stripLeading</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to com/puppycrawl/tools/checkstyle/utils/CommonUtil::isCodePointWhitespace</description>
<lineContent>&amp;&amp; CommonUtil.isCodePointWhitespace(codePoints, startIndex)) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>CodePointUtil.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.utils.CodePointUtil</mutatedClass>
<mutatedMethod>stripLeading</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_ELSE</mutator>
<description>removed conditional - replaced equality check with false</description>
<lineContent>&amp;&amp; CommonUtil.isCodePointWhitespace(codePoints, startIndex)) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>CodePointUtil.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.utils.CodePointUtil</mutatedClass>
<mutatedMethod>stripLeading</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to java/util/Arrays::copyOfRange with argument</description>
<lineContent>return Arrays.copyOfRange(codePoints, startIndex, codePoints.length);</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>CodePointUtil.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.utils.CodePointUtil</mutatedClass>
<mutatedMethod>stripLeading</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_ORDER_ELSE</mutator>
<description>removed conditional - replaced comparison check with false</description>
<lineContent>while (startIndex &lt; codePoints.length</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>CodePointUtil.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.utils.CodePointUtil</mutatedClass>
<mutatedMethod>trim</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/utils/CodePointUtil::stripTrailing with argument</description>
<lineContent>final int[] strippedCodePoints = stripTrailing(codePoints);</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>CodePointUtil.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.utils.CodePointUtil</mutatedClass>
<mutatedMethod>trim</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/utils/CodePointUtil::stripLeading with argument</description>
<lineContent>return stripLeading(strippedCodePoints);</lineContent>
</mutation>


Explaintaion

Both the method

public static int[] stripTrailing(int... codePoints) {
int lastIndex = codePoints.length;
while (lastIndex > 0 && CommonUtil.isCodePointWhitespace(codePoints, lastIndex - 1)) {
lastIndex--;
}
return Arrays.copyOfRange(codePoints, 0, lastIndex);
}

and
public static int[] stripLeading(int... codePoints) {
int startIndex = 0;
while (startIndex < codePoints.length
&& CommonUtil.isCodePointWhitespace(codePoints, startIndex)) {
startIndex++;
}
return Arrays.copyOfRange(codePoints, startIndex, codePoints.length);
}

are same only logic has written differently.
in stripTrailing method loop start from lastIndex of array and finsih at index 0 and same but opposite in stripLeading
the condition of loop is isCodePointWhitespace(codePoints, startIndex) will fail in both the method if their is no whitespace


Regression

Report-1 :- https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2237062_2023171438/reports/diff/index.html

Report-2 :- https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2237062_2023180212/reports/diff/index.html

Report-3 :- https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2237062_2023191958/reports/diff/index.html

Report-4 :-

Report-5 :-


Diff Regression config: https://gist.githubusercontent.com/Kevin222004/66e91526d84b11d76ed35dc61f651108/raw/01d1012ebdb5cae259e1f1775c9b25d68c41c881/codeutil2.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/2207ddd139a1721d00b0e6b312bc3f03/raw/a0b63175830fccda7c242058d8f513d61d4dce0d/util1.properties
Report label: Aug-28-2.2

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@Kevin222004 Kevin222004 marked this pull request as draft July 27, 2023 17:32
@github-actions
Copy link
Copy Markdown
Contributor

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

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

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

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 4, 2023

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 4, 2023

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 9, 2023

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 9, 2023

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

@Kevin222004 Kevin222004 changed the title Issue #13321: Kill mutation for CodePointUtil Issue #13501: Kill mutation for CodePointUtil Aug 15, 2023
@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@Kevin222004 Kevin222004 marked this pull request as ready for review August 15, 2023 17:51
@github-actions
Copy link
Copy Markdown
Contributor

Report generation failed on phase ,
step .
Link: https://github.com/checkstyle/checkstyle/actions/runs/5870108880

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Kevin222004 commented Aug 16, 2023

@romani please re-run pitest-common

https://github.com/checkstyle/checkstyle/actions/runs/5870097408/job/15916453617?pr=13473#step:7:15

+  <mutation unstable="false">
+    <sourceFile>Checker.java</sourceFile>
+    <mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
+    <mutatedMethod>finishLocalSetup</mutatedMethod>
+    <mutator>org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator</mutator>
+    <description>removed call to com/puppycrawl/tools/checkstyle/LocalizedMessage::setLocale</description>
+    <lineContent>LocalizedMessage.setLocale(locale);</lineContent>
+  </mutation>
+

@romani
Copy link
Copy Markdown
Member

romani commented Aug 16, 2023

Relaunched

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

Copy link
Copy Markdown
Contributor

@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.

Please rearrange declaration order and order of usage to be the same, ex:

boolean x = ...;
boolean y = ...;

if (x) {
...
} else if (y) {
...
}

Items:

@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

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

@nrmancuso
Copy link
Copy Markdown
Contributor

@Kevin222004 please make CI happy

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

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

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

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

@romani
Copy link
Copy Markdown
Member

romani commented Aug 28, 2023

@Kevin222004 , please generate report

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@nrmancuso nrmancuso assigned Vyom-Yadav and unassigned nrmancuso Aug 28, 2023
@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@romani romani removed the request for review from Vyom-Yadav August 29, 2023 04:49
@romani romani assigned romani and unassigned Vyom-Yadav Aug 29, 2023
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.

Ok to merge

@romani romani merged commit 54649c9 into checkstyle:master Aug 29, 2023
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.

5 participants