Inspectopedia 2024.3 Help

Probable bugs

'Comparable' implemented but 'equals()' not overridden   New in this release

Reports classes that implement java.lang.Comparable but do not override equals().

'Iterator.hasNext()' which calls 'next()'   New in this release

Reports implementations of Iterator.hasNext() or ListIterator.hasPrevious() that call Iterator.next() or ListIterator.previous() on the iterator instance.

'Iterator.next()' which can't throw 'NoSuchElementException'   New in this release

Reports implementations of Iterator.next() that cannot throw java.util.NoSuchElementException.

'Math.random()' cast to 'int'   New in this release

Reports calls to Math.random() which are immediately cast to int.

'ScheduledThreadPoolExecutor' with zero core threads   New in this release

Reports any java.util.concurrent.ScheduledThreadPoolExecutor instances in which corePoolSize is set to zero via the setCorePoolSize method or the object constructor.

'String.equals()' called with 'CharSequence' argument   New in this release

Reports calls to String.equals() with a CharSequence as the argument.

'Throwable' not thrown   New in this release

Reports instantiations of Throwable or its subclasses, where the created Throwable is never actually thrown.

'assert' statement with side effects   New in this release

Reports assert statements that cause side effects.

'equal()' instead of 'equals()'   New in this release

Reports declarations of equal() with a single parameter.

'equals()' and 'hashCode()' not paired   New in this release

Reports classes that override the equals() method but do not override the hashCode() method or vice versa, which can potentially lead to problems when the class is added to a Collection or a HashMap.

'equals()' between objects of inconvertible types   New in this release

Reports calls to equals() where the target and argument are of incompatible types.

'equals()' called on array   New in this release

Reports equals() calls that compare two arrays.

'equals()' called on classes which don't override it   New in this release

Reports equals() calls on StringBuilder, StringBuffer and instances of java.util.concurrent.atomic package.

'equals()' called on itself   New in this release

Reports calls to equals(), compareTo() or similar, that compare an object for equality with itself.

'equals()' method that does not check the class of its parameter   New in this release

Reports equals() methods that do not check the type of their parameter.

'hashCode()' called on array   New in this release

Reports incorrect hash code calculation for arrays.

'instanceof' with incompatible type   New in this release

Reports instanceof expressions where the expression that is checked has a class/interface type that neither extends/implements the class/interface type on the right-side of the instanceof expression, nor has subclasses that do.

Array comparison using '==', instead of 'Arrays.equals()'   New in this release

Reports operators == and != used to test for array equality.

Call math rounding with 'int' argument   New in this release

Reports calls to round(), ceil(), floor(), rint() methods for Math and StrictMath with int as the argument.

Call methods with unsupported 'java.time.temporal.ChronoUnit' and 'java.time.temporal.ChronoField'   New in this release

Reports java.time method calls (get(), getLong(), with(), plus(), minus()) with unsupported java.time.temporal.ChronoField or java.time.temporal.ChronoUnit enum constants as arguments.

Call to 'toString()' on array   New in this release

Reports arrays used in String concatenations or passed as parameters to java.io.PrintStream methods, such as System.out.println().

Call to default 'toString()'   New in this release

Reports calls to toString() that use the default implementation from java.lang.Object.

Cast conflicts with 'instanceof'   New in this release

Reports type cast expressions that are preceded by an instanceof check for a different type.

Cast to incompatible type   New in this release

Reports type cast expressions where the casted expression has a class/interface type that neither extends/implements the cast class/interface type, nor has subclasses that do.

Cleaner captures object reference   New in this release

Reports Runnable passed to a Cleaner.register() capturing reference being registered.

Collection added to itself   New in this release

Reports cases where the argument of a method call on a java.util.Collection or java.util.Map is the collection or map itself.

Confusing 'main()' method   New in this release

Reports methods that are named "main", but do not have the public static void main(String[]) signature in Java up to 21.

Confusing argument to varargs method   New in this release

Reports calls to variable arity methods that have a single argument in the vararg parameter position, which is either a null or an array of a subtype of the vararg parameter.

Confusing primitive array argument to varargs method   New in this release

Reports any calls to a variable arity method where the call has a primitive array in the variable arity parameter position (for example, System.out.printf("%s", new int[]{1, 2, 3})).

Constant condition in 'assert' statement   New in this release

Reports assert statement conditions that are constants.

Constant values   New in this release

Reports expressions and conditions that always produce the same result, like true, false, null, or zero.

Contract issues   New in this release

Reports issues in method @Contract annotations.

Copy constructor misses field   New in this release

Reports copy constructors that don't copy all the fields of the class.

Covariant 'equals()'   New in this release

Reports equals() methods taking an argument type other than java.lang.Object if the containing class does not have other overloads of equals() that take java.lang.Object as its argument type.

Duplicated delimiters in 'StringTokenizer'   New in this release

Reports StringTokenizer() constructor calls or nextToken() method calls that contain duplicate characters in the delimiter argument.

Expression is compared to itself   New in this release

Reports comparisons where left and right operand represent the identical expression.

Inconsistent whitespace indentation in text block   New in this release

Reports text blocks that are indented using both spaces and tabs.

Incorrect 'DateTimeFormat' pattern   New in this release

Reports incorrect date time format patterns.

Incorrect 'MessageFormat' pattern   New in this release

Reports incorrect message format patterns or incorrect indexes of placeholders The following errors are reported: Unparsed or negative index Unclosed brace Unpaired quote.

Infinite recursion  

Reports methods that call themselves infinitely unless an exception is thrown.

Inner class referenced via subclass   New in this release

Reports accesses of inner and nested classes where the call is qualified by a subclass of the declaring class, rather than the declaring class itself.

Instantiation of utility class   New in this release

Reports instantiation of utility classes using the new keyword.

Invalid method reference used for 'Comparator'   New in this release

Reports method references mapped to the Comparator interface that don't fulfill its contract.

Iterable is used as vararg   New in this release

Reports suspicious usages of Collection or Iterable in vararg method calls.

Loop executes zero or billions of times   New in this release

Reports loops that cannot be completed without an index overflow or loops that don't loop at all.

Magic constant   New in this release

Reports expressions that can be replaced with "magic" constants.

Malformed format string   New in this release

Reports format strings that don't comply with the standard Java syntax.

Meaningless record annotation   New in this release

Reports annotations used on record components that have no effect.

Mismatched case in 'String' operation   New in this release

Reports String method calls that always return the same value (-1 or false) because a lowercase character is searched in an uppercase-only string or vice versa.

Mismatched query and update of 'StringBuilder'   New in this release

Reports StringBuilder, StringBuffer or StringJoiner objects whose contents are read but not written to, or written to but not read.

Mismatched query and update of collection  

Reports collections whose contents are either queried and not updated, or updated and not queried.

Mismatched read and write of array   New in this release

Reports arrays whose contents are read but not updated, or updated but not read.

New object is compared using '=='   New in this release

Reports code that applies == or != to a newly allocated object instead of calling equals().

Non-final field referenced in 'compareTo()'   New in this release

Reports access to a non-final field inside a compareTo() implementation.

Non-final field referenced in 'equals()'   New in this release

Reports implementations of equals() that access non-final variables.

Non-final field referenced in 'hashCode()'   New in this release

Reports implementations of hashCode() that access non-final variables.

Non-short-circuit boolean expression   New in this release

Reports usages of the non-short-circuit forms of boolean 'and' and 'or' (&, |, &= and |=).

Non-short-circuit operation consumes infinite stream   New in this release

Reports non-short-circuit operations consuming an infinite stream.

Nullability and data flow problems   New in this release

Reports code constructs that always violate nullability contracts, may throw exceptions, or are just redundant, based on data flow analysis.

Number comparison using '==', instead of 'equals()'   New in this release

Reports code that uses == or != instead of equals() to test for Number equality.

Object comparison using '==', instead of 'equals()'   New in this release

Reports code that uses == or != rather than equals() to test for object equality.

Optional.get() is called without isPresent() check   New in this release

Reports calls to get() on an Optional without checking that it has a value.

Overwritten Map, Set, or array element   New in this release

Reports code that overwrites a Map key, a Set element, or an array element in a sequence of add/put calls or using a Java 9 factory method like Set.of (which will result in runtime exception).

Redundant operation on empty container   New in this release

Reports redundant operations on empty collections, maps or arrays.

Reference checked for 'null' is not used inside 'if'   New in this release

Reports references to variables that are checked for nullability in the condition of an if statement or conditional expression but not used inside that if statement.

Reflective access to a source-only annotation   New in this release

Reports attempts to reflectively check for the presence of a non-runtime annotation.

Result of method call ignored   New in this release

Reports method calls whose result is ignored.

Result of object allocation ignored  

Reports object allocations where the allocated object is ignored and neither assigned to a variable nor used in another way.

Return value is outside of declared range   New in this release

Reports numeric values returned from methods that don't conform to the declared method return range.

Sorted collection with non-comparable elements   New in this release

Reports construction of sorted collections, for example TreeSet, that rely on natural ordering, whose element type doesn't implement the Comparable interface.

Statement with empty body  

Reports if, while, do, for, and switch statements with empty bodies.

Static field referenced via subclass   New in this release

Reports accesses to static fields where the call is qualified by a subclass of the declaring class, rather than by the declaring class itself.

Static method referenced via subclass   New in this release

Reports static method calls where the call is qualified by a subclass of the declaring class, rather than by the declaring class itself.

String comparison using '==', instead of 'equals()'   New in this release

Reports code that uses of == or != to compare strings.

String concatenation as argument to 'MessageFormat.format()' call   New in this release

Reports non-constant string concatenations used as an argument to a call to MessageFormat.format().

String concatenation as argument to 'format()' call   New in this release

Reports non-constant string concatenations used as a format string argument.

StringBuilder constructor call with 'char' argument   New in this release

Reports calls to StringBuffer and StringBuilder constructors with char as the argument.

Subtraction in 'compareTo()'   New in this release

Reports subtraction in compareTo() methods and methods implementing java.util.Comparator.compare().

Suspicious 'Arrays' method call   New in this release

Reports calls to non-generic-array manipulation methods like Arrays.fill() with mismatched argument types.

Suspicious 'Class.getClass()' call   New in this release

Reports getClass() methods that are called on a java.lang.Class instance.

Suspicious 'Collection.toArray()' call   New in this release

Reports suspicious calls to Collection.toArray().

Suspicious 'Comparator.compare()' implementation   New in this release

Reports problems in Comparator.compare() and Comparable.compareTo() implementations.

Suspicious 'InvocationHandler' implementation   New in this release

Reports implementations of InvocationHandler that do not proxy standard Object methods like hashCode(), equals(), and toString().

Suspicious 'List.remove()' in loop   New in this release

Reports list.remove(index) calls inside an ascending counted loop.

Suspicious 'System.arraycopy()' call   New in this release

Reports suspicious calls to System.arraycopy().

Suspicious array cast   New in this release

Reports suspicious array casts.

Suspicious byte value returned from 'InputStream.read()'   New in this release

Reports expressions of byte type returned from a method implementing the InputStream.read() method.

Suspicious collection method call   New in this release

Reports method calls on parameterized collections, where the actual argument type does not correspond to the collection's elements type.

Suspicious date format pattern   New in this release

Reports date format patterns that are likely used by mistake.

Suspicious indentation after control statement without braces   New in this release

Reports suspicious indentation of statements after a control statement without braces.

Suspicious integer division assignment   New in this release

Reports assignments whose right side is a division that shouldn't be truncated to integer.

Suspicious regex expression argument   New in this release

Reports calls to String.replaceAll() or String.split() where the first argument is a single regex meta character argument.

Suspicious ternary operator in varargs method call   New in this release

Reports vararg method calls that use a ternary operator with mixed array and non-array branches.

Suspicious usage of compare method   New in this release

Reports comparisons of the result of Comparator.compare() or Comparable.compareTo() calls with non-zero constants.

Suspicious variable/parameter name combination  

Reports assignments and function calls in which the name of the target variable or the function parameter does not match the name of the value assigned to it.

Text label in 'switch' statement  

Reports labeled statements inside of switch statements.

Unreachable code  

Reports the code which is never reached according to data flow analysis.

Unsafe call to 'Class.newInstance()'   New in this release

Reports calls to java.lang.Class.newInstance().

Unused assignment  

Reports assignment values that are not used after assignment.

Use of 'Properties' object as a 'Hashtable'   New in this release

Reports calls to the following methods on java.util.Properties objects: put() putIfAbsent() putAll() get() For historical reasons, java.util.Properties inherits from java.util.Hashtable, but using these methods is discouraged to prevent pollution of properties with values of types other than String.

Use of Optional.ofNullable with null or not-null argument   New in this release

Reports uses of Optional.ofNullable() where always null or always not-null argument is passed.

Use of index 0 in JDBC ResultSet   New in this release

Reports attempts to access column 0 of java.sql.ResultSet or java.sql.PreparedStatement.

Use of shallow or 'Objects' methods with arrays   New in this release

Reports expressions that seem to use an inappropriate method for determining array equality or calculating their hashcode.

Whitespace may be missing in string concatenation   New in this release

Reports string concatenations with missing whitespaces, that is where the left-hand side ends with a Unicode letter or digit and the right-hand side starts with a Unicode letter or digit.

Write-only object   New in this release

Reports objects that are modified but never queried.

Wrong package statement   New in this release

Detects package statements that do not correspond to the project directory structure.

Nullability problems  

Sub-group of 3 inspections that provide checks for Nullability problems

Last modified: 11 September 2024