Findbugs缺陷等级对照表Word格式文档下载.docx
- 文档编号:5558938
- 上传时间:2023-05-05
- 格式:DOCX
- 页数:24
- 大小:33.59KB
Findbugs缺陷等级对照表Word格式文档下载.docx
《Findbugs缺陷等级对照表Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《Findbugs缺陷等级对照表Word格式文档下载.docx(24页珍藏版)》请在冰点文库上搜索。
=
使用==或者!
=去比较字符串或对象
29
B
IJU:
TestCaseimplementssetUpbutdoesn'
tcallsuper.setUp()
测试实例实现了setUp()但没有调用super.setUp()
36
NP:
Nullpointerdereferenceinmethod
方法中存在空指针
37
Nullpointerdereferenceinmethodonexceptionpath
方法中存在某异常路径中的空指针
38
Possiblenullpointerdereferenceinmethod
方法中存在可能在运行时出现的空指针异常
39
Possiblenullpointerdereferenceinmethodonexceptionpath
方法中存在可能在某些异常路径下出现的空指针异常
41
C
Nm:
Classdefinesequal();
shoulditbeequals()?
类中定义了equal方法,但是没有重写java.lang.Object中equal方法,这也有可能是有意这么做的
42
Confusingmethodnames
一些方法名只有大小写的区别,容易混绕
43
Confusingmethodname
方法名和其超类的类名相同
44
Classdefineshashcode();
shoulditbehashCode()?
类中定义了hashCode()方法,但是没有重写java.lang.Object中的hashCode()方法,这也有可能是有意这么做的
45
Classdefinestostring();
shoulditbetoString()?
类中定义了tostring()方法,但是没有重写java.lang.Object中的tostring()方法,这也有可能是有意这么做的
46
Veryconfusingmethodnames
一些方法名只有大小写的区别,特别容易混绕
47
ODR:
Methodmayfailtoclosedatabaseresource
方法可能没有关闭数据源
48
Methodmayfailtoclosedatabaseresourceonexception
方法在异常时可能无法关闭数据源
49
OS:
Methodmayfailtoclosestream
方法可能没有关闭流
50
Methodmayfailtoclosestreamonexception
方法在异常时可能无法关闭流
53
RCN:
Redundantcomparisiontonullofpreviouslycheckedvalue
预测值的几个比较的值中有null值
54
Redundantcomparisontonull
几个比较的值中有null值
57
RV:
Methodignoresreturnvalue
方法忽略了返回值
59
SI:
Staticinitializerforclasscreatesinstancebeforeallstaticfinalfieldsassigned
类的静态初始化器实例化一个该类对象要在所有的常量属性定义之前
72
UwF:
Unwrittenfield
永远不会写到的字段,所有读取将返回默认值
83
MS:
Fieldisn'
tfinalbutshouldbe
字段应该为常量的却不是常量
Maliciouscodevulnerability
86
IS2:
Inconsistentsynchronization
类中字段访问不同步
Multithreadedcorrectness
88
ML:
Methodsynchronizesonanupdatedfield
方法从一个可变字段对象的引用中同步。
这是不太可能有用的,因为不同的线程可以在不同的对象上同步。
92
Ru:
Invokesrunonathread(didyoumeantostartitinstead?
)
当一个类继承Runnable接口时候,还去调用run方法,实际上只需要调用Start方法就可以启动新的线程,
93
SC:
ConstructorinvokesThread.start()
构造函数调用Thread.start()
102
Dm:
MethodinvokesdubiousnewString(String)constructor;
justusetheargument
方法中调用String的构造函数来新建一个字符串,直接使用其参数即可
Performance
103
MethodinvokesdubiousString.equals("
"
);
useString.length()==0instead
方法中调用了不确定的String.equals("
),使用String.length()==0来代替
104
MethodinvokestoString()methodonaString;
justusetheString
方法中用一个字符串去调用方法toString(),用String就可以了
105
MethodinvokesdubiousnewString()constructor;
justuse"
方法中新建一个空字符串用newString()。
直接用“”就可以了
106
FI:
Emptyfinalizershouldbedeleted
空finalizer()方法是没有用的,所以应该予以删除
114
UPM:
Privatemethodisnevercalled
这个私有方法从来没有被调用到
115
UrF:
Unreadfield
读不到的字段,应该从类中删除
116
UuF:
Unusedfield
Descriptions
AM:
Createsanemptyjarfileentry
ThecodecallsputNextEntry(),immediatelyfollowedbyacalltocloseEntry().ThisresultsinanemptyJarFileentry.ThecontentsoftheentryshouldbewrittentotheJarFilebetweenthecallstoputNextEntry()andcloseEntry().
Createsanemptyzipfileentry
ThecodecallsputNextEntry(),immediatelyfollowedbyacalltocloseEntry().ThisresultsinanemptyZipFileentry.ThecontentsoftheentryshouldbewrittentotheZipFilebetweenthecallstoputNextEntry()andcloseEntry().
BIT:
Incompatiblebitmasks
Thismethodcomparesanexpressionoftheform(a&
C)toD,whichwillalwayscompareunequalduetothespecificvaluesofconstantsCandD.Thismayindicatealogicerrorortypo.
0)to0,whichwillalwayscompareequal.Thismayindicatealogicerrorortypo.
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.
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.
Methodmightignoreexception
Thismethodmightignoreanexception.
MethodinvokesSystem.exit(...)
InvokingSystem.exitshutsdowntheentireJavavirtualmachine.Thisshouldonlybeendonewhenitisappropriate.Suchcallsmakeithardorimpossibleforyourcodetobeinvokedbyothercode.ConsiderthrowingaRuntimeExceptioninstead.
Thismethodcallsequals(Object),passinganullvalueastheargument.Accordingtothecontractoftheequals()method,thiscallshouldalwaysreturnfalse.
Calltoequals()comparingdifferentinterfacetypes
Thismethodcallsequals(Object)ontworeferencesofunrelatedinterfacetypes(neitherisasubtypeoftheother).Accordingtothecontractofequals(),objectsofdifferentclassesshouldalwayscompareasunequal.Notethatitispossiblethattheprogramcontainsclassesthatimplementbothinterfaces,sothecomparisonmaybevalid.However,itisworthinspectingclosely.
Thismethodcallsequals(Object)ontworeferencesofdifferenttypes.Accordingtothecontractofequals(),objectsofdifferentclassesshouldalwayscompareasunequal;
therefore,itislikelythattheresultofthiscomparisionwillalwaysbefalseatruntime.
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.
Covariantequals()methoddefined,Object.equals(Object)inherited
Thisclassdefinesacovariantversionoftheequals()method,butcallsthenormalequals(Object)methoddefinedinthebasejava.lang.Objectclass.
Theclassshouldprobablydefineanon-covariantversionofequals().
(I.e.,amethodwiththesignaturebooleanequals(java.lang.Object).
Explicitinvocationoffinalizer
Thismethodcontainsanexplicitinvocationofthefinalize()methodonanobject.
Becausefinalizermethodsaresupposedtobeexecutedonce,andonlybytheVM,thisisabadidea.
Finalizerdoesnotcallsuperclassfinalizer
Thisfinalize()methoddoesnotmakeacalltoitssuperclass'
sfinalize()method.
So,anyfinalizeractionsdefinedforthesuperclasswillnotbeperformed.
Addacalltosuper.finalize().
Finalizernullifiessuperclassfinalizer
Thisemptyfinalize()methodexplicitlynegatestheeffectofanyfinalizerdefinedbyitssuperclass.
Anyfinalizeractionsdefinedforthesuperclasswillnotbeperformed.
Unlessthisisintended,deletethismethod.
HE:
Classdefinesequals()butnothashCode()
Thisclassoverridesequals(Object),butdoesnotoverridehashCode().
Therefore,theclassmayviolatetheinvariantthatequalobjects
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Findbugs 缺陷 等级 对照
![提示](https://static.bingdoc.com/images/bang_tan.gif)