Skip to content
Permalink
Browse files

Merge branch 'findbugs' into spotbugs

  • Loading branch information...
mebigfatguy committed Mar 23, 2019
2 parents 9033d36 + 05b7d99 commit 18b21fc636d559b7fd36e4ee6a70cf6e75f5b664
@@ -80,6 +80,7 @@
+2 BugPattern IMC_IMMATURE_CLASS_NO_TOSTRING
+0 BugPattern IMC_IMMATURE_CLASS_PRINTSTACKTRACE
+0 BugPattern IMC_IMMATURE_CLASS_UPPER_PACKAGE
+0 BugPattern IMC_IMMATURE_CLASS_VAR_NAME
+0 BugPattern IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER
+0 BugPattern IOI_COPY_WITH_READER
+0 BugPattern IOI_DOUBLE_BUFFER_COPY
@@ -286,7 +286,7 @@

<Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes" speed="fast" reports="STT_STRING_PARSING_A_FIELD,STT_TOSTRING_STORED_IN_FIELD,STT_TOSTRING_MAP_KEYING" />

<Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING,IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES,IMC_IMMATURE_CLASS_PRINTSTACKTRACE,IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER,IMC_IMMATURE_CLASS_UPPER_PACKAGE,IMC_IMMATURE_CLASS_LOWER_CLASS,IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" />
<Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING,IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES,IMC_IMMATURE_CLASS_PRINTSTACKTRACE,IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER,IMC_IMMATURE_CLASS_UPPER_PACKAGE,IMC_IMMATURE_CLASS_LOWER_CLASS,IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID,IMC_IMMATURE_CLASS_VAR_NAME" />

<Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues" speed="fast" reports="JXI_GET_ENDPOINT_CONSUMES_CONTENT,JXI_INVALID_CONTEXT_PARAMETER_TYPE,JXI_PARM_PARAM_NOT_FOUND_IN_PATH,JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" />

@@ -595,6 +595,7 @@
<BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_UPPER_PACKAGE" category="STYLE" />
<BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_LOWER_CLASS" category="STYLE" />
<BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" category="CORRECTNESS" />
<BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_VAR_NAME" category="CORRECTNESS" />
<BugPattern abbrev="JXI" type="JXI_GET_ENDPOINT_CONSUMES_CONTENT" category="CORRECTNESS" />
<BugPattern abbrev="JXI" type="JXI_INVALID_CONTEXT_PARAMETER_TYPE" category="CORRECTNESS" />
<BugPattern abbrev="JXI" type="JXI_PARM_PARAM_NOT_FOUND_IN_PATH" category="CORRECTNESS" />
@@ -5652,7 +5652,17 @@ for (Person p : people) {
recompute the serialVersionUID using your IDE.</p>
]]>
</Details>
</BugPattern>
</BugPattern>

<BugPattern type="IMC_IMMATURE_CLASS_VAR_NAME">
<ShortDescription>Class defines a field or local variable named 'var'</ShortDescription>
<LongDescription>Class {0} defines a field or local variable named 'var'</LongDescription>
<Details>
<![CDATA[
<p>A field or variable is named 'var' which will conflict with the built in Java 10 feature using 'var' as a keyword.</p>
]]>
</Details>
</BugPattern>

<BugPattern type="JXI_GET_ENDPOINT_CONSUMES_CONTENT">
<ShortDescription>JAX-RS Method implements a GET request but consumes input</ShortDescription>
@@ -175,6 +175,12 @@ public void visitClassContext(ClassContext classContext) {

@Override
public void visitField(Field f) {

if ("var".equals(f.getName())) {
bugReporter.reportBug(new BugInstance(this, BugType.IMC_IMMATURE_CLASS_VAR_NAME.name(), NORMAL_PRIORITY)
.addClass(this).addField(this));
}

if (!f.isSynthetic() && (f.getName().indexOf(Values.SYNTHETIC_MEMBER_CHAR) < 0)) {
switch (fieldStatus) {
case NONE:
@@ -222,11 +228,23 @@ public void visitField(Field f) {
} catch (ClassNotFoundException e) {
bugReporter.reportMissingClass(e);
}

}

}

public void visitMethod(Method m) {
LocalVariableTable lvt = m.getLocalVariableTable();
if (lvt != null) {
LocalVariable[] lv = lvt.getLocalVariableTable();
if (lv != null) {
for (LocalVariable l : lv) {
if ("var".equals(l.getName())) {
bugReporter.reportBug(new BugInstance(this, BugType.IMC_IMMATURE_CLASS_VAR_NAME.name(), NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this, l.getStartPC()));
}
}
}
}
}
/**
* implements the visitor to check for calls to Throwable.printStackTrace()
*
@@ -112,6 +112,7 @@
IMC_IMMATURE_CLASS_UPPER_PACKAGE,
IMC_IMMATURE_CLASS_LOWER_CLASS,
IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID,
IMC_IMMATURE_CLASS_VAR_NAME,
IOI_COPY_WITH_READER,
IOI_DOUBLE_BUFFER_COPY,
IOI_UNENDED_ZLIB_OBJECT,
@@ -191,7 +191,7 @@ private static JavaClass findInheritedMethod(JavaClass[] classes, String methodN
for (int i = start; i < limit; i++) {
if (!methodSignature.startsWith(Values.SIG_ARRAY_PREFIX, i)) {
String parmSignature = null;
if (methodSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX, i)) {
if (methodSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX, i) || methodSignature.startsWith(Values.SIG_GENERIC_TEMPLATE, i)) {
int semiPos = methodSignature.indexOf(Values.SIG_QUALIFIED_CLASS_SUFFIX_CHAR, i + 1);
parmSignature = methodSignature.substring(sigStart, semiPos + 1);
slotIndexToParms.put(Integer.valueOf(slot), parmSignature);
@@ -231,7 +231,7 @@ private static JavaClass findInheritedMethod(JavaClass[] classes, String methodN
int sigStart = start;
for (int i = start; i < limit; i++) {
if (!methodSignature.startsWith(Values.SIG_ARRAY_PREFIX, i)) {
if (methodSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX, i)) {
if (methodSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX, i) || methodSignature.startsWith(Values.SIG_GENERIC_TEMPLATE, i)) {
int semiPos = methodSignature.indexOf(Values.SIG_QUALIFIED_CLASS_SUFFIX_CHAR, i + 1);
parmSignatures.add(methodSignature.substring(sigStart, semiPos + 1));
i = semiPos;
@@ -281,7 +281,7 @@ public static int getNumParameters(String methodSignature) {
int numParms = 0;
for (int i = start; i < limit; i++) {
if (!methodSignature.startsWith(Values.SIG_ARRAY_PREFIX, i)) {
if (methodSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX, i)) {
if (methodSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX, i) || methodSignature.startsWith(Values.SIG_GENERIC_TEMPLATE, i)) {
i = methodSignature.indexOf(Values.SIG_QUALIFIED_CLASS_SUFFIX_CHAR, i + 1);
} else if (isWonkyEclipseSignature(methodSignature, i)) {
continue;
@@ -372,7 +372,7 @@ public static int getSignatureSize(String signature) {
* @return the slashed class name
*/
public static @SlashedClassName String trimSignature(String signature) {
if ((signature != null) && signature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX) && signature.endsWith(Values.SIG_QUALIFIED_CLASS_SUFFIX)) {
if ((signature != null) && (signature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX) || signature.startsWith(Values.SIG_GENERIC_TEMPLATE)) && signature.endsWith(Values.SIG_QUALIFIED_CLASS_SUFFIX)) {
return signature.substring(1, signature.length() - 1);
}

@@ -22,6 +22,7 @@
private static final long serialVersionUID = 5213802770984511942L;

private String reportMe;
private String var;

private static final int OUT_OF_PLACE_STATIC = 0;

@@ -42,6 +43,10 @@ public void psf(File f) {
e.printStackTrace();
}
}

public void hasVar() {
int var = 0;
}
}

class IMCFPHasAToString {

0 comments on commit 18b21fc

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