Xiaoven / codegex

A light-weight tools like spotbugs
GNU Lesser General Public License v2.1
1 stars 0 forks source link

FPs #191

Closed Xiaoven closed 2 years ago

Xiaoven commented 2 years ago

DM_FP_NUMBER_CTOR 和 BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION

下面的例子应该报 BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION,但codegex两个都报

total_max_contacts=new Double(minDomSize*maxDomSize*10).longValue();
Xiaoven commented 2 years ago

DM_BOXED_PRIMITIVE_FOR_PARSING

SP例子

SP实现 XXX.valueOf(str).xxxValue() 里的 xxx 要配对

return isNumber == 1 ? Long.parseLong(str) : (isNumber == 2 ? Double.valueOf(str).longValue() : 0L);

上面的 Double.valueOf(str).longValue() 是没问题的,因为 Integer.valueOf("3.14") 会抛出 NumberFormatException,只能用 Double

Xiaoven commented 2 years ago

IIO_INEFFICIENT_INDEX_OF

int index   = hexPropertyNames.indexOf(" " + thisName + " ");
// 这个例子的转义写法:"String cleaned = currentHypos[i].substring(0, currentHypos[i].indexOf(\"\\\"\"));\n"
String cleaned = currentHypos[i].substring(0, currentHypos[i].indexOf("\""));