List of Java inspections
Arquillian
| Inspection name | Default state | Default severity |
|---|---|---|
| Arquillian test class should be properly prepared | ||
Arquillian test class should have method with @Deployment annotation | ||
Arquillian test class should have only one method with @Deployment annotation | ||
Wrong return type of @Deployment method | ||
Wrong signature of @Deployment method |
Abstraction issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Cast to a concrete class | ||
Chain of instanceof checks | ||
| Class references one of its subclasses | ||
| Feature envy | ||
instanceof a concrete class | ||
instanceof check for this | ||
Interface method clashes with method in java.lang.Object | ||
| Local variable of concrete class | ||
| Magic number | ||
| Method parameter to concrete class | ||
| Method return of concrete class | ||
Optional used as field or parameter type | ||
| Overly strong type cast | ||
| Private method only used from inner class | ||
public method not exposed in interface | ||
public method with boolean parameter | ||
| Static field of concrete class | ||
| Static member used only from one other class | ||
| Type may be weakened | ||
| Type of instance field is concrete class |
Assignment issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Assignment replaceable with operator assignment | ||
Assignment to for loop parameter | ||
| Assignment to catch block parameter | ||
| Assignment to lambda parameter | ||
| Assignment to method parameter | ||
| Assignment to static field from instance context | ||
| Assignment used as condition | ||
| Constructor assigns value to field defined in superclass | ||
null assignment | ||
| Results of assignment used | ||
| Value of ++ or -- used |
Bitwise operation issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Incompatible bitwise mask operation | ||
| Pointless bitwise expression | ||
| Shift operation by inappropriate constant |
Class metrics
| Inspection name | Default state | Default severity |
|---|---|---|
| Anonymous inner class with too many methods | ||
| Class too deep in inheritance tree | ||
| Class with too many constructors | ||
| Class with too many fields | ||
| Class with too many methods | ||
| Inner class too deeply nested | ||
| Overly complex anonymous class | ||
| Overly complex class | ||
| Overly coupled class |
Class structure
| Inspection name | Default state | Default severity |
|---|---|---|
| Abstract class may be interface | ||
| Anonymous inner class | ||
| Class may extend adapter instead of implementing listener | ||
| Class name differs from file name | ||
Class with only private constructors should be declared final | ||
| Constant declared in abstract class | ||
| Constant declared in interface | ||
| Empty class | ||
| Field can be local | ||
final class | ||
final method | ||
final method in final class | ||
| Inner class of interface | ||
Interface may be annotated @FunctionalInterface | ||
| Limited-scope inner class | ||
| Marker interface | ||
| Method returns per-class constant | ||
| Multiple top level classes in single file | ||
| Non-op method in abstract class | ||
Non- final field in enum | ||
Non- static initializer | ||
| Parameter can be local | ||
private method declared final | ||
private method in final class | ||
public constructor | ||
public constructor in non-public class | ||
| Singleton | ||
static, non- final field | ||
static method declared final | ||
| Utility class | ||
Utility class can be enum | ||
Utility class is not final | ||
Utility class with public constructor | ||
Utility class without public constructor |
Inspections labeled with are not available in the editor and can be launched via or .
Cloning issues
| Inspection name | Default state | Default severity |
|---|---|---|
clone() does not declare CloneNotSupportedException | ||
clone() instantiates objects with constructor | ||
clone() method in non-Cloneabe class | ||
clone() method in non-Cloneabe class | ||
clone() method not public | ||
clone() should have return type equal to the class it contains | ||
Cloneable class without clone() method | ||
Use of clone() Cloneable |
Code maturity
| Inspection name | Default state | Default severity |
|---|---|---|
Call to printStackTrace() | ||
Call to Thread.dumpStack() | ||
| Deprecated API usage | ||
| Deprecated method is still used | ||
| Inspection suppression annotation | ||
Throwable printed to System.out | ||
| Usage of API marked for removal | ||
| Use of obsolete collection type | ||
| Use of obsolete date-time API | ||
| Use of System.out or System.err |
Code style issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Array can be replaced with enum values | ||
Array creation without new expression | ||
assert message is not a String | ||
| Assignment can be joined with declaration | ||
| Block marker comment | ||
| C-style array declaration | ||
Call to String.concat() can be replaced with + | ||
| Can use bounded wildcard | ||
| Chained equality comparisons | ||
| Chained method calls | ||
Class explicitly extends java.lang.Object | ||
| Code block contains single statement | ||
| Conditional can be replaced with Optional | ||
| Confusing octal escape sequence | ||
| Constant expression can be evaluated | ||
| Constant on the wrong side of comparison | ||
| Control flow statement without braces | ||
| Diamond can be replaced with explicit type arguments | ||
equals() called on Enum value | ||
expression.equals("literal") rather than "literal".equals(expression) | ||
| Field assignment can be moved to initializer | ||
Field can be Final | ||
| If statement can be replaced with ?:, && or || expression | ||
Implicit call to super() | ||
Instance field access not qualified with this | ||
Instance field access not qualified with this | ||
| Labeled switch rule can have code block | ||
| Labeled switch rule has redundant code block | ||
| Lambda body can be code block | ||
| Lambda can be replaced with anonymous class | ||
| Lambda parameter type can be specified | ||
'List.indexOf()' expression is replaceable with contains() | ||
| Local variable or parameter can be final | ||
| Method reference can be replaced with lambda | ||
| Missorted modifiers | ||
| Multi-catch can be split into separate catch blocks | ||
| Multiple variables in one declaration | ||
| Nested method call | ||
| Null value for Optional type | ||
| Objects.equals() can be replaced with equals() | ||
| Optional can be replaced with sequence of if statements | ||
Optional contains array or collection | ||
| Optional.isPresent() can be replaced with functional-style expression | ||
| Raw type can be generic | ||
Redundant new expression in constant array creation | ||
| Redundant field initialization | ||
| Redundant interface declaration | ||
| Redundant no-arg constructor | ||
return separated from the result computation | ||
Return of this | ||
| Simplifiable annotation | ||
| Single-element annotation | ||
size() == 0 replaceable with isEmpty() | ||
| Standard Charset object can be used | ||
| Stream API call chain can be replaced with loop | ||
| Subsequent steps can be fused into Stream API chain | ||
try statement with multiple resources can be split | ||
Type parameter explicitly extends java.lang.Object | ||
| Unclear expression | ||
| Unnecessarily qualified inner class access | ||
| Unnecessarily qualified static access | ||
| Unnecessarily qualified statically imported element | ||
Unnecessary final on local variable or parameter | ||
Unnecessary null check before equals() call | ||
Unnecessary super qualifier | ||
Unnecessary this qualifier | ||
Unnecessary call to super() | ||
Unnecessary call to toString() | ||
| Unnecessary code block | ||
| Unnecessary conversion to String | ||
| Unnecessary enum modifier | ||
| Unnecessary fully qualified name | ||
| Unnecessary interface modifier | ||
| Unnecessary parentheses | ||
Unnecessary qualifier for this or super | ||
| Unnecessary semicolon | ||
| Unqualified inner class access | ||
| Unqualified static access |
Compiler issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Javac quirks | ||
| Unchecked warning |
Concurrency annotation issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Instance member guarded by static field | ||
| Non-final @GuardedBy field | ||
| Non-final field in @Immutable class | ||
| Static member guarded by instance filed or this | ||
| Unguarded field access | ||
| Unknown @GuardedBy field |
Control flow issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Assertion can be replaced with if statement | ||
| Boolean expression could be replaced with conditional expression | ||
break statement with label | ||
break statement | ||
| Conditional break inside infinite loop | ||
| Conditional can be pushed inside branch expression | ||
| Conditional expression (?:) | ||
| Conditional expression with identical branches | ||
| Conditional expression with negated condition | ||
| Constant conditional expression | ||
continue statement with label | ||
continue statement | ||
default not last case in switch statement | ||
| Double negation | ||
Duplicate condition in if statement | ||
Duplicate condition on && or || | ||
Enum switch statement that misses case | ||
Fallthrough in switch statement | ||
for loop may be replaced with while loop | ||
for loop with missing components | ||
| Idempotent loop body | ||
if statement could be replaced with conditional expression | ||
if statement with common parts | ||
if statement with negated condition | ||
if statement with too many branches | ||
| Infinite loop statement | ||
| Labeled statement | ||
Local variable used and declared in different switch branches | ||
| Loop statement that does not loop | ||
| Loop variable not updated inside loop | ||
| Loop with implicit termination condition | ||
| Negated conditional expression | ||
| Negated equality expression | ||
Nested switch | ||
| Nested conditional expression | ||
| Overly complex boolean expression | ||
Pointless indexOf() comparison | ||
| Pointless boolean expression | ||
Redundant else | ||
Redundant if statement | ||
| Redundant conditional expression | ||
| Simplifiable boolean expression | ||
| Simplifiable conditional expression | ||
Statement can be replaced with assert or Objects.requireNonNull | ||
switch statement | ||
switch statement with too few branches | ||
switch statement with too low of a branch density | ||
switch statement with too many branches | ||
switch statement without default branch | ||
Unnecessary null check before method call |
Data flow
| Inspection name | Default state | Default severity |
|---|---|---|
| Boolean method is always inverted | ||
| Boolean variable is always inverted | ||
| Method call violates Law of Demeter | ||
| Negatively named boolean variable | ||
| Redundant local variable | ||
| Reuse of local variable | ||
| Scope of variable is too broad | ||
| Use of variable whose value is known to be constant |
Declaration redundancy
| Inspection name | Default state | Default severity |
|---|---|---|
| Access static member via instance reference | ||
| Actual method parameter is the same constant | ||
| Collector can be simplified | ||
| Declaration access can be weaker | ||
| Declaration can have final modifier | ||
| Default annotation parameter value | ||
| Duplicate throws | ||
| Empty method | ||
| Functional expression can be folded | ||
| Method can be void | ||
| Method returns the same value | ||
| Null-check method is called with obviously non-null argument | ||
| Optional call chain can be simplified | ||
Redundant close() | ||
Redundant requires statement in module-info | ||
Redundant throws clause | ||
| Redundant lambda parameter types | ||
| Redundant operation on empty container | ||
| Redundant step in Stream or Optional call chain | ||
| Stream API call chain can be simplified | ||
| Trivial usage of functional expression | ||
| Unnecessary module dependency | ||
| Unused declaration | ||
| Unused label | ||
| Variable is assigned to itself | ||
| Wrapper type may be primitive |
Inspections labeled with are not available in the editor and can be launched via or .
Dependency issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Class with too many dependencies | ||
| Class with too many dependents | ||
| Class with too many transitive dependencies | ||
| Class with too many transitive dependents | ||
| Cyclic class dependency | ||
| Cyclic package dependency | ||
| Illegal package dependencies | ||
| Suspicious package-private access |
Inspections labeled with are not available in the editor and can be launched via or .
Encapsulation
| Inspection name | Default state | Default severity |
|---|---|---|
| Accessing a non-public field of another object | ||
| Assignment or return of field with mutable type | ||
| Package-visible field | ||
| Package-visible nested class | ||
| Protected field | ||
| Protected nested class | ||
public field | ||
public nested class |
Error handling
| Inspection name | Default state | Default severity |
|---|---|---|
| Catch block may ignore exception | ||
| Caught exception is immediately rethrown | ||
| Checked exception class | ||
Class directly extends java.lang.Throwable | ||
continue or break inside finally block | ||
Empty finally block | ||
Empty try block | ||
| Exception constructor called without arguments | ||
finally block which cannot complete normally | ||
instanceof on catch parameter | ||
java.lang.Error not rethrown | ||
java.lang.ThreadDeath not rethrown | ||
Nested try statement | ||
| Non-final field of exception class | ||
null thrown | ||
Overly broad catch block | ||
Overly broad throws clause | ||
| Prohibited exception caught | ||
| Prohibited exception declared | ||
| Prohibited exception thrown | ||
return inside finally block | ||
throw caught by containing try statement | ||
throw inside catch block which ignores the caught exception | ||
throw inside finally block | ||
| Unchecked exception class | ||
Unchecked exception declared in throws clause | ||
Unnecessary call to Throwable.initCause() |
Finalization
| Inspection name | Default state | Default severity |
|---|---|---|
finalize() called explicitly | ||
finalize() declaration | ||
finalize() not declared protected |
General
| Inspection name | Default state | Default severity |
|---|---|---|
| Test-only class or method call in production code |
Imports
| Inspection name | Default state | Default severity |
|---|---|---|
* import | ||
| Import from same package | ||
java.lang import | ||
| Single class import | ||
| Static import | ||
| Unused import |
Inheritance issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Abstract class extends concrete class | ||
| Abstract class which has no concrete subclass | ||
| Abstract class without abstract methods | ||
| Abstract method overrides abstract method | ||
| Abstract method overrides concrete method | ||
| Abstract method with missing implementations | ||
| Class explicitly extends a Collection class | ||
| Class extends annotation interface | ||
| Class extends utility class | ||
| Class may extend a commonly used base class | ||
| Final declaration can't be overridden at runtime | ||
| Interface which has no concrete subclass | ||
| Method does not call super method | ||
| Method is identical to its super method | ||
| Missing @Override annotation | ||
| Non-varargs method overrides varargs method | ||
| Parameter type prevents overriding | ||
public constructor in abstract class | ||
| Static inheritance | ||
| Type parameter extends final class |
Initialization
| Inspection name | Default state | Default severity |
|---|---|---|
| Abstract method called during object construction | ||
| Double brace initialization | ||
| Instance field may not be initialized | ||
| Instance field used before initialization | ||
| Non-final static field is used during class initialization | ||
| Overridable method called during object construction | ||
| Overridden method called during object construction | ||
| Static field may not be initialized | ||
| Static field used before initialization | ||
this reference escaped in object construction | ||
Unsafe lazy initialization of static field |
Internationalization
| Inspection name | Default state | Default severity |
|---|---|---|
| Absolute alignment used in AWT/Swing code | ||
Call to Date.toString() | ||
Call to String.toUpperCase() or codetoLowerCase() without a Locale | ||
Call to Time.toString() | ||
Call to Numeric toString() | ||
| Call to suspicious String method | ||
| Character comparison | ||
| Duplicate string literal | ||
| Hard coded strings | ||
| Implicit usage of platformcodes default charset | ||
| Incorrect string capitalization | ||
| Instantiating a SimpleDateFormat without a Locale | ||
| Magic character | ||
| String concatenation | ||
| Unnecessary unicode escape sequence | ||
| Use of StringTokenizer |
J2ME issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Abstract class which has only one direct inheritor | ||
| Array.length in loop condition | ||
| Connection opened but not safely closed | ||
| Interface which has only one direct inheritor | ||
| Large array allocation with no OutOfMemoryError check | ||
| Method call in loop condition | ||
| Multiply or divide by power of two | ||
| Overly large initializer for array of primitive type | ||
| RecordStore opened but not safely closed | ||
Single character startsWith() or codeendsWith() | ||
| Synthetic accessor call |
Java language level
| Inspection name | Default state | Default severity |
|---|---|---|
| Annotation | ||
| Annotation class | ||
assert statement | ||
| Auto-boxing | ||
| Auto-unboxing | ||
| Enumerated class | ||
Extended for statement | ||
Use of assert as identifier | ||
Use of enum as identifier | ||
| Varargs method |
Java language level migration aids
| Inspection name | Default state | Default severity |
|---|---|---|
compare() method can be used to compare numbers | ||
| Enumeration can be iteration | ||
if replaceable with switch | ||
| Usages of API which isn't available at the configured language level |
Java 5
BigDecimal legacy method called | ||
Collections.EMPTY_* field access replaceable with Collections.empty*() method call | ||
for loop replaceable with enhanced for loop | ||
String.indexOf() expression is replaceable with contains() | ||
| Method can be varargs method | ||
| Raw use of parameterized class | ||
StringBuffer may be StringBuilder | ||
| Unnecessary boxing | ||
| Unnecessary unboxing | ||
while loop replaceable with enhanced for loop |
Java 7
equals() expression replaceable by Objects.equals() expression | ||
| Explicit type can be replaced with <> | ||
Identical catch branches in try statement | ||
| Possible heap pollution from parameterized vararg type | ||
try finally replaceable with try with resources |
Java 8
| Anonymous type can be replaced with lambda | ||
| Anonymous type can be replaced with method reference | ||
| Anonymous type has shorter lambda alternative | ||
| Collections.sort() can be replaced with List.sort() | ||
| Comparator combinator can be used | ||
| Expression can be folded into Stream chain | ||
| forEach call can be simplified | ||
| Guava's functional primitives can be replaced by Java | ||
| Lambda can be replaced with method call | ||
| Lambda can be replaced with method reference | ||
| Loop can be collapsed with Stream API | ||
| Loop can be replaced with Collection.removeIf() | ||
| Map.forEach can be used | ||
| Pseudo functional expression using static class | ||
| Single Map method can be used | ||
| Statement lambda can be replaced with expression lambda |
Java 9
| Dependencies on automatic modules | ||
| Immutable collection creation can be replaced with collection factory call | ||
| Null check can be replaced with method call |
Java 10
| Local variable type can be omitted | ||
| Variable type can be explicit |
Java 11
Files.readString() or Files.writeString() can be used | ||
| String.repeat() can be used |
Java 13
New style switch can be replaced with old style one | ||
Statement can be replaced with enhanced switch | ||
| Text block can be replaced with regular string literal | ||
| Text block can be used |
JavaBeans issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Class without constructor | ||
| Class without no-arg constructor | ||
| Field has setter but no getter | ||
| Property value set to itself | ||
| Suspicious getter/setter |
JavaDoc
| Inspection name | Default state | Default severity |
|---|---|---|
| <code>...</code> can be replaced with {@code ...} | ||
| Dangling Javadoc comment | ||
| Declaration has Javadoc problems | ||
| Declaration has problems in Javadoc references | ||
| HTML problems in Javadoc (DocLint) | ||
Missing package-info.java | ||
| Missing @Deprecated annotation | ||
package-info.java without package statement | ||
package.html may be converted to package-info.java | ||
| Unnecessary Javadoc link | ||
| Unnecessary {@inheritDoc} Javadoc comment |
JUnit
| Inspection name | Default state | Default severity |
|---|---|---|
assertEquals() between objects of inconvertible types | ||
assertEquals() called on array | ||
assertEquals() may be assertSame() | ||
Assertion expression can be replaced with assertThat method call | ||
| Constant JUnit assert argument | ||
| Expected exception never thrown in test method body | ||
| Highlight problem line in test | ||
JUnit test annotated with @Ignore/ @Disabled | ||
| JUnit test method in product source | ||
| JUnit test method without any assertions | ||
| JUnit TestCase in product source | ||
| JUnit TestCase with non-trivial constructors | ||
| JUnit 4 test can be JUnit 5 | ||
| JUnit 4 test method in class extending JUnit 3 TestCase | ||
| JUnit 5 malformed @Nested class | ||
| JUnit 5 malformed parameterized test | ||
| JUnit 5 malformed repeated test | ||
Malformed setUp() or tearDown() method | ||
| Malformed @Before or @After method | ||
| Malformed @BeforeClass/@BeforeAll or @AfterClass/@AfterAll method | ||
| Malformed @DataPoint field | ||
| Malformed @Rule/@ClassRule field | ||
| Malformed test method | ||
| Message missing on JUnit assertion | ||
Misordered assertEquals() arguments | ||
| Multiple exceptions declared on test method | ||
| Obsolete assertions in JUnit 5 tests | ||
| Old style JUnit test method in JUnit 4 class | ||
| @RunWith(JUnitPlatform.class) without test methods | ||
| @RunWith(Parameterized.class) without data provider | ||
| Simplifiable JUnit assertion | ||
suite() method not declared static | ||
super.tearDown() not called from finally block | ||
| Test class with no tests | ||
| Unconstructable JUnit TestCase | ||
Usage of obsolete junit.framework.Assert method |
Logging
| Inspection name | Default state | Default severity |
|---|---|---|
| Class with multiple loggers | ||
| Class without logger | ||
| Log condition does not match logging call | ||
| Logger initialized with foreign class | ||
| Logging call not guarded by log condition | ||
| Non-constant logger | ||
| Non-constant string concatenation as argument to logging call | ||
| Number of placeholders does not match number of arguments in logging call | ||
public method without logging |
Memory
| Inspection name | Default state | Default severity |
|---|---|---|
Anonymous class may be a named static inner class | ||
Calls to System.gc() or Runtime.gc() | ||
Inner class may be static | ||
| Return of instance of anonymous, local or inner class | ||
| Static collection | ||
| StringBuilder field | ||
| Unnecessary zero length array usage | ||
| Zero-length array allocation |
Method metrics
| Inspection name | Default state | Default severity |
|---|---|---|
| Constructor with too many parameters | ||
| Method with more than three negations | ||
| Method with multiple loops | ||
| Method with multiple return points | ||
| Method with too many exceptions declared | ||
| Method with too many parameters | ||
| Overly complex method | ||
| Overly coupled method | ||
| Overly long lambda expression | ||
| Overly long method | ||
| Overly nested method |
Modularization issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Class independent of its module | ||
| Class only used from one other module | ||
| Inconsistent language level settings | ||
| Module with too few classes | ||
| Module with too many classes |
Inspections labeled with are not available in the editor and can be launched via or .
Naming conventions
| Inspection name | Default state | Default severity |
|---|---|---|
| Boolean method name must start with question word | ||
| Class name prefixed with package name | ||
| Class name same as ancestor name | ||
| Class naming convention | ||
Confusing main() method | ||
Exception class name does not end with Exception | ||
| Field naming convention | ||
| Java module naming conventions | ||
| Lambda parameter naming convention | ||
| Lambda-unfriendly method overload | ||
| Local variable naming convention | ||
| Method name same as class name | ||
| Method name same as parent class name | ||
| Method names differing only by case | ||
| Method naming convention | ||
| Method parameter naming convention | ||
| Non-boolean method name must not start with question word | ||
| Non-constant field with upper-case name | ||
Non-exception class name ends with Exception | ||
| Overloaded methods with same number of parameters | ||
| Overloaded varargs method | ||
| Package naming convention | ||
| Parameter name differs from parameter in overridden method | ||
| Questionable name | ||
| Standard variable names | ||
Use of $ in identifier |
Numeric issues
| Inspection name | Default state | Default severity |
|---|---|---|
Call to BigDecimal method without a rounding mode argument | ||
char expression used in arithmetic context | ||
Comparison of short and char values | ||
| Comparison to Double.NaN or Float.NaN | ||
| Confusing floating-point literal | ||
Constant call to java.lang.Math | ||
| Divide by zero | ||
double literal cast to float could be float literal | ||
equals() called on java.math.BigDecimal | ||
| Floating point equality comparison | ||
| Implicit numeric conversion | ||
int literal cast to long could be long literal | ||
| Integer division in floating point context | ||
| Integer multiplication or shift implicitly cast to long | ||
long literal ending with l instead of L | ||
Non-reproducible call to java.lang.Math | ||
| Number constructor call with primitive argument | ||
| Numeric cast that loses precision | ||
| Numeric overflow | ||
| Octal and decimal integers in same array | ||
| Octal integer | ||
| Overly complex arithmetic expression | ||
| Pointless arithmetic expression | ||
| Suspicious test for oddness | ||
| Suspicious underscore in number literal | ||
| Unary plus | ||
| Unnecessary explicit numeric cast | ||
| Unnecessary unary minus | ||
| Unpredictable BigDecimal constructor call |
Packaging issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Class independent of its package | ||
| Class only used from one other package | ||
| Empty directory | ||
| Exception package | ||
| Package with classes in multiple modules | ||
| Package with disjoint dependency graph | ||
| Package with too few classes | ||
| Package with too many classes |
Inspections labeled with are not available in the editor and can be launched via or .
Performance
| Inspection name | Default state | Default severity |
|---|---|---|
| Boolean constructor call | ||
| Boxing of already boxed value | ||
| Bulk operation can be used instead of iteration | ||
Call to Arrays.asList() with too few arguments | ||
| Call to simple getter from within class | ||
| Call to simple setter from within class | ||
Class initializer may be static | ||
Collection.toArray() call style | ||
| Collection without initial capacity | ||
| Concatenation with empty string | ||
| Dynamic regular expression could be replaced by compiled Pattern | ||
equals() call can be replaced with == | ||
equals() or hashCode() called on java.net.URL object | ||
| Explicit argument can be lambda | ||
Field may be static | ||
| Inefficient Stream API call chains ending with count() | ||
| Instantiating object to get Class object | ||
Iteration over keySet() may be optimized | ||
List.remove() called in loop | ||
| Loop can be terminated after condition is met | ||
| Manual array copy | ||
| Manual array to collection copy | ||
Map or Set may contain java.net.URL objects | ||
| Map replaceable with EnumMap | ||
Method may be static | ||
| Non-constant String should be StringBuilder | ||
| Object allocation in loop | ||
Object instantiation inside equals() or hashCode() | ||
Redundant Collection.addAll() call | ||
Redundant call to String.format() | ||
| Set replaceable with EnumSet | ||
Single character string argument in String.indexOf() call | ||
| Single character string concatenation | ||
String.equals("") | ||
String concatenation as argument to StringBuilder.append() call | ||
| String concatenation in loop | ||
StringBuilder.toString() in concatenation | ||
| StringBuilder without initial capacity | ||
| Tail recursion | ||
| Unnecessary temporary object in conversion from String | ||
| Unnecessary temporary object in conversion to String | ||
Using Random.nextDouble() to get random integer |
Portability
| Inspection name | Default state | Default severity |
|---|---|---|
Call to Runtime.exec() | ||
Call to System.exit() or related methods | ||
Call to System.getenv() | ||
| Hardcoded file separator | ||
| Hardcoded line separator | ||
| Native method | ||
Use of java.lang.ProcessBuilder class | ||
| Use of AWT peer class | ||
| Use of concrete JDBC driver class | ||
| Use of sun.* classes |
Probable bugs
Nullability problems
| Inspection name | Default state | Default severity |
|---|---|---|
| @NotNull field is not initialized | ||
| @NotNull/@Nullable problems | ||
Return of null |
| Inspection name | Default state | Default severity |
|---|---|---|
Array comparison using ==, instead of Arrays.equals() | ||
assert statement condition is constant | ||
assert statement with side effects | ||
Call to toString() on array | ||
| Call to String.replaceAll(".", ...) | ||
Call to default toString() | ||
Cast conflicts with instanceof | ||
| Casting to incompatible interface | ||
| Class.getClass() call | ||
| Cleaner captures object reference | ||
| Collection added to self | ||
Comparable implemented but equals() not overridden | ||
| Confusing argument to varargs method | ||
| Confusing primitive array argument to varargs method | ||
| Constant conditions & exceptions | ||
| Contract issues | ||
| Copy constructor misses field | ||
Covariant equals() | ||
| Duplicated delimiters in java.util.StringTokenizer | ||
| Empty class initializer | ||
equal() instead of equals() | ||
equals() and hashCode() not paired | ||
equals() between objects of inconvertible types | ||
equals() called on StringBuilder | ||
equals() called on array | ||
equals() called on itself | ||
equals() method which does not check class of parameter | ||
hashCode() called on array | ||
| Infinite recursion | ||
| Inner class referenced via subclass | ||
instanceof with incompatible interface | ||
| Instantiation of utility class | ||
| Invalid method reference used for Comparator | ||
| Iterable is used as vararg | ||
Iterator.hasNext() which calls next() | ||
Iterator.next() which can't throw NoSuchElementException | ||
| Loop executes zero or billions times | ||
| Magic Constant | ||
| Malformed format string | ||
| Malformed regular expression | ||
| Malformed XPath expression | ||
Math.random() cast to int | ||
| Mismatched case in String operation | ||
| Mismatched query and update of StringBuilder | ||
| Mismatched query and update of collection | ||
| Mismatched read and write of array | ||
New object is compared using == | ||
Non-final field referenced in compareTo() | ||
Non-final field referenced in equals() | ||
Non-final field referenced in hashCode() | ||
| Non-short-circuit boolean expression | ||
| Non-short-circuit operation consumes the infinite stream | ||
Number comparison using ==, instead of equals() | ||
Object comparison using ==, instead of equals() | ||
Objects.equals() called on arrays | ||
| Optional.get() is called without isPresent() check | ||
| Overwritten Map key or Set element | ||
Reference checked for null is not used inside if | ||
| Reflective access to a source-only annotation | ||
| Result of method call ignored | ||
| Result of object allocation ignored | ||
| Sorted collection with non-comparable elements | ||
| Statement with empty body | ||
| Static field referenced via subclass | ||
| Static method referenced via subclass | ||
String.equals() called with CharSequence argument | ||
String comparison using ==, instead of equals() | ||
String concatenation as argument to MessageFormat.format() call | ||
String concatenation as argument to format() call | ||
| String literal concatenation missing whitespace | ||
StringBuilder constructor call with char argument | ||
Subtraction in compareTo() | ||
Suspicious Collection.toArray() call | ||
Suspicious Comparator.compare() implementation | ||
Suspicious List.remove() in the loop | ||
Suspicious System.arraycopy() call | ||
| Suspicious Arrays method calls | ||
| Suspicious array cast | ||
| Suspicious collections method calls | ||
| Suspicious indentation after control statement without braces | ||
| Suspicious integer division assignment | ||
| Suspicious usage of compare method | ||
| Suspicious variable/parameter name combination | ||
Text label in switch statement | ||
| Throwable not thrown | ||
Unsafe call to Class.newInstance() | ||
| Unused assignment | ||
| Use of Properties object as a Hashtable | ||
| Use of index 0 in JDBC ResultSet | ||
| Wrong package statement |
Properties Files
| Inspection name | Default state | Default severity |
|---|---|---|
| Invalid property key |
Reflective access
| Inspection name | Default state | Default severity |
|---|---|---|
| MethodHandle/VarHandle type mismatch | ||
| Non-runtime annotation to be used by reflection | ||
| Reflective access across modules issues | ||
| Reflective access to nonexistent/not visible class member | ||
| Reflective invocation arguments mismatch |
Resource management
| Inspection name | Default state | Default severity |
|---|---|---|
| Channel opened but not safely closed | ||
| Hibernate resource opened but not safely closed | ||
| I/O resource opened but not safely closed | ||
| JDBC resource opened but not safely closed | ||
| JNDI resource opened but not safely closed | ||
| Socket opened but not safely closed | ||
| Use of DriverManager to get JDBC connection |
Security
| Inspection name | Default state | Default severity |
|---|---|---|
| Access of system properties | ||
Call to Connection.prepare*() with non-constant string | ||
Call to Runtime.exec() with non-constant string | ||
Call to Statement.execute() with non-constant string | ||
Call to System.loadLibrary() with non-constant string | ||
Call to System.setSecurityManager() | ||
| ClassLoader instantiation | ||
| Cloneable class in secure context | ||
| Custom ClassLoader | ||
| Custom SecurityManager | ||
| Design for extension | ||
| Insecure random number generation | ||
Non- static inner class in secure context | ||
Non-final clone() in secure context | ||
public static array field | ||
public static collection field | ||
| Serializable class in secure context |
Serialization issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Comparator class not declared Serializable | ||
Externalizable class with readObject() or writeObject() | ||
Externalizable class without public no-arg constructor | ||
Instance field may not be initialized by readObject() | ||
Non-serializable class with readObject() or writeObject() | ||
Non-serializable class with serialVersionUID | ||
| Non-serializable field in a Serializable class | ||
| Non-serializable object bound to HttpSession | ||
| Non-serializable object passed to ObjectOutputStream | ||
readObject() or writeObject() not declared private | ||
readResolve() or writeReplace() not declared protected | ||
| Serializable class with unconstructable ancestor | ||
Serializable class without readObject() and writeObject() | ||
Serializable class without serialVersionUID | ||
Serializable non- static inner class with non-Serializable outer class | ||
Serializable non- static inner class without serialVersionUID | ||
| Serializable object implicitly stores non-Serializable object | ||
serialPersistentFields field not declared private static final ObjectStreamField[] | ||
serialVersionUID field not declared private static final long | ||
| Transient field in non-serializable class | ||
| Transient field is not initialized on deserialization |
TestNG
| Inspection name | Default state | Default severity |
|---|---|---|
assertEquals() between objects of inconvertible types | ||
| Constant TestNG assert argument | ||
| Data provider problems | ||
dependsOnMethods problem | ||
| Duplicated data provider names | ||
| Expected exception never thrown in test method body | ||
| Groups problem | ||
| Invalid data provider return type | ||
| JUnit Test can be converted to TestNG | ||
| Message missing on TestNG assertion | ||
Misordered assertEquals() arguments | ||
| Old TestNG annotation @Configuration is used | ||
| Simplifiable TestNG assertion | ||
| TestNG Javadoc can be converted to annotations | ||
| Undeclared test |
Threading issues
| Inspection name | Default state | Default severity |
|---|---|---|
| Access to static field locked on instance data | ||
AtomicFieldUpdater field not declared static final | ||
| AtomicFieldUpdater issues | ||
await() not in loop | ||
await() without corresponding signal() | ||
| Busy wait | ||
Call to System.runFinalizersOnExit() | ||
Call to Thread.run() | ||
Call to Thread.setPriority() | ||
Call to Thread.sleep() while synchronized | ||
Call to Thread.start() during object construction | ||
Call to Thread.stop(), suspend() or resume() | ||
Call to Thread.yield() | ||
Call to notify() instead of notifyAll() | ||
Call to signal() instead of signalAll() | ||
| Call to a native method while locked | ||
Class directly extends java.lang.Thread | ||
| Double-checked locking | ||
Empty synchronized statement | ||
| Field accessed in both synchronized and unsynchronized contexts | ||
Instantiating a Thread with default run() method | ||
| Lock acquired but not safely unlocked | ||
| Method with synchronized block could be synchronized method | ||
Nested synchronized statement | ||
| Non-atomic operation on volatile field | ||
| Non-private field accessed in synchronized context | ||
| Non thread-safe static field access | ||
notify() or notifyAll() called on java.util.concurrent.locks.Condition object | ||
notify() or notifyAll() without corresponding state change | ||
notify() without corresponding wait() | ||
signal() without corresponding await() | ||
| Static initializer references subclass | ||
Synchronization on getClass() | ||
Synchronization on static field | ||
Synchronization on this | ||
| Synchronization on a Lock object | ||
| Synchronization on a non-final field | ||
| Synchronization on an object initialized with a literal | ||
| Synchronization on local variable or method parameter | ||
synchronized method | ||
| ThreadLocal field not declared static final | ||
ThreadLocalRandom instance might be shared | ||
Unconditional wait() call | ||
| Unsynchronized method overrides synchronized method | ||
| Volatile array field | ||
wait() called on java.util.concurrent.locks.Condition object | ||
wait() not in loop | ||
wait() or await() without timeout | ||
wait() or notify() while not synchronized | ||
wait() while holding two locks | ||
wait() without corresponding notify() | ||
while loop spins on field |
toString() issues
| Inspection name | Default state | Default severity |
|---|---|---|
Class does not override toString() method | ||
Field not used in toString() method |
Verbose or redundant code constructs
| Inspection name | Default state | Default severity |
|---|---|---|
| Comparator can be simplified | ||
| Condition is covered by further condition | ||
Duplicate branches in switch | ||
| Excessive lambda usage | ||
| Excessive range check | ||
| Explicit array filling | ||
| Manual min/max calculation | ||
| Multiple occurrences of the same expression | ||
Redundant compare method call | ||
Redundant isInstance or cast call | ||
| Redundant Collection operation | ||
| Redundant String operation | ||
| Redundant array creation | ||
| Redundant type arguments | ||
| Redundant type cast | ||
StringBuilder can be replaced with String | ||
| Too weak variable type leads to unnecessary cast | ||
Unnecessary break statement | ||
Unnecessary continue statement | ||
Unnecessary default for enum switch statement | ||
| Unnecessarily escaped character | ||
Unnecessary return statement | ||
Unnecessary label on break statement | ||
Unnecessary label on continue statement |
Visibility
| Inspection name | Default state | Default severity |
|---|---|---|
| Access of inherited field looks like access of element in surrounding code | ||
| Anonymous class variable hides variable in containing method | ||
| Call to inherited method looks like call to local method | ||
| Field name hides field in superclass | ||
| Inner class field hides outer class field | ||
| Lambda parameter hides field | ||
| Local variable hides field | ||
| Method overloads method of superclass | ||
| Method overrides inaccessible method of superclass | ||
| Method tries to override static method of superclass | ||
| Module exports/opens package to itself | ||
| Non-accessible class is exposed | ||
| Parameter hides field | ||
| Type parameter hides visible type | ||
Usage of service not declared in module-info |
Last modified: 01 July 2021