GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] UnnecessaryFullyQualifiedName - FP for inner class pkg.ClassA.Foo implementing pkg.Foo · Issue #4133 · pmd/pmd

[java] UnnecessaryFullyQualifiedName - FP for inner class pkg.ClassA.Foo implementing pkg.Foo #4133

New issue
Copy link
New issue
Copy link
Closed
Closed
[java] UnnecessaryFullyQualifiedName - FP for inner class pkg.ClassA.Foo implementing pkg.Foo#4133
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.50.0

Description

@garydgregory
garydgregory
opened on Sep 24, 2022
Issue body actions

Affects PMD Version: 6.49.0

Rule: UnnecessaryFullyQualifiedName

Description:

Code Sample demonstrating the issue:

https://github.com/apache/commons-text/blob/3291c507ccb900c84a42f598362a3478da660354/src/main/java/org/apache/commons/text/RandomStringGenerator.java#L85

This happens in Apache Commons Text pinned at commit aec0a326c3659ec19c6d5b1bd446b05d83bfd81e

git clone https://github.com/apache/commons-text.git
cd commons-text
git checkout aec0a326c3659ec19c6d5b1bd446b05d83bfd81e
mvn pmd:check
cat target/pmd.xml

The fist error is a false-positive:

<?xml version="1.0" encoding="UTF-8"?>
<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd" version="6.49.0" timestamp="2022-09-24T10:11:52.311">
<file name="/Users/garydgregory/rc/commons-text/src/main/java/org/apache/commons/text/RandomStringGenerator.java">
<violation beginline="85" endline="85" begincolumn="44" endcolumn="97" rule="UnnecessaryFullyQualifiedName" ruleset="Code Style" package="org.apache.commons.text" class="RandomStringGenerator$Builder" externalInfoUrl="https://pmd.github.io/pmd-6.49.0/pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname" priority="4">
Unnecessary use of fully qualified name 'org.apache.commons.text.Builder' due to existing same package import 'org.apache.commons.text.*'
</violation>
</file>
...

Expected outcome:

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

The class org.apache.commons.text.RandomStringGenerator.Builder MUST use the fully qualified name of the interface org.apache.commons.text.Builder to extend it because both type's simple names are equal.

Running PMD through: Maven

Activity

  1. garydgregory
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on Sep 24, 2022
  2. adangel
    changed the title [-][java] FP for inner class my.pkg.ClassA.Foo that extends an interface of the same simple name my.pkg.Foo[/-] [+][java] UnnecessaryFullyQualifiedName - FP for inner class my.pkg.ClassA.Foo that extends an interface of the same simple name my.pkg.Foo[/+] on Sep 30, 2022
  3. adangel
    changed the title [-][java] UnnecessaryFullyQualifiedName - FP for inner class my.pkg.ClassA.Foo that extends an interface of the same simple name my.pkg.Foo[/-] [+][java] UnnecessaryFullyQualifiedName - FP for inner class pkg.ClassA.Foo implementing pkg.Foo[/+] on Sep 30, 2022
  4. adangel
    added this to the 6.50.0 milestone on Sep 30, 2022
  5. adangel commented on Sep 30, 2022

    @adangel
    adangel
    on Sep 30, 2022
    Member
    More actions

    This has been fixed by #4128 for PMD 6.50.0

  6. adangel
    added a commit that references this issue on Sep 30, 2022

    [java] UnnecessaryFullyQualifiedName - add test for pmd#4133

    f8e298d
  7. adangel
    closed this as completedin f8e298don Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      • 6.50.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.