[英]squid:S2583 : Change this condition so that it does not always evaluate to “true”
S2583: How can the condition ps != null
be changed so that it does not always evaluate to "false"? S2583:如何更改条件
ps != null
,以使其始终不等于“ false”?
PreparedStatement ps = null;
if (ps != null) {
try {
ps.close();
} catch (SQLException uncatched) {
uncatched.printStackTrace();
}
}
if ps is not null because you always set a value to it (at lines that you omitted), the conditional statement is completely redundant and you can eliminate the condition. 如果ps不为null,因为您总是为它设置一个值(在省略的行中),那么条件语句是完全多余的,您可以消除该条件。
From squid:S2583 description: 来自鱿鱼:S2583说明:
Conditional statements using a condition which cannot be anything but FALSE have the effect of making blocks of code non-functional.
使用条件不能为FALSE的条件语句会导致使代码块不起作用。 If the condition cannot evaluate to anything but TRUE, the conditional statement is completely redundant, and makes the code less readable.
如果条件不能评估为TRUE,则条件语句将完全多余,并使代码的可读性降低。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.