Class AbstractPoorMethodCall

  • All Implemented Interfaces:
    JavaParserVisitor, ImmutableLanguage, PropertySource, Rule
    Direct Known Subclasses:
    UseIndexOfCharRule

    @Deprecated
    @InternalApi
    public abstract class AbstractPoorMethodCall
    extends AbstractJavaRule
    Deprecated.
    Internal API
    Detects and flags the occurrences of specific method calls against an instance of a designated class. I.e. String.indexOf. The goal is to be able to suggest more efficient/modern ways of implementing the same function.

    Concrete subclasses are expected to provide the name of the target class and an array of method names that we are looking for. We then pass judgment on any literal arguments we find in the subclass as well.

    Author:
    Brian Remedios
    • Constructor Detail

      • AbstractPoorMethodCall

        public AbstractPoorMethodCall()
        Deprecated.
    • Method Detail

      • targetTypename

        protected abstract String targetTypename()
        Deprecated.
        The name of the type the method will be invoked against.
        Returns:
        String
      • methodNames

        protected abstract String[] methodNames()
        Deprecated.
        Return the names of all the methods we are scanning for, no brackets or argument types.
        Returns:
        String[]
      • isViolationArgument

        protected abstract boolean isViolationArgument​(Node arg)
        Deprecated.
        Returns whether the node being sent to the method is OK or not. Return true if you want to record the method call as a violation.
        Parameters:
        arg - the node to inspect
        Returns:
        boolean