Class AbstractRegexCheckTrackingMatchers

All Implemented Interfaces:
RegexCheck, JavaCheck, JavaFileScanner
Direct Known Subclasses:
AbstractRegexCheckTrackingMatchType, UnusedGroupNamesCheck

public abstract class AbstractRegexCheckTrackingMatchers extends AbstractRegexCheck
  • Constructor Details

    • AbstractRegexCheckTrackingMatchers

      public AbstractRegexCheckTrackingMatchers()
  • Method Details

    • trackedMethodMatchers

      protected abstract MethodMatchers trackedMethodMatchers()
      The methods for which we want to know whether they're invoked on the given regex. These should either be methods of the Pattern or Matcher class or part of REGEX_METHODS.
    • checkRegex

      protected abstract void checkRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation, List<MethodInvocationTree> trackedMethodsCalled, boolean didEscape)
      Parameters:
      regexForLiterals - The regex to be checked
      methodInvocationOrAnnotation - The method invocation or annotation that the regex string is passed to
      trackedMethodsCalled - The list of method invocations performed on the Pattern or Matcher object associated with the regex (only taking into account methods returned by trackedMethodMatchers)
      didEscape - Whether or not the regex escaped the method in which it was created (via return, being assigned to a non-local variable or being passed to a different method). If true, trackedMethodsCalled may not be exhaustive.
    • nodesToVisit

      public List<Tree.Kind> nodesToVisit()
      Overrides:
      nodesToVisit in class AbstractRegexCheck
    • leaveNode

      public void leaveNode(Tree tree)
      Overrides:
      leaveNode in class SubscriptionVisitor
    • visitNode

      public void visitNode(Tree tree)
      Overrides:
      visitNode in class AbstractRegexCheck
    • onMethodInvocationFound

      protected void onMethodInvocationFound(MethodInvocationTree mit)
      Overrides:
      onMethodInvocationFound in class AbstractRegexCheck
    • checkRegex

      public void checkRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation)
      Specified by:
      checkRegex in class AbstractRegexCheck