Affects PMD Version: 6.49.0
Rule: UnnecessaryFullyQualifiedName
Description:
Code Sample demonstrating the issue:
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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4