|
The code performs an integer shift by a constant amount outside
the range 0..31.
The effect of this is to use the lower 5 bits of the integer
value to decide how much to shift by. This probably isn't want was expected,
and it at least confusing.
Repository: findbugs
Key: ICAST_BAD_SHIFT_AMOUNT
Available since 07 Jan 2014
|
|
The code here uses a regular expression that is invalid according to the syntax
for regular expressions. This statement will throw a PatternSyntaxException when
executed.
Repository: findbugs
Key: RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION
Available since 07 Jan 2014
|
|
This method invokes the .equals(Object o) method on an array. Since arrays do not override the equals
method of Object, calling equals on an array is the same as comparing their addresses. To compare the
contents of the arrays, use java.util.Arrays.equals(Object[], Object[]).
Repository: findbugs
Key: EC_BAD_ARRAY_COMPARE
Available since 07 Jan 2014
|
|
The code invokes hashCode on an array. Calling hashCode on
an array returns the same value as System.identityHashCode, and ingores
the contents and length of the array. If you need a hashCode that
depends on the contents of an array a ,
use java.util.Arrays.hashCode(a) .
Repository: findbugs
Key: DMI_INVOKING_HASHCODE_ON_ARRAY
Available since 07 Jan 2014
|
|
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.
Repository: findbugs
Key: DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY
Available since 07 Jan 2014
|
|
The code invokes toString on an array, which will generate 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.
Repository: findbugs
Key: DMI_INVOKING_TOSTRING_ON_ARRAY
Available since 07 Jan 2014
|
|
A JUnit assertion is performed in a run method. Failed JUnit assertions
just result in exceptions being thrown.
Thus, if this exception occurs in a thread other than the thread that invokes
the test method, the exception will terminate the thread but not result
in the test failing.
Repository: findbugs
Key: IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD
Available since 07 Jan 2014
|
|
A method is called that expects a Java printf format string and a list of arguments. However, the format string doesn't contain any format specifiers (e.g., %s) but does contain message format elements (e.g., {0}). It is likely that the code is supplying a MessageFormat string when a printf-style format string is required. At runtime, all of the arguments will be ignored and the format string will be returned exactly as provided without any formatting.
Repository: findbugs
Key: VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED
Available since 07 Jan 2014
|
|
This method assigns a literal boolean value (true or false) to a boolean variable inside
an if or while expression. Most probably this was supposed to be a boolean comparison using
==, not an assignment using =.
Repository: findbugs
Key: QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT
Available since 07 Jan 2014
|
|
A call to a setXXX method of a prepared statement was made where the
parameter index is 0. As parameter indexes start at index 1, this is always a mistake.
Repository: findbugs
Key: SQL_BAD_PREPARED_STATEMENT_ACCESS
Available since 07 Jan 2014
|
|
A call to getXXX or updateXXX methods of a result set was made where the
field index is 0. As ResultSet fields start at index 1, this is always a mistake.
Repository: findbugs
Key: SQL_BAD_RESULTSET_ACCESS
Available since 07 Jan 2014
|
|
This method call passes a null value for a nonnull method parameter.
Either the parameter is annotated as a parameter that should
always be nonnull, or analysis has shown that it will always be
dereferenced.
Repository: findbugs
Key: NP_NULL_PARAM_DEREF
Available since 07 Jan 2014
|
|
A possibly-null value is passed at a call site where all known
target methods require the parameter to be nonnull.
Either the parameter is annotated as a parameter that should
always be nonnull, or analysis has shown that it will always be
dereferenced.
Repository: findbugs
Key: NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS
Available since 07 Jan 2014
|
|
This method passes a null value as the parameter of a method which
must be nonnull. Either this parameter has been explicitly marked
as @Nonnull, or analysis has determined that this parameter is
always dereferenced.
Repository: findbugs
Key: NP_NONNULL_PARAM_VIOLATION
Available since 07 Jan 2014
|
|
This method defines a local variable with the same name as a field
in this class or a superclass. This may cause the method to
read an uninitialized value from the field, leave the field uninitialized,
or both.
Repository: findbugs
Key: MF_METHOD_MASKS_FIELD
Available since 07 Jan 2014
|
|
A parameter to this method has been identified as a value that should
always be checked to see whether or not it is null, but it is being dereferenced
without a preceding null check.
Repository: findbugs
Key: NP_ARGUMENT_MIGHT_BE_NULL
Available since 07 Jan 2014
|
|
The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match
the type of the corresponding parameter in the superclass. For example, if you have:
import alpha.Foo;
public class A {
public int f(Foo x) { return 17; }
}
----
import beta.Foo;
public class B extends A {
public int f(Foo x) { return 42; }
}
The f(Foo) method defined in class B doesn't
override the
f(Foo) method defined in class A , because the argument
types are Foo 's from different packages.
Repository: findbugs
Key: NM_WRONG_PACKAGE
Available since 07 Jan 2014
|
|
The return value of this method should be checked. One common
cause of this warning is to invoke a method on an immutable object,
thinking that it updates the object. For example, in the following code
fragment,
String dateString = getHeaderField(name);
dateString.trim();
the programmer seems to be thinking that the trim() method will update
the String referenced by dateString. But since Strings are immutable, the trim()
function returns a new String value, which is being ignored here. The code
should be corrected to:
String dateString = getHeaderField(name);
dateString = dateString.trim();
Repository: findbugs
Key: RV_RETURN_VALUE_IGNORED
Available since 07 Jan 2014
|
|
The return value of this method should be checked. One common
cause of this warning is to invoke a method on an immutable object,
thinking that it updates the object. For example, in the following code
fragment,
String dateString = getHeaderField(name);
dateString.trim();
the programmer seems to be thinking that the trim() method will update
the String referenced by dateString. But since Strings are immutable, the trim()
function returns a new String value, which is being ignored here. The code
should be corrected to:
String dateString = getHeaderField(name);
dateString = dateString.trim();
Repository: findbugs
Key: RV_RETURN_VALUE_IGNORED2
Available since 07 Jan 2014
|
|
This method may return a null value, but the method (or a superclass method
which it overrides) is declared to return @NonNull.
Repository: findbugs
Key: NP_NONNULL_RETURN_VIOLATION
Available since 07 Jan 2014
|
|
This class implements the Serializable interface, and defines a method
for custom serialization/deserialization. But since that method isn't declared private,
it will be silently ignored by the serialization/deserialization API.
Repository: findbugs
Key: SE_METHOD_MUST_BE_PRIVATE
Available since 07 Jan 2014
|
|
The method performs math operations using floating point precision.
Floating point precision is very imprecise. For example,
16777216.0f + 1.0f = 16777216.0f. Consider using double math instead.
Repository: findbugs
Key: FL_MATH_USING_FLOAT_PRECISION
Available since 07 Jan 2014
|
|
A format-string method with a variable number of arguments is called,
but more arguments are passed than are actually used by the format string.
This won't cause a runtime exception, but the code may be silently omitting
information that was intended to be included in the formatted string.
Repository: findbugs
Key: VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED
Available since 07 Jan 2014
|
|
The format string specifies a relative index to request that the argument for the previous format specifier
be reused. However, there is no previous argument.
For example,
formatter.format("%<s %s", "a", "b")
would throw a MissingFormatArgumentException when executed.
Repository: findbugs
Key: VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT
Available since 07 Jan 2014
|
|
This call to a generic collection method contains an argument
with an incompatible class from that of the collection's parameter
(i.e., the type of the argument is neither a supertype nor a subtype
of the corresponding generic type argument).
Therefore, it is unlikely that the collection contains any objects
that are equal to the method argument used here.
Most likely, the wrong value is being passed to the method.
In general, instances of two unrelated classes are not equal.
For example, if the Foo and Bar classes
are not related by subtyping, then an instance of Foo
should not be equal to an instance of Bar .
Among other issues, doing so will likely result in an equals method
that is not symmetrical. For example, if you define the Foo class
so that a Foo can be equal to a String ,
your equals method isn't symmetrical since a String can only be equal
to a String .
In rare cases, people do define nonsymmetrical equals methods and still manage to make
their code work. Although none of the APIs document or guarantee it, it is typically
the case that if you check if a Collection<String> contains
a Foo , the equals method of argument (e.g., the equals method of the
Foo class) used to perform the equality checks.
Repository: findbugs
Key: GC_UNRELATED_TYPES
Available since 07 Jan 2014
|