Class UseCollectionIsEmptyRule

  • All Implemented Interfaces:
    JavaParserVisitor, net.sourceforge.pmd.lang.rule.ImmutableLanguage, net.sourceforge.pmd.properties.PropertySource, net.sourceforge.pmd.Rule

    public class UseCollectionIsEmptyRule
    extends AbstractInefficientZeroCheck
    Detect structures like "foo.size() == 0" and suggest replacing them with foo.isEmpty(). Will also find != 0 (replaceable with !isEmpty()).
    Author:
    Jason Bennett