2.0/10
verdict: needs_serious_help
"Braindead boolean handling"
lang: Java·7 lines
//your_submission
BooleanBungle.java
public boolean isAuthorized(String status) {
if (status.equals("true") == true) {
return true;
} else {
return false;
}
}//detailed_analysis
!
Pointless Comparison
Using 'status.equals("true") == true' is like asking your mom if she's sure she's your mom. Just parse the boolean, genius.
?
Redundant Conditional
The if-else statement is a cringeworthy attempt at simplicity. It's like using a sledgehammer to crack a nut, but the nut is just a boolean value.
!
Lack of Input Validation
This code assumes the input will always be a valid string representation of a boolean. Newsflash: it won't. Use a try-catch or some actual error handling for once.
//suggested_fix
BooleanBungle_fixed.java
+public boolean isAuthorized(String status) {
+ return Boolean.parseBoolean(status);
+}