UseCollectionIsEmpty throws NullPointerException
A source code analyzer
Brought to you by:
adangel,
juansotuyo
PMD prints "Exception applying rule UseCollectionIsEmpty" when analyzing the attached java file.
The top of the printed stacktrace:
[pmd] java.lang.NullPointerException
[pmd] at net.sourceforge.pmd.lang.ast.AbstractNode.jjtGetChild(AbstractNode.java:90)
[pmd] at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.checkComparison(AbstractInefficientZeroCheck.java:129)
[pmd] at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.isCompare(AbstractInefficientZeroCheck.java:108)
[pmd] at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.checkNodeAndReport(AbstractInefficientZeroCheck.java:88)
[pmd] at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.visit(AbstractInefficientZeroCheck.java:71)
[pmd] at net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId.jjtAccept(ASTVariableDeclaratorId.java:29)
So, there is no crash if "this." is removed from the method call the collection size is compared to.
Thanks for the bug report. This will be fixed with the next release of PMD.
Commit: https://github.com/pmd/pmd/commit/171fdb877fa5cfc3225a2b8bbc830bf0ce34041f