PMD规则之Migration Rules

18 篇文章 1 订阅

·  ReplaceVectorWithList: Consider replacing Vector usages with the newer java.util.ArrayList if expensive threadsafe operation is not required.

翻译   List替换Vector:如果不是在必须线程安全的环境下,考虑使用List代替Vector

·  ReplaceHashtableWithMap: Consider replacing this Hashtable with the newer java.util.Map

翻译   Map替换Hashtable: 如果不是在必须线程安全的环境下,考虑使用Map替换Hashtable

·  ReplaceEnumerationWithIterator: Consider replacing this Enumeration with the newer java.util.Iterator

翻译   Iterator替换Enumeration:考虑用Iterator替换Enumeration

·  AvoidEnumAsIdentifier: Finds all places where 'enum' is used as an identifier.

翻译   避免用enum作为标识符:找到所有使用enum作为标识符的地方

·  AvoidAssertAsIdentifier: Finds all places where 'assert' is used as an identifier.

翻译   避免使用Assert作为标识符:找到所有使用assert作为标识符的地方

·  IntegerInstantiation: In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly.

翻译   Integer类型实例化:对于JDK1.5,调用new Integer()会造成内存分配,而Integer.valueOf()具有更好的内存友好性。

·  ByteInstantiation: In JDK 1.5, calling new Byte() causes memory allocation. Byte.valueOf() is more memory friendly.

翻译   Byte类型初始化:对于JDK1.5,调用new Byte()会造成内存分配,而Byte.valueOf()具有更好的内存友好性。

·  ShortInstantiation: In JDK 1.5, calling new Short() causes memory allocation. Short.valueOf() is more memory friendly.

翻译   Short类型初始化:对于JDK1.5,调用new Short ()会造成内存分配,而Short.valueOf()具有更好的内存友好性。

·  LongInstantiation: In JDK 1.5, calling new Long() causes memory allocation. Long.valueOf() is more memory friendly.

翻译   Long类型初始化:对于JDK1.5,调用new Long()会造成内存分配,而Long.valueOf()具有更好的内存友好性。

·  JUnit4TestShouldUseBeforeAnnotation: In JUnit 3, the setUp method was used to set up all data entities required in running tests. JUnit 4 skips the setUp method and executes all methods annotated with @Before before all tests

翻译   Junit4测试时应该使用Before注解:在Junit3中,我们使用setUp()方法设置运行测试时需要的值,然而Junit4忽略setUp方法在所有测试前先执行被@Before标注过的方法。

·  JUnit4TestShouldUseAfterAnnotation: In JUnit 3, the tearDown method was used to clean up all data entities required in running tests. JUnit 4 skips the tearDown method and executes all methods annotated with @After after running each test

翻译   Junit4测试时应该使用After注解:对于Junit3,tearDown()方法被用来清除测试执行后的数据。Junit4忽略tearDown方法然后在执行每个测试方法后执行所有标记为@After的方法。

·  JUnit4TestShouldUseTestAnnotation: In JUnit 3, the framework executed all methods which started with the word test as a unit test. In JUnit 4, only methods annotated with the @Test annotation are executed.

翻译   Junit4测试应使用Test注解:对于Junit3,测试框架执行每个以test单词打头的方法作为单元测试。而对于Junit4,只有标记为@Test注解的方法才能被执行。

·  JUnit4SuitesShouldUseSuiteAnnotation: In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicated through the @RunWith(Suite.class) annotation.

翻译   Junit4测试套件应使用Suite注解:对于Junit3,测试套件表现为suite()方法,而对于Junit4,测试套件表现为@RunWith(Suite.class)注解

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值