Verbose or redundant code constructs
- 'StringBuilder' can be replaced with 'String'
Reports usages of StringBuffer, StringBuilder, or StringJoiner which can be replaced with a single String concatenation.
- Cast can be replaced with variable
Reports type cast operations that can be replaced with existing local or pattern variables with the same value.
- Comparator method can be simplified
Reports Comparator combinator constructs that can be simplified.
- Concatenation with empty string
Reports empty string operands in string concatenations.
- Condition is covered by further condition
Reports conditions that become redundant as they are completely covered by a subsequent condition.
- Copy of existing static method body
Reports fragments of Java code which are identical to the existing static methods suggesting to reuse these static methods.
- Duplicate branches in 'switch'
Reports switch statements or expressions that contain the same code in different branches and suggests merging the duplicate branches.
- Excessive lambda usage
Reports if a trivial lambda expression is used in cases in which there's an alternative method that behaves in the same way, but accepts a concrete value instead of a lambda.
- Excessive range check
Reports condition chains in which a value range is checked and these condition chains can be simplified to a single check.
- Explicit array filling
Reports loops that can be replaced with Arrays.setAll() or Arrays.fill() calls.
- Lombok @Getter may be used
Reports standard getter method that can be replaced by the lombok @Getter annotation.
- Lombok @Setter may be used
Reports standard setter method that can be replaced by the lombok @Setter annotation.
- Manual min/max calculation
Reports cases where the minimum or the maximum of two numbers can be calculated using a Math.max() or Math.min() call, instead of doing it manually.
- Mapping call before count()
Reports redundant Stream API calls like map(), or boxed() right before the count() call.
- Multiple occurrences of the same expression
Reports multiple equivalent occurrences of the same expression within a method (or constructor, or class initializer) if the result of the expression can be reused.
- Non-strict inequality '>=' or '<=' can be replaced with '=='
Reports inequality conditions that, according to data flow analysis, can be satisfied only for a single operand value.
- Null-check method is called with obviously non-null argument
Reports if a null-checking method (for example, Objects.requireNonNull or Assert.assertNotNull) is called on a value that is obviously non-null (for example, a newly created object).
- Only one element is used
Reports lists, arrays, and strings where exactly one element is queried right upon the creation.
- Optional call chain can be simplified
Reports Optional call chains that can be simplified.
- Redundant 'Collection' operation
Reports unnecessarily complex collection operations which have simpler alternatives.
- Redundant 'File' instance creation
Reports redundant File creation in one of the following constructors when only String path can be used: FileInputStream, FileOutputStream, FileReader, FileWriter, PrintStream, PrintWriter, Formatter.
- Redundant 'String' operation
Reports redundant calls to String constructors and methods like toString() or substring() that can be replaced with a simpler expression.
- Redundant 'compare()' method call
Reports comparisons in which the compare method is superfluous.
- Redundant 'isInstance()' or 'cast()' call
Reports redundant calls of java.lang.Class methods.
- Redundant array creation
Reports arrays that are created specifically to be passed as a varargs parameter.
- Redundant array length check
Reports unnecessary array length checks followed by array iteration.
- Redundant embedded expression in string template
Reports redundant embedded expressions in STR templates, such as trivial literals or empty expressions.
- Redundant escape in regex replacement string
Reports redundant escapes in the replacement string of regex methods.
- Redundant operation on 'java.time' object
Reports redundant operation on 'java.time' object redundant: creation of date/time objects from the JDK java.time package when simpler method calls can be used or creation can be avoided.
- Redundant step in 'Stream' or 'Optional' call chain
Reports redundant Stream or Optional calls like map(x -> x), filter(x -> true) or redundant sorted() or distinct() calls.
- Redundant type arguments
Reports calls to parametrized methods with explicit argument types that can be omitted since they will be unambiguously inferred by the compiler.
- Redundant type cast
Reports unnecessary cast expressions.
- Redundant usage of unmodifiable collection wrappers
Reports redundant calls to unmodifiable collection wrappers from the Collections class.
- Replacement operation has no effect
Reports calls to the String methods replace(), replaceAll() or replaceFirst() that have no effect.
- Simplifiable collector
Reports collectors that can be simplified.
- Stream API call chain can be simplified
Reports stream API call chains that can be simplified.
- Too weak variable type leads to unnecessary cast
Reports type casts that can be removed if the variable type is narrowed to the cast type.
- Unnecessarily escaped character
Reports unnecessarily escaped characters in String and optionally char literals.
- Unnecessary 'break' statement
Reports any unnecessary break statements.
- Unnecessary 'continue' statement
Reports continue statements if they are the last reachable statements in the loop.
- Unnecessary 'default' for enum 'switch' statement
Reports enum switch statements or expression with default branches which can never be taken, because all possible values are covered by a case branch.
- Unnecessary 'return' statement
Reports return statements at the end of constructors and methods returning void.
- Unnecessary label on 'break' statement
Reports break statements with unnecessary labels.
- Unnecessary label on 'continue' statement
Reports continue statements with unnecessary labels.