我已经在 Eclipse 中针对我的代码运行了PMD 插件,并且我收到了类似于下图所示代码的高优先级警告:
if(singleRequest !=null){
// do my work
}else{
// do my other work
}
PMD 说`Avoid if (x != y) ..; else ..
;
错误的描述如下所示:
In an "if" expression with an "else" clause, avoid negation in
the test. For example, rephrase:
if (x != y) diff(); else same();
as:
if (x == y) same(); else diff();
Most "if (x != y)" cases without an "else" are often return
但我仍然无法理解对我的代码的影响。如果有人可以举例指导我,我将不胜感激。