-
Notifications
You must be signed in to change notification settings - Fork 690
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
SONARJAVA-5341 Fix FP reported for too many cases on switches when enum types are unknown #5041
Conversation
2b7c7e9
to
8af3a4a
Compare
public static TernaryValue ofBoolean(@Nullable Boolean b) { | ||
if (b == null) { | ||
return UNKNOWN; | ||
} | ||
return b ? TRUE : FALSE; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the usefulness of ofBoolean
compared to of
, I don't see where there could be ambiguity.
When we have a boolean like isEnum()
, I would prefer having a dedicated method instead of converting it to Boolean
in a method that converts it back to boolean
.
public static TernaryValue ofBoolean(@Nullable Boolean b) { | |
if (b == null) { | |
return UNKNOWN; | |
} | |
return b ? TRUE : FALSE; | |
} | |
public static TernaryValue of(boolean b) { | |
return b ? TRUE : FALSE; | |
} | |
public static TernaryValue of(@Nullable Boolean b) { | |
return b == null ? UNKNOWN : of(b.booleanValue()); | |
} |
8af3a4a
to
b03a509
Compare
To handle better the cases where something is unknown.
b03a509
to
55ceea5
Compare
|
SONARJAVA-5341
When we don't know if the symbol in the switch is an enum, we shouldn't raise that issue.