A RetroSearch Logo

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

Search Query:

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

GitHub ยท Where software is built

Affects PMD Version: 7.14.0

Description:

By default, the rule UselessOverridingMethod doesn't report a violation, if there are other annotations present (except for Override).

But when SupressWarnings annotation is added, then the rule skips itself - because this is an annotation other than Override and it never reports a violation that gets suppressed...

Then UnnecessaryWarningSuppression reports, that the suppress warnings annotation is unnecessary...

By the way - the rule description should be improved. I had a hard time understanding what is happening - and double negation (ignoreAnnotation = false) is adding to the confusion...

Code Sample demonstrating the issue:

// src/BaseClass.java
class BaseClass {
  void method() {
    System.out.println("base class");
  }
}

// src/SubClass.java
class SubClass extends BaseClass {
    @Override
    @SuppressWarnings("PMD.UselessOverridingMethod")
    void method() {
        super.method();
    }
}

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

  1. compile: javac -d bin src/*.java
  2. run pmd:
    $PMD_HOME/bin/pmd check --aux-classpath bin \
      --rulesets category/java/design.xml/UselessOverridingMethod,category/java/bestpractices.xml/UnnecessaryWarningSuppression \
      --dir src
  3. Result is: src/SubClass.java:3: UnnecessaryWarningSuppression: Unnecessary @SuppressWarnings annotation
  4. Remove the suppressWarnings annotation and rerun pmd
  5. Result is: src/SubClass.java:3: UselessOverridingMethod: Overriding method merely calls super

Running PMD through: CLI


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