Skip to content

Issue #13321: Kill mutation for OrderedPropertiesCheck-2#13374

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:opc2
Aug 9, 2023
Merged

Issue #13321: Kill mutation for OrderedPropertiesCheck-2#13374
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:opc2

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jul 7, 2023

Issue #13321: Kill mutation for OrderedPropertiesCheck-2


Check :-

https://checkstyle.org/checks/misc/orderedproperties.html#OrderedProperties


Mutation :-

<mutation unstable="false">
<sourceFile>OrderedPropertiesCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck</mutatedClass>
<mutatedMethod>getKeyPattern</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to java/util/regex/Matcher::quoteReplacement</description>
<lineContent>.replaceAll(Matcher.quoteReplacement(&quot;\\\\ &quot;)) + &quot;[\\s:=].*&quot;;</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>OrderedPropertiesCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck</mutatedClass>
<mutatedMethod>getKeyPattern</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to java/util/regex/Matcher::quoteReplacement with argument</description>
<lineContent>.replaceAll(Matcher.quoteReplacement(&quot;\\\\ &quot;)) + &quot;[\\s:=].*&quot;;</lineContent>
</mutation>


Explaination

Test added


Diff Regression config: https://gist.githubusercontent.com/Kevin222004/c3213434af8523d918594b88ce5554f7/raw/3565cfcd975e228af515bb34ce22c83afce0a7c7/opc.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/9600f179b602d4c971bdb0a050099005/raw/360a95ed7bb60d7a0956e531199d484c4d6f6617/test-projects.properties
Report label: Regression-2

@Kevin222004
Copy link
Copy Markdown
Contributor Author

GIthub, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 7, 2023

@Kevin222004 Kevin222004 marked this pull request as ready for review July 7, 2023 19:40
@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 7, 2023

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Kevin222004 No rationale?

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

Items:

private static Pattern getKeyPattern(String keyName) {
final String keyPatternString = "^" + SPACE_PATTERN.matcher(keyName)
.replaceAll(Matcher.quoteReplacement("\\\\ ")) + "[\\s:=].*";
.replaceAll("") + "[\\s:=].*";
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.

@Kevin222004 You can have properties with space in them, eg:

foo\ bar:hoo

The whitespace is escaped. You can see https://stackoverflow.com/q/2108103/15412365

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.

@Kevin222004 SPACE_PATTERN.matcher(keyName).replaceAll(Matcher.quoteReplacement("\\\\ ")), whitespace is being quoted to get the key pattern. Whitespace is escaped using \ in key so double quoting is required to get the pattern.

Please add print statements to see the difference between patterns, which will highlight what is needed to be changed. Please do ask if something is unclear.

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 @Vyom-Yadav for your help.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Test added

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@romani please re-run failing ci

@romani
Copy link
Copy Markdown
Member

romani commented Aug 8, 2023

Circleci was relaunched

Copy link
Copy Markdown
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!

@Vyom-Yadav Vyom-Yadav assigned rdiachenko and unassigned Vyom-Yadav Aug 9, 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

Covered by new test

@romani romani merged commit b57a0f8 into checkstyle:master Aug 9, 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.

4 participants