Class AbstractInefficientZeroCheck

  • All Implemented Interfaces:
    JavaParserVisitor, net.sourceforge.pmd.lang.rule.ImmutableLanguage,, net.sourceforge.pmd.Rule
    Direct Known Subclasses:
    InefficientEmptyStringCheckRule, UseCollectionIsEmptyRule

    public abstract class AbstractInefficientZeroCheck
    extends AbstractJavaRule
    This is an abstract rule for patterns which compare a method invocation to 0. It could be further abstracted to find code that compares something to another definable pattern
    • Constructor Detail

      • AbstractInefficientZeroCheck

        public AbstractInefficientZeroCheck()
    • Method Detail

      • appliesToClassName

        public abstract boolean appliesToClassName​(String name)
      • getComparisonTargets

        public Map<String,​List<String>> getComparisonTargets()
        For each relation/equality operator, comparison targets need to define.
      • checkNodeAndReport

        protected void checkNodeAndReport​(Object data,
                                          net.sourceforge.pmd.lang.ast.Node location,
                                          net.sourceforge.pmd.lang.ast.Node expr)
        Checks whether the given expression is a equality/relation expression that compares with a size() call.
        data - the rule context
        location - the node location to report
        expr - the ==, <, > expression