mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
better warning message & more tests
This commit is contained in:
+1
-1
@@ -1050,7 +1050,7 @@ string.buffer.replaceable.by.string.builder.problem.descriptor=<code>StringBuffe
|
||||
string.buffer.replaceable.by.string.problem.descriptor=<code>{0} #ref</code> can be replaced with ''String'' #loc
|
||||
new.string.buffer.replaceable.by.string.problem.descriptor=<code>#ref</code> can be replaced with 'String' #loc
|
||||
string.replaceable.by.string.buffer.problem.descriptor=Non-constant <code>String #ref</code> should probably be declared as ''StringBuilder'' #loc
|
||||
collections.must.have.initial.capacity.problem.descriptor=<code>#ref</code> without initial capacity #loc
|
||||
collections.must.have.initial.capacity.problem.descriptor=<code>new #ref()</code> without initial capacity #loc
|
||||
string.concatenation.in.loops.problem.descriptor=String concatenation <code>#ref</code> in loop #loc
|
||||
string.concatenation.inside.string.buffer.append.problem.descriptor=String concatenation as argument to <code>{0}.#ref()</code> call #loc
|
||||
boolean.constructor.problem.descriptor=Boolean constructor call #loc
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
package com.siyeh.igtest.performance;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class CollectionsMustHaveInitialCapacityInspection
|
||||
{
|
||||
public CollectionsMustHaveInitialCapacityInspection()
|
||||
{
|
||||
}
|
||||
|
||||
public void foo() throws IOException
|
||||
{
|
||||
// new HashMap<String, String>();
|
||||
// new HashMap<String, String>(3);
|
||||
|
||||
new HashMap();
|
||||
new HashMap(3);
|
||||
|
||||
new WeakHashMap();
|
||||
new WeakHashMap(3);
|
||||
|
||||
new HashSet();
|
||||
new HashSet(3);
|
||||
|
||||
new Hashtable();
|
||||
new Hashtable(3);
|
||||
|
||||
new BitSet();
|
||||
new BitSet(3);
|
||||
|
||||
new Vector();
|
||||
new Vector(3);
|
||||
|
||||
new ArrayList();
|
||||
new ArrayList(3);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+46
-2
@@ -31,11 +31,55 @@ public class CollectionsMustHaveInitialCapacityInspectionTest extends LightInspe
|
||||
protected String[] getEnvironmentClasses() {
|
||||
return new String[] {
|
||||
"package java.util.concurrent;" +
|
||||
"public class ConcurrentHashMap {}"
|
||||
"public class ConcurrentHashMap {}",
|
||||
"package java.util;" +
|
||||
"public class WeakHashMap {" +
|
||||
" public WeakHashMap() {}" +
|
||||
" public WeakHashMap(int c) {}" +
|
||||
"}",
|
||||
"package java.util;" +
|
||||
"public class HashSet {" +
|
||||
" public HashSet() {}" +
|
||||
" public HashSet(int c) {}" +
|
||||
"}",
|
||||
"package java.util;" +
|
||||
"public class BitSet {" +
|
||||
" public BitSet() {}" +
|
||||
" public BitSet(int c) {}" +
|
||||
"}",
|
||||
"package java.util;" +
|
||||
"public class Vector {" +
|
||||
" public Vector() {}" +
|
||||
" public Vector(int c) {}" +
|
||||
"}"
|
||||
};
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
doStatementTest("new /*'java.util.concurrent.ConcurrentHashMap' without initial capacity*/java.util.concurrent.ConcurrentHashMap/**/();");
|
||||
doStatementTest("new /*'new java.util.concurrent.ConcurrentHashMap()' without initial capacity*/java.util.concurrent.ConcurrentHashMap/**/();");
|
||||
}
|
||||
|
||||
public void testMore() {
|
||||
doTest("import java.util.*;" +
|
||||
"class X {" +
|
||||
" void m() {" +
|
||||
" new /*'new HashMap<String, String>()' without initial capacity*/HashMap<String, String>/**/();" +
|
||||
" new HashMap<String, String>(3);" +
|
||||
" new /*'new HashMap()' without initial capacity*/HashMap/**/();" +
|
||||
" new HashMap(3);" +
|
||||
" new /*'new WeakHashMap()' without initial capacity*/WeakHashMap/**/();" +
|
||||
" new WeakHashMap(3);" +
|
||||
" new /*'new HashSet()' without initial capacity*/HashSet/**/();" +
|
||||
" new HashSet(3);" +
|
||||
" new /*'new Hashtable()' without initial capacity*/Hashtable/**/();" +
|
||||
" new Hashtable(3);" +
|
||||
" new /*'new BitSet()' without initial capacity*/BitSet/**/();" +
|
||||
" new BitSet(3);" +
|
||||
" new /*'new Vector()' without initial capacity*/Vector/**/();" +
|
||||
" new Vector(3);" +
|
||||
" new /*'new ArrayList()' without initial capacity*/ArrayList/**/();" +
|
||||
" new ArrayList(3);" +
|
||||
" }" +
|
||||
"}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user