Issue #13109: Kill mutation for CustomImportOrderCheck 4#13212
Issue #13109: Kill mutation for CustomImportOrderCheck 4#13212romani merged 1 commit intocheckstyle:masterfrom
Conversation
|
Github, generate report |
|
Github, generate report |
|
Yes, we do not use user defined values, as we convert it to collection, and use only collection in logic. |
| */ | ||
| public final void setCustomImportOrderRules(final String inputCustomImportOrder) { | ||
| if (!customImportOrderRules.equals(inputCustomImportOrder)) { | ||
| if (!CUSTOM_IMPORT_ORDER_RULES.equals(inputCustomImportOrder)) { |
There was a problem hiding this comment.
I don't get it :) Why do we need CUSTOM_IMPORT_ORDER_RULES when we just compare the input with empty string in this place only?
There was a problem hiding this comment.
We have fields as constants for default values of all users accessible properties.
But I agree it looked weird even for me.
If expression as inputCustomImportOrder.isEmpty will looks better.
Naming constant as DEFAULT_xxxxxx would make it more clear, but all other default value constants are not named like this. Should we rename all of them to be more explicit?
But end up in gray area of ... What is default value of property for this module, as for user it is String.
https://checkstyle.org/config_imports.html#CustomImportOrder_Properties
There was a problem hiding this comment.
I see, so it's a Checkstyle's requirement that the user's property field must be present even though it is not actually used. This allows setter to be called and use incoming value in the way we want.
I don't see we use DEFAULT_xxx that much in other checks, but I agree that DEFAULT_CUSTOM_IMPORT_ORDER_RULES.equals(inputCustomImportOrder) is more readable than CUSTOM_IMPORT_ORDER_RULES.equals(inputCustomImportOrder)
There was a problem hiding this comment.
Ok then I have changed name as DEFAULT_CUSTOM_IMPORT_ORDER_RULES
There was a problem hiding this comment.
It is not a requirement, but end up our pattern for most of Checks.
Issue #13109: Kill mutation for CustomImportOrderCheck 4
check
https://checkstyle.org/config_imports.html#CustomImportOrder
Mutation
checkstyle/config/pitest-suppressions/pitest-imports-suppressions.xml
Lines 30 to 37 in 79d3c55
Explaination
This is setter for
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Line 726 in 79d3c55
which is
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Lines 809 to 817 in 79d3c55
we are not directly using this property hence all the rule will be first stored in
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Line 720 in 79d3c55
hence in all the code wherever we define the property all the logic has been written using
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
Line 720 in 79d3c55
so no test case is possible
Regression
Diff Regression config: https://gist.githubusercontent.com/Kevin222004/2463f07cae06e0317712d3aae38b3d0b/raw/42a3cd2e7a12eb3b02ccac0906aace21ddaa02ce/custom.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/9600f179b602d4c971bdb0a050099005/raw/360a95ed7bb60d7a0956e531199d484c4d6f6617/test-projects.properties
Report label: Report 1