Skip to content

Conversation

@timtebeek
Copy link
Member

timtebeek and others added 4 commits July 9, 2025 16:58
This recipe replaces inefficient string concatenation patterns like
`"" + ...` with `String.valueOf(...)`. This improves code readability
and may have minor performance benefits.

The recipe preserves parentheses when they exist in the original
expression, e.g., ("" + 42) becomes (String.valueOf(42)).

Fixes #628

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…ring types

- Use TypeUtils.isString() instead of comparing with JavaType.Primitive.String
- Update test expectation for comment preservation (known JavaTemplate limitation)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@timtebeek timtebeek requested a review from greg-at-moderne July 9, 2025 16:34
@timtebeek timtebeek self-assigned this Jul 9, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jul 9, 2025
@timtebeek timtebeek marked this pull request as draft July 9, 2025 16:36
@timtebeek
Copy link
Member Author

timtebeek commented Jul 9, 2025

Seeing some perhaps undesirable effects:
image

@greg-at-moderne
Copy link
Contributor

Seeing some perhaps undesirable effects:

This might look a bit off as it violates the symmetry of the code text, but I think it's fine actually.

@greg-at-moderne greg-at-moderne removed their request for review July 31, 2025 12:32
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

This PR is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in two weeks. PRs may be reopened when there is renewed interest.

@github-actions github-actions bot added the Stale label Nov 3, 2025
@timtebeek timtebeek marked this pull request as ready for review November 3, 2025 13:53
@timtebeek timtebeek removed the Stale label Nov 3, 2025
@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite Nov 3, 2025
@timtebeek timtebeek merged commit 5b24d07 into main Nov 3, 2025
2 checks passed
@timtebeek timtebeek deleted the empty-string-concatenation-to-valueOf branch November 3, 2025 14:11
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Recipe to avoid concatenating with empty String to perform type conversion

3 participants