Inspectopedia 2024.3 Help

Code style issues

'List.indexOf()' expression can be replaced with 'contains()'   New in this release

Reports any List.indexOf() expressions that can be replaced with the List.contains() method.

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

Reports calls to Objects.equals(a, b) in which the first argument is statically known to be non-null.

'Optional' can be replaced with sequence of 'if' statements   New in this release

Reports Optional call chains that can be replaced with a sequence of if statements.

'Optional' contains array or collection   New in this release

Reports java.util.Optional or com.google.common.base.Optional types with an array or collection type parameter.

'assert' message is not a string   New in this release

Reports assert messages that are not of the java.lang.String type.

'equals()' called on enum value   New in this release

Reports equals() calls on enum constants.

'if' statement can be replaced with conditional or boolean expression   New in this release

Reports if statements that can be replaced with conditions using the &&, ||, ==, !=, or ?: operator.

'return' separated from the result computation   New in this release

Reports return statements that return a local variable where the value of the variable is computed somewhere else within the same method.

'size() == 0' can be replaced with 'isEmpty()'   New in this release

Reports .size() or .length() comparisons with a 0 literal that can be replaced with a call to .isEmpty().

'try' statement with multiple resources can be split   New in this release

Reports try statements with multiple resources that can be automatically split into multiple try-with-resources statements.

Array can be replaced with enum values   New in this release

Reports arrays of enum constants that can be replaced with a call to EnumType.values().

Array creation without 'new' expression   New in this release

Reports array initializers without new array expressions and suggests adding them.

Assignment can be joined with declaration   New in this release

Reports variable assignments that can be joined with a variable declaration.

Block marker comment   New in this release

Reports comments which are used as code block markers.

C-style array declaration   New in this release

Reports array declarations written in C-style syntax, where the array brackets are placed after a variable name or after a method parameter list.

Call to 'String.concat()' can be replaced with '+'   New in this release

Reports calls to java.lang.String.concat().

Can use bounded wildcard   New in this release

Reports generic method parameters that can make use of bounded wildcards.

Chained equality comparisons   New in this release

Reports chained equality comparisons.

Chained method calls   New in this release

Reports method calls whose target is another method call.

Class explicitly extends 'Object'   New in this release

Reports any classes that are explicitly declared to extend java.lang.Object.

Code block contains single statement   New in this release

Reports control flow statements with a single statement in their code block and suggests removing the braces from the control flow statement body.

Conditional can be replaced with Optional   New in this release

Reports null-check conditions and suggests replacing them with Optional chains.

Confusing octal escape sequence   New in this release

Reports string literals containing an octal escape sequence immediately followed by a digit.

Constant expression can be evaluated   New in this release

Reports constant expressions, whose value can be evaluated statically, and suggests replacing them with their actual values.

Constant on wrong side of comparison   New in this release

Reports comparison operations where the constant value is on the wrong side.

Control flow statement without braces   New in this release

Reports any if, while, do, or for statements without braces.

Diamond can be replaced with explicit type arguments   New in this release

Reports instantiation of generic classes in which the <> symbol (diamond) is used instead of type parameters.

Field assignment can be moved to initializer   New in this release

Suggests replacing initialization of fields using assignment with initialization in the field declaration.

Field may be 'final'   New in this release

Reports fields that can be safely made final.

Implicit call to 'super()'   New in this release

Reports constructors that do not begin with a call to "super" constructor or another constructor of the same class.

Instance field access not qualified with 'this'   New in this release

Reports field access operations that are not qualified with this or some other qualifier.

Instance method call not qualified with 'this'   New in this release

Reports calls to non-static methods on the same instance that are not qualified with this.

Labeled switch rule can have code block   New in this release

Reports rules of switch expressions or enhanced switch statements with an expression body.

Labeled switch rule has redundant code block   New in this release

Reports labeled rules of switch statements or switch expressions that have a redundant code block.

Lambda body can be code block   New in this release

Reports lambdas whose body is an expression and suggests converting expression bodies to code blocks.

Lambda can be replaced with anonymous class   New in this release

Reports lambda expressions that can be replaced with anonymous classes.

Lambda parameter type can be specified   New in this release

Reports lambda parameters that do not have their type specified and suggests adding the missing type declarations.

Local variable or parameter can be 'final'   New in this release

Reports parameters or local variables that may have the final modifier added to their declaration.

Method reference can be replaced with lambda   New in this release

Reports method references, like MyClass::myMethod and myObject::myMethod, and suggests replacing them with an equivalent lambda expression.

Missorted modifiers   New in this release

Reports declaration modifiers that are not in the canonical preferred order (as stated in the Java Language Specification).

Multi-catch can be split into separate catch blocks   New in this release

Reports multi-catch sections and suggests splitting them into separate catch blocks.

Multiple operators with different precedence   New in this release

Reports binary, conditional, or instanceof expressions that consist of different operators without parentheses.

Multiple variables in one declaration   New in this release

Reports multiple variables that are declared in a single declaration and suggest creating a separate declaration for each variable.

Nested method call   New in this release

Reports method calls used as parameters to another method call.

Non functional style 'Optional.isPresent()' usage   New in this release

Reports Optional expressions used as if or conditional expression conditions, that can be rewritten in a functional style.

Non-normalized annotation   New in this release

Reports annotations in a shorthand form and suggests rewriting them in a normal form with an attribute name.

Non-terminal use of '\s' escape sequence   New in this release

Reports \s escape sequences anywhere except at text-block line endings or within a series of several escaped spaces.

Reassigned variable   New in this release

Reports reassigned variables, which complicate reading and understanding the code.

Record can be converted to class   New in this release

Reports record classes and suggests converting them to ordinary classes.

Redundant 'new' expression in constant array creation   New in this release

Reports constant new array expressions that can be replaced with an array initializer.

Redundant field initialization   New in this release

Reports fields explicitly initialized to their default values.

Redundant no-arg constructor   New in this release

Reports unnecessary constructors.

Return of 'this'   New in this release

Reports methods returning this.

Same file subclasses are missing from permits clause of a sealed class   New in this release

Reports sealed classes without an explicit permits list.

Simplifiable annotation   New in this release

Reports annotations that can be simplified to their single-element or marker shorthand form.

Standard 'Charset' object can be used   New in this release

Reports methods and constructors in which constant charset String literal (for example, "UTF-8") can be replaced with the predefined StandardCharsets.UTF_8 code.

Stream API call chain can be replaced with loop   New in this release

Reports Stream API chains, Iterable.forEach(), and Map.forEach() calls that can be automatically converted into classical loops.

String literal may be 'equals()' qualifier   New in this release

Reports String.equals() or String.equalsIgnoreCase() calls with a string literal argument.

Subsequent steps can be fused into Stream API chain   New in this release

Detects transformations outside a Stream API chain that could be incorporated into it.

Trailing whitespace in text block   New in this release

Reports text blocks with trailing whitespace characters.

Type parameter explicitly extends 'Object'   New in this release

Reports type parameters and wildcard type arguments that are explicitly declared to extend java.lang.Object.

Unnecessarily qualified inner class access   New in this release

Reports any references to inner classes that are unnecessarily qualified with the name of the enclosing class.

Unnecessarily qualified static access   New in this release

Reports usages of static members unnecessarily qualified with the class name.

Unnecessarily qualified statically imported element   New in this release

Reports usage of statically imported members qualified with their containing class name.

Unnecessary 'final' on local variable or parameter   New in this release

Reports local variables or parameters unnecessarily declared final.

Unnecessary 'null' check before 'equals()' call   New in this release

Reports comparisons to null that are followed by a call to equals() with a constant argument.

Unnecessary 'super' qualifier   New in this release

Reports unnecessary super qualifiers in method calls and field references.

Unnecessary 'this' qualifier   New in this release

Reports unnecessary this qualifier.

Unnecessary call to 'super()'   New in this release

Reports calls to no-arg superclass constructors during object construction.

Unnecessary call to 'toString()'   New in this release

Reports calls to toString() that are used in the following cases: In string concatenations In the java.lang.StringBuilder#append() or java.lang.StringBuffer#append() methods In the methods of java.io.PrintWriter or java.io.PrintStream in the methods org.slf4j.Logger In these cases, conversion to string will be handled by the underlying library methods, and the explicit call to toString() is not needed.

Unnecessary code block   New in this release

Reports code blocks that are redundant to the semantics of the program and can be replaced with their contents.

Unnecessary conversion to 'String'   New in this release

Reports unnecessary calls to static methods that convert their parameters to a string, e.g.

Unnecessary fully qualified name  

Reports fully qualified class names that can be shortened.

Unnecessary modifier   New in this release

Reports redundant modifiers and suggests to remove them.

Unnecessary parentheses  

Reports any instance of unnecessary parentheses.

Unnecessary qualifier for 'this' or 'super'   New in this release

Reports unnecessary qualification of this or super.

Unnecessary semicolon  

Reports any unnecessary semicolons, including semicolons that are used between class members, inside block statements, or after class definitions.

Unqualified inner class access   New in this release

Reports references to inner classes that are not qualified with the name of the enclosing class.

Unqualified static access   New in this release

Reports usage of static members that is not qualified with the class name.

Using 'instanceof' with patterns   New in this release

Reports instanceof with patterns and suggests converting them to ordinary instanceof with casts.

Last modified: 03 December 2024