As other already mentioned, Sonar wants you to make sure that you don't have any null pointer exception, or at least that's what see when I do a null check before trying to validate against the variable:
if I have the next code, Sonar raises an alert that this code can throw a null pointer exception.
if (properties.getEnabled()) {
// Your code
}
But if I add a quick validation against nulls, Sonar stops complaining about it:
if (properties.getEnabled() != null && properties.getEnabled()) {
// Your code
}
Now, as you mentioned you can use the Boolean class to compare Booleans like the next code:
Boolean.TRUE.equals(properties.getEnabled());
And you can place it in an if statement like the next code:
if (Boolean.TRUE.equals(properties.getEnabled())){
// Your code
}
This might look like it's too verbose, but the implementation of Boolean.TRUE.equals() checks if the object is an instance of the Boolean class, and null cannot be an instance of any class, as null is not an instance. You can find it better explained here: Is null check needed before calling instanceof?
They used to have a very nice and easy set of test to understand what was accepted and what's not that I published in this answer when I first answered it but it looks like it does no longer exists in master (I still add it for an easier understanding but this is an old version of sonar so it should be used only as reference): https://github.com/SonarSource/sonar-java/blob/5.14.0.18788/java-checks/src/test/files/checks/BoxedBooleanExpressionsCheck.java
You can reference the Implementation code as well for this rule here: https://github.com/SonarSource/sonar-java/blob/master/java-checks/src/main/java/org/sonar/java/checks/BoxedBooleanExpressionsCheck.java#L131