A RetroSearch Logo

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

Search Query:

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

[java] SwitchStmtsShouldHaveDefault triggered when default case is present · Issue #3605 · pmd/pmd · GitHub

Affects PMD Version:
6.40.0

Rule:
PMD.SwitchStmtsShouldHaveDefault
https://pmd.github.io/pmd-6.40.0/pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault

Description:

Code Sample demonstrating the issue:

enum State {
  ON, OFF
}

... switch(state) {
      case ON -> System.out.println("it is on");
      case OFF -> System.out.println("it is off");
      default -> System.out.println("it is neither on nor off - should not happen? maybe null?")
    }

Expected outcome:
No violation

** Actual outcome:**
PMD reports a violation at line switch(state), but that's wrong. That's a false positive.

Running PMD through: Gradle


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