Findbugs缺陷等级对照表.docx
- 文档编号:28773876
- 上传时间:2023-07-19
- 格式:DOCX
- 页数:25
- 大小:32.92KB
Findbugs缺陷等级对照表.docx
《Findbugs缺陷等级对照表.docx》由会员分享,可在线阅读,更多相关《Findbugs缺陷等级对照表.docx(25页珍藏版)》请在冰豆网上搜索。
Findbugs缺陷等级对照表
FindBugsBugDescriptions
Thisdocumentliststhestandardbugpatternsreportedbyversion0.8.5.
Summary
序号
等级
Description
Category
14
A
EC:
Calltoequals()withnullargument
调用Equal方法的参数为空
Correctness
15
A
EC:
Calltoequals()comparingdifferentinterfacetypes
调用Equal方法去比较不同的接口类型
Correctness
16
A
EC:
Calltoequals()comparingdifferenttypes
调用Equal方法去比较不同的数据类型
Correctness
17
A
ES:
ComparisonofStringobjectsusing==or!
=
使用==或者!
=去比较字符串或对象
Correctness
29
B
IJU:
TestCaseimplementssetUpbutdoesn'tcallsuper.setUp()
测试实例实现了setUp()但没有调用super.setUp()
Correctness
36
A
NP:
Nullpointerdereferenceinmethod
方法中存在空指针
Correctness
37
A
NP:
Nullpointerdereferenceinmethodonexceptionpath
方法中存在某异常路径中的空指针
Correctness
38
A
NP:
Possiblenullpointerdereferenceinmethod
方法中存在可能在运行时出现的空指针异常
Correctness
39
A
NP:
Possiblenullpointerdereferenceinmethodonexceptionpath
方法中存在可能在某些异常路径下出现的空指针异常
Correctness
41
C
Nm:
Classdefinesequal();shoulditbeequals()?
类中定义了equal方法,但是没有重写java.lang.Object中equal方法,这也有可能是有意这么做的
Correctness
42
B
Nm:
Confusingmethodnames
一些方法名只有大小写的区别,容易混绕
Correctness
43
B
Nm:
Confusingmethodname
方法名和其超类的类名相同
Correctness
44
C
Nm:
Classdefineshashcode();shoulditbehashCode()?
类中定义了hashCode()方法,但是没有重写java.lang.Object中的hashCode()方法,这也有可能是有意这么做的
Correctness
45
C
Nm:
Classdefinestostring();shoulditbetoString()?
类中定义了tostring()方法,但是没有重写java.lang.Object中的tostring()方法,这也有可能是有意这么做的
Correctness
46
A
Nm:
Veryconfusingmethodnames
一些方法名只有大小写的区别,特别容易混绕
Correctness
47
A
ODR:
Methodmayfailtoclosedatabaseresource
方法可能没有关闭数据源
Correctness
48
A
ODR:
Methodmayfailtoclosedatabaseresourceonexception
方法在异常时可能无法关闭数据源
Correctness
49
A
OS:
Methodmayfailtoclosestream
方法可能没有关闭流
Correctness
50
A
OS:
Methodmayfailtoclosestreamonexception
方法在异常时可能无法关闭流
Correctness
53
C
RCN:
Redundantcomparisiontonullofpreviouslycheckedvalue
预测值的几个比较的值中有null值
Correctness
54
C
RCN:
Redundantcomparisontonull
几个比较的值中有null值
Correctness
57
C
RV:
Methodignoresreturnvalue
方法忽略了返回值
Correctness
59
A
SI:
Staticinitializerforclasscreatesinstancebeforeallstaticfinalfieldsassigned
类的静态初始化器实例化一个该类对象要在所有的常量属性定义之前
Correctness
72
C
UwF:
Unwrittenfield
永远不会写到的字段,所有读取将返回默认值
Correctness
83
A
MS:
Fieldisn'tfinalbutshouldbe
字段应该为常量的却不是常量
Maliciouscodevulnerability
86
A
IS2:
Inconsistentsynchronization
类中字段访问不同步
Multithreadedcorrectness
88
A
ML:
Methodsynchronizesonanupdatedfield
方法从一个可变字段对象的引用中同步。
这是不太可能有用的,因为不同的线程可以在不同的对象上同步。
Multithreadedcorrectness
92
C
Ru:
Invokesrunonathread(didyoumeantostartitinstead?
)
当一个类继承Runnable接口时候,还去调用run方法,实际上只需要调用Start方法就可以启动新的线程,
Multithreadedcorrectness
93
C
SC:
ConstructorinvokesThread.start()
构造函数调用Thread.start()
Multithreadedcorrectness
102
C
Dm:
MethodinvokesdubiousnewString(String)constructor;justusetheargument
方法中调用String的构造函数来新建一个字符串,直接使用其参数即可
Performance
103
A
Dm:
MethodinvokesdubiousString.equals("");useString.length()==0instead
方法中调用了不确定的String.equals(""),使用String.length()==0来代替
Performance
104
A
Dm:
MethodinvokestoString()methodonaString;justusetheString
方法中用一个字符串去调用方法toString(),用String就可以了
Performance
105
C
Dm:
MethodinvokesdubiousnewString()constructor;justuse""
方法中新建一个空字符串用newString()。
直接用“”就可以了
Performance
106
C
FI:
Emptyfinalizershouldbedeleted
空finalizer()方法是没有用的,所以应该予以删除
Performance
114
C
UPM:
Privatemethodisnevercalled
这个私有方法从来没有被调用到
Performance
115
C
UrF:
Unreadfield
读不到的字段,应该从类中删除
Performance
116
C
UuF:
Unusedfield
读不到的字段,应该从类中删除
Performance
Descriptions
AM:
Createsanemptyjar
ThecodecallsputNextEntry(),immediatelyfollowedbyacalltocloseEntry().ThisresultsinanemptyJar.ThecontentsoftheentryshouldbewrittentotheJarthecallstoputNextEntry()andcloseEntry().
AM:
Createsanemptyzip
ThecodecallsputNextEntry(),immediatelyfollowedbyacalltocloseEntry().ThisresultsinanemptyZip.ThecontentsoftheentryshouldbewrittentotheZipthecallstoputNextEntry()andcloseEntry().
BIT:
Incompatiblebitmasks
Thismethodcomparesanexpressionoftheform(a&C)toD,whichwillalwayscompareunequalduetothespecificvaluesofconstantsCandD.Thismayindicatealogicerrorortypo.
BIT:
Incompatiblebitmasks
Thismethodcomparesanexpressionoftheform(a&0)to0,whichwillalwayscompareequal.Thismayindicatealogicerrorortypo.
BIT:
Incompatiblebitmasks
Thismethodcomparesanexpressionoftheform(a|C)toD.whichwillalwayscompareunequalduetothespecificvaluesofconstantsCandD.Thismayindicatealogicerrorortypo.
Typically,thisbugoccursbecausethecodewantstoperformamembershiptestinabitset,butusesthebitwiseORoperator("|")insteadofbitwiseAND("&").
BOA:
ClassoverridesamethodimplementedinsuperclassAdapterwrongly
Thismethodoverridesamethodfoundinaparentclass,wherethatclassisanAdapterthatimplementsalistenerdefinedinthejava.awt.eventorjavax.swing.eventpackage.Asaresult,thismethodwillnotgetcalledwhentheeventoccurs.
BRSA:
Methodattemptstoaccessaresultsetfieldwithindex0
AcalltogetXXXorupdateXXXmethodsofaresultsetwasmadewherethefieldindexis0.AsResultSetfieldsstartatindex1,thisisalwaysamistake.
CN:
ClassimplementsCloneablebutdoesnotdefineoruseclonemethod
ClassimplementsCloneablebutdoesnotdefineorusetheclonemethod.
CN:
clonemethoddoesnotcallsuper.clone()
Thisclassdefinesaclone()methodthatdoesnotcallsuper.clone(),andisnotfinal.Ifthisclass("A")isextendedbyasubclass("B"),andthesubclassBcallssuper.clone(),thenitislikelythatB'sclone()methodwillreturnanobjectoftypeA,whichviolatesthestandardcontractforclone().
Ifallclone()methodscallsuper.clone(),thentheyareguaranteedtouseObject.clone(),whichalwaysreturnsanobjectofthecorrecttype.
Co:
CovariantcompareTo()methoddefined
ThisclassdefinesacovariantversionofcompareTo(). TocorrectlyoverridethecompareTo()methodintheComparableinterface,theparameterofcompareTo()musthavetypejava.lang.Object.
DE:
Methodmightdropexception
Thismethodmightdropanexception. Ingeneral,exceptionsshouldbehandledorreportedinsomeway,ortheyshouldbethrownoutofthemethod.
DE:
Methodmightignoreexception
Thismethodmightignoreanexception. Ingeneral,exceptionsshouldbehandledorreportedinsomeway,ortheyshouldbethrownoutofthemethod.
Dm:
MethodinvokesSystem.exit(...)
InvokingSystem.exitshutsdowntheentireJavavirtualmachine.Thisshouldonlybeendonewhenitisappropriate.Suchcallsmakeithardorimpossibleforyourcodetobeinvokedbyothercode.ConsiderthrowingaRuntimeExceptioninstead.
EC:
Calltoequals()withnullargument
Thismethodcallsequals(Object),passinganullvalueastheargument.Accordingtothecontractoftheequals()method,thiscallshouldalwaysreturnfalse.
EC:
Calltoequals()comparingdifferentinterfacetypes
Thismethodcallsequals(Object)ontworeferencesofunrelatedinterfacetypes(neitherisasubtypeoftheother).Accordingtothecontractofequals(),objectsofdifferentclassesshouldalwayscompareasunequal.Notethatitispossiblethattheprogramcontainsclassesthatimplementbothinterfaces,sothecomparisonmaybevalid.However,itisworthinspectingclosely.
EC:
Calltoequals()comparingdifferenttypes
Thismethodcallsequals(Object)ontworeferencesofdifferenttypes.Accordingtothecontractofequals(),objectsofdifferentclassesshouldalwayscompareasunequal;therefore,itislikelythattheresultofthiscomparisionwillalwaysbefalseatruntime.
ES:
ComparisonofStringobjectsusing==or!
=
Thiscodecomparesjava.lang.Stringobjectsforreferenceequalityusingthe==or!
=operators.Unlessbothstringsareeitherconstantsinasourcefile,orhavebeeninternedusingtheString.intern()method,thesamestringvaluemayberepresentedbytwodifferentStringobjects.Considerusingtheequals(Object)methodinstead.
Eq:
Covariantequals()methoddefined
Thisclassdefinesacovariantversionofequals(). Tocorrectlyoverridetheequals()methodinjava.lang.Object,theparameterofequals()musthavetypejava.lang.Object.
Eq:
Covariantequals()methoddefined,Object.equals(Object)inherited
Thisclassdefinesacovariantversionoftheequals()method,butcallsthenormalequals(Object)methoddefinedinthebasejava.lang.Objectclass. Theclassshouldprobablydefineanon-covariantversionofequals(). (I.e.,amethodwiththesignaturebooleanequals(java.lang.Object).
FI:
Explicitinvocationoffinalizer
Thismethodcontainsanexplicitinvocationofthefinalize()methodonanobject. Becausefinalizermethodsaresupposedtobeexecutedonce,andonlybytheVM,thisisabadidea.
FI:
Finalizerdoesnotcallsuperclassfinalizer
Thisfinalize()methoddoesnotmakeacalltoitssuperclass'sfinalize()method. So,anyfinalizeractionsdefinedforthesuperclasswillnotbeperformed. Addacalltosuper.finalize().
FI:
Finalizernullifiessuperclassfinalizer
Thisemptyfinalize()methodexplicitlynegatestheeffectofanyfinalizerdefinedbyitssuperclass. Anyfinalizeractionsdefinedforthesuperclasswillnotbeperformed. Unlessthisisintended,deletethismethod.
HE:
Classdefinesequals()butnothashCode()
Thisclassoverridesequals(Object),butdoesnotoverridehashCode(). Therefore,theclassmayviolatetheinvariantthatequalobjectsmusthaveequalhashcodes.
HE:
Classdefinesequals()anduses
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Findbugs 缺陷 等级 对照