openrewrite / openrewrite/rewrite-static-analysis

Issue discovered on `src/main/java/org/openrewrite/java/migrate/AddJDeprScanPlugin.java` with `Fix `String#format` and `String#formatted` expressions`

Open
#16 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
62
Forks
112
Avg merge
1d 19h
Merged PRs (30d)
40

Description

Problem

Describe the issue you are experiencing.

Expected behavior

Describe what you expected to see.

Example diff

From: src/main/java/org/openrewrite/java/migrate/AddJDeprScanPlugin.java

                  "org.apache.maven.plugins",
            "maven-jdeprscan-plugin",
            "3.0.0-alpha-1",
-                    String.format("<configuration>
<release>%s</release>
</configuration>",
+                    String.format("<configuration>%n   <release>%s</release>%n</configuration>",
                    StringUtils.isNullOrEmpty(getRelease()) ? "11" : getRelease()),
            null,
            null));
Recipes in example diff:
  • org.openrewrite.java.cleanup.FixStringFormatExpressions
References:
  • View original result
  • Recipe ID: org.openrewrite.java.cleanup.FixStringFormatExpressions
  • Recipe Name: Fix String#formatandString#formatted expressions
  • Repository: openrewrite/rewrite-migrate-java/main
  • Created at Thu Dec 29 2022 22:00:23 GMT-0500 (Eastern Standard Time)

This issue originally created by @jkschneider on: https://github.com/moderneinc/support-public/issues/17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the FixStringFormatExpressions recipe and the reported source at src/main/java/org/openrewrite/java/migrate/AddJDeprScanPlugin.java. Reproduce the example transformation and verify that String.format and String.formatted expressions produce the expected newline formatting shown in the diff.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.