rewrite-logging-frameworks icon indicating copy to clipboard operation
rewrite-logging-frameworks copied to clipboard

Keep formatting in case of newline only change

Open koppor opened this issue 6 months ago • 3 comments

I think, the following diff is only a newline diff.

             );
         } catch (FetcherException e) {
-            LOGGER.error(
-                "FetcherException should not be found here, as main Bibtex Entry already exists "
-                + "(and failing additional fetches should be skipped)",
-                e
+            LOGGER.error("FetcherException should not be found here, as main Bibtex Entry already exists " + "(and failing additional fetches should be skipped)", e
             );
         }
     }

I am going to use prettier-java with 80 column width. And now OpenRewrite and prettier-java "fight" about proper formatting.

I think, a solution of that could be if OpenRewrite does not change the AST if there are only whitespace changes.

koppor avatar Aug 19 '25 21:08 koppor

Hmm; the console output or data table should show which recipe is making those changes. Sounds like a potential bug with the recipe where it should not be making whitespace only changes. Which one is it? And is there a wider context you can share?

timtebeek avatar Aug 19 '25 22:08 timtebeek

Oh, sorry, I forgot. The most broad context I can give that this is the PR: https://github.com/JabRef/jabref-koppor/pull/717

I filed here because I needed to disable org.openrewrite.java.logging.slf4j.ParameterizedLogging

(The other one was org.openrewrite.staticanalysis.ChainStringBuilderAppendCalls)

koppor avatar Aug 19 '25 22:08 koppor

That's odd; I'd not expect either of those to make changes here; especially not when it's only whitespace changes. 🤔

timtebeek avatar Aug 19 '25 22:08 timtebeek