当前位置: 首页>>代码示例>>Java>>正文


Java Priorities.HIGH_PRIORITY属性代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.Priorities.HIGH_PRIORITY属性的典型用法代码示例。如果您正苦于以下问题:Java Priorities.HIGH_PRIORITY属性的具体用法?Java Priorities.HIGH_PRIORITY怎么用?Java Priorities.HIGH_PRIORITY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在edu.umd.cs.findbugs.Priorities的用法示例。


在下文中一共展示了Priorities.HIGH_PRIORITY属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkForCompatibleLongComparison

private void checkForCompatibleLongComparison(OpcodeStack.Item left, OpcodeStack.Item right) {
    if (left.getSpecialKind() == Item.RESULT_OF_I2L && right.getConstant() != null) {
        long value = ((Number) right.getConstant()).longValue();
        if ( (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE)) {
            int priority  = Priorities.HIGH_PRIORITY;
            if (value == Integer.MAX_VALUE+1 || value == Integer.MIN_VALUE -1)
                priority = Priorities.NORMAL_PRIORITY;
            String stringValue = IntAnnotation.getShortInteger(value)+"L";
            if (value == 0xffffffffL)
                stringValue = "0xffffffffL";
            else if (value == 0x80000000L)
                stringValue = "0x80000000L";
            accumulator.accumulateBug(new BugInstance(this, "INT_BAD_COMPARISON_WITH_INT_VALUE", priority ).addClassAndMethod(this)
                    .addString(stringValue).describe(StringAnnotation.STRING_NONSTRING_CONSTANT_ROLE)
                    .addValueSource(left, this) , this);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:18,代码来源:DumbMethods.java

示例2: getPriority

public int getPriority() {
    int hash = getHash();

    if ((hash & 0x1ff0) == 0) {
        hash = hash & 0xf;
        if (hash < 1)
            return Priorities.HIGH_PRIORITY;
        else if (hash < 1 + 2)
            return Priorities.NORMAL_PRIORITY;
        else if (hash < 1 + 2 + 4)
            return Priorities.LOW_PRIORITY;
        else
            return Priorities.IGNORE_PRIORITY;
    } else
        return Priorities.IGNORE_PRIORITY + 1;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:16,代码来源:Noise.java

示例3: getIntPriorityAsString

/**
 * Convert an integer warning priority threshold value to a String.
 */
public static String getIntPriorityAsString(int prio) {
    String minPriority;
    switch (prio) {
    case Priorities.EXP_PRIORITY:
        minPriority = ProjectFilterSettings.EXPERIMENTAL_PRIORITY;
        break;
    case Priorities.LOW_PRIORITY:
        minPriority = ProjectFilterSettings.LOW_PRIORITY;
        break;
    case Priorities.NORMAL_PRIORITY:
        minPriority = ProjectFilterSettings.MEDIUM_PRIORITY;
        break;
    case Priorities.HIGH_PRIORITY:
        minPriority = ProjectFilterSettings.HIGH_PRIORITY;
        break;
    default:
        minPriority = ProjectFilterSettings.DEFAULT_PRIORITY;
        break;
    }
    return minPriority;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:24,代码来源:ProjectFilterSettings.java

示例4: taintPriority

private int taintPriority(OpcodeStack.Item writing) {
    if (writing == null)
        return Priorities.NORMAL_PRIORITY;
    XMethod method = writing.getReturnValueOf();
    if (method != null && method.getName().equals("getParameter")
            && method.getClassName().equals("javax.servlet.http.HttpServletRequest"))
        return Priorities.HIGH_PRIORITY;
    return Priorities.NORMAL_PRIORITY;

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:10,代码来源:CrossSiteScripting.java

示例5: visit

@Override
public void visit(Code code) {
    boolean interesting = getMethodName().equals("<init>") || getMethodName().equals("<clinit>");
    if (!interesting)
        return;

    secondaryConstructor = false;
    HashSet<XField> needToInitialize = getMethod().isStatic() ? nonnullStaticFields : nonnullFields;
    if (needToInitialize.isEmpty())
        return;
    // initialize any variables we want to initialize for the method
    super.visit(code); // make callbacks to sawOpcode for all opcodes
    if (!secondaryConstructor && !initializedFields.containsAll(needToInitialize)) {
        int priority = Priorities.NORMAL_PRIORITY;
        if (needToInitialize.size() - initializedFields.size() == 1 && needToInitialize.size() > 1)
            priority = Priorities.HIGH_PRIORITY;

        for (XField f : needToInitialize) {
            if (initializedFields.contains(f))
                continue;

            BugInstance b = new BugInstance(this, "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", priority)
                    .addClassAndMethod(this).addField(f);
            bugReporter.reportBug(b);
        }

    }
    initializedFields.clear();

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:30,代码来源:InitializeNonnullFieldsInConstructor.java

示例6: handleSuspiciousRefComparison

private void handleSuspiciousRefComparison(JavaClass jclass, Method method, MethodGen methodGen,
        List<WarningWithProperties> refComparisonList, Location location, String lhs, ReferenceType lhsType,
        ReferenceType rhsType) {
    XField xf = null;
    if (lhsType instanceof FinalConstant)
        xf = ((FinalConstant) lhsType).getXField();
    else if (rhsType instanceof FinalConstant)
        xf = ((FinalConstant) rhsType).getXField();
    String sourceFile = jclass.getSourceFileName();
    String bugPattern = "RC_REF_COMPARISON";
    int priority = Priorities.HIGH_PRIORITY;
    if (lhs.equals("java.lang.Boolean")) {
        bugPattern = "RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN";
        priority = Priorities.NORMAL_PRIORITY;
    } else if (xf != null && xf.isStatic() && xf.isFinal()) {
        bugPattern = "RC_REF_COMPARISON_BAD_PRACTICE";
        if (xf.isPublic() || !methodGen.isPublic())
            priority = Priorities.NORMAL_PRIORITY;
    }
    BugInstance instance = new BugInstance(this, bugPattern, priority).addClassAndMethod(methodGen, sourceFile)
            .addType("L" + lhs.replace('.', '/') + ";").describe(TypeAnnotation.FOUND_ROLE);
    if (xf != null)
        instance.addField(xf).describe(FieldAnnotation.LOADED_FROM_ROLE);
    else
        instance.addSomeSourceForTopTwoStackValues(classContext, method, location);
    SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen,
            sourceFile, location.getHandle());
    if (sourceLineAnnotation != null)
        refComparisonList.add(new WarningWithProperties(instance, new WarningPropertySet<WarningProperty>(),
                sourceLineAnnotation, location));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:31,代码来源:FindRefComparison.java

示例7: sawOpcode

@Override
public void sawOpcode(int seen) {
    // System.out.println(state + " " + getPC() + " " + OPCODE_NAMES[seen]);
    if (countDown == 2 && seen == GOTO) {
        CodeException tryBlock = getSurroundingTryBlock(getPC());
        if (tryBlock != null && tryBlock.getEndPC() == getPC())
            pendingBug.lowerPriority();
    }
    if (countDown > 0) {
        countDown--;
        if (countDown == 0) {
            if (seen == MONITOREXIT)
                pendingBug.lowerPriority();

            bugReporter.reportBug(pendingBug);
            pendingBug = null;
        }
    }
    if (seen == PUTFIELD) {

        if (syncField != null && getPrevOpcode(1) != ALOAD_0 && syncField.equals(getXFieldOperand())) {
            OpcodeStack.Item value = stack.getStackItem(0);
            int priority = Priorities.HIGH_PRIORITY;
            if (value.isNull())
                priority = Priorities.NORMAL_PRIORITY;
            pendingBug = new BugInstance(this, "ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD", priority)
                    .addClassAndMethod(this).addField(syncField).addSourceLine(this);
            countDown = 2;

        }

    }
    if (seen == MONITOREXIT) {
        pendingBug = null;
        countDown = 0;
    }

    if (seen == MONITORENTER)
        syncField = null;

    switch (state) {
    case 0:
        if (seen == ALOAD_0)
            state = 1;
        break;
    case 1:
        if (seen == GETFIELD) {
            state = 2;
            field = getXFieldOperand();
        } else
            state = 0;
        break;
    case 2:
        if (seen == DUP)
            state = 3;
        else
            state = 0;
        break;
    case 3:
        if (isRegisterStore())
            state = 4;
        else
            state = 0;
        break;
    case 4:
        if (seen == MONITORENTER) {
            state = 0;
            syncField = field;
        } else
            state = 0;
        break;

    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:75,代码来源:SynchronizingOnContentsOfFieldToProtectField.java

示例8: getPriorityForBeingMutable

private static int getPriorityForBeingMutable(Type type) {
    if (type instanceof ArrayType) {
        return HIGH_PRIORITY;
    } else if (type instanceof ObjectType) {
        UnreadFieldsData unreadFields = AnalysisContext.currentAnalysisContext().getUnreadFieldsData();

        ClassDescriptor cd = DescriptorFactory.getClassDescriptor((ObjectType) type);
        @SlashedClassName
        String className = cd.getClassName();
        if (immutableClassNames.contains(className))
            return Priorities.LOW_PRIORITY;

        XClass xClass = AnalysisContext.currentXFactory().getXClass(cd);
        if (xClass == null)
            return Priorities.IGNORE_PRIORITY;
        ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor();
        if (superclassDescriptor != null) {
            @SlashedClassName
            String superClassName = superclassDescriptor.getClassName();
            if (superClassName.equals("java/lang/Enum"))
                return Priorities.LOW_PRIORITY;
        }
        boolean hasMutableField = false;
        boolean hasUpdates = false;
        for (XField f : xClass.getXFields())
            if (!f.isStatic()) {
                if (!f.isFinal() && !f.isSynthetic()) {
                    hasMutableField = true;
                    if (unreadFields.isWrittenOutsideOfInitialization(f))
                        hasUpdates = true;
                }
                String signature = f.getSignature();
                if (signature.startsWith("Ljava/util/concurrent") || signature.startsWith("Ljava/lang/StringB")
                        || signature.charAt(0) == '[' || signature.indexOf("Map") >= 0 || signature.indexOf("List") >= 0
                        || signature.indexOf("Set") >= 0)
                    hasMutableField = hasUpdates = true;

            }

        if (!hasMutableField && !xClass.isInterface() && !xClass.isAbstract())
            return Priorities.LOW_PRIORITY;
        if (hasUpdates || className.startsWith("java/util") || className.indexOf("Map") >= 0
                || className.indexOf("List") >= 0)
            return Priorities.HIGH_PRIORITY;
        return Priorities.NORMAL_PRIORITY;

    } else
        return Priorities.IGNORE_PRIORITY;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:49,代码来源:DontIgnoreResultOfPutIfAbsent.java

示例9: getTreeCellRendererComponent

@Override
public Component getTreeCellRendererComponent(JTree tree, Object node, boolean selected, boolean expanded, boolean leaf,
        int row, boolean hasFocus) {
    Component toReturn = super.getTreeCellRendererComponent(tree, node, selected, expanded, leaf, row, hasFocus);

    if (!(node instanceof BugLeafNode))
        return toReturn;
    else {
        BugInstance bug = ((BugLeafNode) node).getBug();
        final Color c;
        switch (bug.getPriority()) {
        case Priorities.LOW_PRIORITY:
            c = new Color(0.4f, 0.4f, 0.6f);
            break;
        case Priorities.NORMAL_PRIORITY:
            if (bug.isDead())
                c = new Color(0.2f, 0.2f, 0.2f);
            else
                c = new Color(255, 204, 0);
            break;
        case Priorities.HIGH_PRIORITY:
            if (bug.isDead())
                c = new Color(.65f, 0.2f, 0.2f);
            else
                c = new Color(.85f, 0, 0);
            break;
        case Priorities.EXP_PRIORITY:
        case Priorities.IGNORE_PRIORITY:
        default:
            c = Color.blue;
            break;
        }
        if (leaf) {
            Icon icon = new Icon() {
                public void paintIcon(Component comp, Graphics g, int x, int y) {
                    Graphics2D g2 = (Graphics2D) g;
                    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                    g2.setColor(c);
                    g2.fillOval(2, 2, 12, 12);
                    g2.setColor(Color.BLACK);
                    g2.drawOval(2, 2, 12, 12);
                }

                public int getIconWidth() {
                    return 16;
                }

                public int getIconHeight() {
                    return 16;
                }
            };
            ((BugRenderer) toReturn).setLeafIcon(icon);
        }
        return toReturn;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:56,代码来源:BugRenderer.java

示例10: getPriority

/**
 * The default implementation of <code>getPriority()</code> can be overridden if the severity and the confidence for risk
 * is particular.
 *
 * By default, injection will be rated "High" if the complete link between source and sink is made.
 * If it is not the case but concatenation with external source is made, "Medium" is used.
 *
 * @param taint Detail about the state of the value passed (Cumulative information leading to the variable passed).
 * @return Priorities interface values from 1 to 5 (Enum-like interface)
 */
protected int getPriority(Taint taint) {
    if (taint.isTainted()) {
        return Priorities.HIGH_PRIORITY;
    } else if (!taint.isSafe()) {
        return Priorities.NORMAL_PRIORITY;
    } else {
        return Priorities.IGNORE_PRIORITY;
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:19,代码来源:AbstractInjectionDetector.java


注:本文中的edu.umd.cs.findbugs.Priorities.HIGH_PRIORITY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。