Class AbstractRegexCheck
java.lang.Object
org.sonar.java.ast.visitors.SubscriptionVisitor
org.sonar.plugins.java.api.IssuableSubscriptionVisitor
org.sonar.java.checks.regex.AbstractRegexCheck
- All Implemented Interfaces:
RegexCheck,JavaCheck,JavaFileScanner
- Direct Known Subclasses:
AbstractRegexCheckTrackingMatchers,AnchorPrecedenceCheck,CanonEqFlagInRegexCheck,DuplicatesInCharacterClassCheck,EmptyLineRegexCheck,EmptyRegexGroupCheck,EmptyStringRepetitionCheck,EscapeSequenceControlCharacterCheck,GraphemeClustersInClassesCheck,ImpossibleBackReferenceCheck,ImpossibleBoundariesCheck,InvalidRegexCheck,MultipleWhitespaceCheck,PossessiveQuantifierContinuationCheck,RedundantRegexAlternativesCheck,RegexComplexityCheck,RegexStackOverflowCheck,ReluctantQuantifierCheck,SingleCharacterAlternationCheck,SingleCharCharacterClassCheck,StringReplaceCheck,SuperfluousCurlyBraceCheck,UnicodeAwareCharClassesCheck,UnicodeCaseCheck,UnquantifiedNonCapturingGroupCheck,VerboseRegexCheck
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.sonar.java.regex.RegexCheck
RegexCheck.RegexIssueLocation -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final MethodMatchersprotected static final MethodMatchersprotected static final MethodMatchersFields inherited from class org.sonar.java.ast.visitors.SubscriptionVisitor
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidcheckRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation) protected 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 voidprotected 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) voidMethods inherited from class org.sonar.plugins.java.api.IssuableSubscriptionVisitor
addIssue, addIssueOnFile, leaveFile, reportIssue, reportIssue, reportIssue, reportIssue, scanFile, scanTreeMethods inherited from class org.sonar.java.ast.visitors.SubscriptionVisitor
leaveNode, visitToken, visitTriviaMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.sonar.plugins.java.api.JavaFileScanner
scanWithoutParsing
-
Field Details
-
JAVA_LANG_STRING
- See Also:
-
LANG3_REGEX_UTILS
- See Also:
-
REGEX_ON_THE_SECOND_ARGUMENT_METHODS
-
METHODS_IMPLYING_DOT_ALL_FLAG
-
REGEX_METHODS
-
-
Constructor Details
-
AbstractRegexCheck
public AbstractRegexCheck()
-
-
Method Details
-
setContext
- Overrides:
setContextin classIssuableSubscriptionVisitor
-
nodesToVisit
- Specified by:
nodesToVisitin classSubscriptionVisitor
-
getMethodInvocationMatchers
-
filterAnnotation
-
visitNode
- Overrides:
visitNodein classSubscriptionVisitor
-
onMethodInvocationFound
-
getRegexLiteralExpression
@Nullable protected ExpressionTree getRegexLiteralExpression(ExpressionTree methodInvocationOrAnnotation) -
onAnnotationFound
-
regexForLiterals
protected final org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals(org.sonarsource.analyzer.commons.regex.ast.FlagSet flags, LiteralTree... literals) -
getLiterals
-
getFinalVariableInitializer
-
checkRegex
public abstract void checkRegex(org.sonarsource.analyzer.commons.regex.RegexParseResult regexForLiterals, ExpressionTree methodInvocationOrAnnotation) -
reportIssue
public final void reportIssue(org.sonarsource.analyzer.commons.regex.ast.RegexSyntaxElement regexTree, String message, @Nullable Integer cost, List<RegexCheck.RegexIssueLocation> secondaries) -
reportIssueFromCommons
-
methodOrAnnotationName
-
reportIssue
public final void reportIssue(Tree javaTree, String message, @Nullable Integer cost, List<RegexCheck.RegexIssueLocation> secondaries) -
getFlagsTree
- Parameters:
methodInvocationOrAnnotation- A method call or annotation constructing a regex.- Returns:
- An optional containing the expression used to set the regex's flag if the regex is created using Pattern.compile or "flags" annotation parameter with an argument to set the flags. An empty optional otherwise.
-