A RetroSearch Logo

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

Search Query:

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

[java] TooFewBranchesForASwitchStatement should consider Switch Expressions · Issue #5250 · pmd/pmd · GitHub

Affects PMD Version: 7.6.0

Rule: TooFewBranchesForASwitchStatement

Description:
The rule currently only checks Switch Statements, but should also check Switch Expressions.

Therefore, the rule should be renamed to TooFewBranchesForSwitch (remove the statement part)

Code Sample demonstrating the issue:

public class DumbSwitch {
    public String foo(int i) {
        return switch (i) {  // violation expected here
            case 0:
            {
                yield "I am a fish.";
            }
        };
    }
}

Expected outcome:

PMD should report a violation at line ..., but doesn't. This is a false-negative.

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]


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