Package edu.umd.cs.findbugs.ba

Examples of edu.umd.cs.findbugs.ba.CheckReturnValueAnnotation


        if (seen == NEW) {
            previousOpcodeWasNEW = true;
        } else {
            if (seen == INVOKESPECIAL && previousOpcodeWasNEW) {
                CheckReturnValueAnnotation annotation = checkReturnAnnotationDatabase.getResolvedAnnotation(callSeen, false);
                if (annotation != null && annotation != CheckReturnValueAnnotation.CHECK_RETURN_VALUE_IGNORE) {
                    int priority = annotation.getPriority();
                    if (!checkReturnAnnotationDatabase.annotationIsDirect(callSeen)
                            && !callSeen.getSignature().endsWith(callSeen.getClassName().replace('.', '/') + ";")) {
                        priority++;
                    }
                    bugAccumulator.accumulateBug(new BugInstance(this, annotation.getPattern(), priority).addClassAndMethod(this)
                            .addCalledMethod(this), this);
                }

            }
            previousOpcodeWasNEW = false;
View Full Code Here


    /**
     *
     */
    private void sawMethodCallWithIgnoredReturnValue() {
        {
            CheckReturnValueAnnotation annotation = checkReturnAnnotationDatabase.getResolvedAnnotation(callSeen, false);
            if (annotation == null) {
                XFactory xFactory = AnalysisContext.currentXFactory();

                if (xFactory.isFunctionshatMightBeMistakenForProcedures(callSeen.getMethodDescriptor())) {
                    annotation = CheckReturnValueAnnotation.CHECK_RETURN_VALUE_INFERRED;
                }
            }
            if (annotation != null && annotation.getPriority() <= LOW_PRIORITY) {
                int popPC = getPC();
                if (DEBUG) {
                    System.out.println("Saw POP @" + popPC);
                }
                int catchSize = getSizeOfSurroundingTryBlock(popPC);

                int priority = annotation.getPriority();
                if (catchSize <= 1) {
                    priority += 2;
                } else if (catchSize <= 2) {
                    priority += 1;
                }
                if (!checkReturnAnnotationDatabase.annotationIsDirect(callSeen)
                        && !callSeen.getSignature().endsWith(callSeen.getClassName().replace('.', '/') + ";")) {
                    priority++;
                }
                if (callSeen.isPrivate()) {
                    priority++;
                }
                if (callSeen.getName().equals("clone") || callSeen.getName().startsWith("get")) {
                    priority++;
                }
                String pattern = annotation.getPattern();
                if (callSeen.getName().equals("<init>")
                        && (callSeen.getClassName().endsWith("Exception") || callSeen.getClassName().endsWith("Error"))) {
                    pattern = "RV_EXCEPTION_NOT_THROWN";
                }
                BugInstance warning = new BugInstance(this, pattern, priority).addClassAndMethod(this).addMethod(callSeen)
View Full Code Here

            }

            return;
        }

        CheckReturnValueAnnotation n;

        if (annotationClassName.equals(javax.annotation.CheckReturnValue.class.getName())) {
            ElementValue v = map.get("when");
            if (v instanceof EnumElementValue) {
                EnumElementValue when = (EnumElementValue) v;
View Full Code Here

    }

    private void handleClassElementValue(ClassElementValue value, Map<String, ElementValue> map, Target annotationTarget) {
        if (simpleClassName(value.getClassString()).equals("CheckReturnValue")) {
            CheckReturnValueAnnotation n = CheckReturnValueAnnotation.parse(getAnnotationParameterAsString(map, "priority"));
            if (n != null) {
                AnalysisContext.currentAnalysisContext().getCheckReturnAnnotationDatabase()
                .addDefaultAnnotation(annotationTarget, getDottedClassName(), n);
            }
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.CheckReturnValueAnnotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.