@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { reportIssue(ExpressionUtils.methodName(mit), "Remove use of this unsecured \"getRequestedSessionId()\" method"); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { reportIssue(ExpressionUtils.methodName(mit), "Remove this call to \"isLast()\"."); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { reportIssue(ExpressionUtils.methodName(mit), "\"notify\" may not wake up the appropriate thread."); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { reportIssue(ExpressionUtils.methodName(mit), "Make sure that encrypting data is safe here."); } }
private void handleMethodInvocationTree(MethodInvocationTree tree) { if (METHOD_MATCHERS.anyMatch(tree)) { reportIssue(ExpressionUtils.methodName(tree)); } }
@Override public void visitMethodInvocation(MethodInvocationTree tree) { IdentifierTree methodNameTree = ExpressionUtils.methodName(tree); if (SIDE_EFFECT_METHOD_NAMES.matcher(methodNameTree.name()).find()) { reportIssue(methodNameTree, "Move this \"assert\" side effect to another statement."); } else { // only report once super.visitMethodInvocation(tree); } }
private void checkIncompatiblePropagation(MethodInvocationTree methodInvocation, @Nullable String callerPropagation, Symbol calleeMethodSymbol, String calleePropagation) { Set<String> incompatiblePropagation = INCOMPATIBLE_PROPAGATION_MAP.getOrDefault(callerPropagation, Collections.emptySet()); if (incompatiblePropagation.contains(calleePropagation)) { String message = "\"" + calleeMethodSymbol.name() + "'s\" @Transactional requirement is incompatible with the one for this method."; List<JavaFileScannerContext.Location> secondaryLocations = Collections.singletonList( new JavaFileScannerContext.Location("", ((MethodTree) calleeMethodSymbol.declaration()).simpleName())); reportIssue(ExpressionUtils.methodName(methodInvocation), message, secondaryLocations, null); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { String methodName = mit.symbol().name(); reportIssue(ExpressionUtils.methodName(mit), "Replace this with a call to the \"toFile()." + messageParam.get(methodName) + "()\" method"); }
private void checkIfUnknown(MethodInvocationTree mit) { if (mit.symbol().isUnknown()) { unresolvedMethodNames.add(ExpressionUtils.methodName(mit).name()); } }
private void checkMethodInvocation(MethodInvocationTree node) { Symbol symbol = node.symbol(); if (symbol.isMethodSymbol()) { List<Type> types = ((Symbol.MethodSymbol) symbol).thrownTypes(); if (!types.isEmpty()) { addIssueIfNotCatched(types, ExpressionUtils.methodName(node), "Add a \"try/catch\" block for \"" + symbol.name() + "\"."); } } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { if (!"openConnection".equals(mit.symbol().name()) || isCastToHttpUrlConnection(mit.parent())) { reportIssue(ExpressionUtils.methodName(mit), "Make sure that this http request is sent safely."); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { String stringConstant = ConstantUtils.resolveAsStringConstant(mit.arguments().get(0)); if (stringConstant == null) { reportIssue(ExpressionUtils.methodName(mit), "Remove this use of dynamic class loading."); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { Arguments arguments = mit.arguments(); // if at least one argument is provided the first argument is always the name if (arguments.isEmpty() || ConstantUtils.resolveAsStringConstant(arguments.get(0)) == null) { reportIssue(ExpressionUtils.methodName(mit), "Make sure that this dynamic injection or execution of code is safe."); } } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { if (mit.symbol().owner().type().is(SECRET_KEY_FACTORY)) { String algorithm = ConstantUtils.resolveAsStringConstant(mit.arguments().get(0)); if (algorithm == null || !algorithm.startsWith("PBKDF2")) { return; } } reportIssue(ExpressionUtils.methodName(mit), MESSAGE); }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { Type symbolType = mit.arguments().get(0).symbolType(); if (!(symbolType.is("long") || symbolType.is("java.lang.Long"))) { reportIssue(ExpressionUtils.methodName(mit), "Remove this \"Double.longBitsToDouble\" call."); } } }
private static boolean throwsNoSuchElementException(MethodInvocationTree methodInvocationTree) { Symbol symbol = methodInvocationTree.symbol(); if (!symbol.isMethodSymbol()) { return false; } if (throwsNoSuchElementException(((Symbol.MethodSymbol) symbol).thrownTypes())) { return true; } MethodJavaType methodJavaType = (MethodJavaType) ExpressionUtils.methodName(methodInvocationTree).symbolType(); return throwsNoSuchElementException(methodJavaType.thrownTypes()); }
@Override public void visitMethodInvocation(MethodInvocationTree tree) { Symbol method = tree.symbol(); if ("next".equals(method.name()) && tree.arguments().isEmpty() && isIteratorMethod(method) && (hasNextOwner == method.owner() || hasNextOwner.type().isSubtypeOf(method.owner().type()))) { reportIssue(ExpressionUtils.methodName(tree), "Refactor the implementation of this \"Iterator.hasNext()\" method to not call \"Iterator.next()\"."); } super.visitMethodInvocation(tree); }
@Override public void visitMethodInvocation(MethodInvocationTree tree) { if(tree.symbol().isMethodSymbol()) { Type type = tree.symbol().owner().type(); if (isCheckedType(type)) { reportIssue(ExpressionUtils.methodName(tree), "Remove this assertion."); } } super.visitMethodInvocation(tree); }
@Override public void visitMethodInvocation(MethodInvocationTree tree) { Symbol symbol = tree.symbol(); if (tree.methodSelect().is(Tree.Kind.IDENTIFIER) && isCallToSuperclassMethod(symbol)) { String methodName = ((IdentifierTree) tree.methodSelect()).name(); reportIssue(ExpressionUtils.methodName(tree), "Prefix this call to \"" + methodName + "\" with \"super.\"."); } super.visitMethodInvocation(tree); }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { if (COMMONS_IO_CHARSET_MATCHERS.anyMatch(mit)) { Arguments arguments = mit.arguments(); ExpressionTree lastArgument = arguments.get(arguments.size() - 1); testNullLiteralPassedForEncoding(lastArgument); } else if (FILEUTILS_WRITE_WITH_CHARSET_MATCHERS.anyMatch(mit)) { testNullLiteralPassedForEncoding(mit.arguments().get(2)); } else { reportIssue(ExpressionUtils.methodName(mit), "Remove this use of \"" + mit.symbol().name() + "\""); } }