findbugs中Dead store to local variable [DLS_DEAD_LOCAL_STORE]
来源:互联网 发布:cdn网络加速技术 编辑:程序博客网 时间:2024/05/19 09:49
用findbugs执行后,说List<BY102010ResultDetailModel> detailList = new ArrayList();存在Dead store to local variable,中文意思是
“本地变量存储了闲置不用的对象”。
原因:
List<BY102010ResultDetailModel> detailList = new ArrayList();执行了以下三个动作
1、创建一个引用
2、创建一个ArrayList对象
3、把ArrayList的引用赋值给detailList
其中,后面两个动作变得会是多余的,因为后面的程序中你没有使用这个新建的ArrayList,而是重新给ArrayList赋值。
detailList = resultModel.getDetails();
所以,只需要 List<BY102010ResultDetailModel> detailList;即可。
以上转载自Dead store to local variable in findbugs
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------如下代码也有相同的findbugs
- boolean del = false;
- del = delByUserId(userid);
boolean del = false; del = delByUserId(userid);
上面说了一大通,不是很明白。个人感觉就是新声明的变量在赋值后就没有再被使用了,下面的代码使用下自然就消除虫子了
比如加上Assert.assertTrue(del);
0 0
- findbugs中Dead store to local variable [DLS_DEAD_LOCAL_STORE]
- findbugs中Dead store to local variable [DLS_DEAD_LOCAL_STORE]
- Dead store to local variable in findbugs
- FINDBUGS错误:Deadstore to local variable
- Eclipse快捷键Assign to local variable
- 警告:returning pointer to local variable
- 警告:returning pointer to local variable
- Set OpenSolaris publisher to local software store
- Thread local to save a variable for each Thread
- java中instance variable,class variable,local variable之间的区别
- global variable and local variable
- Duplicate local variable sql
- Duplicate local variable context
- Duplicate local variable studentname
- Duplicate local variable message
- python local variable
- Duplicate local variable btn
- Duplicate local variable session
- Nginx+PHP+mysql
- 斯坦福大学-朴素贝叶斯_Exercise Code
- sql关于重复记录
- jquery.validate入门demo
- OpenMP编程->并行循环
- findbugs中Dead store to local variable [DLS_DEAD_LOCAL_STORE]
- Nginx 禁止IP访问 只允许域名访问
- 第七周工作总结
- 设计模式学习
- malloc函数详解
- make menuconfig 出错
- java switch用法
- MongoDB学习之旅九:MongoDB高级查询の存储过程
- sql 表的约束