Skip to content

[java] MoreThanOneLogger is reported on mocked Logger field #3860

@magwas

Description

@magwas

Affects PMD Version:
6.42.0

Rule:
MoreThanOneLogger
https://pmd.github.io/pmd-6.42.0/pmd_rules_java_errorprone.html#morethanonelogger

Description:

Rule Violation Line
MoreThanOneLogger Class contains more than one logger. 6–10

Code Sample demonstrating the issue:

package com.kodekonveyor.authentication;

import org.mockito.Mockito;
import org.slf4j.Logger;

class PMDErrorDemonstrationTestBase {

  Logger loggerService = Mockito.mock(Logger.class);

}

Expected outcome:

PMD reports a violation at line 6-10, 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