Skip to content

Issue #13109: Kill mutation for IllegalTokenTextCheck#13200

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:ITTC1
Jun 13, 2023
Merged

Issue #13109: Kill mutation for IllegalTokenTextCheck#13200
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:ITTC1

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 11, 2023

Issue #13109: Kill mutation for IllegalTokenTextCheck


Check

https://checkstyle.org/config_coding.html#IllegalTokenText


Mutation covered

<mutation unstable="false">
<sourceFile>IllegalTokenTextCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck</mutatedClass>
<mutatedMethod>&lt;init&gt;</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to java/util/regex/Pattern::compile</description>
<lineContent>private Pattern format = Pattern.compile(formatString);</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>IllegalTokenTextCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck</mutatedClass>
<mutatedMethod>&lt;init&gt;</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator</mutator>
<description>Removed assignment to member variable format</description>
<lineContent>private Pattern format = Pattern.compile(formatString);</lineContent>
</mutation>


Explaintaion

Test cases added


Regression

Diff Regression config: https://gist.githubusercontent.com/Kevin222004/13ca2532a9d40774066ac08c558f4111/raw/e41a49826864eac40ca16a3d2865cfb993255e98/IllegalTokenText.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/21e3934e85f802e2fbd48af06d122364/raw/604256badd733d8568064f371d55657c04b00dfd/test-projects-2.properties
Report label: Report-2

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

Report generation failed on phase "parse_body",
step "Parsing content of PR description".
Link: https://github.com/checkstyle/checkstyle/actions/runs/5235848546

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@romani
Copy link
Copy Markdown
Member

romani commented Jun 11, 2023

Setter is executed only when property is defined in config.
To reproduce mutation you need to play with config that is default, no properties are defined. In this case default values on field declaration are in play.

@Kevin222004
Copy link
Copy Markdown
Contributor Author

I really missed it. such one-sided thinking :)

@github-actions
Copy link
Copy Markdown
Contributor

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 class InputIllegalTokenTextDefaultFormat {
public void myTest() {
String test = "a href"; // ok
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.

Please remove all ok comments and never use them, it was our mistake to start to use them.

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.

If i am not wrong the ant task will be failed in mvn clean verify

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.

image

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.

Share it as text

Copy link
Copy Markdown
Member

@romani romani Jun 12, 2023

Choose a reason for hiding this comment

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

Ok, put one unrelated comment over class, to juy cheat this Check. To avoid dealing with this Check, I will try to disable it in separate PR.

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.

[INFO] --- maven-antrun-plugin:3.1.0:run (ant-phase-verify) @ checkstyle ---
[INFO] Executing tasks
[INFO]      [echo] Checkstyle started (checkstyle-checks.xml): 12/06/2023 10:32:21 am
[INFO] [checkstyle] Running Checkstyle  on 1507 files
[INFO]      [echo] Checkstyle finished (checkstyle-checks.xml) : 12/06/2023 10:33:26 am
[INFO]      [echo] Checkstyle started (checkstyle-non-main-files-checks.xml): 12/06/2023 10:32:21 am
[INFO] [checkstyle] Running Checkstyle  on 3657 files
[INFO]      [echo] Checkstyle finished (checkstyle-non-main-files-checks.xml): 12/06/2023 10:33:26 am
[INFO]      [echo]     
[INFO]      [echo] Checkstyle started (checkstyle-resources-checks.xml): 12/06/2023 10:32:21 am
[INFO] [checkstyle] Running Checkstyle  on 3307 files
[INFO]      [echo] Checkstyle finished (checkstyle-resources-checks.xml): 12/06/2023 10:33:26 am
[INFO]      [echo] Checkstyle started (checkstyle-input-checks.xml): 12/06/2023 10:32:21 am
[INFO] [checkstyle] Running Checkstyle  on 2102 files
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltokentext/InputIllegalTokenTextDefaultFormat.java:0: All check input files in the 'src/(it|test)/resources*/' folder must                    have trailing comments "// ok" and/or "// violation". [StyleValidationCommentInInputs]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:16 min
[INFO] Finished at: 2023-06-12T10:35:27+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.1.0:run (ant-phase-verify) on project checkstyle: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/config/ant-phase-verify.xml:192: Got 1 errors and 0 warnings.
[ERROR] around Ant part ...<ant antfile="config/ant-phase-verify.xml" />... @ 6:50 in /home/kevin/Desktop/check_style/checkstyle/checkstyle/target/antrun/build-main.xml
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

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 Simply remove trailing //ok comments from variable defs and place one at class level i.e.

public class InputIllegalTokenTextDefaultFormat { // ok

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

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.

Request to remove ok comments - #13213

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!

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

Copy link
Copy Markdown
Member

@rdiachenko rdiachenko left a comment

Choose a reason for hiding this comment

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

lgtm

@rdiachenko rdiachenko assigned romani and unassigned rdiachenko Jun 12, 2023
@romani romani merged commit 398035a into checkstyle:master Jun 13, 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