checkstyle icon indicating copy to clipboard operation
checkstyle copied to clipboard

Resolve Pitest Suppression in Pitest-Javadoc Profile

Open Kevin222004 opened this issue 2 years ago • 16 comments

As a part of this issue, we have to kill the mutation listed below and remove the suppression from pitest-javadoc-suppression.xml

How to Kill the Mutation

1) Take 1 mutation and apply to the code

Pick up the one mutation from the pitest-javadoc-suppression.xml file or for better understanding you can generate the pitest report as well by Following Steps and finally hardcode the mutation.

How to hardcode the mutation For better understanding of mutatnt, That how it works. Please checkout Pitest Doc In this you will find the detail explaination of each mutant with example.

2) Send the pr and generate the report

After hardcoding the code please send a pull request and try to generate the regression Report. If Regression report found the diff then you got your test cases. use that part of code as your input and create a test.

How to generate the Regression Report To learn how to generate the regression report Please go through the Following link. https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#report-generation

After reading this you found the 2 method two genrate the report please try to generate the report with Github Action. For example https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#generation-examples Basically you have to generate the 2 report in with project file

  1. Project-list-1
  2. Project-list-2
  3. Project-list-3

3) Removal of code

If no diff found from all the report just follow the mutation apply the changes and update the pr.

Apart of this for more detailed explaination please go through Wiki-Page and Pit Documentation

Example of how we did not find by report test case that kill mutation https://github.com/checkstyle/checkstyle/pull/13342 and we simply updated code as pitest mutated.

Example of how to share analytical explanation on why removal of code is ok - https://github.com/checkstyle/checkstyle/pull/14410


List of survivals to kill mutation

please always choose single mutation for Pull Request.

1) JavadocParagraphCheck

  • [x] MemberVariableMutator on DetailNode newLine = JavadocUtil.getPreviousSibling(node)

3) JavadocStyleCheck

  • [x] NonVoidMethodCallMutator on builder.deleteCharAt(index)
  • [x] NonVoidMethodCallMutator on if (Character.isWhitespace(builder.charAt(index)))
  • [x] NonVoidMethodCallMutator on if (Character.isWhitespace(builder.charAt(index)))
  • [x] RemoveConditionalMutator_EQUAL_ELSE on if (Character.isWhitespace(builder.charAt(index))) {
  • [x] RemoveConditionalMutator_EQUAL_ELSE on if (Character.isWhitespace(builder.charAt(index))) {
  • [x] RemoveConditionalMutator_EQUAL_IF on if (Character.isWhitespace(builder.charAt(index)))
  • [x] RemoveIncrementsMutator on index += 2;
  • [x] NakedReceiverMutator on builder.deleteCharAt(index)

4) JavadocMethodCheck

  • [x] NonVoidMethodCallMutator on columnNo = fullIdent.getColumnNo()

  • [x] MemberVariableMutator on columnNo = fullIdent.getColumnNo()

  • [x] NonVoidMethodCallMutator on .lineNo = fullIdent.getLineNo();

  • [x] MemberVariableMutator on lineNo = fullIdent.getLineNo();

  • [x] ArgumentPropagationMutator on final int col = calculateTagColumn(noargCurlyMatcher, i, startColumnNumber)

  • [x] NonVoidMethodCallMutator on final Token token = new Token(tag.getFirstArg(), tag.getLineNo(), tag

  • [x] NonVoidMethodCallMutator on final int col = calculateTagColumn(noargCurlyMatcher, i, startColumnNumber)

  • [x] NonVoidMethodCallMutator on foundThrows.add(documentedClassInfo.getName().getText())

  • [x] NonVoidMethodCallMutator on foundThrows.add(documentedClassInfo.getName().getText())

  • [x] RemoveConditionalMutator_EQUAL_ELSE on if (class1.contains(separator) || class2.contains(separator)) {

  • [x] RemoveConditionalMutator_EQUAL_IF on if (arg1.startsWith(ELEMENT_START) && arg1.endsWith(ELEMENT_END))

  • [x] RemoveConditionalMutator_EQUAL_IF on if (child.getType() == TokenTypes.PARAMETER_DEF) {

  • [x] RemoveConditionalMutator_EQUAL_IF on if (class1.contains(separator) || class2.contains(separator)) {

  • [x] RemoveConditionalMutator_EQUAL_IF on if (ancestor.getType() == TokenTypes.LITERAL_TRY

  • [x] RemoveConditionalMutator_EQUAL_IF on return surroundingAccessModifier != null

  • [x] NakedReceiverMutator on final DetailAST blockAst = methodAst.findFirstToken(TokenTypes.SLIST)

  • [ ] NakedReceiverMutator on DetailAST ancestor = throwAst.getParent();


2) JavadocMethodCheck$Token

  • [ ] NonVoidMethodCallMutator on columnNo = fullIdent.getColumnNo();
  • [x] NonVoidMethodCallMutator - https://github.com/checkstyle/checkstyle/pull/13342
  • [ ] MemberVariableMutator on columnNo = fullIdent.getColumnNo();
  • [ ] MemberVariableMutator on lineNo = fullIdent.getLineNo();
  • [ ] MemberVariableMutator on lineNo = fullIdent.getLineNo()

5) JavadocNodeImpl

  • [x] NonVoidMethodCallMutator on + ", children=" + Objects.hashCode(children)

6) JavadocTagInfo$15

  • [ ] RemoveConditionalMutator_EQUAL_IF on varType.getFirstChild().getType() == TokenTypes.ARRAY_DECLARATOR
  • [ ] RemoveConditionalMutator_EQUAL_IF on return astType == TokenTypes.VARIABLE_DE https://github.com/checkstyle/checkstyle/pull/13601 https://github.com/checkstyle/checkstyle/pull/13600

7) JavadocTagInfo$14

  • [ ] RemoveConditionalMutator_EQUAL_IF (1) on return astType == TokenTypes.METHOD_DEF https://github.com/checkstyle/checkstyle/pull/13599

8) JavadocTagInfo$11

  • [ ] RemoveConditionalMutator_EQUAL_IF (1) on return astType == TokenTypes.METHOD_DEF https://github.com/checkstyle/checkstyle/pull/13598.

9) TagParser

  • [x] ArgumentPropagationMutator on Point position = findChar(text, '<', new Point(0, 0))
  • [x] ArgumentPropagationMutator on toPoint = findChar(text, '>', getNextPoint(text, toPoint))
  • [x] ArgumentPropagationMutator on toPoint = findChar(text, '>', toPoint)
  • [x] NonVoidMethodCallMutator on (Character.isJavaIdentifierStart(text.charAt(position))
  • [x] NonVoidMethodCallMutator on (Character.isJavaIdentifierStart(text.charAt(position))
  • [x] RemoveConditionalMutator_EQUAL_ELSE on if (incompleteTag) {
  • [x] RemoveConditionalMutator_EQUAL_ELSE on .substring(0, toPoint.getColumnNo() + 1).endsWith("-->"))
  • [x] RemoveConditionalMutator_EQUAL_IF on (Character.isJavaIdentifierStart(text.charAt(position))
  • [x] NakedReceiverMutator on text = text.substring(column).trim()
  • [x] RemoveConditionalMutator_ORDER_ELSE while (toPoint.getLineNo() < text.length && !text[toPoint.getLineNo()]

10) AbstractJavadocCheck

  • [x] NonVoidMethodCallMutator on JavadocUtil.getTokenName(javadocTokenId), getClass().getName())
  • [x] NonVoidMethodCallMutator on avadocToken, getClass().getName()
  • [x] NonVoidMethodCallMutator on blockCommentNode.getColumnNo())
  • [x] NonVoidMethodCallMutator on waitsForProcessing = shouldBeProcessed(curNode);
  • [x] RemoveConditionalMutator_EQUAL_ELSE on if (curNode != null) {
  • [x] RemoveConditionalMutator_EQUAL_IF on if (getRequiredJavadocTokens().length != 0)
  • [x] RemoveConditionalMutator_EQUAL_IF on if (toVisit == null) { https://github.com/checkstyle/checkstyle/pull/13602

Kevin222004 avatar Nov 06 '23 17:11 Kevin222004

@Kevin222004 why aren’t we referencing https://github.com/checkstyle/checkstyle/issues/12341#issue-1419918015 and why are we rewriting the pitest procedure here?

nrmancuso avatar Nov 16 '23 11:11 nrmancuso

Javadoc are very special group, we less demanding to prove that code is required. We know already that implementation of such checks are very error prone, so if regression can not be found by regression, code should be removed.

If there will be regression, we are sorry and we will fix easily in next release.

This rule is not applicable to AST based javadoc Checks, we might do the same for Indentation module ( I am not sure).

This rule is not applicable to https://github.com/checkstyle/checkstyle/issues/14019 .

romani avatar Nov 16 '23 16:11 romani

I am on JavadocParagraphCheck

suniti0804 avatar Dec 04 '23 07:12 suniti0804

I am on parseTags() method of TagParser

suniti0804 avatar Dec 23 '23 15:12 suniti0804

I am on ArgumentPropagationMutator on toPoint = findChar(text, '>', getNextPoint(text, toPoint)) of TagParser class.

suniti0804 avatar Dec 24 '23 05:12 suniti0804

I am on ArgumentPropagationMutator on toPoint = findChar(text, '>', toPoint) of TagParser class

suniti0804 avatar Dec 25 '23 12:12 suniti0804

I am on RemoveConditionalMutator_EQUAL_IF on (Character.isJavaIdentifierStart(text.charAt(position)) of TagParser class

suniti0804 avatar Dec 26 '23 07:12 suniti0804

I am on RemoveConditionalMutator_EQUAL_ELSE on if (incompleteTag) { of TagParser class

suniti0804 avatar Dec 27 '23 05:12 suniti0804

I am working on index += 2; of JavadocStyleCheck

Zopsss avatar Jan 12 '24 07:01 Zopsss

I'm working on DetailAST ancestor = throwAst.getParent(); of JavadocMethodCheck

Zopsss avatar Jan 17 '24 18:01 Zopsss

I am on RemoveConditionalMutator_EQUAL_IF on if (child.getType() == TokenTypes.PARAMETER_DEF) {

Coding-Aliens avatar Jan 29 '24 03:01 Coding-Aliens

I am on if (ancestor.getType() == TokenTypes.LITERAL_TRY (JavadocMethodCheck)

sktpy avatar Feb 01 '24 17:02 sktpy

i am on text = text.substring(column).trim()

mahfouz72 avatar Feb 16 '24 14:02 mahfouz72

I am on foundThrows.add(documentedClassInfo.getName().getText())

Coding-Aliens avatar Feb 23 '24 03:02 Coding-Aliens