Skip to content

Issue #13321: Kill mutation for TranslationCheck-1#13366

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:TC1
Jul 10, 2023
Merged

Issue #13321: Kill mutation for TranslationCheck-1#13366
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:TC1

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jul 6, 2023

Issue #13321: Kill mutation for TranslationCheck-1


Check

https://checkstyle.org/checks/misc/translation.html#Translation


Mutation

<mutation unstable="false">
<sourceFile>TranslationCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.TranslationCheck</mutatedClass>
<mutatedMethod>logException</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to com/puppycrawl/tools/checkstyle/checks/TranslationCheck::getId</description>
<lineContent>getId(),</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>TranslationCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.TranslationCheck$ResourceBundle</mutatedClass>
<mutatedMethod>getFiles</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(files);</lineContent>
</mutation>


Explaination

To Kill the mutation unmodifiableCollectionUtil I have used avoid call to for out class created to wrap that method in util by default avoidcall to is applied to https://pitest.org/quickstart/maven/#:~:text=If%20a%20list%20is%20not%20explicitly%20supplied%20then%20PIT%20will%20default%20to%20a%20list%20of%20common%20logging%20packages%20as%20follows
so add log method to avoid the error at

* Returns the violation key to locate the translation, can also be used


@Kevin222004 Kevin222004 force-pushed the TC1 branch 2 times, most recently from b649c5d to 3e36015 Compare July 6, 2023 09:56
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:

key,
args,
getId(),
null,
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 will mean that:
If used define id for module - https://checkstyle.org/config.html#Id
It will not be printed to user in report instead of module name, so just module name will be used. If user has two instances of same module type he will not know what module instance caused it.

Example of id printing instead of module name in CLI output - #13038

We can not cover such mutation by our Inputs with embedded config. But we should create test method that validate violation id with config defined in java code and assert on violation object field or checking content of some test audit listener https://checkstyle.org/config.html#Audit_Listeners we should already have some tests for this.

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.

ok i got it Thanks.

I found this type of testing at https://github.com/checkstyle/checkstyle/blob/master/src/test/java/com/puppycrawl/tools/checkstyle/AuditEventDefaultFormatterTest.java

i have update an exisiting test is it fine

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

romani commented Jul 10, 2023

We just extended test, I am merging

@romani romani merged commit 12b165d into checkstyle:master Jul 10, 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.

2 participants