Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.BugInstance$BugPropertyIterator


            if (isConstant(fcb.item0, bb) && isConstant(fcb.item1, bb)) {
                SourceLineAnnotation loopBottom = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this, bb.from);
                int loopBottomLine = loopBottom.getStartLine();
                SourceLineAnnotation loopTop = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this, bb.to);
                int loopTopLine = loopTop.getStartLine();
                BugInstance bug = new BugInstance(this, "IL_INFINITE_LOOP", HIGH_PRIORITY).addClassAndMethod(this)
                        .addSourceLine(this, fcb.from).addSourceLine(loopBottom)
                        .describe(SourceLineAnnotation.DESCRIPTION_LOOP_BOTTOM);
                int reg0 = fcb.item0.getRegisterNumber();
                boolean reg0Invariant = true;
                if (reg0 >= 0 && fcb.item0.getConstant() == null) {
                    reg0Invariant = !isRegModified(reg0, myBackwardsReach, bb.from);
                    SourceLineAnnotation lastChange = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this,
                            constantSince(fcb.item0));
                    int lastChangeLine = lastChange.getEndLine();
                    if (loopBottomLine != -1 && lastChangeLine != -1 && loopTopLine != -1 && loopTopLine <= lastChangeLine
                            && lastChangeLine < loopBottomLine) {
                        continue backwardBranchLoop;
                    }
                    bug.add(LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), reg0, fcb.from, bb.from))
                    .addSourceLine(lastChange).describe(SourceLineAnnotation.DESCRIPTION_LAST_CHANGE);
                }
                int reg1 = fcb.item1.getRegisterNumber();
                if (reg1 >= 0 && reg1 != reg0 && fcb.item1.getConstant() == null) {
                    SourceLineAnnotation lastChange = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this,
                            constantSince(fcb.item1));
                    int lastChangeLine = lastChange.getEndLine();
                    if (loopBottomLine != -1 && lastChangeLine != -1 && loopTopLine != -1 && loopTopLine <= lastChangeLine
                            && lastChangeLine < loopBottomLine) {
                        continue backwardBranchLoop;
                    }
                    bug.add(LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), reg1, fcb.from, bb.from))
                    .addSourceLine(lastChange).describe(SourceLineAnnotation.DESCRIPTION_LAST_CHANGE);
                }
                boolean reg1Invariant = true;
                if (reg1 >= 0) {
                    reg1Invariant = !isRegModified(reg1, myBackwardsReach, bb.from);
View Full Code Here


                break;
            }

            if (constantSince(item0, target)) {
                int since0 = constantSince(item0);
                BugInstance bug = new BugInstance(this, "IL_INFINITE_LOOP", HIGH_PRIORITY).addClassAndMethod(this).addSourceLine(
                        this, getPC());
                int reg0 = item0.getRegisterNumber();
                if (reg0 >= 0) {
                    bug.add(LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), reg0, getPC(), target))
                    .addSourceLine(this, since0);
                }
                if (reg0 < 0 || !isRegModified(reg0, target, getPC())) {
                    reportPossibleBug(bug);
                }

            }
        }
        break;
        case IF_ACMPEQ:
        case IF_ACMPNE:
        case IF_ICMPNE:
        case IF_ICMPEQ:
        case IF_ICMPGT:
        case IF_ICMPLE:
        case IF_ICMPLT:
        case IF_ICMPGE: {
            addBackwardsReach();
            OpcodeStack.Item item0 = stack.getStackItem(0);
            OpcodeStack.Item item1 = stack.getStackItem(1);
            int target = getBranchTarget();
            if (getBranchOffset() > 0) {
                forwardConditionalBranches.add(new ForwardConditionalBranch(item0, item1, getPC(), target));
                break;
            }
            if (getFurthestJump(target) > getPC()) {
                break;
            }

            if (constantSince(item0, target) && constantSince(item1, target)) {
                // int since0 = constantSince(item0);
                // int since1 = constantSince(item1);
                BugInstance bug = new BugInstance(this, "IL_INFINITE_LOOP", HIGH_PRIORITY).addClassAndMethod(this).addSourceLine(
                        this, getPC());
                int reg0 = item0.getRegisterNumber();
                if (reg0 >= 0) {
                    bug.add(LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), reg0, getPC(), target));
                }
                int reg1 = item1.getRegisterNumber();
                if (reg1 >= 0) {
                    bug.add(LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), reg1, getPC(), target));
                }

                reportPossibleBug(bug);
            }
View Full Code Here

        //         System.out.println("Investigating " + getFullyQualifiedMethodName());
        returnSelf = returnOther = updates = returnNew = returnUnknown = 0;

        if (testingEnabled && REPORT_INFERRED_METHODS
                && AnalysisContext.currentAnalysisContext().isApplicationClass(getThisClass())) {
            inferredMethod = new BugInstance("TESTING", NORMAL_PRIORITY).addClassAndMethod(this);
        } else {
            inferredMethod = null;
        }
        super.visit(code); // make callbacks to sawOpcode for all opcodes
        //         System.out.printf("  %3d %3d %3d %3d%n", returnSelf, updates, returnOther, returnNew);
View Full Code Here

    @Override
    public void sawBranchTo(int target) {
        Iterator<BugInstance> i = pendingBugs.iterator();
        while (i.hasNext()) {
            BugInstance bug = i.next();
            if (bug.getPrimarySourceLineAnnotation().getStartBytecode() >= target) {
                i.remove();
            }
        }
    }
View Full Code Here

                        priority++;
                        priorityLoweredBecauseOfIfNonnullTest = true;
                    }
                }

                BugInstance bug = new BugInstance(this, "UR_UNINIT_READ", priority).addClassAndMethod(this).addField(f)
                        .addOptionalAnnotation(possibleTarget).addSourceLine(this);
                pendingBugs.add(bug);
                if (priorityLoweredBecauseOfIfNonnullTest) {
                    uninitializedFieldReadAndCheckedForNonnull = bug;
                }
View Full Code Here

                if (getMethod().isStatic() && getMethodName().equals("main") && getMethodSig().equals("([Ljava/lang/String;)V")) {
                    priority = NORMAL_PRIORITY;
                }

                OpcodeStack.Item item = stack.getItemMethodInvokedOn(this);
                BugInstance bug = new BugInstance(this, "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE", priority)
                .addClassAndMethod(this).addValueSource(item, this);
                bugAccumulator.accumulateBug(bug, this);
                break;
            }
            checkForImport();
View Full Code Here

        sawNotify = false;
        earliestJump = 9999999;
        super.visit(obj);
        if ((sawWait || sawAwait) && waitAt < earliestJump) {
            String bugType = sawWait ? "WA_NOT_IN_LOOP" : "WA_AWAIT_NOT_IN_LOOP";
            bugReporter.reportBug(new BugInstance(this, bugType, waitHasTimeout ? LOW_PRIORITY : NORMAL_PRIORITY)
            .addClassAndMethod(this).addSourceLine(this, waitAt));
        }
        if (sawNotify) {
            bugReporter.reportBug(new BugInstance(this, "NO_NOTIFY_NOT_NOTIFYALL", LOW_PRIORITY).addClassAndMethod(this)
                    .addSourceLine(this, notifyPC));
        }
    }
View Full Code Here

            String leakClass = stream.getStreamBase();
            if (isMainMethod(method) && (leakClass.contains("InputStream") || leakClass.contains("Reader"))) {
                return;
            }

            bugAccumulator.accumulateBug(new BugInstance(this, pos.bugType, pos.priority)
            .addClassAndMethod(methodGen, sourceFile).addTypeOfNamedClass(leakClass)
            .describe(TypeAnnotation.CLOSEIT_ROLE), SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen,
                    sourceFile, stream.getLocation().getHandle()));
        }
    }
View Full Code Here

                    }
                    int priority = NORMAL_PRIORITY;
                    if (getNameConstantOperand().equals("asList") && getClassConstantOperand().equals("java/util/Arrays")) {
                        priority = HIGH_PRIORITY;
                    }
                    bugReporter.reportBug(new BugInstance(this, "VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG", priority)
                    .addClassAndMethod(this).addType(primitiveArraySig).describe(TypeAnnotation.FOUND_ROLE)
                    .addCalledMethod(this).addSourceLine(this));
                }
                state = SEEN_NOTHING;
                break;
View Full Code Here

                if (minimumDistance > 0.6 && (matches > 1 || storeOfDefaultValue)) {
                    intendedTarget = null;
                } else if (intendedTarget != null) {
                    priority--;
                }
                BugInstance bug = new BugInstance(this, "SA_FIELD_DOUBLE_ASSIGNMENT", priority).addClassAndMethod(this)
                        .addReferencedField(this);
                if (intendedTarget != null) {
                    bug.addField(intendedTarget).describe(FieldAnnotation.DID_YOU_MEAN_ROLE);
                }

                bugAccumulator.accumulateBug(bug, this);
            }
            putFieldPC = getPC();
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.BugInstance$BugPropertyIterator

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.