A RetroSearch Logo

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

Search Query:

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

False-positive with nested switch statements · Issue #4948 · pmd/pmd · GitHub

Affects PMD Version: 7.0.0

Rule: category/java/errorprone.xml/ImplicitSwitchFallThrough

Description:

Code Sample demonstrating the issue:

public class Test {

	boolean foo(String a, String b) {

		switch (a) {
		case "a1":
			return true;
		case "a2":
			switch (b) {
			case "b1":
				return true;
			default:
				return false;
			}
		default:   // <--- false-positive ImplicitSwitchFallThrough
			return false;
		}
	}

}

Outcome:

PMD reports a violation at line 15, but that's wrong. That's a false positive.

the outer case "a2" cannot fall through, since the inner switch is exhaustive and returns from all branches.

Running PMD through: CLI | Maven


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