Findbugs缺陷等级对照表(25页).doc
《Findbugs缺陷等级对照表(25页).doc》由会员分享,可在线阅读,更多相关《Findbugs缺陷等级对照表(25页).doc(25页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-Findbugs缺陷等级对照表-第 25 页FindBugs Bug DescriptionsThis document lists the standard bug patterns reported by version .Summary序号等级DescriptionCategory14AEC: Call to equals() with null argument调用Equal方法的参数为空Correctness15AEC: Call to equals() comparing different interface types 调用Equal方法去比较不同的接口类型Correctne
2、ss16AEC: Call to equals() comparing different types调用Equal方法去比较不同的数据类型Correctness17AES: Comparison of String objects using = or !=使用= 或者 != 去比较字符串或对象Correctness29BIJU: TestCase implements setUp but doesnt call super.setUp()测试实例实现了setUp()但没有调用super.setUp()Correctness36ANP: Null pointer dereference in
3、 method方法中存在空指针Correctness37ANP: Null pointer dereference in method on exception path方法中存在某异常路径中的空指针Correctness38ANP: Possible null pointer dereference in method方法中存在可能在运行时出现的空指针异常Correctness39ANP: Possible null pointer dereference in method on exception path方法中存在可能在某些异常路径下出现的空指针异常Correctness41CNm:
4、Class defines equal(); should it be equals()?类中定义了,这也有可能是有意这么做的Correctness42BNm: Confusing method names一些方法名只有大小写的区别,容易混绕Correctness43BNm: Confusing method name方法名和其超类的类名相同Correctness44CNm: Class defines hashcode(); should it be hashCode()?类中定义了hashCode()方法,但是没有重写中的hashCode()方法,这也有可能是有意这么做的Correctne
5、ss45CNm: Class defines tostring(); should it be toString()?类中定义了tostring()方法,但是没有重写中的tostring()方法,这也有可能是有意这么做的Correctness46ANm: Very confusing method names一些方法名只有大小写的区别,特别容易混绕Correctness47AODR: Method may fail to close database resource方法可能没有关闭数据源Correctness48AODR: Method may fail to close database
6、resource on exception方法在异常时可能无法关闭数据源Correctness49AOS: Method may fail to close stream方法可能没有关闭流Correctness50AOS: Method may fail to close stream on exception方法在异常时可能无法关闭流Correctness53CRCN: Redundant comparision to null of previously checked value预测值的几个比较的值中有null值Correctness54CRCN: Redundant compariso
7、n to null几个比较的值中有null值Correctness57CRV: Method ignores return value方法忽略了返回值Correctness59ASI: Static initializer for class creates instance before all static final fields assigned类的静态初始化器实例化一个该类对象要在所有的常量属性定义之前Correctness72CUwF: Unwritten field永远不会写到的字段,所有读取将返回默认值Correctness83AMS: Field isnt final but
8、 should be字段应该为常量的却不是常量Malicious code vulnerability86AIS2: Inconsistent synchronization类中字段访问不同步Multithreaded correctness88AML: Method synchronizes on an updated field方法从一个可变字段对象的引用中同步。这是不太可能有用的,因为不同的线程可以在不同的对象上同步。Multithreaded correctness92CRu: Invokes run on a thread (did you mean to start it inst
9、ead?)当一个类继承Runnable接口时候,还去调用run方法,实际上只需要调用Start方法就可以启动新的线程,Multithreaded correctness93CSC: Constructor invokes Thread.start()构造函数调用Thread.start()Multithreaded correctness102CDm: Method invokes dubious new String(String) constructor; just use the argument方法中调用String的构造函数来新建一个字符串,直接使用其参数即可Performance1
10、03ADm: Method invokes dubious String.equals(); use String.length() = 0 instead方法中调用了不确定的String.equals(),使用String.length() = 0来代替Performance104ADm: Method invokes toString() method on a String; just use the String方法中用一个字符串去调用方法toString(),用String就可以了Performance105CDm: Method invokes dubious new String
11、() constructor; just use 方法中新建一个空字符串用new String()。直接用“”就可以了Performance106CFI: Empty finalizer should be deleted空finalizer()方法是没有用的,所以应该予以删除Performance114CUPM: Private method is never called这个私有方法从来没有被调用到Performance115CUrF: Unread field读不到的字段,应该从类中删除Performance116CUuF: Unused field读不到的字段,应该从类中删除Perfo
12、rmanceDescriptionsAM: Creates an empty jar file entryThe 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 e
13、mpty zip file entryThe 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 masksThis method compares an
14、 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 masksThis method compares an expression of the form (a & 0) to 0, which will always compare equal. This may indicate
15、a logic error or typo.BIT: Incompatible bit masksThis 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 memb
16、ership 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 wronglyThis method overrides a method found in a parent class, where that class is an Adapter that implements a listener defined in the java.awt.
17、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 0A 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
18、is always a mistake.CN: Class implements Cloneable but does not define or use clone methodClass 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
19、 class (A) is extended by a subclass (B), and the subclass B calls super.clone(), then it is likely that Bs 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(), whic
20、h always returns an object of the correct type.Co: Covariant compareTo() method definedThis class defines a covariant version of compareTo(). To correctly override the compareTo() method in the Comparable interface, the parameter of compareTo() must have type .DE: Method might drop exceptionThis met
21、hod 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 exceptionThis method might ignore an exception. In general, exceptions should be handled or reported in some way, or they should be thrown
22、 out of the method.Dm: Method invokes System.exit(.)Invoking System.exit shuts down the entire Java virtual machine. This should only been done when it is appropriate. Such calls make it hard or impossible for your code to be invoked by other code. Consider throwing a RuntimeException instead.EC: Ca
23、ll to equals() with null argumentThis method calls equals(Object), passing a null value as the argument. According to the contract of the equals() method, this call should always return false.EC: Call to equals() comparing different interface typesThis method calls equals(Object) on two references o
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Findbugs 缺陷 等级 对照 25
限制150内