Duration.withNanos()
may not produce correct results JAVA-E1087Using Duration.withNanos()
may produce wrong results, because it will only set the value of the nanoseconds field of
the duration, and will not correctly adjust for any overflow.
ZoneId.of()
should be passed a valid timezone identifier JAVA-E1092java.time.ZoneId.of()
should not be passed invalid time zone identifier strings, as this will cause exceptions to be thrown at runtime.
The Java analyzer has detected a narrowing cast of a subtraction in a comparison method that may flip the sign of the result.
If a method of a superclass has one particular nullability annotation applied to it, avoid marking any overrides in subtypes with a different nullability annotation.
Make sure to use the same annotation present on the super method as much as possible.
setUp
but does not invoke super.setUp()
JAVA-S0337This class inherits from JUnit's TestCase
class and implements the setUp()
method. The setUp
method should call super.setUp()
, but doesn't.
@OverridingMethodsMustInvokeSuper
annotation in super method is ignored by overriding method JAVA-S0001The super method is annotated with @OverridingMethodsMustInvokeSuper
, but the overriding method isn't calling the super method.
A call has been made to an unsupported method.
close()
is being invoked on a value that is always null. If this statement is executed, a null pointer exception will occur. Another serious issue is the fact that the resource that is meant to be closed is not closed.
This loop doesn't seem to have a way to terminate (other than by perhaps throwing an exception).
It is better to explicitly break out of the loop instead of relying on a possibly unclear exit condition.
BigDecimal
constructed from double
may be imprecise JAVA-S0008BigDecimal
s constructed from a double
may not be represented correctly.
This class extends from a Servlet class, and uses an instance member variable. Since only one instance of a Servlet class is created by the J2EE framework, and it is used in a multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider only using method local variables, or implement proper synchronization on the static fields.
readResolve
must return Object
JAVA-E1032readResolve()
must return only java.lang.Object
, not any other type.
serialVersionUID
should be correctly declared JAVA-E1042The serialVersionUID
field must be declared as <access modifier> static final long serialVersionUID
. Not declaring it as such will prevent Java from processing it.
A double assignment of a variable to itself has been detected. This may be a typo.
Check whether this is correct and edit it or remove the extra assignment.
getClass
should not be used with enums whose members have custom bodies JAVA-E1106Enum variants with custom bodies are implemented as anonymous classes, and calling getClass
on an enum variant with a body will return the Class instance corresponding to the anonymous class, not the enum itself.
Use the getDeclaringClass()
method to retrieve the actual enum type in such cases.
Thread
methods JAVA-E1107Deprecated methods from java.lang.Thread
such as Thread.stop()
or Thread.suspend()
should not be used as they can cause instability.
Always terminate calls to assertThat()
or verify()
with a relevant assertion call, such as equals()
, or similar.
Boolean
method may return null
JAVA-S0030A method with a Boolean
return type returns an explicit null. This is likely intentional, but be aware that API consumers may not realize that.
toArray()
result detected JAVA-S0386This code is casting the result of calling toArray()
on a collection to a subtype of Object[]
, as in:
null
JAVA-E1097Throwing null
is a bad practice and should be avoided, as it serves no meaningful purpose.