本文整理汇总了Java中edu.umd.cs.findbugs.BugInstance.addClassAndMethod方法的典型用法代码示例。如果您正苦于以下问题:Java BugInstance.addClassAndMethod方法的具体用法?Java BugInstance.addClassAndMethod怎么用?Java BugInstance.addClassAndMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.BugInstance
的用法示例。
在下文中一共展示了BugInstance.addClassAndMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateBugInstance
import edu.umd.cs.findbugs.BugInstance; //导入方法依赖的package包/类
/**
* Uses immutable values, updated priority and added lines for reporting
*
* @param taintedInsideMethod true if not influenced by method arguments
* @return new bug instance filled with information
*/
public BugInstance generateBugInstance(boolean taintedInsideMethod) {
BugInstance bug = new BugInstance(detector, bugType, originalPriority);
bug.addClassAndMethod(classContext.getJavaClass(), method);
bug.addSourceLine(SourceLineAnnotation.fromVisitedInstruction(classContext, method, instructionHandle));
addMessage(bug, "Sink method", sinkMethod);
for(TaintLocation source : unknownSources) {
addMessage(bug, "Unknown source", source.getTaintSource());
//md.getSlashedClassName() + "." + md.getName() + md.getSignature());
}
addMessage(bug, "Sink method", sinkMethod);
if (sinkPriority != UNKNOWN_SINK_PRIORITY) {
// higher priority is represented by lower integer
if (sinkPriority < originalPriority) {
bug.setPriority(sinkPriority);
addMessage(bug, "Method usage", "with tainted arguments detected");
} else if (sinkPriority > originalPriority) {
bug.setPriority(Priorities.LOW_PRIORITY);
addMessage(bug, "Method usage", "detected only with safe arguments");
}
} else if (!taintedInsideMethod) {
addMessage(bug, "Method usage", "not detected");
}
Collections.sort(lines);
SourceLineAnnotation annotation = null;
for (Iterator<SourceLineAnnotation> it = lines.iterator(); it.hasNext();) {
SourceLineAnnotation prev = annotation;
annotation = it.next();
if (prev != null && prev.getClassName().equals(annotation.getClassName())
&& prev.getStartLine() == annotation.getStartLine()) {
// keep only one annotation per line
it.remove();
}
}
for (SourceLineAnnotation sourceLine : lines) {
bug.addSourceLine(sourceLine);
}
return bug;
}