Skip to content

Issue #13321: Kill mutation for SummaryJavaDocCheck-7#13317

Merged
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:s7
Jul 7, 2023
Merged

Issue #13321: Kill mutation for SummaryJavaDocCheck-7#13317
rdiachenko merged 1 commit intocheckstyle:masterfrom
Kevin222004:s7

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 26, 2023

Issue #13321: Kill mutation for SummaryJavaDocCheck-7


Check :-

https://checkstyle.org/checks/javadoc/summaryjavadoc.html#SummaryJavadoc


Mutation

<mutation unstable="false">
<sourceFile>SummaryJavadocCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck</mutatedClass>
<mutatedMethod>isInlineTagWithName</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_IF</mutator>
<description>removed conditional - replaced equality check with true</description>
<lineContent>return child[1].getType() == JavadocTokenTypes.CUSTOM_NAME</lineContent>
</mutation>


Explaination

this method is used by two method

private static boolean isSummaryTag(DetailNode javadocInlineTag) {
return isInlineTagWithName(javadocInlineTag, SUMMARY_TEXT);
}
/**
* Checks if the first tag inside ast is {@code {@return}} tag.
*
* @param javadocInlineTag node of type {@link JavadocTokenTypes#JAVADOC_INLINE_TAG}
* @return {@code true} if first tag is return tag.
*/
private static boolean isInlineReturnTag(DetailNode javadocInlineTag) {
return isInlineTagWithName(javadocInlineTag, RETURN_TEXT);

Please guide if this is wrong. as per https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html#CUSTOM_NAME whatever the tag will come it will always be true.

another and main reason the method is returning

* @return {@code true} if first tag is a tag with the given name.

the tag with given name then that task is already done by only if they don't match it is false.


Regression :-


Diff Regression config: https://gist.githubusercontent.com/Kevin222004/61eaa69fe98585b6ee1882ca082362bc/raw/316ca02ce9fd290119d9bfc560f2b11e84a1b685/Summary.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

@Kevin222004 Kevin222004 changed the title Issue #13109: Kill mutation for SummaryJavaDocCheck-7 Issue #13321: Kill mutation for SummaryJavaDocCheck-7 Jun 29, 2023
@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@Kevin222004 Kevin222004 marked this pull request as ready for review June 29, 2023 05:25
@github-actions
Copy link
Copy Markdown
Contributor

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Github, generate report

@github-actions
Copy link
Copy Markdown
Contributor

@romani
Copy link
Copy Markdown
Member

romani commented Jun 29, 2023

Pitest are failing .
Restated

@Kevin222004 Kevin222004 force-pushed the s7 branch 2 times, most recently from a11781f to 1bb370a Compare June 30, 2023 18:00
@romani
Copy link
Copy Markdown
Member

romani commented Jul 1, 2023

Not all tags are Custom named.
Please review https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html#JAVADOC_INLINE_TAG

There are bunch of standard inline tags please make test with recognized inlined tag or show existing line in Input and explain why it doesn't help to kill survival

@Kevin222004
Copy link
Copy Markdown
Contributor Author

#13317 (comment) Thanks for clarifying @romani
but the main reason to remove is

private static boolean isInlineTagWithName(DetailNode javadocInlineTag, String name) {
final DetailNode[] child = javadocInlineTag.getChildren();
// Checking size of ast is not required, since ast contains
// children of Inline Tag, as at least 2 children will be present which are
// RCURLY and LCURLY.
return child[1].getType() == JavadocTokenTypes.CUSTOM_NAME
&& name.equals(child[1].getText());
}

this method check 2 condition that the name of inline tag should be match to child1.getText() which is text of JavadocInline Tag so if they mismatch then it will be false.

Know this method is only called by 2 method which are

private static boolean isSummaryTag(DetailNode javadocInlineTag) {
return isInlineTagWithName(javadocInlineTag, SUMMARY_TEXT);
}

and
private static boolean isInlineReturnTag(DetailNode javadocInlineTag) {
return isInlineTagWithName(javadocInlineTag, RETURN_TEXT);
}

in which as a name parameter already we are passing the name as @summary and @return as form of Summary_text and Return_text

so if this name will not match with the name of javadoc tag then method return false and in return statment both the condition are in && so if the removed statement is true still it will fail

@romani
Copy link
Copy Markdown
Member

romani commented Jul 2, 2023

@Kevin222004 , Please resolve conflict meanwhile

@romani
Copy link
Copy Markdown
Member

romani commented Jul 2, 2023

Yes, we check only predefined inline tags
Like

, and all of them are Custom for us.
So we do not need this extra condition.

@romani romani requested review from Vyom-Yadav and rdiachenko July 2, 2023 19:46
@romani romani self-requested a review July 2, 2023 19:46
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

@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 Jul 3, 2023
@rdiachenko
Copy link
Copy Markdown
Member

@Kevin222004 please resolve a conflict

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 86b95ff into checkstyle:master Jul 7, 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