Java

Java

Made by DeepSource
ZoneId.of("Z") should be replaced with ZoneOffset.UTC JAVA-W1085
Anti-pattern
Major
Autofix

Avoid calling ZoneId.of() to get the UTC timezone offset, and instead use ZoneOffset.UTC directly.

Inject annotations on abstract class constructors have no effect JAVA-W1084
Anti-pattern
Major
Autofix

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.

Returned Futures should not be ignored JAVA-W1087
Anti-pattern
Major

Always use the value returned by a method with return type Future<T>.

Unnecessary imports detected JAVA-W1069
Anti-pattern
Major

Unused imports should be removed from all source files.

Object appears to have been created for no reason JAVA-S0235
Anti-pattern
Minor

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.

Empty catch clauses may hide exceptions JAVA-E0052
Anti-pattern
Major

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.

Protected fields in a final class are useless JAVA-W0417
Anti-pattern
Minor
Autofix

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.

Synchronization performed on a util.concurrent Lock object JAVA-S0321
Anti-pattern
Critical

This 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.

Use assertNull/NotNull instead of assertEquals/notEquals to assert nullity JAVA-W1091
Anti-pattern
Major
Autofix

Use the assertNull and assertNotNull methods instead of using assertEquals or assertNotEquals with an expected null argument.

Class is not an Exception/Throwable, even though it is named as such JAVA-S0182
Anti-pattern
Minor

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.

Iterator next method must throw NoSuchElementException JAVA-S0146
Anti-pattern
Major

This 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.

IllegalMonitorStateExceptions should not be handled JAVA-S0040
Anti-pattern
Critical

IllegalMonitorStateException 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).

Empty zip file entries should not be created JAVA-S0038
Anti-pattern
Major

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
Anti-pattern
Major
Autofix

@javax.inject.Inject should not be used on final fields.

Empty jar file entries should not be created JAVA-S0039
Anti-pattern
Major

The code calls putNextEntry(), immediately followed by a call to closeEntry(). This results in an empty JarFile entry.

Float precision math may be imprecise JAVA-S0041
Anti-pattern
Minor

The method performs math operations using floating point precision. Floating point precision is very imprecise.

Detected use of the Date API JAVA-W1072
Anti-pattern
Major

java.util.Date API should be avoided.

Possible database resource leak detected JAVA-S0327
Anti-pattern
Critical

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-S0056
Anti-pattern
Major

A 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.