Affects PMD Version:
6.22.0
Rule:
Description:
ReturnEmptyArrayRatherThanNull can not detect return null surrounded by if statement
AST analyse result of the code sample:
//MethodDeclaration
[
(./ResultType/Type[@ArrayType='true'])
and
(./Block/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral)
]
AST chain to return null in the following code sample is: Block -> BlockStatement -> Statement -> IfStatement -> Statement -> ReturnStatement -> ... -> NullLiteral
Code Sample demonstrating the issue:
public byte []readBytes() throws IOException {
int tag = is.read();
if (tag == 'N')
return null;
Expected outcome:
false-negative
Running PMD through:
CLI
Affects PMD Version:
6.22.0
Rule:
Description:
ReturnEmptyArrayRatherThanNull can not detect
return nullsurrounded by if statementAST analyse result of the code sample:
AST chain to
return nullin the following code sample is: Block -> BlockStatement -> Statement -> IfStatement -> Statement -> ReturnStatement -> ... -> NullLiteralCode Sample demonstrating the issue:
Expected outcome:
false-negative
Running PMD through:
CLI