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 final Stringprotected static final Stringprotected static final MethodMatchersprotected static final Patternprotected static final Stringprotected static final Stringprotected static final 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 final 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>> 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, leaveFile, reportIssue, reportIssue, reportIssue, scanFile, scanTree, setContextMethods 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:
-
JAVA_LANG_THROWABLE
- See Also:
-
ORG_APACHE_LOGGING_LOG4J_LOGGER
- See Also:
-
PRINTF_METHOD_NAME
- See Also:
-
LEVELS
-
MESSAGE_FORMAT
-
STRING_FORMATTED
-
MESSAGE_FORMAT_PATTERN
-
MESSAGE_FORMAT_PATTERN_PREDICATE
-
-
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)
-