A RetroSearch Logo

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

Search Query:

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

[java] SwitchStmtsShouldHaveDefault false positive on enum inside enums · Issue #2946 · pmd/pmd · GitHub

Affects PMD Version: 6.29.0

Rule: SwitchStmtsShouldHaveDefault

Description:

If a switch-case over a enum is used inside the enum itself, PMD wrongly requests to add a default case, even though the switch statement is exhaustive. The switch is over this:

Code Sample demonstrating the issue:

package myPackage;

public enum GradeSystem {

    SysA, SysB;

    public boolean isValid() {
      switch (this) { // false-positive
        case SysA:
        case SysB:
          return true;
      }
      
      return false;
    }
}

Result:
myPackage/GradeSystem.java:8: Switch statements should have a default label

Expected outcome:

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