-
Notifications
You must be signed in to change notification settings - Fork 2
Issue #33: FinalLocalVariable recipe created #40
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
base: main
Are you sure you want to change the base?
Conversation
the recipe currently has partial coverage: When multiple variables are declared together like |
@rdiachenko kindly review. |
import org.openrewrite.java.tree.Space; | ||
import org.openrewrite.marker.Markers; | ||
|
||
public class FinalLocalVariable extends Recipe { |
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.
can you please add javadoc
import org.junit.jupiter.api.Test; | ||
import org.openrewrite.Recipe; | ||
|
||
public class FinalLocalVariableTest extends AbstractRecipeTest { |
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 see that https://checkstyle.sourceforge.io/checks/coding/finallocalvariable.html#FinalLocalVariable has different params
Can you please add tests covering the following cases to make sure it works correctly
for (String item : items) {
for (int i = 0; i < 10; i++)
public void processData(String data, int count)
final int alreadyFinal
try (FileReader fr = new FileReader(filename)) {
int a, b, c;
items.forEach(item -> System.out.println(item));
If it requires too much rework, let me know
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.
Will apply fixes on the bases of violation report.
None of the param will be helpful.
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.
Sorry, let me clarify
Not asking to support FinalLocalVariable's params
What I meant is that Checkstyle's FinalLocalVariable might fail for different positions based on the configurations
For example, validateEnhancedForLoopVariable
means that the FinalLocalVariable check might fail for for (String item : items) {
- will your recipe fix it?
<checkstyle version="10.12.3"> | ||
<file name="org/checkstyle/autofix/recipe/finallocalvariable/missingfinal/InputMissingFinal.java"> | ||
<error line="5" column="12" severity="error" | ||
message="Use uppercase 'L' for long literals." |
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.
Error messages seem to be incorrect
Fixes: #33
Implemented FinalLocalVariable recipe.