SakaiBogoBugs for the scoreboard

SakaiBogoBugs

Feel free to add, remove rules, change weightings and generally make comments.

OK, so some bugs are worse than others so lets change that to Weighted SakaiBogoBugs per thousand lines of code.

Resources

http://findbugs.sourceforge.net/bugDescriptions.html
http://pmd.sourceforge.net/rules/index.html

Suggested rules and weightings

1=trivial
50=Extremely bad

Rule

Weight

Description

PMD

EmptyCatchBlock

10

Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this swallows an exception which should either be acted on or reported.

OverrideBothEqualsAndHashcode

5


DoubleCheckedLocking

20





IntegerInstantiation

1


AvoidReassigningParameters

2


PositionLiteralsFirstInComparisons

2


UnusedLocalVariable

1


UnusedPrivateField

1


AvoidCatchingThrowable

10


UnusedPrivateMethod

5


MissingSerialVersionUID

5


UnsynchronizedStaticDateFormatter

20


FindBugs

BC_IMPOSSIBLE_CAST
Correctness

30

This cast will always throw a ClassCastException




Correctness

10

This instanceof test will always return false. Although this is safe, make sure it isn't an indication of some misunderstanding or some other logic error.

DLS_DEAD_STORE_OF_CLASS_LITERAL
Correctness

8

This instruction assigns a class literal to a variable and then never uses it. The behavior of this differs in Java 1.4 and in Java 5. In Java 1.4 and earlier, a reference to Foo.class would force the static initializer for Foo to be executed, if it has not been executed already. In Java 5 and later, it does not

DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY
DMI_INVOKING_TOSTRING_ON_ARRAY
Correctness

1

The code invokes toString on an (anonymous) array. Calling toString on an array generates a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.

EC_ARRAY_AND_NONARRAY

10

This method invokes the .equals(Object o) to compare an array and a reference that doesn't seem to be an array. If things being compared are of different types, they are guaranteed to be unequal and the comparison is almost certainly an error. Even if they are both arrays, the equals method on arrays only determines of the two arrays are the same object. To compare the contents of the arrays, use java.util.Arrays.equals(Object[], Object[])

EC_UNRELATED_CLASS_AND_INTERFACE
EC_UNRELATED_CLASS_AND_INTERFACE
EC_UNRELATED_INTERFACES
EC_UNRELATED_TYPES
EC_UNRELATED_TYPES_USING_POINTER_EQUALITY
BC_IMPOSSIBLE_INSTANCEOF
EQ_ALWAYS_FALSE
EQ_ALWAYS_TRUE
FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER
NP_NULL_INSTANCEOF

10

Wrong sort of comparisons always returning true or false

HE_USE_OF_UNHASHABLE_CLASS

20

A class defines an equals(Object) method but not a hashCode() method, and thus doesn't fulfill the requirement that equal Objects have equal hashCodes. An instance of this class is used in a hash data structure, making the need to fix this problem of highest importance.

IL_INFINITE_LOOP
IL_INFINITE_RECURSIVE_LOOP

30

Infinite loops under certain conditions

NP_ALWAYS_NULL
NP_ALWAYS_NULL_EXCEPTION
NP_ARGUMENT_MIGHT_BE_NULL
NP_GUARANTEED_DEREF
NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH
NP_NONNULL_PARAM_VIOLATION
NP_NONNULL_RETURN_VIOLATION
NP_NULL_ON_SOME_PATH
NP_NULL_ON_SOME_PATH_EXCEPTION
NP_UNWRITTEN_FIELD

10

Possible Null pointer generation

DL_SYNCHRONIZATION_ON_BOOLEAN
DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE
DL_SYNCHRONIZATION_ON_SHARED_CONSTANT
IS2_INCONSISTENT_SYNC
IS_FIELD_NOT_GUARDED
LI_LAZY_INIT_STATIC
LI_LAZY_INIT_UPDATE_STATIC
L_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD
ML_SYNC_ON_UPDATED_FIELD
MSF_MUTABLE_SERVLET_FIELD
STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE
STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE
STCAL_STATIC_CALENDAR_INSTANCE
STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE
UL_UNRELEASED_LOCK

20

Synchronization

DM_BOXED_PRIMITIVE_TOSTRING

1


HSC_HUGE_SHARED_STRING_CONSTANT

6

A large String constant is duplicated across multiple class files. This is likely because a final field is initialized to a String constant, and the Java language mandates that all references to a final field from other classes be inlined into that classfile. See JDK bug 6447475 for a description of an occurrence of this bug in the JDK and how resolving it reduced the size of the JDK by 1 megabyte.