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


Java BugInstance类代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.BugInstance的典型用法代码示例。如果您正苦于以下问题:Java BugInstance类的具体用法?Java BugInstance怎么用?Java BugInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: report

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void report() {
	// Find the set of properties for which we have both
	// unsynchronized get and synchronized set methods
	HashSet<String> commonProperties = new HashSet<String>(getMethods.keySet());
	commonProperties.retainAll(setMethods.keySet());

	// Report method pairs
	for (Iterator<String> i = commonProperties.iterator(); i.hasNext();) {
		String propName = (String) i.next();

		MethodAnnotation getMethod = getMethods.get(propName);
		MethodAnnotation setMethod = setMethods.get(propName);

		bugReporter.reportBug(new BugInstance(this, "UG_SYNC_SET_UNSYNC_GET", NORMAL_PRIORITY)
		        .addClass(prevClassName)
		        .addMethod(getMethod)
		        .addMethod(setMethod));
	}
	getMethods.clear();
	setMethods.clear();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:FindUnsyncGet.java

示例2: visitClassContext

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    
    //The class extends WebChromeClient
    boolean isWebChromeClient = InterfaceUtils.isSubtype(javaClass, "android.webkit.WebChromeClient");
    
    //Not the target of this detector
    if (!isWebChromeClient) {
        return;
    }
    Method[] methodList = javaClass.getMethods();
    for (Method m : methodList) {
        if (DEBUG) {
            System.out.println(">>> Method: " + m.getName());
        }
        //The presence of onGeolocationPermissionsShowPrompt is not enforce for the moment
        if (!m.getName().equals("onGeolocationPermissionsShowPrompt")) {
            continue;
        }
        //Since the logic implemented need to be analyze by a human, all implementation will be flagged.
        bugReporter.reportBug(new BugInstance(this, ANDROID_GEOLOCATION_TYPE, Priorities.NORMAL_PRIORITY) //
                .addClassAndMethod(javaClass, m));
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:26,代码来源:GeolocationDetector.java

示例3: checkSuper

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
private boolean checkSuper(MyMethod m, HashSet<MyMethod> others) {
	for (Iterator<MyMethod> i = others.iterator(); i.hasNext();) {
		MyMethod m2 = i.next();
		try {
			if (m.confusingMethodNames(m2)
			        && Repository.instanceOf(m.clazz, m2.clazz)) {
				MyMethod m3 = new MyMethod(m.clazz, m2.methodName, m.methodSig);
				boolean r = others.contains(m3);
				if (r) continue;
				bugReporter.reportBug(new BugInstance(this, "NM_VERY_CONFUSING", HIGH_PRIORITY)
				        .addClass(m.getClassName())
				        .addMethod(m.getClassName(), m.methodName, m.methodSig)
				        .addClass(m2.getClassName())
				        .addMethod(m2.getClassName(), m2.methodName, m2.methodSig));
				return true;
			}
		} catch (ClassNotFoundException e) {
		}
	}
	return false;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:Naming.java

示例4: visit

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void visit(JavaClass obj) {
	String name = obj.getClassName();
	String[] parts = name.split("[$+.]");
	baseClassName = parts[parts.length - 1];
	classIsPublicOrProtected = obj.isPublic() || obj.isProtected();
	if (baseClassName.length() == 1) return;
	if(Character.isLetter(baseClassName.charAt(0))
	   && !Character.isUpperCase(baseClassName.charAt(0))
	   && baseClassName.indexOf("_") ==-1 
		)
		bugReporter.reportBug(new BugInstance(this, 
			"NM_CLASS_NAMING_CONVENTION", 
			classIsPublicOrProtected 
			? NORMAL_PRIORITY
			: LOW_PRIORITY
				)
		        .addClass(this));
	super.visit(obj);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:Naming.java

示例5: visitAfter

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void visitAfter(JavaClass obj) {
	if (!check) return;
	if (implementsCloneableDirectly && !hasCloneMethod) {
		if (!referencesCloneMethod)
			bugReporter.reportBug(new BugInstance(this, "CN_IDIOM", NORMAL_PRIORITY)
			        .addClass(this));
	}

	if (hasCloneMethod && !invokesSuperClone && !isFinal && obj.isPublic()) {
		bugReporter.reportBug(new BugInstance(this, "CN_IDIOM_NO_SUPER_CALL", (obj.isPublic() || obj.isProtected()) ?
		        NORMAL_PRIORITY : LOW_PRIORITY)
		        .addClass(this)
		        .addMethod(cloneMethodAnnotation));
	}

	/*
	if (!isCloneable && hasCloneMethod) {
		if (throwsExceptions)
		System.out.println("has public clone method that throws exceptions and class is not Cloneable: " + betterClassName) ;
		else System.out.println("has public clone method but is not Cloneable: " + betterClassName) ;
		}
	*/
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:CloneIdiom.java

示例6: visit

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void visit(Method obj) {
	if (!validClass)
		return;
	validMethod = false;
	methodName = obj.getName();
	if (methodName.equals("setUp") || methodName.equals("tearDown")) {
		if (methodName.equals("setUp"))
			setUpAnnotation = MethodAnnotation.fromVisitedMethod(this);
		else if (methodName.equals("tearDown"))
			tearDownAnnotation = MethodAnnotation.fromVisitedMethod(this);
		validMethod = true;
		state = SEEN_NOTHING;
		super.visit(obj);
	} else if (methodName.equals("suite") && !obj.isStatic())
		bugReporter.reportBug(new BugInstance(this, "IJU_SUITE_NOT_STATIC", NORMAL_PRIORITY)
		        .addClass(this)
		        .addMethod(MethodAnnotation.fromVisitedMethod(this)));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:InvalidJUnitTest.java

示例7: inspectResult

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void inspectResult(JavaClass javaClass, MethodGen methodGen, CFG cfg,
                          Dataflow<ResourceValueFrame, ResourceValueAnalysis<Lock>> dataflow, Lock resource) {

	ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
	int exitStatus = exitFrame.getStatus();

	if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
		String bugType;
		int priority;
		if (exitStatus == ResourceValueFrame.OPEN) {
			bugType = "UL_UNRELEASED_LOCK";
			priority = HIGH_PRIORITY;
		} else {
			bugType = "UL_UNRELEASED_LOCK_EXCEPTION_PATH";
			priority = NORMAL_PRIORITY;
		}

		String sourceFile = javaClass.getSourceFileName();
		bugReporter.reportBug(new BugInstance(this, bugType, priority)
		        .addClassAndMethod(methodGen, sourceFile)
		        .addSourceLine(methodGen, sourceFile, resource.getLocation().getHandle()));
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:FindUnreleasedLock.java

示例8: visit

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void visit(Code obj) {
	sawSuperFinalize = false;
	super.visit(obj);
	if (!getMethodName().equals("finalize")
	        || !getMethodSig().equals("()V"))
		return;
	String overridesFinalizeIn
	        = Lookup.findSuperImplementor(getDottedClassName(),
	                "finalize",
	                "()V",
	                bugReporter);
	boolean superHasNoFinalizer = overridesFinalizeIn.equals("java.lang.Object");
	// System.out.println("superclass: " + superclassName);
	if (obj.getCode().length == 1) {
		if (superHasNoFinalizer)
			bugReporter.reportBug(new BugInstance(this, "FI_EMPTY", NORMAL_PRIORITY).addClassAndMethod(this));
		else
			bugReporter.reportBug(new BugInstance(this, "FI_NULLIFY_SUPER", NORMAL_PRIORITY)
			        .addClassAndMethod(this)
			        .addClass(overridesFinalizeIn));
	} else if (obj.getCode().length == 5 && sawSuperFinalize)
		bugReporter.reportBug(new BugInstance(this, "FI_USELESS", NORMAL_PRIORITY).addClassAndMethod(this));
	else if (!sawSuperFinalize && !superHasNoFinalizer)
		bugReporter.reportBug(new BugInstance(this, "FI_MISSING_SUPER_CALL", NORMAL_PRIORITY).addClassAndMethod(this)
		        .addClass(overridesFinalizeIn));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:FindFinalizeInvocations.java

示例9: visit

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void visit(Method obj) {
	if (isAdapter) {
		String methodName = obj.getName();
		String signature = methodMap.get(methodName);
		if (!methodName.equals("<init>") && signature != null) {
			if (!signature.equals(obj.getSignature())) {
				if (!badOverrideMap.keySet().contains(methodName)) {
					badOverrideMap.put(methodName, new BugInstance(this, "BOA_BADLY_OVERRIDDEN_ADAPTER", NORMAL_PRIORITY)
							.addClassAndMethod(this)
							.addSourceLine(this));
				}
			}
			else {
				badOverrideMap.put(methodName, null);
			}
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:BadlyOverriddenAdapter.java

示例10: sawOpcode

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void sawOpcode(int seen) {
	try {
		if ((seen == INVOKEINTERFACE)
		&&  (getClassConstantOperand().equals("java/sql/ResultSet"))) {
			String methodName = getNameConstantOperand();
			if ((methodName.startsWith("get") && dbFieldTypesSet.contains(methodName.substring(3)))
			||  (methodName.startsWith("update") && dbFieldTypesSet.contains(methodName.substring(6)))) {
				String signature = getSigConstantOperand();
				Type[] argTypes = Type.getArgumentTypes(signature);
				int numParms = argTypes.length;
				if (stack.getStackDepth() >= numParms) {
					OpcodeStack.Item item = stack.getStackItem(numParms-1);
					Object cons = item.getConstant();
					if ((cons != null) && ("I".equals(item.getSignature())) && (((Integer) cons).intValue() == 0)) {
						bugReporter.reportBug(new BugInstance(this, "BRSA_BAD_RESULTSET_ACCESS", NORMAL_PRIORITY)
						        .addClassAndMethod(this)
						        .addSourceLine(this));
					}
				}
			} 
		}
	} finally {
		stack.sawOpcode(this, seen);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:BadResultSetAccess.java

示例11: sawOpcode

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void sawOpcode(int seen) {
	switch (stage) {
	case 0:
		if (seen == MONITORENTER)
			stage = 1;
		break;
	case 1:
		if (seen == INVOKEVIRTUAL && getNameConstantOperand().equals("wait")) {
			bugReporter.reportBug(new BugInstance(this, "UW_UNCOND_WAIT",
			        getSigConstantOperand().equals("()V") ? NORMAL_PRIORITY : LOW_PRIORITY)
			        .addClassAndMethod(this)
			        .addSourceLine(this));
			stage = 2;
		}
		break;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:FindUnconditionalWait.java

示例12: reportMatch

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void reportMatch(ClassContext classContext, Method method, ByteCodePatternMatch match) {
	MethodGen methodGen = classContext.getMethodGen(method);
	JavaClass javaClass = classContext.getJavaClass();

	BindingSet bindingSet = match.getBindingSet();

	// Note that the lookup of "h" cannot fail, and
	// it is guaranteed to be bound to a FieldVariable.
	Binding binding = bindingSet.lookup("h");
	FieldVariable field = (FieldVariable) binding.getVariable();

	// Ignore fields generated for accesses to Foo.class
	if (field.getFieldName().startsWith("class$"))
		return;

	// Find start and end instructions (for reporting source lines)
	InstructionHandle start = match.getLabeledInstruction("startDC");
	InstructionHandle end = match.getLabeledInstruction("endDC");

	String sourceFile = javaClass.getSourceFileName();
	bugReporter.reportBug(new BugInstance(this, "BCPDC_DOUBLECHECK", NORMAL_PRIORITY)
	        .addClassAndMethod(methodGen, sourceFile)
	        .addField(field).describe("FIELD_ON")
	        .addSourceLine(methodGen, sourceFile, start, end));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:BCPDoubleCheck.java

示例13: sawOpcode

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {
    //printOpCode(seen);
    if (seen == Constants.INVOKEVIRTUAL && getClassConstantOperand().equals("android/webkit/WebSettings") &&
            (getNameConstantOperand().equals("setJavaScriptEnabled") ||
             getNameConstantOperand().equals("setAllowFileAccess") ||
             getNameConstantOperand().equals("setAllowFileAccessFromFileURLs") ||
             getNameConstantOperand().equals("setAllowUniversalAccessFromFileURLs"))) {
        OpcodeStack.Item item = stack.getStackItem(0); //First item on the stack is the last
        if(StackUtils.isConstantInteger(item)) {
            Integer value = (Integer) item.getConstant();
            if(value == null || value == 1) {
                bugReporter.reportBug(new BugInstance(this, ANDROID_WEB_VIEW_JAVASCRIPT_TYPE, Priorities.NORMAL_PRIORITY) //
                        .addClass(this).addMethod(this).addSourceLine(this));
            }
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:19,代码来源:WebViewJavascriptEnabledDetector.java

示例14: sawOpcode

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
public void sawOpcode(int seen) {


		if (seen == PUTSTATIC && getClassConstantOperand().equals(getClassName())) {
			// Don't do this check; it generates too many false
			// positives. We need to do a more detailed check
			// of which variables could be seen.
			if (REPORT_CREATE_INSTANCE_BEFORE_FIELDS_ASSIGNED &&
			        instanceCreated && !instanceCreatedWarningGiven) {
				String okSig = "L" + getClassName() + ";";
				if (!okSig.equals(getSigConstantOperand())) {
					bugReporter.reportBug(new BugInstance(this, "SI_INSTANCE_BEFORE_FINALS_ASSIGNED", NORMAL_PRIORITY)
					        .addClassAndMethod(this)
					        .addSourceLine(this, instanceCreatedPC));
					instanceCreatedWarningGiven = true;
				}
			}
		} else if (seen == NEW && getClassConstantOperand().equals(getClassName())) {
			instanceCreated = true;
			instanceCreatedPC = getPC();
		} else if (seen == PUTSTATIC || seen == GETSTATIC || seen == INVOKESTATIC
		        || seen == NEW)
			if (getPC() + 6 < codeBytes.length)
				requires.add(getDottedClassConstantOperand());
	}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:InitializationChain.java

示例15: sawOpcode

import edu.umd.cs.findbugs.BugInstance; //导入依赖的package包/类
@Override
    public void sawOpcode(int seen) {
        //printOpCode(seen);

        // getClassConstantOperand().equals("java/net/Socket")

        if (seen == Constants.INVOKEVIRTUAL && ( //List of method mark as external file access
                getNameConstantOperand().equals("sendStickyBroadcast") ||
                        getNameConstantOperand().equals("sendStickyOrderedBroadcast") ||
                        getNameConstantOperand().equals("sendStickyBroadcastAsUser") ||
                        getNameConstantOperand().equals("sendStickyOrderedBroadcastAsUser")
        )) {
//            System.out.println(getSigConstantOperand());
            bugReporter.reportBug(new BugInstance(this, ANDROID_STICKY_BROADCAST_TYPE, Priorities.NORMAL_PRIORITY) //
                    .addClass(this).addMethod(this).addSourceLine(this));
        }
    }
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:18,代码来源:StickyBroadcastDetector.java


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