FindBugs Bug Descriptions
This document lists the standard bug patterns reported by version 0.8.5.
Summary
序等号 级 14 A Description Category Correctness Correctness EC: Call to equals() with null argument 调用Equal方法的参数为空 EC: Call to equals() comparing different 15 A interface types 调用Equal方法去比较不同的接口类型 EC: Call to equals() comparing different 16 A types 调用Equal方法去比较不同的数据类型 ES: Comparison of String objects using == 17 A or != 使用== 或者 != 去比较字符串或对象 IJU: TestCase implements setUp but doesn't call super.setUp() 29 B 测试实例实现了setUp()但没有调用super.setUp() 36 A NP: Null pointer dereference in method 方法中存在空指针 Correctness Correctness Correctness Correctness Correctness NP: Null pointer dereference in method on 37 A exception path 方法中存在某异常路径中的空指针 NP: Possible null pointer dereference in 38 A method 方法中存在可能在运行时出现的空指针异常 Correctness NP: Possible null pointer dereference in method on exception path 39 A Correctness 方法中存在可能在某些异常路径下出现的空指针异常 Nm: Class defines equal(); should it be equals()? 41 C 类中定义了equal方法,但是没有重写Correctness java.lang.Object中equal方法,这也有可能是有意这么做的 42 B 43 B Nm: Confusing method names 一些方法名只有大小写的区别,容易混绕 Nm: Confusing method name 方法名和其超类的类名相同 Correctness Correctness Nm: Class defines hashcode(); should it be hashCode()? 44 C 类中定义了hashCode()方法,但是没有重写java.lang.Object中的hashCode()方法,这也有可能是有意这么做的 Nm: Class defines tostring(); should it be toString()? 45 C 类中定义了tostring()方法,但是没有重写java.lang.Object中的tostring()方法,这也有可能是有意这么做的 46 A Nm: Very confusing method names 一些方法名只有大小写的区别,特别容易混绕 Correctness Correctness Correctness Correctness ODR: Method may fail to close database 47 A resource 方法可能没有关闭数据源 ODR: Method may fail to close database 48 A resource on exception 方法在异常时可能无法关闭数据源 49 A OS: Method may fail to close stream 方法可能没有关闭流 Correctness Correctness Correctness OS: Method may fail to close stream on 50 A exception 方法在异常时可能无法关闭流 RCN: Redundant comparision to null of 53 C previously checked value 预测值的几个比较的值中有null值 54 C 57 C RCN: Redundant comparison to null 几个比较的值中有null值 RV: Method ignores return value 方法忽略了返回值 Correctness Correctness Correctness SI: Static initializer for class creates instance before all static final fields 59 A assigned Correctness 类的静态初始化器实例化一个该类对象要在所有的常量属性定义之前 72 C UwF: Unwritten field 永远不会写到的字段,所有读取将返回默认值 Correctness 83 A 86 A MS: Field isn't final but should be 字段应该为常量的却不是常量 IS2: Inconsistent synchronization 类中字段访问不同步 Malicious code vulnerability Multithreaded correctness ML: Method synchronizes on an updated field 方法从一个可变字段对象的引用中同步。这是不太Multithreaded 88 A 可能有用的,因为不同的线程可以在不同的对象上correctness 同步。 Ru: Invokes run on a thread (did you mean to start it instead?) Multithreaded 92 C 当一个类继承Runnable接口时候,还去调用run方correctness 法,实际上只需要调用Start方法就可以启动新的线程, 93 C SC: Constructor invokes Thread.start() 构造函数调用Thread.start() Multithreaded correctness Dm: Method invokes dubious new String(String) constructor; just use the 102 C argument 方法中调用String的构造函数来新建一个字符串,直接使用其参数即可 Performance Dm: Method invokes dubious String.equals(\103 A instead Performance 方法中调用了不确定的String.equals(\,使用String.length() == 0来代替 Dm: Method invokes toString() method on a String; just use the String 104 A Performance 方法中用一个字符串去调用方法toString(),用String就可以了 Dm: Method invokes dubious new String() constructor; just use \ 105 C Performance 方法中新建一个空字符串用new String()。直接用“”就可以了 FI: Empty finalizer should be deleted 106 C 空finalizer()方法是没有用的,所以应该予Performance 以删除 114 C 115 C UPM: Private method is never called 这个私有方法从来没有被调用到 UrF: Unread field 读不到的字段,应该从类中删除 Performance Performance Performance 116 C UuF: Unused field 读不到的字段,应该从类中删除 Descriptions
AM: Creates an empty jar file entry
The code calls putNextEntry(), immediately followed by a call to
closeEntry(). This results in an empty JarFile entry. The contents of the entry should be written to the JarFile between the calls to putNextEntry() and closeEntry().
AM: Creates an empty zip file entry
The code calls putNextEntry(), immediately followed by a call to
closeEntry(). This results in an empty ZipFile entry. The contents of the entry should be written to the ZipFile between the calls to putNextEntry() and closeEntry().
BIT: Incompatible bit masks
This method compares an expression of the form (a & C) to D, which will always compare unequal due to the specific values of constants C and D. This may indicate a logic error or typo.
BIT: Incompatible bit masks
This method compares an expression of the form (a & 0) to 0, which will always compare equal. This may indicate a logic error or typo.
BIT: Incompatible bit masks
This method compares an expression of the form (a | C) to D. which will always compare unequal due to the specific values of constants C and D. This may indicate a logic error or typo.
Typically, this bug occurs because the code wants to perform a
membership test in a bit set, but uses the bitwise OR operator (\instead of bitwise AND (\
BOA: Class overrides a method implemented in super class Adapter wrongly
This method overrides a method found in a parent class, where that class is an Adapter that implements a listener defined in the
java.awt.event or javax.swing.event package. As a result, this method will not get called when the event occurs.
BRSA: Method attempts to access a result set field with index 0
A call to getXXX or updateXXX methods of a result set was made where the field index is 0. As ResultSet fields start at index 1, this is always a mistake.
CN: Class implements Cloneable but does not define or use clone method
Class implements Cloneable but does not define or use the clone method.
CN: clone method does not call super.clone()
This class defines a clone() method that does not call super.clone(), and is not final. If this class (\A\B\and the subclass B calls super.clone(), then it is likely that B's clone() method will return an object of type A, which violates the standard contract for clone().
If all clone() methods call super.clone(), then they are guaranteed to use Object.clone(), which always returns an object of the correct type.
Co: Covariant compareTo() method defined
This class defines a covariant version of compareTo(). To correctly
override the compareTo() method in the Comparable interface, the parameter of compareTo() must have type java.lang.Object.
DE: Method might drop exception
This method might drop an exception. In general, exceptions should be handled or reported in some way, or they should be thrown out of the method.
DE: Method might ignore exception
This method might ignore an exception. In general, exceptions should be handled or reported in some way, or they should be thrown out of the method.