if (Boolean.TRUE.equals(condition)) which is what SonarQube's default Java rules will recommend. (edit: in case anyone wonders, it's because of null safety; if (condition) throws an NPE if condition is null, Boolean.TRUE.equals(condition) just evaluates to false)
try {
if (condition) { /* code whatever */ }
} catch (MommaAintRaisedNoCowardException _) {
log.error("No bugs to be seen here no sirreee");
}
public class MommaAintRaisedNoCowardException
extends NullPointerException
{ /* standard exception stuff */ }
View all comments
76
u/Ignisami 7d ago edited 7d ago
You're missing
if (Boolean.TRUE.equals(condition))which is what SonarQube's default Java rules will recommend. (edit: in case anyone wonders, it's because of null safety;if (condition)throws an NPE ifconditionis null,Boolean.TRUE.equals(condition)just evaluates tofalse)