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.
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:
This method ignores the original value of a parameter and attempts to assign a new value to it. This often indicates a mistaken belief that the write to the parameter will be conveyed back to the caller. Because a parameter is just a copy of a reference from the calling scope, overwriting it will only modify the method's local copy of the reference, not the calling scope's copy.
Optional
return type must not return null
JAVA-S0031The usage of an Optional
return type (java.util.Optional
or com.google.common.base.Optional
for Java 7) always means that explicit null
returns were not desired by design.
System.exit()
should only be invoked within application entry points JAVA-S0060This method invokes System.exit()
, and is called by other code. This can prevent proper error handling and debugging.
This code contains a possible null pointer dereference. Double-check the code to ensure that the concerned variable always has a non-null value when accessed.
This code contains a possible null dereference that may occur based on whether an exception is thrown or not. Carefully check your code to ensure that the concerned value can never be null at this point.
Collections should not be modified when an iterator is still in scope.
equals
method does not handle null valued operands JAVA-S0110This implementation of equals
violates the contract defined by java.lang.Object.equals
because it does not check for null
being passed as the argument.