Skip to content
Permalink
Browse files

Merge branch 'findbugs' into spotbugs

  • Loading branch information...
mebigfatguy committed Aug 13, 2019
2 parents 52fde9f + 042caf7 commit 981212cf637f56c4c58cba04f614a34ed7dfd845
@@ -28,6 +28,8 @@
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;

import com.mebigfatguy.fbcontrib.collect.MethodInfo;
import com.mebigfatguy.fbcontrib.collect.Statistics;
import com.mebigfatguy.fbcontrib.utils.BugType;
import com.mebigfatguy.fbcontrib.utils.OpcodeUtils;
import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
@@ -48,13 +50,17 @@
*/
public class BogusExceptionDeclaration extends BytecodeScanningDetector {

private static final String IGNORE_INHERITED_METHODS_PROPERTY = "fb-contrib.bed.ignore_inherited";

private static final Set<String> safeClasses = UnmodifiableSet.create(
// @formatter:off
Values.SLASHED_JAVA_LANG_OBJECT, Values.SLASHED_JAVA_LANG_STRING, Values.SLASHED_JAVA_LANG_INTEGER,
Values.SLASHED_JAVA_LANG_LONG, Values.SLASHED_JAVA_LANG_FLOAT, Values.SLASHED_JAVA_LANG_DOUBLE,
Values.SLASHED_JAVA_LANG_SHORT, Values.SLASHED_JAVA_LANG_BYTE, Values.SLASHED_JAVA_LANG_BOOLEAN
// @formatter:on
);

private static final boolean IGNORE_INHERITED_METHODS = Boolean.getBoolean(IGNORE_INHERITED_METHODS_PROPERTY);

private final BugReporter bugReporter;
private JavaClass runtimeExceptionClass;
@@ -116,7 +122,14 @@ public void visitCode(Code obj) {
if (method.isSynthetic()) {
return;
}


if (IGNORE_INHERITED_METHODS) {
MethodInfo mi = Statistics.getStatistics().getMethodStatistics(getClassName(), getMethodName(), getMethodSig());
if (mi != null && mi.isDerived()) {
return;
}
}

declaredCheckedExceptions.clear();
stack.resetForMethodEntry(this);

@@ -115,6 +115,13 @@ public void sawOpcode(int seen) {
sawMethodWeight = 0;
return;
}

for (String parmSig : SignatureUtils.getParameterSignatures(signature)) {
if (parmSig.charAt(0) == '[') {
sawMethodWeight = 0;
return;
}
}

String clsName = getClassConstantOperand();
MethodInfo mi = Statistics.getStatistics().getMethodStatistics(clsName, getNameConstantOperand(), signature);
@@ -123,5 +123,15 @@ public static FPAnonBase makeAnon(InputStream is) throws IOException {
};
}
}


static class BaseBED {
public void foo() throws IOException {
}
}

/* is caught based on the option fb-contrib.bed.ignore_inherited */
static class ChildBED extends BaseBED {
public void foo() throws IOException {
}
}
}
@@ -38,6 +38,18 @@ private void fp223Aliasing() {
System.out.println("Got It");
}
}

private String fpArrays(String[] data) {
if (isEmpty(data) && data[0] != null && data[1] != null)
return data[0] + data[1];
else {
return "";
}
}

private boolean isEmpty(String[] d) {
return d == null || d.length == 0;
}

class Holder {
private int[] data;

0 comments on commit 981212c

Please sign in to comment.
You can’t perform that action at this time.