rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

Add BufferedWriterCreation recipe & SimplifyConstantTernaryExecution

Open JLLeitschuh opened this issue 1 year ago • 2 comments

  • BufferedWriterCreation
  • SimplifyConstantTernaryExecution

Signed-off-by: Jonathan Leitschuh [email protected]

What's your motivation?

More recipes, more better?

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

There seems to be a bug in autoFormat where the J.Literal isn't having it's prefix padding removed.

Anyone you would like to review specifically?

  • @knutwannheden

Have you considered any alternatives or workarounds?

Any additional context

Checklist

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

JLLeitschuh avatar Feb 17 '24 03:02 JLLeitschuh

This PR is currently failing. It seems that autoFormat isn't working correctly in the SimplifyConstantTernaryExecution, and I have no idea what I'm doing wrong. Any insights here would be greatly appreciated.

JLLeitschuh avatar Feb 17 '24 03:02 JLLeitschuh

Also, waiting on https://github.com/openrewrite/rewrite/pull/4015 to land too for this PR

JLLeitschuh avatar Feb 17 '24 03:02 JLLeitschuh

Thanks both! Took me a little while to get to, but I've pushed up a few small improvements to rewrite & rewrite-templating to narrow down the changes here to just a regular Refaster recipe, such that other recipes can also benefit from those improvements:

  • https://github.com/openrewrite/rewrite/pull/4617
  • https://github.com/openrewrite/rewrite-templating/pull/114

timtebeek avatar Oct 27 '24 15:10 timtebeek

Also added to Java security best practices: https://github.com/openrewrite/rewrite-java-security/commit/9d9c9ffff82ffc680059ae8282e02e79c1694dc2 Was doubting if this should be added into the OWASP top ten as well; leave that up to you @JLLeitschuh , and thanks again!

timtebeek avatar Oct 27 '24 15:10 timtebeek