Skip to content

Issue #13102: kill mutation for DeclarationOrderCheck 2#13123

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:DO2
Jun 7, 2023
Merged

Issue #13102: kill mutation for DeclarationOrderCheck 2#13123
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:DO2

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 1, 2023

Issue #13102: kill mutation for DeclarationOrderCheck 2

check :- https://checkstyle.org/config_coding.html#DeclarationOrder

covering :-

<mutation unstable="false">
<sourceFile>DeclarationOrderCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck</mutatedClass>
<mutatedMethod>processModifiersState</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator</mutator>
<description>Removed assignment to member variable currentScopeState</description>
<lineContent>state.currentScopeState = STATE_STATIC_VARIABLE_DEF;</lineContent>
</mutation>

Explanation:-
if we look at else part the if condition will execute when state.currentScopeState is greater than STATE_STATIC_VARIABLE_DEF
As per

private static final int STATE_STATIC_VARIABLE_DEF = 1;

the value of STATE_STATIC_VARIABLE_DEF is 1
know 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_DEF which value is 1. so we are assigning the same value to state.currentScopeState so 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

@Kevin222004
Copy link
Copy Markdown
Contributor Author

GitHub, generate report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 1, 2023

@Kevin222004 Kevin222004 marked this pull request as draft June 2, 2023 05:02
@Kevin222004 Kevin222004 force-pushed the DO2 branch 2 times, most recently from b350980 to cb5a068 Compare June 2, 2023 17:12
@Kevin222004 Kevin222004 marked this pull request as ready for review June 2, 2023 17:13
@Kevin222004
Copy link
Copy Markdown
Contributor Author

@romani ready for review

@rdiachenko rdiachenko self-assigned this Jun 2, 2023
@Kevin222004 Kevin222004 force-pushed the DO2 branch 2 times, most recently from 1037fe0 to d9a90d8 Compare June 3, 2023 17:22
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 requested a review from Vyom-Yadav June 5, 2023 09:16
@rdiachenko rdiachenko removed their assignment Jun 5, 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

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 -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);
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.

@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);                                       
}                                                                       

Copy link
Copy Markdown
Member

@Vyom-Yadav Vyom-Yadav Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal of else condition is justified but why have you changed the boolean operators?

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.

@Vyom-Yadav #13123 (comment) please gave a look at this conversation it is done for simplification purposes.

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.

Ok, #13123 (comment).
Resolved.

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!

@Vyom-Yadav Vyom-Yadav assigned romani and unassigned Vyom-Yadav Jun 7, 2023
@romani romani merged commit 1e85476 into checkstyle:master Jun 7, 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