ZoneId.of("Z")
should be replaced with ZoneOffset.UTC
JAVA-W1085Avoid calling ZoneId.of()
to get the UTC timezone offset, and instead use ZoneOffset.UTC
directly.
Object.equals()
JAVA-W1080Comparing two primitive values with Objects.equals()
can be inefficient, since both primitives will have to be boxed before being compared.
The constructor of an abstract class can never be called directly by the dependency injection framework, meaning any injection annotations applied to it will not be considered. Remove the annotation.
Future
s should not be ignored JAVA-W1087Always use the value returned by a method with return type Future<T>
.
Unused imports should be removed from all source files.
Our analysis shows that this object is useless. It's created and modified, but its value never goes outside the method or produces any side effect. Either there is a mistake and the object was intended to be used or it can be removed.
When a catch
clause is empty, it essentially ignores any occurrences of the particular exception it handles. This could allow critical bugs to go undiagnosed because any relevant exceptions indicative of a bug would be discarded within this catch
block.
This class is declared to be final, but declares fields to be protected. Such code is confusing, since protected fields in final classes are effectively the same as private fields.
Lock
object JAVA-S0321This method performs synchronization on an object that implements java.util.concurrent.locks.Lock
. Such an object is locked/unlocked using acquire()
/release()
rather than using the synchronized (...)
construct.
assertNull
/NotNull
instead of assertEquals
/notEquals
to assert nullity JAVA-W1091Use the assertNull
and assertNotNull
methods instead of using assertEquals
or assertNotEquals
with an expected null
argument.
This class is not an exception, and does not extend Throwable
or any other exception class, but ends with 'Exception'
. This may be confusing to users of this class.
next
method must throw NoSuchElementException
JAVA-S0146This class implements the java.util.Iterator
interface. However, its next()
method is not capable of throwing java.util.NoSuchElementException
. This is a violation of the Iterator
interface's contract, and will not work with code that expects next()
to throw when the iterator is exhausted.
IllegalMonitorStateException
s should not be handled JAVA-S0040IllegalMonitorStateException
is generally only thrown in case of a design flaw in your code (calling wait
or notify
on an object you do not hold a lock on).
The code calls putNextEntry()
, immediately followed by a call to closeEntry()
. This results in an empty ZipFile
entry.
@Inject
detected on a final field JAVA-W1071@javax.inject.Inject
should not be used on final fields.
The code calls putNextEntry()
, immediately followed by a call to closeEntry()
. This results in an empty JarFile
entry.
The method performs math operations using floating point precision. Floating point precision is very imprecise.
Date
API JAVA-W1072java.util.Date
API should be avoided.
The method creates a database resource (such as a database connection or row set), does not assign it to any fields, pass it to other methods, or return it, and does not appear to close the object on all exception paths out of the method. Failure to close database resources on all paths out of a method may result in poor performance, and could cause the application to have problems communicating with the database.
Thread
passed where Runnable
expected JAVA-S0056A Thread
object is passed as a parameter to a method where a Runnable
is expected. This is rather unusual, and may indicate a logic error or cause unexpected behavior.