|
This class defines a serialVersionUID field that is not long.
The field should be made long
if it is intended to specify
the version UID for purposes of serialization.
Repository: findbugs
Key: SE_NONLONG_SERIALVERSIONID
Available since 07 Jan 2014
|
|
This class defines a serialVersionUID field that is not static.
The field should be made static
if it is intended to specify
the version UID for purposes of serialization.
Repository: findbugs
Key: SE_NONSTATIC_SERIALVERSIONID
Available since 07 Jan 2014
|
|
The class's static initializer creates an instance of the class
before all of the static final fields are assigned.
Repository: findbugs
Key: SI_INSTANCE_BEFORE_FINALS_ASSIGNED
Available since 07 Jan 2014
|
|
This code seems to be storing a non-serializable object into an HttpSession.
If this session is passivated or migrated, an error will result.
Repository: findbugs
Key: J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION
Available since 07 Jan 2014
|
|
During the initialization of a class, the class makes an active use of a subclass.
That subclass will not yet be initialized at the time of this use.
For example, in the following code, foo will be null.
public class CircularClassInitialization {
static class InnerClassSingleton extends CircularClassInitialization {
static InnerClassSingleton singleton = new InnerClassSingleton();
}
static CircularClassInitialization foo = InnerClassSingleton.singleton;
}
Repository: findbugs
Key: IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION
Available since 07 Jan 2014
|
|
This method compares two reference values using the == or != operator,
where the correct way to compare instances of this type is generally
with the equals() method. Examples of classes which should generally
not be compared by reference are java.lang.Integer, java.lang.Float, etc.
Repository: findbugs
Key: RC_REF_COMPARISON
Available since 07 Jan 2014
|
|
In order for the readResolve method to be recognized by the serialization
mechanism, it must be declared to have a return type of Object.
Repository: findbugs
Key: SE_READ_RESOLVE_MUST_RETURN_OBJECT
Available since 07 Jan 2014
|
|
This toString method seems to return null in some circumstances. A liberal reading of the
spec could be interpreted as allowing this, but it is probably a bad idea and could cause
other code to break. Return the empty string or some other appropriate string rather than null.
Repository: findbugs
Key: NP_TOSTRING_COULD_RETURN_NULL
Available since 07 Jan 2014
|
|
This class contains a field that is updated at multiple places in the class, thus it seems to be part of the state of the class. However, since the field is marked as transient and not set in readObject or readResolve, it will contain the default value in any
deserialized instance of the class.
Repository: findbugs
Key: SE_TRANSIENT_FIELD_NOT_RESTORED
Available since 07 Jan 2014
|
|
This call to a generic collection method passes an argument
while compile type Object where a specific type from
the generic type parameters is expected.
Thus, neither the standard Java type system nor static analysis
can provide useful information on whether the
object being passed as a parameter is of an appropriate type.
Repository: findbugs
Key: GC_UNCHECKED_TYPE_IN_GENERIC_CALL
Available since 07 Jan 2014
|
|
Calling this.getClass().getResource(...) could give
results other than expected if this class is extended by a class in
another package.
Repository: findbugs
Key: UI_INHERITANCE_UNSAFE_GETRESOURCE
Available since 07 Jan 2014
|
|
This identifier is used as a keyword in later versions of Java. This code, and
any code that references this API,
will need to be changed in order to compile it in later versions of Java.
Repository: findbugs
Key: NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER
Available since 07 Jan 2014
|
|
The identifier is a word that is reserved as a keyword in later versions of Java, and your code will need to be changed
in order to compile it in later versions of Java.
Repository: findbugs
Key: NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER
Available since 07 Jan 2014
|
|
The referenced methods have names that differ only by capitalization.
This is very confusing because if the capitalization were
identical then one of the methods would override the other. From the existence of other methods, it
seems that the existence of both of these methods is intentional, but is sure is confusing.
You should try hard to eliminate one of them, unless you are forced to have both due to frozen APIs.
Repository: findbugs
Key: NM_VERY_CONFUSING_INTENTIONAL
Available since 07 Jan 2014
|
|
Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and for 1.5 on, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)
Repository: pmd
Key: BigIntegerInstantiation
Available since 07 Jan 2014
|
|
This code creates a BigDecimal from a double value that doesn't translate well to a decimal number. For example,
one might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1
(an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625.
You probably want to use the BigDecimal.valueOf(double d) method, which uses the String representation of the double to
create the BigDecimal (e.g., BigDecimal.valueOf(0.1) gives 0.1).
Repository: findbugs
Key: DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE
Available since 07 Jan 2014
|
|
Boolean expressions should be as compact as possible to improve readability.
Useless operators should be removed.
Noncompliant Code Example
if (booleanVariable == true) { /* ... */ }
if (booleanVariable != true) { /* ... */ }
if (booleanVariable || false) { /* ... */ }
doSomething(!false);
Compliant Solution
if (booleanVariable) { /* ... */ }
if (!booleanVariable) { /* ... */ }
if (booleanVariable) { /* ... */ }
doSomething(true);
Repository: squid
Key: S1125
Available since 07 Jan 2014
|
|
Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead.
Repository: pmd
Key: BooleanInstantiation
Available since 07 Jan 2014
|
|
A boxed value is unboxed and then immediately reboxed.
Repository: findbugs
Key: BX_UNBOXING_IMMEDIATELY_REBOXED
Available since 07 Jan 2014
|
|
The null check is broken since it will throw a Nullpointer itself. The reason is that a method is called on the object when it is null. It is likely that you used || instead of && or vice versa.
Repository: pmd
Key: BrokenNullCheck
Available since 07 Jan 2014
|
|
Using toLowerCase() or toUpperCase() to make case insensitive comparisons is inefficient because it requires the creation of temporary, intermediate String objects.
The following code:
boolean result1 = foo.toUpperCase().equals(bar); // Non-Compliant
boolean result2 = foo.equals(bar.toUpperCase()); // Non-Compliant
boolean result3 = foo.toLowerCase().equals(bar.LowerCase()); // Non-Compliant
should be refactored into:
boolean result = foo.equalsIgnoreCase(bar); // Compliant
Repository: squid
Key: S1157
Available since 07 Jan 2014
|
|
if you need to get an array of a class from your Collection, you should pass an array of the desidered class as the parameter of the toArray method. Otherwise you will get a ClassCastException.
Repository: pmd
Key: ClassCastExceptionWithToArray
Available since 07 Jan 2014
|
|
This class defines a method equal(Object) .
This method does not override the equals(Object) method
in java.lang.Object , which is probably what was intended.
Repository: findbugs
Key: NM_BAD_EQUAL
Available since 07 Jan 2014
|
|
This class defines a method called tostring() .
This method does not override the toString()
method in java.lang.Object , which is probably what was intended.
Repository: findbugs
Key: NM_LCASE_TOSTRING
Available since 07 Jan 2014
|
|
Sharing some naming conventions is a key point to make it possible for a team to efficiently collaborate. This rule allows to check that all class names match a provided regular expression.
The following code snippet illustrates this rule when the regular expression value is "^[A-Z][a-zA-Z0-9]*$":
public class MyFirstClass { ... } // Compliant
public class mySecondClass { ... } // Non-Compliant
Repository: squid
Key: S00101
Available since 07 Jan 2014
|