Issue #13109: Kill mutation for CustomImport#13210
Merged
romani merged 1 commit intocheckstyle:masterfrom Jun 24, 2023
Merged
Conversation
Contributor
Author
|
Github, generate report |
Contributor
Contributor
Author
|
Github, generate report |
Contributor
Contributor
Author
|
@romani I have tried to explain the whole thing, I hope i have covered all case, if you still have any doubt about it please ask me |
Contributor
Author
|
Github, generate report |
Contributor
Contributor
Author
|
Github, generate report |
Contributor
Member
|
@Kevin222004 Please put the final reports in the PR description. |
Contributor
Author
|
@Vyom-Yadav done |
Member
|
@kevin Please generate a report with regex |
Contributor
Author
|
Github, generate report |
Contributor
Contributor
Author
|
Github, generate report |
Contributor
Contributor
Author
|
@Vyom-Yadav Reports are clean please go through the explanation |
romani
approved these changes
Jun 24, 2023
40 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #13109: Kill mutation for CustomImport
Check:-
https://checkstyle.org/config_imports.html#CustomImportOrder
Mutation
checkstyle/config/pitest-suppressions/pitest-imports-suppressions.xml
Lines 3 to 19 in c7f3688
Explaination
ok so there are 4 places where
samePackageMatchingDepthis used let's talk about first in methodaddRulesToListcheckstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Lines 1225 to 1234 in c7f3688
know it will actually call by only a setter method which is
setCustomImportOrderRulescheckstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Lines 809 to 817 in c7f3688
know else if part only executes when condition
ruleStr.startsWith(SAME_PACKAGE_RULE_GROUP)meet hence in this method user always defined such likeSAME_PACKAGE(3)know here we are reassigning
samePackageMatchingDepthwith the value inside the bracket in
SAME_PACKAGEhence whatever value ofsamePackageMatchingDepthdoesn't matter because the further operation will be performed based on the new value.append('.')
ok so basically the removal of append('.') is not creating an issue the reason is this method basically used in 2 methods 1)
createSamePackageRegexphttps://github.com/checkstyle/checkstyle/blob/c7f3688f4380144bb712bee7ad6808cd075b327c/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java#L1249C1-L1252
which is actually called
visitTokenwhencheckstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Lines 844 to 849 in c7f3688
astis equal toPACKAGE_DEF.so logically here
samePackageDomainsRegExpwill assign to the String which will be return byour method
getFirstDomainsFromIdenthere if we removeappend('.')so let's suppose ifString with
append('.')look like 'java.awt.button.'look like
javaawtbutton.know the
samePackageDomainsRegExphas a use case only ingetImportGroupcheckstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Lines 1084 to 1090 in c7f3688
at
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Lines 1085 to 1087 in c7f3688
in if statement know we are equaling
samePackageDomainsRegExpwithimportPathTrimmedToSamePackageDepthandimportPathTrimmedToSamePackageDepthwill also callgetFirstDomainsFromIdentto get string so here if we remove append it will affect bothsamePackageDomainsRegExpandimportPathTrimmedToSamePackageDepthand remove doty from both so their will no issue appear here while comparing. apart from this, there is no usage ofsamePackageDomainsRegExpwhich will cause output/logging violation hence the test forappend('.')is not possible.and know rest two usage of
samePackageMatchingDepthare here. while callinggetFirstDomainsFromIdentthey always pass samePackageMatchingDepth with it. and that value of samePackageMatchingDepth will be updated
addRulesToListso it never bezeroand update by the value provided by user inSAME_PACKAGE_RULE_GROUPso no issue is their
Regression
Report-1: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/1d4f30f_2023083444/reports/diff/index.html
Report-2: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/1d4f30f_2023105216/reports/diff/index.html
Report-3: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/1d4f30f_2023223348/reports/diff/index.html
Report-4: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/1d4f30f_2023055327/reports/diff/index.html
Diff Regression config: https://gist.githubusercontent.com/Kevin222004/c77cb85c86c9676985cf8fb916591a94/raw/713375f8427445ec0297b481413a185f4afbe8dc/cic.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/9600f179b602d4c971bdb0a050099005/raw/360a95ed7bb60d7a0956e531199d484c4d6f6617/test-projects.properties
Report label: New Report-2(2)