Skip to content

ParameterizedLogging should also replace String.format / .formatted #149

@koppor

Description

@koppor

Got:

-            LOGGER.debug(String.format("Could not parse the FileAnnotation %s into any known FileAnnotationType. It was %s!", annotation, annotation.getSubtype()));
+            LOGGER.debug("Could not parse the FileAnnotation %s into any known FileAnnotationType. It was %s!".formatted(annotation, annotation.getSubtype()))

Expected:

LOGGER.debug("Could not parse the FileAnnotation {} into any known FileAnnotationType. It was {}.", annotation, annotation.getSubtype());

Similarly,

-  LOGGER.warn("Unexpected attribute '%s' for <%s>".formatted(key, tagName));
+  LOGGER.warn("Unexpected attribute '{}' for <{}>", key, tagName);

I checked https://github.com/openrewrite/rewrite-logging-frameworks/blob/main/src/test/java/org/openrewrite/java/logging/ParameterizedLoggingTest.java - and there is no test for String.format and .formatted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions