Skip to content

Conversation

@timtebeek
Copy link
Member

Added precondition check to ensure the recipe only runs when at least one
of the supported format methods is present in the code. This improves
performance by avoiding unnecessary AST traversal when the recipe would
not make any changes.

Also fixed a code style issue by replacing 'size() > 0' with '!isEmpty()'.

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

Co-Authored-By: Claude <[email protected]>
@timtebeek timtebeek self-assigned this Sep 8, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Sep 8, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/java/org/openrewrite/staticanalysis/UsePortableNewlines.java
    • lines 33-33
    • lines 59-59
  • src/test/java/org/openrewrite/staticanalysis/UsePortableNewlinesTest.java
    • lines 33-33

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/java/org/openrewrite/staticanalysis/UsePortableNewlines.java
    • lines 31-31
    • lines 57-57

timtebeek and others added 3 commits September 8, 2025 14:20
Added two test cases to verify text block handling:
1. doNotReplaceNewlinesInTextBlocks - Ensures actual newlines in text blocks
   are preserved since they represent real line breaks, not format specifiers
2. replaceEscapedNewlineInTextBlockFormat - Verifies that escaped \n sequences
   within text blocks are still replaced with %n when appropriate

This ensures the recipe correctly distinguishes between:
- Actual newlines in text blocks (should be preserved)
- Escaped newline sequences \n (should be replaced with %n)

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

Co-Authored-By: Claude <[email protected]>
@timtebeek timtebeek marked this pull request as ready for review September 8, 2025 12:26
@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite Sep 8, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/java/org/openrewrite/staticanalysis/UsePortableNewlines.java
    • lines 32-32
    • lines 59-59

@timtebeek timtebeek merged commit 9ac3674 into main Sep 8, 2025
2 checks passed
@timtebeek timtebeek deleted the feature/use-portable-newlines branch September 8, 2025 12:37
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Sep 8, 2025
mergify bot added a commit to robfrank/linklift that referenced this pull request Sep 21, 2025
… 2.16.0 to 2.17.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-static-analysis](https://github.com/openrewrite/rewrite-static-analysis) from 2.16.0 to 2.17.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-static-analysis's releases](https://github.com/openrewrite/rewrite-static-analysis/releases).*

> 2.17.0
> ------
>
> What's Changed
> --------------
>
> * Simplify `else` branch if it only has a single `if` ([#666](https://redirect.github.com/openrewrite/rewrite-static-analysis/issues/666)) by [`@​olwispe`](https://github.com/olwispe) in [openrewrite/rewrite-static-analysis#726](https://redirect.github.com/openrewrite/rewrite-static-analysis/pull/726)
> * Polish `UsePortableNewlines` by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-static-analysis#731](https://redirect.github.com/openrewrite/rewrite-static-analysis/pull/731)
>
> New Contributors
> ----------------
>
> * [`@​olwispe`](https://github.com/olwispe) made their first contribution in [openrewrite/rewrite-static-analysis#726](https://redirect.github.com/openrewrite/rewrite-static-analysis/pull/726)
>
> **Full Changelog**: <openrewrite/rewrite-static-analysis@v2.16.0...v2.17.0>


Commits

* [`49cd6a0`](openrewrite/rewrite-static-analysis@49cd6a0) OpenRewrite recipe best practices
* [`9ac3674`](openrewrite/rewrite-static-analysis@9ac3674) Polish `UsePortableNewlines` ([#731](https://redirect.github.com/openrewrite/rewrite-static-analysis/issues/731))
* [`a86c8ac`](openrewrite/rewrite-static-analysis@a86c8ac) Add UsePortableNewlines recipe to replace \n with %n in format strings
* [`3db6b8c`](openrewrite/rewrite-static-analysis@3db6b8c) OpenRewrite recipe best practices
* [`232339c`](openrewrite/rewrite-static-analysis@232339c) Simplify `else` branch if it only has a single `if` ([#666](https://redirect.github.com/openrewrite/rewrite-static-analysis/issues/666)) ([#726](https://redirect.github.com/openrewrite/rewrite-static-analysis/issues/726))
* [`cec848f`](openrewrite/rewrite-static-analysis@cec848f) Fix missing import
* [`a3c292d`](openrewrite/rewrite-static-analysis@a3c292d) Use in-house `@InlineMe` annotation
* See full diff in [compare view](openrewrite/rewrite-static-analysis@v2.16.0...v2.17.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-static-analysis&package-manager=maven&previous-version=2.16.0&new-version=2.17.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
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.

2 participants