Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30702/src/com/mebigfatguy/fbcontrib/detect
Modified Files:
DubiousListCollection.java
Log Message:
report DLC at LOW_PRIORITY if class is less than 1.4 as no LinkedHashSet exists. If a list is returned from a method, remove it from consideration.
Index: DubiousListCollection.java
===================================================================
RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- DubiousListCollection.java 26 Feb 2006 03:28:46 -0000 1.14
+++ DubiousListCollection.java 26 Feb 2006 03:51:35 -0000 1.15
@@ -60,8 +60,10 @@
listMethods.add("remove(I)Ljava/lang/Object;");
listMethods.add("set(ILjava/lang/Object;)Ljava/lang/Object;");
listMethods.add("subList(II)Ljava/util/List;");
+ listMethods.add("listIterator()Ljava/util/ListIterator;");
+ listMethods.add("listIterator(I)Ljava/util/ListIterator;");
- //Theoretically get(i) and indexOf(Object) are setMethods but are so abused, as to be meaningless
+ //Theoretically get(i) and indexOf(Object) are list Methods but are so abused, as to be meaningless
}
private BugReporter bugReporter;
private OpcodeStack stack = new OpcodeStack();
@@ -150,6 +152,15 @@
fieldsReported.remove(field);
}
}
+ } else if (seen == ARETURN) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ FieldAnnotation fa = item.getField();
+ if (fa != null) {
+ String field = fa.getFieldName();
+ fieldsReported.remove(field);
+ }
+ }
}
} finally {
stack.sawOpcode(this, seen);
@@ -178,6 +189,7 @@
* implements the detector, by reporting all remaining fields that only have set based access
*/
private void reportBugs() {
+ int major = getClassContext().getJavaClass().getMajor();
for (Map.Entry<String, FieldInfo> entry : fieldsReported.entrySet()) {
String field = entry.getKey();
FieldInfo fi = entry.getValue();
@@ -185,7 +197,8 @@
if (cnt > 0) {
FieldAnnotation fa = getFieldAnnotation(field);
if (fa != null) {
- bugReporter.reportBug(new BugInstance(this, "DLC_DUBIOUS_LIST_COLLECTION", NORMAL_PRIORITY)
+ //can't use LinkedHashSet in 1.3 so report at LOW
+ bugReporter.reportBug(new BugInstance(this, "DLC_DUBIOUS_LIST_COLLECTION", (major >= MAJOR_1_4) ? NORMAL_PRIORITY : LOW_PRIORITY)
.addClass(this)
.addField(fa)
.addSourceLine(fi.getSourceLineAnnotation()));
|