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

[java] UnnecessaryFullyQualifiedName: false positive for nested inner class defining method with same name as static import #1316

Open
cobratbq opened this Issue Aug 22, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@cobratbq
Contributor

cobratbq commented Aug 22, 2018

Affects PMD Version: PMD 6.5.0 running using maven plug-in 3.10.0 (also present in version 6.6.0).

Rule: UnnecessaryFullyQualifiedName (category/java/codestyle.xml/UnnecessaryFullyQualifiedName)

Description:
The rule correctly identifies that a static import is defined for sessionStatusChanged. The implementation does not identify that the method the find is used in is defined as sessionStatusChanged as well. Therefore, calling the static import name would result in a recursive method call instead of a reference to the static import. It is necessary to refer to the method call by class name.

Code Sample demonstrating the issue:

private final OtrEngineListener slaveSessionsListener = new OtrEngineListener() {

    // FIXME temporarily suppress warning due to false-positive in use of existing static import.
    @SuppressWarnings("PMD.UnnecessaryFullyQualifiedName")
    @Override
    public void sessionStatusChanged(@Nonnull final SessionID sessionID, @Nonnull final InstanceTag receiver) {
        OtrEngineListenerUtil.sessionStatusChanged(duplicate(listeners), sessionID, receiver);
    }

    // ...
};

Running PMD through: Maven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment