A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2016 below:

GitHub ยท Where software is built

Affects PMD Version:
confirmed from 6.9.0 to 6.17.0 and 6.18

Rule:
UnusedImports

Description:
False positives from UnusedImports in some specific conditions:

Code Sample demonstrating the issue:

package demo; 

import java.util.*;

public class Demo {
    public void testFunction() {
        Objects.toString(null);
    }
}

Running PMD through: CLI and Ant

bash run.sh pmd -d src/ -R category/java/bestpractices.xml/UnusedImports -auxclasspath classes
sep 15, 2019 12:51:53 AM net.sourceforge.pmd.PMD processFiles
ADVERTENCIA: This analysis could be faster, please consider using Incremental Analysis: https://pmd.github.io/pmd-6.17.0/pmd_userdocs_incremental_analysis.html
src/demo/Demo.java:3:	Avoid unused imports such as 'java.util'

Curiously, placing the following test code in UnusedImports.xml works fine:

    <test-code>
    	<description>False positive in Unused imports with Wildcard</description>
    	<expected-problems>0</expected-problems>
    	<code><![CDATA[
package net.sourceforge.pmd.lang.java.rule.bestpractices.unusedimports;
	
import java.util.*;

public class Demo {
	
    public void testFunction() {
        Objects.toString(null);
    }
}    	
    	 ]]></code>    
    </test-code>

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