Skip to content

[java] GuardLogStatement: Should not need to guard parameterized log messages where the replacement arg is an array element #5153

@jbisotti

Description

@jbisotti

Affects PMD Version:
7.0.0

Rule:
GuardLogStatement

Description:
I do not believe an argument, which is an array element, should result in a violation of this rule.

Code Sample demonstrating the issue:

        final String[] foo = ...
        LOG.info(
                "Some message here : foo0={}",
                foo[0]
        );

Expected outcome:

PMD reports "... Rule:GuardLogStatement Priority:2 Logger calls should be surrounded by log level guards..".
I think that's a false positive.

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Run via maven-pmd-plugin (3.24.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions