Issue #13328: Kill mutation for UnusedLocalVariableCheck 10#13331
Merged
rdiachenko merged 1 commit intocheckstyle:masterfrom Jul 3, 2023
Merged
Issue #13328: Kill mutation for UnusedLocalVariableCheck 10#13331rdiachenko merged 1 commit intocheckstyle:masterfrom
rdiachenko merged 1 commit intocheckstyle:masterfrom
Conversation
Contributor
Author
|
Github, generate report |
12 tasks
romani
requested changes
Jul 1, 2023
| instanceAndClassVarStack.forEach(instVar -> { | ||
| final VariableDesc variableDesc = new VariableDesc(instVar.getName(), | ||
| instVar.getTypeAst(), updatedScope); | ||
| null, updatedScope); |
Member
There was a problem hiding this comment.
Please make two params ctor instead
Contributor
Contributor
Author
|
Github, generate report |
Contributor
Author
|
@romani @rdiachenko @Vyom-Yadav Please merge this pr first before #13151 and #13152 |
Contributor
Vyom-Yadav
reviewed
Jul 2, 2023
Comment on lines
+878
to
+889
| /** | ||
| * Create a new VariableDesc instance. | ||
| * | ||
| * @param name name of the variable | ||
| * @param scope ast of type {@link TokenTypes#SLIST} or | ||
| * {@link TokenTypes#LITERAL_FOR} or {@link TokenTypes#OBJBLOCK} | ||
| * which is enclosing the variable | ||
| */ | ||
| private VariableDesc(String name, DetailAST scope) { | ||
| this(name, null, scope); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
Ok for killing the mutation. IMO the check design should be slightly modified not to ask for type if it is an instance variable.
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 #13328: Kill mutation for UnusedLocalVariableCheck 10
Check :-
https://checkstyle.org/checks/coding/unusedlocalvariable.html#UnusedLocalVariable
Mutation
https://github.com/checkstyle/checkstyle/blob/554a87ea9b5ae27f9519e8dbca15a116bcc108a4/config/pitest-suppressions/pitest-coding-2-suppressions.xml#L84-L95
Explaination
The reason to make typeast null is as similar as #13145 (comment)
that we don't throw violation on instance or class variable
Regression :-
Diff Regression config: https://gist.githubusercontent.com/Kevin222004/0dbdfb487f8e9a050ed0e6356f1a35b4/raw/31f7927f400e11e4285e86fd086b373095227848/unusedLocal.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/9600f179b602d4c971bdb0a050099005/raw/360a95ed7bb60d7a0956e531199d484c4d6f6617/test-projects.properties
Report label: Final-Regression-2