-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #14019: Kill mutation for setSeverity in Checker #14462
Conversation
6d8e4b6
to
b3abaa1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good, minor changes:
a103d61
to
5e614d1
Compare
Cirrus is failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last minor:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
items:
src/test/resources/com/puppycrawl/tools/checkstyle/checker/InputCheckerTestSeverity.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok to merge if CI pass
no this is not okay, the test case should be failing after mutation please check this comment #14462 (comment) |
so you need to set property in Checker not in LineLength.
|
did this but it is still giving the same result, the test case is still passing even after mutation. Pushed the changes for you to review it. The test case was giving violation on line 11 after I set the |
@romani ping |
cceaed1
to
2800511
Compare
I tried debugging the code and found that the |
lets try to move forward and fix code to make in-memory config to be correct (what we expect). |
Can you explain me what do you mean by in-memory config? Do you mean the config created by |
Yes. You can fix problem in this method in this PR, looks like it is first time we use config like this, do it will be natural to see it here and immediately use it in Input. |
Ohkay and should I keep it in seperate commit? |
in same commit is ok. |
8bcc43d
to
e71b610
Compare
fixed a small bug in Reason behind making new the regular createConfiguration() does not checks for the global properties, to check for the global properties we needed the whole xml config to see if it contains any global properties before any child modules, for this I created a new createConfiguration() which takes I could also modify the current createConfiguration() method to check for global properties but then I will also need to update all the caller methods of it and it might cause some unexpected behaviour, so I thought it would be more reliable to use the new createConfiguration() method. And also I'm sorry this is taking longer than I expected, I was little bit busy with college stuff.... |
This is not good, we should reuse existing parser. I can not help on the go, I need big screen time to find solution and guide you. It would be good if you find solution your self |
@@ -247,7 +247,7 @@ inputSource, new PropertiesExpander(System.getProperties()), | |||
throw new CheckstyleException( | |||
"First module should be Checker, but was " + configName); | |||
} | |||
handleXmlConfig(testInputConfigBuilder, inputFilePath, xmlConfig.getChildren()); | |||
handleXmlConfig(testInputConfigBuilder, inputFilePath, xmlConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the getChildren()
so that we can also set the properties of Checker
module to the testInputConfigBuilder
instead of directly setting the children module's properites. By adding Checker's properties to the testInputConfigBuilder
, we can access it from childrenModules
declared in the TestInputConfiguration.java
|
||
if ("Checker".equals(moduleName)) { | ||
handleXmlConfig(testInputConfigBuilder, inputFilePath, module.getChildren()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the current module is Checker
then we're recursively calling the handleXmlConfig()
method to set properties of Checker's children modules, this way the testInputConfigBuilder
will contain Checker properties as well as Checker's children modules' properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is weird that if ("Checker".equals(moduleName)) {
is below of if ("TreeWalker".equals(moduleName)) {
but it is better to fix it at new PR, here is new issue on this - #14653
|
||
childrenModules.remove(checkerConfig); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code checks if the childrenModules contains Checker's properties? if yes then add those properties to the root config and remove the Checker properties' object from childrenModules as we don't need it anymore
@romani I tried different approach this time, I need your opinion on this. Is it okay or do we need to change something? The test case is passing and after mutating the code it is failing as we expected. |
CircleCI is complaining, idk why though |
@@ -320,6 +324,9 @@ private static String getFullyQualifiedClassName(String filePath, String moduleN | |||
"com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck"); | |||
moduleMappings.put("LineLength", | |||
"com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck"); | |||
moduleMappings.put("Checker", | |||
"com.puppycrawl.tools.checkstyle.CheckerCheck"); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to add Checker here, cuz some tests started throwing an error something like:
config comment is not defined properly
@romani ping resolved the merge conflicts. I've made comments explaining the changes, let me know if this is the correct way to enable the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirming that we can not do better solution for now, more refactoring is required.
#14653
but this will unblock all PRs that planning to use Checkers/Treewalker in their tests.
Issue #14019 Kill mutation for setSeverity in checker
created a test case to kill the mutation