我有以下的Properties类:
class Properties {
private Boolean enabled;
public Boolean getEnabled() {
return enabled;
}
}
如果我编写以下代码,则SonarLint会在if条件上发出警告,指出“在此处使用原始布尔表达式。”
if (!properties.getEnabled()) {
return true;
}
// more code
将if条件更改为以下内容可以消除警告。但是那样不够可读,SonarLint不可能想要那样吧?
Changing the if condition to the following eliminates the warning. However, it becomes less readable. Is that really what SonarLint intends?
if (properties.getEnabled().equals(Boolean.FALSE)) {
return true;
}
// more code
SonarLint究竟希望我在这里做什么?问题是什么?