
JAVA代码质量
文章平均质量分 80
清风伴明月0001
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
FindBugs错误问题详解
objects being compared are unlikely to be members of the same class at runtime (unless some application classes were not analyzed, or dynamic class loading can occur at runtime). According to the contract of equals(), objects of different classes should al2010-04-08 13:47:21 · 740 阅读 · 0 评论 -
业务层和持久层单元测试的实践
一些实践经验,希望能够和大家共同提高。如无特殊说明:以下例子采用junit4 + jmock1.0。[b]1. 如何解决外部系统的依赖?[/b]对于业务层的单元测试,比较复杂的情况就是会有很多外部services(接口或者服务等)的依赖,其实对于我们来说最重我们需要得到或者传递出去的都是各种数据对象,那么这种情况下可以采用mock来模拟这些数据对象。这样让测试方便的通过。场景:测试DefaultGetNumAO类的getNum方法,在真正的应用里面,调用此方法的前提是从session中取得用2011-01-19 15:28:40 · 425 阅读 · 0 评论 -
从 FingBugs的错误来看JAVA代码质量(一)
/upload/attachment/506019/9854ef6f-adf3-3a21-abd4-64c754a08d14.jpg[/img]Bug: Method JTAMainFrame.initView(JFrame) makes inefficient use of keySet iterator instead of entrySet iteratorPattern id: WMI_WRONG_MAP_ITERATOR, type: WMI, category: PERFORMA2011-06-28 11:16:18 · 232 阅读 · 0 评论 -
从 FingBugs的错误来看JAVA代码质量(二)
neMerchantId() invokes inefficient Double.valueOf(double) constructor; use OnlineLicenseDAOTest.java:[line 81] insteadPattern id: DM_FP_NUMBER_CTOR, type: Bx, category: PERFORMANCEUsing new Double(double) is guaranteed to always result in a new object2011-06-28 11:26:07 · 232 阅读 · 0 评论 -
从 FingBugs的错误来看JAVA代码质量(三)
Serializable; consider declaring a serialVersionUIDPattern id: SE_NO_SERIALVERSIONID, type: SnVI, category: BAD_PRACTICEThis class implements the Serializable interface, but does not define a serialVersionUID field. A change as simple as adding a refe2011-06-29 15:42:36 · 422 阅读 · 0 评论 -
从 FingBugs的错误来看JAVA代码质量(四)
, which is known to be non-nullPattern id: RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE, type: RCN, category: STYLEThis method contains a redundant check of a known non-null value against the constant null.解释:这种方法包含了一个称为非空对空值的不断重复检查。修改为: [img]htt2011-07-07 22:18:45 · 188 阅读 · 0 评论 -
FindBugs2.0发布了
et/downloads.html[/url]原创 2012-02-08 13:20:42 · 113 阅读 · 0 评论 -
基于Eclipse的FindBugs中文插件发布了
a-55a08161f28a.jpg[/img] 使用方法有两种:第一种: 1.将\eclipse\plugins\edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821目录下的findbugs-plugin.jar替换为附件中的同名文件;或者第二种:将附件中的messages.xml替换你\eclipse\plugins\edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821目录下的fi原创 2012-03-01 20:16:02 · 252 阅读 · 0 评论 -
从 FingBugs的错误来看JAVA代码质量(五)
REC_CATCH_EXCEPTION, type: REC, category: STYLE[/b]This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try原创 2012-05-11 14:30:30 · 137 阅读 · 0 评论