Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent unintentional changes in logging best practices that conflict with Google Java Format #354

Open
koppor opened this issue Oct 5, 2024 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@koppor
Copy link
Contributor

koppor commented Oct 5, 2024

What problem are you trying to solve?

I want to use Google Java Format (AOSP) together with OpenRewrite

Describe the solution you'd like

OpenRewrite should not write files if only whitespace change.

Have you considered any alternatives or workarounds?

Disabling rules.

Additional context

org.openrewrite.staticanalysis.ChainStringBuilderAppendCalls:

--- a/src/main/java/org/jabref/logic/exporter/GroupSerializer.java
+++ b/src/main/java/org/jabref/logic/exporter/GroupSerializer.java
@@ -29,8 +29,7 @@ public class GroupSerializer {
     private String serializeExplicitGroup(ExplicitGroup group) {
         StringBuilder sb = new StringBuilder();
         sb.append(MetadataSerializationConfiguration.EXPLICIT_GROUP_ID);
-        sb.append(
-                StringUtil.quote(
+        sb.append(StringUtil.quote(
                         group.getName(),
                         MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR,
                         MetadataSerializationConfiguration.GROUP_QUOTE_CHAR));

org.openrewrite.java.logging.slf4j.ParameterizedLogging

-                                    "dataModel JabRef52"
-                                            + " only supports pageInfo for the last citation of a group");
+                            LOGGER.warn("dataModel JabRef52" + " only supports pageInfo for the last citation of a group");

(For this, I can do a work-around by using single-line strings only)

Are you interested in contributing this feature to OpenRewrite?

@koppor koppor added the enhancement New feature or request label Oct 5, 2024
@timtebeek timtebeek changed the title Make it compatible with Google Java Foramt Prevent unintentional changes in logging best practices that conflict with Google Java Format Oct 6, 2024
@timtebeek
Copy link
Contributor

hi @koppor ! I'm looking at the original classes but not seeing the same input there:
https://github.com/JabRef/jabref/blob/ebca33e74ee674515e171036d11edc36e8ddc34e/src/main/java/org/jabref/logic/exporter/GroupSerializer.java#L29-L40

Are there additional changed out of view from the diff above that would explain why changes are reported in the first place?
For both cases I suppose the best way to see these resolved is to replicate them in a minimal draft PR unit test, and then from there ensure the prefix is retained for the ChainStringBuilderAppendCalls case for instance.

@timtebeek timtebeek added the question Further information is requested label Oct 6, 2024
@koppor
Copy link
Contributor Author

koppor commented Oct 6, 2024

The classes stem from koppor/jabref#661.

I will try to create an MWE though.

@timtebeek timtebeek moved this to Backlog in OpenRewrite Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
Status: Backlog
Development

No branches or pull requests

2 participants