Affects PMD Version:
6.22.0
Rule:
AvoidDecimalLiteralsInBigDecimalConstructor
Description:
AvoidDecimalLiteralsInBigDecimalConstructor can not detect the case new BigDecimal(Expression)
//AllocationExpression
[ClassOrInterfaceType[@Image="BigDecimal"]]
[Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix
[
Literal[(not(ends-with(@Image,'"'))) and contains(@Image,".")]
or
Name[ancestor::Block/BlockStatement/LocalVariableDeclaration
[Type[PrimitiveType[@Image='double' or @Image='float']
or ReferenceType/ClassOrInterfaceType[@Image='Double' or @Image='Float']]]
/VariableDeclarator/VariableDeclaratorId/@Image = @Image
]
or
Name[ancestor::MethodDeclaration/MethodDeclarator/FormalParameters/FormalParameter
[Type[PrimitiveType[@Image='double' or @Image='float']
or ReferenceType/ClassOrInterfaceType[@Image='Double' or @Image='Float']]]
/VariableDeclaratorId/@Image = @Image
]
]
]
This rule doesn't consider using Expression(for example: foo * bar) to create BigDecimal
Code Sample demonstrating the issue:
new BigDecimal(remaining * 60)
Expected outcome:
false-negative
Running PMD through:
CLI
Affects PMD Version:
6.22.0
Rule:
AvoidDecimalLiteralsInBigDecimalConstructor
Description:
AvoidDecimalLiteralsInBigDecimalConstructor can not detect the case
new BigDecimal(Expression)This rule doesn't consider using Expression(for example:
foo * bar) to createBigDecimalCode Sample demonstrating the issue:
Expected outcome:
false-negative
Running PMD through:
CLI