Package org.sonar.java.checks
Class AbstractPrintfChecker
- java.lang.Object
-
- org.sonar.java.ast.visitors.SubscriptionVisitor
-
- org.sonar.plugins.java.api.IssuableSubscriptionVisitor
-
- org.sonar.java.checks.methods.AbstractMethodDetection
-
- org.sonar.java.checks.AbstractPrintfChecker
-
- All Implemented Interfaces:
JavaCheck,JavaFileScanner
- Direct Known Subclasses:
PrintfFailCheck,PrintfMisuseCheck
public abstract class AbstractPrintfChecker extends AbstractMethodDetection
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringJAVA_LANG_STRINGprotected static MethodMatcherJAVA_UTIL_LOGGERprotected static StringJAVA_UTIL_LOGGING_LOGGERprotected static List<String>LEVELSprotected static MethodMatcherMESSAGE_FORMATprotected static PatternMESSAGE_FORMAT_PATTERNprotected static StringORG_APACHE_LOGGING_LOG4J_LOGGER-
Fields inherited from class org.sonar.java.ast.visitors.SubscriptionVisitor
context
-
-
Constructor Summary
Constructors Constructor Description AbstractPrintfChecker()
-
Method Summary
-
Methods inherited from class org.sonar.java.checks.methods.AbstractMethodDetection
nodesToVisit, onConstructorFound, onMethodInvocationFound, onMethodReferenceFound, visitNode
-
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
hasSemantic, leaveFile, leaveNode, scanFile, setContext, visitToken, visitTrivia
-
-
-
-
Field Detail
-
JAVA_LANG_STRING
protected static final String JAVA_LANG_STRING
- See Also:
- Constant Field Values
-
JAVA_UTIL_LOGGING_LOGGER
protected static final String JAVA_UTIL_LOGGING_LOGGER
- See Also:
- Constant Field Values
-
ORG_APACHE_LOGGING_LOG4J_LOGGER
protected static final String ORG_APACHE_LOGGING_LOG4J_LOGGER
- See Also:
- Constant Field Values
-
MESSAGE_FORMAT
protected static final MethodMatcher MESSAGE_FORMAT
-
JAVA_UTIL_LOGGER
protected static final MethodMatcher JAVA_UTIL_LOGGER
-
MESSAGE_FORMAT_PATTERN
protected static final Pattern MESSAGE_FORMAT_PATTERN
-
-
Method Detail
-
getMethodInvocationMatchers
protected List<MethodMatcher> getMethodInvocationMatchers()
- Specified by:
getMethodInvocationMatchersin classAbstractMethodDetection
-
checkFormatting
protected final void checkFormatting(MethodInvocationTree mit, boolean isMessageFormat)
-
handlePrintfFormat
protected abstract void handlePrintfFormat(MethodInvocationTree mit, String formatString, List<ExpressionTree> args)
-
handleMessageFormat
protected abstract void handleMessageFormat(MethodInvocationTree mit, String formatString, List<ExpressionTree> args)
-
handleOtherFormatTree
protected abstract void handleOtherFormatTree(MethodInvocationTree mit, ExpressionTree formatTree)
-
isNewArrayWithInitializers
protected static boolean isNewArrayWithInitializers(ExpressionTree expression)
-
getMessageFormatIndexes
protected static Set<Integer> getMessageFormatIndexes(String formatString, MethodInvocationTree mit)
-
getParameters
protected List<String> getParameters(String formatString, MethodInvocationTree mit)
-
reportMissingPrevious
protected void reportMissingPrevious(MethodInvocationTree mit)
-
-