GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't if-wrap logs when arguments are getters by pdelagrave · Pull Request #233 · openrewrite/rewrite-logging-frameworks

Conversation

@pdelagrave

@pdelagrave pdelagrave commented Jul 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What's changed?

WrapExpensiveLogStatementsInConditionals is now checking if all log call arguments are getters. When they are, those operations are considered inexpensive and the log call is left as is, unwrapped.

What's your motivation?

  • Fix WrapExpensiveLogStatementsInConditionals not to offer wrapping lines which just retrieve some properties #232

Anyone you would like to review specifically?

@timtebeek
@greg-at-moderne

Have you considered any alternatives or workarounds?

Any additional context

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@moderne-meeseeks moderne-meeseeks Bot added this to OpenRewrite Jul 7, 2025
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jul 7, 2025
pdelagrave added 2 commits July 7, 2025 15:20
@pdelagrave
tests: Don't if-wrap logs when args are getters
96b9820
@pdelagrave
more and better tests
f34c040
started to implement
@pdelagrave
pdelagrave force-pushed the dontwrapgetters branch from 0bc9a59 to f34c040 Compare July 7, 2025 20:25
github-actions[bot]
github-actions Bot reviewed Jul 7, 2025
View reviewed changes

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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/java/logging/slf4j/WrapExpensiveLogStatementsInConditionals.java
    • lines 22-22
    • lines 32-32

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/openrewrite/java/logging/slf4j/WrapExpensiveLogStatementsInConditionals.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/openrewrite/java/logging/slf4j/WrapExpensiveLogStatementsInConditionals.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

pdelagrave and others added 2 commits July 7, 2025 16:29
@pdelagrave @github-actions
Update src/main/java/org/openrewrite/java/logging/slf4j/WrapExpensive…
f74c411
…LogStatementsInConditionals.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@pdelagrave @github-actions
Update src/main/java/org/openrewrite/java/logging/slf4j/WrapExpensive…
8f6ddbf
…LogStatementsInConditionals.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek timtebeek assigned pdelagrave Jul 7, 2025
@pdelagrave
pdelagrave force-pushed the dontwrapgetters branch from fff66dc to df311e9 Compare July 7, 2025 21:37
@pdelagrave
implemented more
0ed940d
added more tests
@pdelagrave
pdelagrave force-pushed the dontwrapgetters branch from df311e9 to 0ed940d Compare July 7, 2025 21:37
@pdelagrave
clean up
a2c43fa
@pdelagrave
pdelagrave marked this pull request as ready for review July 7, 2025 21:44
@pdelagrave pdelagrave moved this from In Progress to Ready to Review in OpenRewrite Jul 7, 2025
timtebeek and others added 4 commits July 8, 2025 00:04
@timtebeek
Adopt @ValueSource(strings = {...}) for simplicity
2c09348
@timtebeek
Illustrate a case missed so far
f137cf3
@timtebeek
Minor changes
9bc5de9
@pdelagrave
Fixed test
104c255
@pdelagrave

pdelagrave commented Jul 8, 2025

Copy link
Copy Markdown
Contributor Author

@timtebeek thanks for the improvements

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@timtebeek timtebeek added bug Something isn't working enhancement New feature or request labels Jul 8, 2025
@timtebeek
Condense logic
3999303
timtebeek
timtebeek approved these changes Jul 8, 2025
View reviewed changes

@timtebeek timtebeek left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nice to see these limits put in place on when the recipe makes changes. Especially like the variations you includes with your tests, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@timtebeek
timtebeek merged commit 5ca86c6 into main Jul 8, 2025
@timtebeek
timtebeek deleted the dontwrapgetters branch July 8, 2025 22:40
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Jul 8, 2025
mergify Bot added a commit to robfrank/linklift that referenced this pull request Aug 15, 2025
@mergify
chore(deps): bump org.openrewrite.recipe:rewrite-logging-frameworks f…
a5f2005
…rom 3.7.0 to 3.13.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-logging-frameworks](https://github.com/openrewrite/rewrite-logging-frameworks) from 3.7.0 to 3.13.0.
Release notes

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

> 3.13.0
> ------
>
> What's Changed
> --------------
>
> * Recipe to migrate deprecated JBoss Logging calls by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#245](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/245)
> * Add `ArgumentArrayToVarargs` for logger methods that take a var args argument Object array by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#246](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/246)
> * Avoid unsafe changes in `JulParameterizedArguments` when `JavaType.Array` argument is not a `J.NewArray` by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#244](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/244)
> * LoggerLevelArgumentToMethod for JBoss Logging by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#243](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/243)
> * Add a recipe to migrate from JBoss Logging to SLF4J by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#241](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/241)
> * rename settings.local.json to settings.json by [`@​zieka`](https://github.com/zieka) in [openrewrite/rewrite-logging-frameworks#247](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/247)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.12.0...v3.13.0>
>
> 3.12.1
> ------
>
> What's Changed
> --------------
>
> * OpenRewrite v8.59.1: <https://github.com/openrewrite/rewrite>
>
> **Full Changelog**: <https://github.com/openrewrite/rewrite-logging-frameworks>
>
> 3.12.0
> ------
>
> What's Changed
> --------------
>
> * Adds filePattern parameter to ConfigureLoggerLevel by [`@​simonzn`](https://github.com/simonzn) in [openrewrite/rewrite-logging-frameworks#235](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/235)
> * Handle existing arguments alongside concatenation in `ParameterizedLogging` by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#237](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/237)
> * Fix Slf4jLogShouldBeConstant to preserve format specifiers with width, alignment, and precision. by [`@​motlin`](https://github.com/motlin) in [openrewrite/rewrite-logging-frameworks#239](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/239)
>
> New Contributors
> ----------------
>
> * [`@​simonzn`](https://github.com/simonzn) made their first contribution in [openrewrite/rewrite-logging-frameworks#235](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/235)
> * [`@​motlin`](https://github.com/motlin) made their first contribution in [openrewrite/rewrite-logging-frameworks#239](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/239)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.11.0...v3.12.0>
>
> 3.11.0
> ------
>
> What's Changed
> --------------
>
> * fix: any last argument matching `Throwable.toString()` is left as is by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#229](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/229)
> * refactor: org.openrewrite.mavencentral by [`@​Laurens-W`](https://github.com/Laurens-W) in [openrewrite/rewrite-logging-frameworks#230](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/230)
> * Don't if-wrap logs when arguments are getters by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#233](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/233)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.10.0...v3.11.0>
>
> 3.10.0
> ------
>
> What's Changed
> --------------
>
> * Add recipe to change logger fields to private by [`@​jhl221123`](https://github.com/jhl221123) in [openrewrite/rewrite-logging-frameworks#221](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/221)
> * Add `MatchIsLogLevelEnabledWithLogStatements` to SLF4J best practices by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#222](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/222)
> * Exclude spotbugs dependency by [`@​greg-at-moderne`](https://github.com/greg-at-moderne) in [openrewrite/rewrite-logging-frameworks#225](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/225)
> * Recipe to remove `.toString()` called on parameterized logging statement arguments by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#224](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/224)
> * fix: match `.toString()` on any type, not just java.lang.Object by [`@​pdelagrave`](https://github.com/pdelagrave) in [openrewrite/rewrite-logging-frameworks#226](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/226)
>
> New Contributors
> ----------------
>
> * [`@​jhl221123`](https://github.com/jhl221123) made their first contribution in [openrewrite/rewrite-logging-frameworks#221](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/221)
> * [`@​pdelagrave`](https://github.com/pdelagrave) made their first contribution in [openrewrite/rewrite-logging-frameworks#224](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/224)

... (truncated)


Commits

* [`946d0ce`](openrewrite/rewrite-logging-frameworks@946d0ce) Update documentation examples
* [`210eff9`](openrewrite/rewrite-logging-frameworks@210eff9) rename settings.local.json to settings.json ([#247](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/247))
* [`2e67627`](openrewrite/rewrite-logging-frameworks@2e67627) Add a recipe to migrate from JBoss Logging to SLF4J ([#241](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/241))
* [`c59c405`](openrewrite/rewrite-logging-frameworks@c59c405) LoggerLevelArgumentToMethod for JBoss Logging ([#243](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/243))
* [`36a5200`](openrewrite/rewrite-logging-frameworks@36a5200) OpenRewrite recipe best practices
* [`aa3f14f`](openrewrite/rewrite-logging-frameworks@aa3f14f) Avoid unsafe changes in `JulParameterizedArguments` when `JavaType.Array` arg...
* [`249944e`](openrewrite/rewrite-logging-frameworks@249944e) Add `ArgumentArrayToVarargs` for logger methods that take a var args argument...
* [`bb34ecf`](openrewrite/rewrite-logging-frameworks@bb34ecf) Create Claude settings file
* [`ce8bc2d`](openrewrite/rewrite-logging-frameworks@ce8bc2d) refactor: Static imports for Collections and Collectors
* [`af44c67`](openrewrite/rewrite-logging-frameworks@af44c67) Recipe to migrate deprecated JBoss Logging calls ([#245](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/245))
* Additional commits viewable in [compare view](openrewrite/rewrite-logging-frameworks@v3.7.0...v3.13.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-logging-frameworks&package-manager=maven&previous-version=3.7.0&new-version=3.13.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)
@retrodaredevil retrodaredevil mentioned this pull request Dec 7, 2025
WrapExpensiveLogStatementsInConditionals considers record components "expensive" #266
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@github-actions github-actions[bot] github-actions[bot] left review comments
@timtebeek timtebeek timtebeek approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@pdelagrave pdelagrave

Labels

bug Something isn't working enhancement New feature or request

Projects

OpenRewrite
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

WrapExpensiveLogStatementsInConditionals not to offer wrapping lines which just retrieve some properties

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pdelagrave @timtebeek
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.