没有合适的资源?快使用搜索试试~ 我知道了~
首页findbugs检测提示详解
findbugs检测提示详解
5星 · 超过95%的资源 需积分: 17 26 下载量 147 浏览量
更新于2023-06-23
评论
收藏 20KB DOCX 举报
1、Comparison of String objects using == or !=; 2、Dead store to newStatusRecord; 3、Invocation of toString on values; 4、ignores exceptional return value of java.io.File.mkdirs(); 5、invokes inefficient new Short(short) constructor; use Short.valueOf(short) instead; ………… 总共总结常见的22条,供大家参考
资源详情
资源评论
资源推荐
ndbugs 检测提示详解
1、Comparison of String objects using == or !=
例,override equals 方法时容易犯错
if(this.topic != key.getTopic())
return false;
2、Dead store to newStatusRecord
定义局部变量后没有引用
3、Invocation of toString on values
直接调用数组的 toString 方法
public Query createQuery(String hql, Object values[],Session
session){
logger.debug(values);
logger.debug((new
StringBuilder()).append("hql=[").append(hql).append("]
").append(((Object)
}
正确的例子,调用 Arrays.toString()和 Arrays.deepToString()方法。
import java.util.Arrays;
class A{
}
class B{
@Override
public String toString() {
return "BBBBB";
}
}
public class Test {
public static void main(String[] args) {
Object [] a = {new Integer(0),new Boolean(true),true,new A(),new
B()};
Object[][]b ={{new A(),new B()},{new A(),new B()},{new A(),new
B()}};
System.out.println(Arrays.deepToString(b));
}
}
4 、 ignores exceptional return value of
java.io.File.mkdirs()
忽略了返回值,应当含有返回值
public void initFolder() {
if (!exitDir.isDirectory()) {
exitDir.mkdirs();
logger.info("===Finishing create exit trade image folder!====");
}
}
This method returns a value that is not checked. The return value
should be checked since it can indicate an unusual or unexpected
function execution. For example, the File.delete() method returns
false if the 3le could not be successfully deleted (rather than
throwing an Exception). If you don't check the result, you won't
notice if the method invocation signals unexpected behavior by
returning an atypical return value.
5、不使用 new String()定义空的字符串
String alarmCodeCond = new String();
应当
String alarmCodeCond = "";
6 invokes ine8cient new Short(short) constructor; use
Short.valueOf(short) instead
JVM 缓存数字常量
Short aShort = new Short(12);
应当
Short aShort = Short.valueOf(12);
7、方法命名习惯,首字母小写
The method name LaneHandShakeService(Short) doesn't start
with a lower case letter
Methods should be verbs, in mixed case with the 3rst letter
lowercase, with the 3rst letter of each internal word capitalized.
8、一个 primtive 的类型的值经过 box 后马上 unbox
Primitive value is boxed then unboxed to perform primitive coercion
剩余13页未读,继续阅读
fabrous
- 粉丝: 2
- 资源: 46
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论6