Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.BugInstance


        case Constants.IF_ICMPEQ:
        case Constants.IF_ICMPNE:
            OpcodeStack.Item left = stack.getStackItem(1);
            OpcodeStack.Item right = stack.getStackItem(0);
            if (bad(left, right) || bad(right, left)) {
                accumulator.accumulateBug(new BugInstance(this, "TESTING", NORMAL_PRIORITY).addClassAndMethod(this)
                        .addValueSource(left, this).addValueSource(right, this)
                        .addString("Just check the sign of the result of compare or compareTo, not specific values such as 1 or -1"), this);
            }
            break;
        }
View Full Code Here


        InstructionHandle elseLastIns = elseFinishHandle.getPrev();
        if (elseLastIns != null) {
            elseFinishPos = elseLastIns.getPosition();
        }

        pendingBugs.add(new BugInstance(this, "DB_DUPLICATE_BRANCHES", NORMAL_PRIORITY)
        .addClassAndMethod(classContext.getJavaClass(), method)
        .addSourceLineRange(classContext, this, thenStartPos, thenFinishPos)
        .addSourceLineRange(classContext, this, elseStartPos, elseFinishPos));
    }
View Full Code Here

            updateMap(map, i, clauseAsInt);

        }
        for (Collection<Integer> clauses : map.values()) {
            if (clauses.size() > 1) {
                BugInstance bug = new BugInstance(this, "DB_DUPLICATE_SWITCH_CLAUSES", LOW_PRIORITY).addClassAndMethod(
                        classContext.getJavaClass(), method);
                for (int i : clauses)
                {
                    bug.addSourceLineRange(this.classContext, this, switchPos[i], switchPos[i + 1] - 1); // not
                }
                // endPos,
                // but
                // that's
                // ok
View Full Code Here

    @Override
    public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature,
            final String[] exceptions) {
        if (Character.isUpperCase(name.charAt(0))) {
            BugInstance bug0 = new BugInstance(this, "NM_METHOD_NAMING_CONVENTION", NORMAL_PRIORITY).addClass(this).addMethod(
                    this.name, name, desc, access);
            bugReporter.reportBug(bug0);
        }
        return new AbstractFBMethodVisitor() {
            int prevOpcode;

            int prevPC;

            @Override
            public void visitInsn(int opcode) {
                prevOpcode = opcode;
                prevPC = getPC();
            }

            @Override
            public void visitMethodInsn(int opcode, String owner, String invokedName, String invokedDesc, boolean itf) {
                if (prevPC + 1 == getPC() && prevOpcode == I2D && opcode == INVOKESTATIC && owner.equals("java/lang/Math")
                        && invokedName.equals("ceil") && invokedDesc.equals("(D)D")) {
                    BugInstance bug0 = new BugInstance(TestASM.this, "ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL", NORMAL_PRIORITY);
                    MethodAnnotation methodAnnotation = MethodAnnotation.fromForeignMethod(TestASM.this.name, name, desc, access);
                    bug0.addClass(TestASM.this).addMethod(methodAnnotation);
                    bugReporter.reportBug(bug0);
                }
            }
        };
View Full Code Here

    @Override
    public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
        if ((access & Opcodes.ACC_STATIC) != 0 && (access & Opcodes.ACC_FINAL) != 0 && (access & Opcodes.ACC_PUBLIC) != 0
                && !name.equals(name.toUpperCase())) {
            bugReporter.reportBug(new BugInstance(this, "NM_FIELD_NAMING_CONVENTION", Priorities.LOW_PRIORITY).addClass(this)
                    .addField(this.name, name, desc, access));
        }
        return null;
    }
View Full Code Here

        switch (seen) {
        case FMUL:
        case FDIV:
            if (getFullyQualifiedMethodName().indexOf("float") == -1 && getFullyQualifiedMethodName().indexOf("Float") == -1
            && getFullyQualifiedMethodName().indexOf("FLOAT") == -1) {
                bugReporter.reportBug(new BugInstance(this, "FL_MATH_USING_FLOAT_PRECISION", LOW_PRIORITY)
                .addClassAndMethod(this).addSourceLine(this));
            }
            break;
        case FCMPG:
        case FCMPL:
            break;
        case FADD:
        case FSUB:
        case FREM:
            if (getFullyQualifiedMethodName().indexOf("float") == -1 && getFullyQualifiedMethodName().indexOf("Float") == -1
            && getFullyQualifiedMethodName().indexOf("FLOAT") == -1) {
                bugReporter.reportBug(new BugInstance(this, "FL_MATH_USING_FLOAT_PRECISION", NORMAL_PRIORITY).addClassAndMethod(
                        this).addSourceLine(this));
            }
            break;
        default:
            break;
View Full Code Here

                            if (alreadyReported.contains(nameCons.getBytes())) {
                                return;
                            }
                            alreadyReported.add(nameCons.getBytes());
                            bugReporter.reportBug(new BugInstance(this,
                                    STRUTS_ACTION_NAME.equals(mtClassName) ? "MTIA_SUSPECT_STRUTS_INSTANCE_FIELD"
                                            : "MTIA_SUSPECT_SERVLET_INSTANCE_FIELD", LOW_PRIORITY)
                            .addField(
                                    new FieldAnnotation(getDottedClassName(), nameCons.getBytes(), typeCons.getBytes(),
                                            false)).addClass(this).addSourceLine(this));
View Full Code Here

        case GETFIELD:
            if (thisOnTOS && getClassConstantOperand().equals(getClassName()) && setFields.contains(getNameConstantOperand())
                    && asUnsignedByte(codeBytes[getPC() + 3]) == DUP && asUnsignedByte(codeBytes[getPC() + 5]) == MONITORENTER

                    && !finalFields.contains(getNameConstantOperand())) {
                bugReporter.reportBug(new BugInstance(this, "ML_SYNC_ON_UPDATED_FIELD", NORMAL_PRIORITY).addClassAndMethod(this)
                        .addReferencedField(this).addSourceLine(this, getPC() + 5));
            }
            break;
        default:
            break;
View Full Code Here

    }

    @Override
    public void visit(Method obj) {
        if (isReservedName(obj.getName())) {
            BugInstance bug = new BugInstance(this, "NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER", isVisible(obj) ? HIGH_PRIORITY
                    : NORMAL_PRIORITY).addClassAndMethod(this);
            bugReporter.reportBug(bug);
        }
    }
View Full Code Here

    }

    @Override
    public void visit(Field obj) {
        if (isReservedName(obj.getName())) {
            BugInstance bug = new BugInstance(this, "NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER", isVisible(obj) ? HIGH_PRIORITY
                    : NORMAL_PRIORITY).addClass(this).addField(this);
            bugReporter.reportBug(bug);
        }
    }
View Full Code Here

TOP

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

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.