Issue #13102: kill mutation for DeclarationOrderCheck 2#13123
Merged
romani merged 1 commit intocheckstyle:masterfrom Jun 7, 2023
Merged
Issue #13102: kill mutation for DeclarationOrderCheck 2#13123romani merged 1 commit intocheckstyle:masterfrom
romani merged 1 commit intocheckstyle:masterfrom
Conversation
Contributor
Author
|
GitHub, generate report |
b350980 to
cb5a068
Compare
Contributor
Author
|
@romani ready for review |
rdiachenko
requested changes
Jun 2, 2023
src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java
Outdated
Show resolved
Hide resolved
1037fe0 to
d9a90d8
Compare
Vyom-Yadav
suggested changes
Jun 7, 2023
Comment on lines
-369
to
+372
| else { | ||
| if (state.currentScopeState > STATE_STATIC_VARIABLE_DEF) { | ||
| if (!ignoreModifiers | ||
| || state.currentScopeState > STATE_INSTANCE_VARIABLE_DEF) { | ||
| isStateValid = false; | ||
| log(modifierAst, MSG_STATIC); | ||
| } | ||
| } | ||
| else { | ||
| state.currentScopeState = STATE_STATIC_VARIABLE_DEF; | ||
| } | ||
| else if (state.currentScopeState > STATE_INSTANCE_VARIABLE_DEF | ||
| || state.currentScopeState > STATE_STATIC_VARIABLE_DEF && !ignoreModifiers) { | ||
| isStateValid = false; | ||
| log(modifierAst, MSG_STATIC); |
Member
There was a problem hiding this comment.
@Kevin222004 Shouldn't it be:
else if (state.currentScopeState > STATE_STATIC_VARIABLE_DEF
&& (!ignoreModifiers
|| state.currentScopeState > STATE_INSTANCE_VARIABLE_DEF)) {
isStateValid = false;
log(modifierAst, MSG_STATIC);
}
Member
There was a problem hiding this comment.
Removal of else condition is justified but why have you changed the boolean operators?
Contributor
Author
There was a problem hiding this comment.
@Vyom-Yadav #13123 (comment) please gave a look at this conversation it is done for simplification purposes.
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 #13102: kill mutation for DeclarationOrderCheck 2
check :- https://checkstyle.org/config_coding.html#DeclarationOrder
covering :-
checkstyle/config/pitest-suppressions/pitest-coding-1-suppressions.xml
Lines 3 to 10 in 81448ea
Explanation:-
if we look at else part the if condition will execute when state.
currentScopeStateis greater thanSTATE_STATIC_VARIABLE_DEFAs per
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java
Line 228 in 81448ea
the value of
STATE_STATIC_VARIABLE_DEFis 1know if will only execute when state.current scope if either 2, 3, 4 means greater than 1 not even 1.
so if their the value of state.currentScopeState is 1 then only else part will exectue and in else part we are assigning state.curcurrentScopeState to
STATE_STATIC_VARIABLE_DEFwhich value is 1. so we are assigning the same value tostate.currentScopeStateso removal of else part wont make any effect.Regression
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/f5bfcc9_2023093628/reports/diff/index.html