Inspectopedia Help

Performance

'Collection.toArray()' call style  

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  

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

'List.remove()' called in loop  

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

'Map' can be replaced with 'EnumMap'  

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

'Set' can be replaced with 'EnumSet'  

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

'String.equals()' can be replaced with 'String.isEmpty()'  

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

'StringBuilder' without initial capacity  

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

'StringBuilder.toString()' in concatenation  

Reports StringBuffer.toString() or StringBuilder.toString() calls in string concatenations.

'equals()' call can be replaced with '=='  

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

Auto-boxing  

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

Auto-unboxing  

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

Boolean constructor call  

Reports creation of Boolean objects.

Boxing of already boxed value  

Reports boxing of already boxed values.

Bulk 'Files.readAttributes()' call can be used  

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  

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

Call to 'Arrays.asList()' with too few arguments  

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

Call to 'list.containsAll(collection)' may have poor performance  

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

Call to 'set.removeAll(list)' may work slowly  

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

Call to simple getter from within class  

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

Call to simple setter from within class  

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

Class initializer may be 'static'  

Reports instance initializers which may be made static.

Collection without initial capacity  

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

Dynamic regular expression could be replaced by compiled 'Pattern'  

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  

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

Explicit argument can be lambda  

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'  

Reports instance variables that can safely be made static.

Inefficient Stream API call chains ending with count()  

Reports Stream API call chains ending with the count() operation that could be optimized.

Instantiating object to get 'Class' object  

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

Iteration over 'keySet()' can be optimized  

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  

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

Manual array to collection copy  

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'  

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

Object allocation in loop  

Reports object or array allocations inside loops.

Object instantiation inside 'equals()' or 'hashCode()'  

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

Redundant 'Collection.addAll()' call  

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

Redundant call to 'String.format()'  

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

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

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  

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

String concatenation in loop  

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'  

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

Unnecessary temporary object in conversion to 'String'  

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

Using 'Random.nextDouble()' to get random integer  

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  

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: 18 June 2024