Inspectopedia Help

Performance

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

Reports Collection.toArray() calls that are not in the preferred style, and suggests applying the preferred style.

'InputStream' and 'OutputStream' can be constructed using 'Files' methods   New in this release

Reports new FileInputStream() or new FileOutputStream() expressions that can be replaced with Files.newInputStream() or Files.newOutputStream() calls respectively.

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

Reports List.remove(index) called in a loop that can be replaced with List.subList().clear().

'Map' can be replaced with 'EnumMap'   New in this release

Reports instantiations of java.util.Map objects whose key types are enumerated classes.

'Set' can be replaced with 'EnumSet'   New in this release

Reports instantiations of java.util.Set objects whose content types are enumerated classes.

'String.equals()' can be replaced with 'String.isEmpty()'   New in this release

Reports equals() being called to compare a String with an empty string.

'StringBuilder' without initial capacity   New in this release

Reports attempts to instantiate a new StringBuffer or StringBuilder object without specifying its initial capacity.

'equals()' call can be replaced with '=='   New in this release

Reports calls to equals() that can be replaced by == or != expressions without a change in semantics.

Auto-boxing   New in this release

Reports expressions that are affected by autoboxing conversion (automatic wrapping of primitive values as objects).

Auto-unboxing   New in this release

Reports expressions that are affected by unboxing conversion (automatic unwrapping of objects into primitive values).

Boolean constructor call   New in this release

Reports creation of Boolean objects.

Boxing of already boxed value   New in this release

Reports boxing of already boxed values.

Bulk 'Files.readAttributes()' call can be used   New in this release

Reports multiple sequential java.io.File attribute checks, such as: isDirectory() isFile() lastModified() length() Such calls can be replaced with a bulk Files.readAttributes() call.

Bulk operation can be used instead of iteration   New in this release

Reports single operations inside loops that could be replaced with a bulk method.

Call to 'Arrays.asList()' with too few arguments   New in this release

Reports calls to Arrays.asList() with at most one argument.

Call to 'list.containsAll(collection)' may have poor performance   New in this release

Reports calls to containsAll() on java.util.List.

Call to 'set.removeAll(list)' may work slowly   New in this release

Reports calls to java.util.Set.removeAll() with a java.util.List argument.

Call to simple getter from within class   New in this release

Reports calls to a simple property getter from within the property's class.

Call to simple setter from within class   New in this release

Reports calls to a simple property setter from within the property's class.

Class initializer may be 'static'   New in this release

Reports instance initializers which may be made static.

Collection without initial capacity   New in this release

Reports attempts to instantiate a new Collection object without specifying an initial capacity.

Dynamic regular expression can be replaced by compiled 'Pattern'   New in this release

Reports calls to the regular expression methods (such as matches() or split()) of java.lang.String using constant arguments.

Early loop exit in 'if' condition   New in this release

Reports loops with an if statement that can end with break without changing the semantics.

Explicit argument can be lambda   New in this release

Reports method calls that accept a non-trivial expression and can be replaced with an equivalent method call which accepts a lambda instead.

Field can be made 'static'   New in this release

Reports instance variables that can safely be made static.

Inefficient Stream API call chains ending with count()   New in this release

Reports Stream API call chains ending with a count() operation, that are optimizable.

Instantiating object to get 'Class' object   New in this release

Reports code that instantiates a class to get its class object.

Iteration over 'keySet()' can be optimized   New in this release

Reports iterations over the keySet() of a java.util.Map instance, where the iterated keys are used to retrieve the values from the map.

Manual array copy   New in this release

Reports manual copying of array contents that can be replaced with a call to System.arraycopy().

Manual array to collection copy   New in this release

Reports code that uses a loop to copy the contents of an array into a collection.

Method can be made 'static'  

Reports methods that can safely be made static.

Non-constant 'String' can be replaced with 'StringBuilder'   New in this release

Reports variables declared as java.lang.String that are repeatedly appended to.

Object allocation in loop   New in this release

Reports object or array allocations inside loops.

Object instantiation inside 'equals()' or 'hashCode()'   New in this release

Reports construction of (temporary) new objects inside equals(), hashCode(), compareTo(), and Comparator.compare() methods.

Redundant 'Collection.addAll()' call   New in this release

Reports Collection.addAll() and Map.putAll() calls immediately after an instantiation of a collection using a no-arg constructor.

Redundant call to 'String.format()'   New in this release

Reports calls to methods like format() and printf() that can be safely removed or simplified.

Single character string argument in 'String.indexOf()' call   New in this release

Reports single character strings being used as an argument in String.indexOf() and String.lastIndexOf() calls.

Single character string concatenation  

Reports concatenation with string literals that consist of one character.

String concatenation as argument to 'StringBuilder.append()' call   New in this release

Reports String concatenation used as the argument to StringBuffer.append(), StringBuilder.append() or Appendable.append().

String concatenation in loop   New in this release

Reports String concatenation in loops.

Tail recursion  

Reports tail recursion, that is, when a method calls itself as its last action before returning.

Unnecessary temporary object in conversion from 'String'   New in this release

Reports unnecessary creation of temporary objects when converting from String to primitive types.

Unnecessary temporary object in conversion to 'String'   New in this release

Reports unnecessary creation of temporary objects when converting from a primitive type to String.

Using 'Random.nextDouble()' to get random integer   New in this release

Reports calls to java.util.Random.nextDouble() that are used to create a positive integer number by multiplying the call by a factor and casting to an integer.

Wrapper type may be primitive   New in this release

Reports local variables of wrapper type that are mostly used as primitive types.

Embedded  

Sub-group of 11 inspections that provide checks for Embedded

Last modified: 11 September 2024