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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Stringprotected static Stringprotected static MethodMatchersprotected static Patternprotected static Stringprotected static Stringprotected static MethodMatchersFields inherited from class org.sonar.java.ast.visitors.SubscriptionVisitor
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionargIndexes(List<String> params)protected booleancheckArgumentNumber(MethodInvocationTree mit, int nbReadParams, int nbArgs)protected voidcheckFormatting(MethodInvocationTree mit, boolean isMessageFormat)protected static StringcleanupDoubleQuote(String formatString)protected static voidcleanupLineSeparator(List<String> params)protected static IntegergetMessageFormatIndexes(String formatString, MethodInvocationTree mit)protected MethodMatchersgetParameters(String formatString, MethodInvocationTree mit)protected abstract voidhandleMessageFormat(MethodInvocationTree mit, String formatString, List<ExpressionTree> args)protected abstract voidhandleOtherFormatTree(MethodInvocationTree mit, ExpressionTree formatTree, List<ExpressionTree> args)protected abstract voidhandlePrintfFormat(MethodInvocationTree mit, String formatString, List<ExpressionTree> args)protected abstract voidhandlePrintfFormatCatchingErrors(MethodInvocationTree mit, String formatString, List<ExpressionTree> args)protected static booleanisNewArrayWithInitializers(ExpressionTree expression)protected voidprotected static Optional<List<ExpressionTree>>transposeArgumentArray(List<ExpressionTree> args)protected voidverifyParametersForErrors(MethodInvocationTree mit, List<ExpressionTree> args, List<String> params)Methods inherited from class org.sonar.java.checks.methods.AbstractMethodDetection
nodesToVisit, onConstructorFound, onMethodInvocationFound, onMethodReferenceFound, visitNodeMethods inherited from class org.sonar.plugins.java.api.IssuableSubscriptionVisitor
addIssue, addIssueOnFile, reportIssue, reportIssue, reportIssue, scanTreeMethods inherited from class org.sonar.java.ast.visitors.SubscriptionVisitor
leaveFile, leaveNode, scanFile, setContext, visitToken, visitTrivia
-
Field Details
-
JAVA_LANG_STRING
- See Also:
- Constant Field Values
-
JAVA_LANG_THROWABLE
- See Also:
- Constant Field Values
-
ORG_APACHE_LOGGING_LOG4J_LOGGER
- See Also:
- Constant Field Values
-
PRINTF_METHOD_NAME
- See Also:
- Constant Field Values
-
LEVELS
-
MESSAGE_FORMAT
-
STRING_FORMATTED
-
MESSAGE_FORMAT_PATTERN
-
-
Constructor Details
-
AbstractPrintfChecker
public AbstractPrintfChecker()
-
-
Method Details
-
getMethodInvocationMatchers
- Specified by:
getMethodInvocationMatchersin classAbstractMethodDetection
-
checkFormatting
-
transposeArgumentArray
-
handlePrintfFormat
protected abstract void handlePrintfFormat(MethodInvocationTree mit, String formatString, List<ExpressionTree> args) -
handlePrintfFormatCatchingErrors
protected abstract void handlePrintfFormatCatchingErrors(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, List<ExpressionTree> args) -
isNewArrayWithInitializers
-
cleanupDoubleQuote
-
getMessageFormatIndexes
protected static Set<Integer> getMessageFormatIndexes(String formatString, MethodInvocationTree mit) -
getParameters
-
reportMissingPrevious
-
getIndex
-
cleanupLineSeparator
-
argIndexes
-
checkArgumentNumber
-
verifyParametersForErrors
protected void verifyParametersForErrors(MethodInvocationTree mit, List<ExpressionTree> args, List<String> params)
-