Skip to content

[java] InvalidLogMessageFormat: False positive with lombok @Value generated methods #5787

@altaiezior

Description

@altaiezior

Affects PMD Version: 7.14.0

Rule: InvalidLogMessageFormat

Description:
If there is no argument but only the log message and the exception then pmd reports InvalidLogMessageFormat

Code Sample demonstrating the issue:

@Slf4j
public class Main {
    public static void main(String[] args) {
        var abcd = new AClass(new Exception("abcd"));
        log.error("Hello World", abcd.getT());
    }

    @Value
    private static class AClass {
        Throwable t;
    }
}

Expected outcome:

PMD reports a violation at line ..., but that's wrong. That's a false positive.

Running PMD through: Maven

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions