GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [java] UnusedImports with static imports on subclasses · Issue #3132 · pmd/pmd Closed Labels a:false-positivePMD flags a piece of code that is not problematic Milestone DescriptionAffects PMD Version: Rule: Description: I have a static import of all methods in a class but the methods referenced in the code are from its base class. The rule flags the derived class' import as unused despite the compiler recognising the import as valid. This is unexpected. Note: In my opinion, this is fine since it's (strictly) true that the methods do not belong to the specified import. I interpret it as forcing the user the use the correct import. If there are methods available in the derived class and if even one is referenced, then it is used and there is no complation or rule violation for the base class' methods. It's a corner case that probably will occur only in error. Code Sample demonstrating the issue: class Hello { public static void sayHello() { //... } } class HelloMore extends Hello { // ... } import static HelloMore.*; // flagged as unused public class Test { public static void main(String... args) { sayHello(); } } Expected outcome:
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other] Referred from: #3130 (comment) Activity
MetadataMetadataAssigneesLabelsa:false-positivePMD flags a piece of code that is not problematic TypeProjectsMilestoneRelationshipsDevelopmentIssue 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. |