Skip to content

Fix LombokValToFinalVar in loops #768

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

MBoegers
Copy link
Contributor

@MBoegers MBoegers commented Jun 18, 2025

What's changed?

LombokValToFinalVar now avoids useing JavaTemplate in for each loops were type attribution is not secure enough and parsing might fail.

What's your motivation?

fix handling in for each loops

Anything in particular you'd like reviewers to focus on?

We assumed that for(val s : strings) is better migrated to for(var s : strings)than for(final var s : strings) as it more comply with the common usage.

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Fixing parser issue in template logic connected to val in loops, see

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@MBoegers MBoegers requested a review from timtebeek June 18, 2025 21:46
@MBoegers MBoegers self-assigned this Jun 18, 2025
@MBoegers MBoegers added the bug Something isn't working label Jun 18, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jun 18, 2025
@MBoegers MBoegers moved this from In Progress to Ready to Review in OpenRewrite Jun 18, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/test/java/org/openrewrite/java/migrate/lombok/LombokValToFinalVarTest.java
    • lines 20-21

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/test/java/org/openrewrite/java/migrate/lombok/LombokValToFinalVarTest.java
    • lines 21-21

@timtebeek timtebeek requested a review from jkschneider June 20, 2025 13:47
@timtebeek
Copy link
Member

This (now) isolated change can already be merged I think, but in chat we said to leave the final review to @jkschneider (no rush).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

2 participants