Skip to content

Issue #13501: Kill mutation for JavadocStyleCheck2#13576

Merged
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:JavadocStyleCheck2
Aug 27, 2023
Merged

Issue #13501: Kill mutation for JavadocStyleCheck2#13576
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:JavadocStyleCheck2

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Aug 21, 2023

Issue #13501: Kill mutation for JavadocStyleCheck2


Check

https://checkstyle.org/checks/javadoc/javadocstyle.html#JavadocStyle


Mutation

<mutation unstable="false">
<sourceFile>JavadocStyleCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck</mutatedClass>
<mutatedMethod>getCommentText</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::trim with receiver</description>
<lineContent>return builder.toString().trim();</lineContent>
</mutation>


Explaination

Trim is not required becuase we are trimming at


Regression :-

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


Diff Regression config: https://gist.githubusercontent.com/Kevin222004/0b07ecc7d3ca0ca403454d504707156d/raw/8c76ea8db01b4bcb565d1af9301130f7c67c3c1d/JavadocStyleCheck.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/9600f179b602d4c971bdb0a050099005/raw/360a95ed7bb60d7a0956e531199d484c4d6f6617/test-projects.properties
Report label: Regression-2

@Kevin222004 Kevin222004 marked this pull request as draft August 21, 2023 18:12
@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

@Kevin222004 Kevin222004 marked this pull request as ready for review August 22, 2023 04:24
@github-actions
Copy link
Copy Markdown
Contributor

@rdiachenko
Copy link
Copy Markdown
Member

Trim is not required becuase we are trimming at
trimTail(builder);

Here's a full context:

private static String getCommentText(String... comments) {
    final StringBuilder builder = new StringBuilder(1024);
    for (final String line : comments) {
        final int textStart = findTextStart(line);

        if (textStart != -1) {
            if (line.charAt(textStart) == '@') {
                // we have found the tag section
                break;
            }
            builder.append(line.substring(textStart));
            trimTail(builder);
            builder.append('\n');
        }
    }

    return builder.toString().trim();
}

By removing .trim() we let '\n' to be present at the end of the resulted String. @Kevin222004 could you recheck the logic please, how that new line affects the rest of the code? Can we come up with a testing input which fails in this case?

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@rdiachenko You are right \n can create an issue, after rechecking I have written a test to remove mutation.

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 merged commit a18d30f into checkstyle:master Aug 27, 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.

3 participants