Package org.sonar.java.checks.regex
Class AbstractRegexCheckTrackingMatchers
- java.lang.Object
-
- org.sonar.java.ast.visitors.SubscriptionVisitor
-
- org.sonar.plugins.java.api.IssuableSubscriptionVisitor
-
- org.sonar.java.checks.regex.AbstractRegexCheck
-
- org.sonar.java.checks.regex.AbstractRegexCheckTrackingMatchers
-
- All Implemented Interfaces:
RegexCheck,JavaCheck,JavaFileScanner
- Direct Known Subclasses:
AbstractRegexCheckTrackingMatchType,UnusedGroupNamesCheck
public abstract class AbstractRegexCheckTrackingMatchers extends AbstractRegexCheck
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.sonar.java.regex.RegexCheck
RegexCheck.RegexIssueLocation
-
-
Field Summary
-
Fields inherited from class org.sonar.java.checks.regex.AbstractRegexCheck
JAVA_LANG_STRING, LANG3_REGEX_UTILS, METHODS_IMPLYING_DOT_ALL_FLAG, REGEX_METHODS, REGEX_ON_THE_SECOND_ARGUMENT_METHODS
-
Fields inherited from class org.sonar.java.ast.visitors.SubscriptionVisitor
context
-
-
Constructor Summary
Constructors Constructor Description AbstractRegexCheckTrackingMatchers()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcheckRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation)protected abstract voidcheckRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation, List<MethodInvocationTree> trackedMethodsCalled, boolean didEscape)voidleaveNode(Tree tree)List<Tree.Kind>nodesToVisit()protected voidonMethodInvocationFound(MethodInvocationTree mit)protected abstract MethodMatcherstrackedMethodMatchers()The methods for which we want to know whether they're invoked on the given regex.voidvisitNode(Tree tree)-
Methods inherited from class org.sonar.java.checks.regex.AbstractRegexCheck
filterAnnotation, getFinalVariableInitializer, getFlagsTree, getLiterals, getMethodInvocationMatchers, getRegexLiteralExpression, methodOrAnnotationName, onAnnotationFound, regexForLiterals, reportIssue, reportIssue, setContext
-
Methods inherited from class org.sonar.plugins.java.api.IssuableSubscriptionVisitor
addIssue, addIssueOnFile, reportIssue, reportIssue, reportIssue, scanTree
-
Methods inherited from class org.sonar.java.ast.visitors.SubscriptionVisitor
leaveFile, scanFile, visitToken, visitTrivia
-
-
-
-
Method Detail
-
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 checkedmethodInvocationOrAnnotation- The method invocation or annotation that the regex string is passed totrackedMethodsCalled- 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:
nodesToVisitin classAbstractRegexCheck
-
leaveNode
public void leaveNode(Tree tree)
- Overrides:
leaveNodein classSubscriptionVisitor
-
visitNode
public void visitNode(Tree tree)
- Overrides:
visitNodein classAbstractRegexCheck
-
onMethodInvocationFound
protected void onMethodInvocationFound(MethodInvocationTree mit)
- Overrides:
onMethodInvocationFoundin classAbstractRegexCheck
-
checkRegex
public void checkRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation)- Specified by:
checkRegexin classAbstractRegexCheck
-
-