Class UnusedGroupNamesCheck
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
org.sonar.java.checks.regex.UnusedGroupNamesCheck
- All Implemented Interfaces:
RegexCheck, JavaCheck, JavaFileScanner
-
Nested Class Summary
Nested classes/interfaces inherited from interface RegexCheck
RegexCheck.RegexIssueLocation -
Field Summary
Fields inherited from class AbstractRegexCheck
JAVA_LANG_STRING, LANG3_REGEX_UTILS, METHODS_IMPLYING_DOT_ALL_FLAG, REGEX_METHODS, REGEX_ON_THE_SECOND_ARGUMENT_METHODSModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final MethodMatchersprotected static final MethodMatchersprotected static final MethodMatchersFields inherited from class SubscriptionVisitor
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation, List<MethodInvocationTree> trackedMethodsCalled, boolean didEscape) protected MethodMatchersThe methods for which we want to know whether they're invoked on the given regex.Methods inherited from class AbstractRegexCheckTrackingMatchers
checkRegex, leaveNode, nodesToVisit, onMethodInvocationFound, visitNodeModifier and TypeMethodDescriptionvoidcheckRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation) voidprotected voidvoidMethods inherited from class AbstractRegexCheck
filterAnnotation, getFinalVariableInitializer, getFlagsTree, getLiterals, getMethodInvocationMatchers, getRegexLiteralExpression, methodOrAnnotationName, onAnnotationFound, regexForLiterals, reportIssue, reportIssue, reportIssueFromCommons, setContextModifier and TypeMethodDescriptionprotected booleanfilterAnnotation(AnnotationTree annotation) protected static Optional<ExpressionTree> getFinalVariableInitializer(IdentifierTree identifier) protected static Optional<ExpressionTree> getFlagsTree(ExpressionTree methodInvocationOrAnnotation) protected static Optional<LiteralTree[]> getLiterals(ExpressionTree expr) protected MethodMatchersprotected ExpressionTreegetRegexLiteralExpression(ExpressionTree methodInvocationOrAnnotation) methodOrAnnotationName(ExpressionTree methodInvocationOrAnnotation) protected voidonAnnotationFound(AnnotationTree annotation) protected final org.sonarsource.analyzer.commons.regex.RegexParseResultregexForLiterals(org.sonarsource.analyzer.commons.regex.ast.FlagSet flags, LiteralTree... literals) final voidreportIssue(Tree javaTree, String message, Integer cost, List<RegexCheck.RegexIssueLocation> secondaries) final voidreportIssue(org.sonarsource.analyzer.commons.regex.ast.RegexSyntaxElement regexTree, String message, Integer cost, List<RegexCheck.RegexIssueLocation> secondaries) final voidreportIssueFromCommons(org.sonarsource.analyzer.commons.regex.ast.RegexSyntaxElement regexTree, String message, Integer cost, List<org.sonarsource.analyzer.commons.regex.RegexIssueLocation> secondaries) final voidsetContext(JavaFileScannerContext context) Methods inherited from class IssuableSubscriptionVisitor
addIssue, addIssueOnFile, leaveFile, reportIssue, reportIssue, reportIssue, reportIssue, scanFile, scanTreeMethods inherited from class SubscriptionVisitor
visitToken, visitTriviaMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface JavaFileScanner
scanWithoutParsing
-
Constructor Details
-
UnusedGroupNamesCheck
public UnusedGroupNamesCheck()
-
-
Method Details
-
trackedMethodMatchers
Description copied from class:AbstractRegexCheckTrackingMatchersThe 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.- Specified by:
trackedMethodMatchersin classAbstractRegexCheckTrackingMatchers
-
checkRegex
protected void checkRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation, List<MethodInvocationTree> trackedMethodsCalled, boolean didEscape) - Specified by:
checkRegexin classAbstractRegexCheckTrackingMatchers- 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.
-