Files
codeql/java/ql/src/Performance/InefficientPrimConstructor.ql
2018-10-11 11:31:37 +02:00

21 lines
581 B
Plaintext

/**
* @name Inefficient primitive constructor
* @description Calling the constructor of a boxed type is inefficient.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id java/inefficient-boxed-constructor
* @tags efficiency
* maintainability
*/
import java
from ClassInstanceExpr call, BoxedType type
where
type = call.getType() and
not call.getEnclosingCallable().getDeclaringType() = type
select call,
"Inefficient constructor for " + type.getPrimitiveType().getName() + " value, use " +
type.getName() + ".valueOf(...) instead."