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

Recipe ReplaceLocalizedStreamMethods #532

Merged

Conversation

BhavanaPidapa
Copy link
Contributor

What's changed?

This PR contains recipe - org.openrewrite.java.migrate.ReplaceLocalizedStreamMethods
Rule:
image

What's your motivation?

This custom recipe replaces the occurrences of Runtime.getLocalizedInputStream and Runtime.getLocalizedOutputStream methods. The occurrence of getLocalizedInputStream(in) is replaced with in parameter and getLocalizedOutputStream(out) is replaced with out parameter.

Anyone you would like to review specifically?

@timtebeek @cjobinabo

Have you considered any alternatives or workarounds?

I created sample files, created a local plugin using
./gradlew publishToMavenLocal then ran it in the Java8 Sample App using mvn rewrite:dryRun

Attaching the rewrite.patch file
rewrite.patch

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

timtebeek and others added 2 commits August 14, 2024 23:39
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Thanks @BhavanaPidapa ! I've done a few quick polish commits but with that we're good from my side. @cjobinabo can do the final review & merge.

@timtebeek timtebeek added the recipe Recipe requested label Aug 14, 2024
@ranuradh ranuradh requested a review from cjobinabo August 15, 2024 13:50

@Override
public String getDescription() {
return "Replace `Runtime.getLocalizedInputStream(InputStream)` and `Runtime.getLocalizedOutputStream(with the argument)` with their direct arguments.";
Copy link
Contributor

Choose a reason for hiding this comment

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

In the description, I think it would be helpful to add some info about why this change is made. That the earlier implementation of these methods simply returned the input parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the description as mentioned.

@cjobinabo cjobinabo merged commit 270244c into openrewrite:main Aug 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants