洁癖专题

【Java代码洁癖】NO.7 for循环异常?不能忍

反例 void function(Collection<String> collection) {// 要么循环根本不会进行,要么当collection为空时死循环for (int i = 0; i >= collection.size(); i++) {// ...}} 正例 void function(Collection<String> collection

【Java代码洁癖】NO.2 单元测试mock显式赋值,不能忍

反例 @RunWith(MockitoJunitRunner.class)public class Test {@Mockpublic SomeBean someBean = new SomeBean();} 正例 @RunWith(MockitoJunitRunner.class)public class Test {@Mockpublic SomeBean someBean ;

【Java代码洁癖】NO.1 集合创建冗余,不能忍

反例 public Collection<String> sort(Collection<String> foos){List<String> sortedFoos = new ArrayList<>(foos);Collection.sort(sortedFoos);return sortedFoos;} 正例 public Collection<String> sort(Collect