Andreas Dangel
-
2015-02-21
- status: open --> in-progress
- assigned_to: Andreas Dangel
- Milestone: New Tickets --> PMD-Next
This appears to be a regression of [#1230] because the case in question is mentioned in https://sourceforge.net/p/pmd/bugs/1230/
When comparing a collection size to 1, UseCollectionIsEmpty is triggered incorrectly. The problem here is isEmpty is insufficient for this case. I actually want to "do something" if size()==0 or size()==1
public class PMDIsEmptyFalsePositive { public void falsePositive() { Collection<String> c = new ArrayList<String>(); if (c.size() <= 1) // false positive { // do something } } }