Skip to content
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

Fix Log4jToSlf4 Single Statement If Could not parse as Java #186

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

FlorianWege-HS-KL
Copy link

@FlorianWege-HS-KL FlorianWege-HS-KL commented Oct 28, 2024

What's changed?

Add test case for #185
TODO: fix issue

What's your motivation?

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

Is this in the right test class? Should there be a separate Log4jToSlf4Test class?

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

@FlorianWege-HS-KL FlorianWege-HS-KL changed the title Fix Log4jToSlf4 Single If Statement could not parse Java Fix Log4jToSlf4 Single Statement If could not parse Java Oct 28, 2024
@FlorianWege-HS-KL FlorianWege-HS-KL changed the title Fix Log4jToSlf4 Single Statement If could not parse Java Fix Log4jToSlf4 Single Statement If Could not parse as Java Oct 28, 2024
@timtebeek timtebeek self-requested a review October 28, 2024 21:01
@timtebeek timtebeek added the bug Something isn't working label Oct 28, 2024
@timtebeek
Copy link
Contributor

hi @FlorianWege-HS-KL ; thanks for reporting as a runnable test! There appears to be a failure in the way the JavaTemplate is created, which only shows if the braces are missing. Here's the generated template; notice the missing ; after the logging statement.

import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.openrewrite.java.internal.template.__M__;
import org.openrewrite.java.internal.template.__P__;
public class SingleStatementIf{Logger log;
public void foo(){
/*__TEMPLATE__*/log.debug("first" + "second")/*__TEMPLATE_STOP__*/
}
private String bar(){
return null;
}
}

That likely needs a fix in openrewrite/rewrite, meaning other recipes would benefit from this fix as well. Thanks for bringing that to our attention!

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: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants