FindBugs

FindBugs是编码期间,检测代码质量的工具。eclispe插件地址:http://findbugs.cs.umd.edu/eclipse-daily

 

刚刚使用,是我的一个数据库引擎项目,叫ojadb。初步分析下问题:

1.Comparison of String objects using == or !=

if (methodNames[i]==fields[j].getName()) {

=>if (methodNames[i].equals(fields[j].getName())) {

 

2.The field name doesn't start with a lower case letter
protected static HashMap<Long, OdbClassInfo> OdbClassAddressMap;

=>protected static HashMap<Long, OdbClassInfo> odbClassAddressMap;

 

3.Method  makes inefficient use of keySet iterator instead of entrySet iterator
Set keys = map.keySet();
        for (Object key : keys) {
            Object value = map.get(key);

……

=>

Set<Map.Entry> entrys=map.entrySet();
        for(Map.Entry entry: entrys){
            Object key=entry.getKey();
            Object value = entry.getValue();

 

4.Possible null pointer dereference of classInfo

OdbCache.setClass(classInfo.getClassName(), classInfo);

=>
if(classInfo!=null)
            OdbCache.setClass(classInfo.getClassName(), classInfo);

 

5.Class defines non-transient non-serializable instance field positionInfo
private OdbClassPositionInfo positionInfo;
=>public class OdbClassPositionInfo implements Serializable{

 

6.Method invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead

this.finderValue = new Integer(value);

=>this.finderValue = Integer.valueOf(value);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值