Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] SwitchStmtsShouldHaveDefault false-positive with Java 14 switch non-fallthrough branches #2806

Closed
boris-petrov opened this issue Sep 28, 2020 · 2 comments · Fixed by #2899
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
Milestone

Comments

@boris-petrov
Copy link
Contributor

boris-petrov commented Sep 28, 2020

Affects PMD Version:

All, including 6.28.0.

Rule: SwitchStmtsShouldHaveDefault

Description:

	public String foo(String foo) {
		switch (foo) {
			case "=" -> foo = "eq";
			case "!=" -> foo = "ne";
			default -> throw new IllegalArgumentException();
		}
		return foo + 'a';
	}

This causes a SwitchStmtsShouldHaveDefault warning.

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

Gradle.

@boris-petrov boris-petrov added the a:bug PMD crashes or fails to analyse a file. label Sep 28, 2020
@adangel adangel added a:false-positive PMD flags a piece of code that is not problematic help-wanted and removed a:bug PMD crashes or fails to analyse a file. labels Oct 3, 2020
@oowekyala oowekyala changed the title [java] SwitchStmtsShouldHaveDefault false-positive with Java 14 switch expressions [java] SwitchStmtsShouldHaveDefault false-positive with Java 14 switch non-fallthrough branches Nov 5, 2020
oowekyala added a commit to oowekyala/pmd that referenced this issue Nov 5, 2020
@oowekyala oowekyala linked a pull request Nov 10, 2020 that will close this issue
5 tasks
@oowekyala oowekyala removed a link to a pull request Nov 10, 2020
5 tasks
@oowekyala oowekyala added this to the 7.0.0 milestone Nov 10, 2020
@oowekyala oowekyala linked a pull request Nov 10, 2020 that will close this issue
5 tasks
@adangel
Copy link
Member

adangel commented Dec 11, 2020

Fixed via #2899 for PMD 7.

@adangel
Copy link
Member

adangel commented Apr 22, 2023

This has been fixed with PMD 7.0.0-rc1.

@adangel adangel closed this as completed Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
No open projects
PMD 7
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants