[英]Eclipse flags a piece of code with a 'Dead code' warning. Why in this case?
I know that there are a few examples of 'random dead code warning' in Eclipse. 我知道Eclipse中有一些“随机死代码警告”的示例。
But specifically for my case, I want to find out whether this is also a 'false positive' or whether I am too tired to understand what is going on... 但特别针对我的情况,我想确定这是否也是“误报”或我是否太累了以至于无法理解正在发生的事情...
@Override
public int getNumUnappendedCol() {
return appendIndex == -1 ? getNumCol() : appendIndex;
}
This ternary statement is being flagged, specifically the condition and appendIndex
. 该三元语句被标记,特别是条件和
appendIndex
。 As I understand it (not my code), this is supposed to return appendIndex
if it is not equal to -1. 据我了解(不是我的代码),如果它不等于-1,则应该返回
appendIndex
。 Otherwise return the value obtained from getNumCol()
. 否则,返回从
getNumCol()
获得的值。
Am I missing something or should I just ignore Eclipse? 我是否缺少某些东西?还是应该忽略Eclipse? I regularly refresh/ clean/ build the project so that wouldn't solve the issue.
我会定期刷新/清理/构建项目,以解决问题。
问题最终导致了将appendIndex
的final
声明初始化为-1,因此三元语句甚至都无法访问false选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.