Skip to content

Issue #13109: Kill mutation for FullIdent.java-2#13179

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:API5
Jul 8, 2023
Merged

Issue #13109: Kill mutation for FullIdent.java-2#13179
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:API5

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

Issue #13109: Kill mutation for FullIdent.java-2


Mutation covered

<mutation unstable="false">
<sourceFile>FullIdent.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.FullIdent</mutatedClass>
<mutatedMethod>createFullIdentBelow</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to com/puppycrawl/tools/checkstyle/api/DetailAST::getFirstChild</description>
<lineContent>return createFullIdent(ast.getFirstChild());</lineContent>
</mutation>

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Ci failure is not related to changes only test added

@Kevin222004
Copy link
Copy Markdown
Contributor Author

@romani This is ready fir review

@romani
Copy link
Copy Markdown
Member

romani commented Jun 11, 2023

This class is mistake to be in API. Better to find way to cover it by Inputs.

@Vyom-Yadav
Copy link
Copy Markdown
Member

Better to find way to cover it by Inputs.

Agreed. FullIdent is used by a lot of checks, used even in sevntu. You can find such a list here:

@rdiachenko
Copy link
Copy Markdown
Member

@Kevin222004 could you resolve the conflict please and follow @Vyom-Yadav's suggestion to test it. Your current approach doesn't use any checks, you need a check which uses FullIdent class and input for that check to write a proper test.

@Kevin222004 Kevin222004 force-pushed the API5 branch 2 times, most recently from 60a4eef to 13a3756 Compare June 18, 2023 11:59
@Kevin222004
Copy link
Copy Markdown
Contributor Author

@rdiachenko Please check i have updated branch

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.

All good except for minor:

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

@@ -0,0 +1 @@
import.ordering=Wrong order for ''{0}'' import.
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.

  1. Why do we include message properties specific to import.ordering only into main resources but not the test ones?
  2. Do we need all the locals to do testing or it's just enough to use a single message properties to test the case?

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.

  1. I have just followed all the check, to throw the message in all the check it is on the resources of main, so I also put it in the resource section of main

  2. import.ordering is only one which is require to throw the violation message at least for the test which I write so single message property is fine

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.

  1. But it's a copy paste of existing properties into a different directory under main (non test) resources. @romani why do we allow this?
  2. Why do you need all those messages_XX.properties, shouldn't a single file be enough?

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.

@rdiachenko for second question

[INFO] 
[INFO] --- maven-antrun-plugin:3.1.0:run (ant-phase-verify) @ checkstyle ---
[INFO] Executing tasks
[INFO]      [echo] Checkstyle started (checkstyle-checks.xml): 22/06/2023 06:47:12 pm
[INFO] [checkstyle] Running Checkstyle  on 1626 files
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_de.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_fi.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_ru.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_pt.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_ja.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_fr.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_es.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_tr.properties' is missing. [Translation]
[ERROR] [checkstyle] [ERROR] /home/kevin/Desktop/check_style/checkstyle/checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/api:1: Properties file 'messages_zh.properties' is missing. [Translation]
[INFO]      [echo] Checkstyle finished (checkstyle-checks.xml) : 22/06/2023 06:48:19 pm

it give error

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.

@romani ping

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.

Considering that FullIdent is used by other checks, it should already be covered by the tests of those checks. I just did what pitest suggested, removed .getFirstChild() and run tests in EqualsHashCodeCheckTest. Many of them failed.

@romani why can't we make that test as part of pitest-api profile?

@Kevin222004 could you try to extend pitest-api profile with additional test class in the pom.xml?

git diff pom.xml 
diff --git a/pom.xml b/pom.xml
index 6bbbdfc62..92b07ca5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4604,6 +4604,7 @@
                 <param>com.puppycrawl.tools.checkstyle.api.*</param>
                 <!-- 1% mutation in FullIdent -->
                 <param>com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheckTest</param>
+                <param>com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheckTest</param>
                 <!-- 1% mutation in CheckUtil -->
                 <param>com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheckTest</param>
                 <param>org.checkstyle.suppressionxpathfilter.XpathRegressionUnusedLocalVariableTest</param>

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.

Yes sure I will do that

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.

I also not have any issue to following thing that i done.

if everyone will not agree on #13179 (comment)

No changes should done in src/main/resources folder at all.

I update this soon

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 class is not API. Unfortunately leaked a long time ago. It is pure implementation and code in this implementation is not required by any of our Checks , it should be removed.

One day in future we will remove this class from API, it should be just another internal class.

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

@Kevin222004 Kevin222004 force-pushed the API5 branch 3 times, most recently from 9289aa9 to 80777b6 Compare June 22, 2023 17:51
@rdiachenko
Copy link
Copy Markdown
Member

@Kevin222004 please resolve conflicts in the meantime.

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 Vyom-Yadav and unassigned rdiachenko Jul 5, 2023
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.

Items:

Comment on lines +247 to +255
@Test
public void testCreateFullIdentBelow2() throws Exception {
final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class);
final String[] expected = {
"3:1: " + getCheckMessage(ImportOrderCheck.class,
MSG_ORDERING, "java.util.HashMap"),
};

verify(checkConfig, getPath("InputFullIdent.java"),
expected);
}
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.

Why haven't we used the InlineConfigParser?

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 removed verify method.

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.

Resolved

@Kevin222004 Kevin222004 force-pushed the API5 branch 2 times, most recently from 3784688 to 8a20f5b Compare July 8, 2023 08:03
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! if CI is green.

@Vyom-Yadav Vyom-Yadav assigned romani and unassigned Vyom-Yadav Jul 8, 2023
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 romani merged commit a2ebb4d into checkstyle:master Jul 8, 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