|
The result of invoking readLine() is immediately dereferenced. If there are no more lines of text
to read, readLine() will return null and dereferencing that will generate a null pointer exception.
Repository: findbugs
Key: NP_IMMEDIATE_DEREFERENCE_OF_READLINE
Available since 07 Jan 2014
|
|
A circularity was detected in the static initializers of the two
classes referenced by the bug instance. Many kinds of unexpected
behavior may arise from such circularity.
Repository: findbugs
Key: IC_INIT_CIRCULARITY
Available since 07 Jan 2014
|
|
This instanceof test will always return true (unless the value being tested is null).
Although this is safe, make sure it isn't
an indication of some misunderstanding or some other logic error.
If you really want to test the value for being null, perhaps it would be clearer to do
better to do a null test rather than an instanceof test.
Repository: findbugs
Key: BC_VACUOUS_INSTANCEOF
Available since 07 Jan 2014
|
|
This code casts the result of an integer division operation to double or
float.
Doing division on integers truncates the result
to the integer value closest to zero. The fact that the result
was cast to double suggests that this precision should have been retained.
What was probably meant was to cast one or both of the operands to
double before performing the division. Here is an example:
int x = 2;
int y = 5;
// Wrong: yields result 0.0
double value1 = x / y;
// Right: yields result 0.4
double value2 = x / (double) y;
Repository: findbugs
Key: ICAST_IDIV_CAST_TO_DOUBLE
Available since 07 Jan 2014
|
|
This code invokes substring(0) on a String, which returns the original value.
Repository: findbugs
Key: DMI_USELESS_SUBSTRING
Available since 07 Jan 2014
|
|
The variable referenced at this point is known to be null due to an earlier
check against null. Although this is valid, it might be a mistake (perhaps you
intended to refer to a different variable, or perhaps the earlier check to see if the
variable is null should have been a check to see if it was nonnull).
Repository: findbugs
Key: NP_LOAD_OF_KNOWN_NULL_VALUE
Available since 07 Jan 2014
|
|
The method invokes String.indexOf and checks to see if the result is positive or non-positive.
It is much more typical to check to see if the result is negative or non-negative. It is
positive only if the substring checked for occurs at some place other than at the beginning of
the String.
Repository: findbugs
Key: RV_CHECK_FOR_POSITIVE_INDEXOF
Available since 07 Jan 2014
|
|
This method allocates a specific implementation of an xml interface. It is preferable to use
the supplied factory classes to create these objects so that the implementation can be
changed at runtime. See
- javax.xml.parsers.DocumentBuilderFactory
- javax.xml.parsers.SAXParserFactory
- javax.xml.transform.TransformerFactory
- org.w3c.dom.Document.createXXXX
for details.
Repository: findbugs
Key: XFB_XML_FACTORY_BYPASS
Available since 07 Jan 2014
|
|
The value returned by readLine is discarded after checking to see if the return
value is non-null. In almost all situations, if the result is non-null, you will want
to use that non-null value. Calling readLine again will give you a different line.
Repository: findbugs
Key: RV_DONT_JUST_NULL_CHECK_READLINE
Available since 07 Jan 2014
|
|
This method uses the same code to implement two branches of a conditional branch.
Check to ensure that this isn't a coding mistake.
Repository: findbugs
Key: DB_DUPLICATE_BRANCHES
Available since 07 Jan 2014
|
|
This method uses the same code to implement two clauses of a switch statement.
This could be a case of duplicate code, but it might also indicate
a coding mistake.
Repository: findbugs
Key: DB_DUPLICATE_SWITCH_CLAUSES
Available since 07 Jan 2014
|
|
This code seems to be passing a non-serializable object to the ObjectOutput.writeObject method.
If the object is, indeed, non-serializable, an error will result.
Repository: findbugs
Key: DMI_NONSERIALIZABLE_OBJECT_WRITTEN
Available since 07 Jan 2014
|
|
An argument not of type Boolean is being formatted with a %b format specifier. This won't throw an
exception; instead, it will print true for any nonnull value, and false for null.
This feature of format strings is strange, and may not be what you intended.
Repository: findbugs
Key: VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN
Available since 07 Jan 2014
|
|
This parameter is always used in a way that requires it to be nonnull,
but the parameter is explicitly annotated as being Nullable. Either the use
of the parameter or the annotation is wrong.
Repository: findbugs
Key: NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE
Available since 07 Jan 2014
|
|
The return value from a method is dereferenced without a null check,
and the return value of that method is one that should generally be checked for null (which requires to use Findbugs annotations to express the developer's intend).
This may lead to a NullPointerException when the code is executed.
Noncompliant Code Example
public long getTime() {
return getDate().getTime(); // NullPointerException may occur
}
@CheckForNull // See javax.annotation.CheckForNull (JSR-305)
public Date getDate() { /* ... */ }
Compliant Solution
public long getTime() {
Date date = getDate();
if (date == null) {
throw new IllegalStateException("...");
}
return date.getTime();
}
@CheckForNull // See javax.annotation.CheckForNull (JSR-305)
public Date getDate() { /* ... */ }
Repository: findbugs
Key: NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
Available since 07 Jan 2014
|
|
There is a branch of statement that, if executed, guarantees that
a null value will be dereferenced, which
would generate a NullPointerException when the code is executed.
Of course, the problem might be that the branch or statement is infeasible and that
the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.
Due to the fact that this value had been previously tested for nullness, this is a definite possibility.
Repository: findbugs
Key: NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE
Available since 07 Jan 2014
|
|
This code seems to be using non-short-circuit logic (e.g., &
or |)
rather than short-circuit logic (&& or ||). In addition,
it seem possible that, depending on the value of the left hand side, you might not
want to evaluate the right hand side (because it would have side effects, could cause an exception
or could be expensive.
Non-short-circuit logic causes both sides of the expression
to be evaluated even when the result can be inferred from
knowing the left-hand side. This can be less efficient and
can result in errors if the left-hand side guards cases
when evaluating the right-hand side can generate an error.
See the Java
Language Specification for details
Repository: findbugs
Key: NS_DANGEROUS_NON_SHORT_CIRCUIT
Available since 07 Jan 2014
|
|
This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses.
This might be intentional and OK, but should be reviewed to ensure it is what is intended.
Repository: findbugs
Key: SE_PRIVATE_READ_RESOLVE_NOT_INHERITED
Available since 07 Jan 2014
|
|
This code casts a Collection to an abstract collection
(such as List , Set , or Map ).
Ensure that you are guaranteed that the object is of the type
you are casting to. If all you need is to be able
to iterate through a collection, you don't need to cast it to a Set or List.
Repository: findbugs
Key: BC_BAD_CAST_TO_ABSTRACT_COLLECTION
Available since 07 Jan 2014
|
|
This code casts an abstract collection (such as a Collection, List, or Set)
to a specific concrete implementation (such as an ArrayList or HashSet).
This might not be correct, and it may make your code fragile, since
it makes it harder to switch to other concrete implementations at a future
point. Unless you have a particular reason to do so, just use the abstract
collection class.
Repository: findbugs
Key: BC_BAD_CAST_TO_CONCRETE_COLLECTION
Available since 07 Jan 2014
|
|
This code seems to be using non-short-circuit logic (e.g., &
or |)
rather than short-circuit logic (&& or ||).
Non-short-circuit logic causes both sides of the expression
to be evaluated even when the result can be inferred from
knowing the left-hand side. This can be less efficient and
can result in errors if the left-hand side guards cases
when evaluating the right-hand side can generate an error.
See the Java
Language Specification for details
Repository: findbugs
Key: NS_NON_SHORT_CIRCUIT
Available since 07 Jan 2014
|
|
This method contains a reference known to be non-null with another reference
known to be null.
Repository: findbugs
Key: RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE
Available since 07 Jan 2014
|
|
This method contains a redundant comparison of two references known to
both be definitely null.
Repository: findbugs
Key: RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES
Available since 07 Jan 2014
|
|
This method contains a redundant check of a known non-null value against
the constant null.
Repository: findbugs
Key: RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
Available since 07 Jan 2014
|
|
This method contains a redundant check of a known null value against
the constant null.
Repository: findbugs
Key: RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE
Available since 07 Jan 2014
|