IntelliJ IDEA Inspections List (632)
IntelliJ IDEA features high-performance dynamic code analysis engine that is capable of inspecting your Java, JavaScript, HTML, XML and other code on the fly.
With more than 600 inspections, IntelliJ IDEA can:
- Find probable bugs
- Locate "dead" code
- Detect performance issues
- Improve code structure and maintainability
- Ensure the code conforms to guidelines, standards and specifications
Read the article Analyzing Code with IntelliJ IDEA (PDF format, HTML format) for more information about how to run and manage inspections in IntelliJ IDEA and get a broad insight into analyzing code with this IDE.
The complete list of IntelliJ IDEA code inspections is available below. Mouse over an inspection name to see its detailed description.
Method metrics
- Overly complex method
- Overly nested method
- Method with multiple loops
- Overly long method
- Method with too many exceptions declared
- Method with too many parameters
- Method with multiple return points.
- Method with more than three negations
- Overly coupled method
Serialization issues
- 'serialPersistentFields' field not declared 'private static final ObjectStreamField[]'
- Serializable class with unconstructable ancestor
- 'readResolve()' or 'writeReplace()' not declared 'protected'
- Serializable non-static inner class without non-Serializable outer class
- Non-serializable object passed to ObjectOutputStream
- Non-serializable class with 'serialVersionUID'
- 'readObject()' or 'writeObject()' not declared 'private'
- Non-serializable field in a Serializable class
- Externalizable class with 'readObject()' or 'writeObject()'
- Serializable class without 'serialVersionUID'
- Non-serializable class with 'readObject()' or 'writeObject()'
- Serializable class without 'readObject()' and 'writeObject()'
- 'serialVersionUID' field not declared 'private static final long'
- Serializable non-static inner class without 'serialVersionUID'
- Non-serializable object bound to HttpSession
- Instance variable may not be initialized by 'readObject()'
- Transient field in non-serializable class
HTML Inspections
- Empty Script Tag
- XML Script Tag Content
- Html tags and attributes conventions
- Required attributes
- Image Size Mismatch
J2ME issues
- Single character 'startsWith()' or 'endsWith()'
- Field repeatedly accessed in method
- Private member access between outer and inner classes
- Interface which has only one direct inheritor
- Abstract class which has only one direct inheritor
- Anonymous inner class may be a named static inner class
- Large array allocation with no OutOfMemoryError check
- If statement may be replaced by && or || expression
- Connection opened but not safely closed
- Method call in loop condition
- Array.length in loop condition
- Overly large initializer for array of primitive type
- RecordStore opened but not safely closed
Java EE issues
- Persistence Model Errors
- EJB Descriptor Inspection
- EJB QL Problems
- EJB Classes Warnings
- Web properties
- EJB Classes Errors
- References to classes from the default package in JSP files
- Self-including JSP files
- Persistence Model Warnings
- Persistence QL Problems
- Persistence Descriptors Problems
Portability issues
- Call to 'System.getenv()'
- Call to 'System.exit()' or related methods
- Hardcoded line separator
- Call to 'Runtime.exec()'
- Use of AWT peer class
- Native method
- Use of java.lang.ProcessBuilder class
- Use of sun.* classes
- Hardcoded file separator
- Use of concrete JDBC driver class
General
- Redundant throws declaration
- Declaration has javadoc problems
- Unused symbol
- Default File Template Usage
- Redundant suppression
- Unnecessary module dependency
- Structural Search Inspection
- Illegal package dependencies
- Wrong package statement
- Unchecked warning
- Boolean method is always inverted
- Unused import
- Access static member via instance reference
- Variable is assigned to itself
- Declaration has problems in javadoc references
- equals() and hashCode() not paired
- Unused declaration
- Deprecated API usage
Initialization issues
- Static variable used before initialization
- Instance variable may not be initialized
- Unsafe lazy initialization of static field
- Overridden method call in constructor
- Abstract method call in constructor
- Overridable method call in constructor
- 'this' reference escaped in object construction
- Static variable may not be initialized
- Non-final static variable is used during class initialization
- Instance variable used before initialized
Google Web Toolkit issues
- GWT Remote Service is not registered in web.xml
- Unresolved references to CSS classes
- Non-serializable parameter type or return type of service method
- Unresolved references to html tags
- Classes not from JRE Emulation Library in client code
- Inconsistent GWT Remote Service
Security issues
- Deserializable class in secure context
- Custom ClassLoader
- Serializable class in secure context
- Public static array field
- Insecure random number generation
- Call to 'Connection.prepareStatement()' or related method with non-constant string
- Call to 'Statement.execute()' or related method with non-constant string
- Call to 'System.setSecurityManager()'
- Design for extension
- Cloneable class in secure context
- Call to 'System.loadLibrary()' with non-constant string
- Non-final 'clone()' in secure context
- Call to 'Runtime.exec()' with non-constant string
- Access of system properties
- Custom SecurityManager
- !class.loader.instantiation.display.name!
- Non-static inner class in secure context
- Public static collection field
Code maturity issues
- Call to 'Thread.dumpStack()'
- Inspection suppression annotation
- Use of obsolete collection type
- Call to 'printStackTrace()'
- Class without 'toString()'
- Use of System.out or System.err
- TODO comment
UI Form Problems
- Assignment to UI-bound field
- Scrollable component not in JScrollPane
- Radio button not in a group
- No label for component
- Button group with one button
- Missing Mnemonics
- Duplicate Mnemonics
Bitwise operation issues
- Shift operation by inappropriate constant
- Incompatible bitwise mask operation
- Pointless bitwise expression
Abstraction issues
- Method parameter of concrete class
- Cast to a concrete class
- Method return of concrete class
- 'Magic number'
- Overly-strong type cast
- Local variable of concrete class
- Instance variable of concrete class
- Collection declared by class, not interface
- Private method only used from inner class
- 'instanceof' a concrete class
- Class references one of its subclasses
- Chain of 'instanceof' checks
- 'instanceof' check for 'this'
- Static method only used from one other class
- Static variable of concrete class
- Feature Envy
- Public method not exposed in interface
Resource management issues
- Hibernate resource opened but not safely closed
- Channel opened but not safely closed
- JNDI resource opened but not safely closed
- Socket opened but not safely closed
- JDBC resource opened but not safely closed
- Use of DriverManager to get JDBC connection
- I/O resource opened but not safely closed
Declaration Redundancy
- Duplicate throws
- Redundant throws clause
- Declaration can have final modifier
- Declaration access can be weaker
- Method returns the same value
- Actual method parameter is the same constant
- Empty method
- Unused method parameters
- Unused method return value
Finalization issues
- 'finalize()' called explicitly
- 'finalize()' not declared 'protected'
- 'finalize()' declaration
- 'finalize()' does not call 'super.finalize()'
Logging issues
Java language level issues
- Variable argument method
- Auto-unboxing
- 'assert' statement
- Annotation
- Annotation class
- Extended 'for' statement
- Use of 'assert' as identifier
- Use of 'enum' as identifier
- Enumerated class
- Auto-boxing
Encapsulation issues
- Return of Collection or array field
- Protected field
- Return of Date or Calendar field
- Accessing a non-public field of another object
- Package-visible field
- Public field
- Protected inner class
- Public inner class
- Package-visible inner class
- Assignment to Date or Calendar field from parameter
- Assignment to Collection or array field from parameter
Assignment issues
- Value of ++ or -- used
- Assignment to 'for' loop parameter
- Nested assignment
- Assignment to method parameter
- Assignment to catch block parameter
- Assignment replaceable with operator assignment
Control flow issues
- Infinite loop statement
- Unnecessary label on 'break' statement
- Pointless boolean expression
- 'break' statement
- Labeled statement
- Loop statement that does not loop
- 'switch' statement with too many branches
- 'if' statement with too many branches
- Redundant conditional expression
- Pointless 'indexOf()' comparison
- Fallthrough in 'switch' statement
- 'switch' statement
- Nested conditional expression
- Duplicate condition in 'if' statement
- 'if' statement with negated condition
- Unnecessary 'continue' statement
- Unused label
- Overly complex boolean expression
- 'continue' statement with label
- Local variable used and declared in different 'switch' branches
- Unnecessary 'return' statement
- Enum 'switch' statement that misses case
- Nested 'switch' statement
- Constant if statement
- 'switch' statement with too low of a branch density
- 'switch' statement with too few branches
- Unnecessary label on 'continue' statement
- Redundant 'if' statement
- 'if' statement with identical branches
- 'break' statement with label
- Duplicate condition on '&&' or '||'
- 'for' loop may be replaced by 'while' loop
- 'switch' statement without 'default' branch
- 'for' loop with missing components
- Unnecessary 'default' for enum switch statement
- Conditional that can be simplified to && or ||
- 'continue' statement
- Conditional expression (?:)
- 'default' not last case in 'switch'
- Constant conditional expression
- Confusing 'else' branch
- Loop variable not updated inside loop
- Conditional expression with negated condition
- Conditional expression with identical branches
Performance issues
- Using 'Random.nextDouble()' to get randominteger
- 'StringBuffer' may be 'StringBuilder' (JDK5.0 only)
- Redundant 'String.toString()'
- Multiply or divide by power of two
- Instantiating object to get Class object
- Single character string concatenation
- String concatenation inside 'StringBuffer.append()'
- Call to simple setter from within class
- Unnecessary temporary object in conversion to String
- Manual array copy
- Redundant '.substring(0)'
- StringBuffer or StringBuilder without initial capacity
- Method may be 'static'
- Single character string parameter in 'String.indexOf()' call
- Inner class may be 'static'
- 'StringBuffer.toString()' in concatenation
- Call to 'intern()' on String constant
- Call to simple getter from within class
- Use of java.lang.reflect
- Unnecessary temporary object in conversion from String
- Constant StringBuffer may be String
- Concatenation with empty string
- String concatenation in loop
- Boolean constructor call
- 'String.equals('')'
- Field may be 'static'
- Non-constant String should be StringBuffer
- Collection without initial capacity
- Redundant String constructor call
- Set replaceable by EnumSet
- Tail recursion
- 'size() == 0' replaceable by 'isEmpty()'
- Map replaceable by EnumMap
- Object allocation in loop
J2SDK5.0 specific issues and migration aids
- Usages of API documented as @since 1.5
- Unnecessary boxing
- Unnecessary unboxing
- 'indexOf()' expression is replaceable by 'contains()'
- 'while' loop replaceable by 'for each'
- 'for' loop replaceable by 'for each'
- Raw use of parameterized class
Internationalization issues
- String concatenation
- Use of StringTokenizer
- Character comparison
- Invalid property key
- Call to 'String.compareTo()'
- Call to 'String.toUpperCase()' or 'toLowerCase()' without a Locale
- Duplicate Property
- Call to 'String.equalsIgnoreCase()'
- Call to 'Time.toString()'
- Call to 'String.equals()'
- Call to 'Date.toString()'
- Call to Numeric 'toString()'
- Duplicate String Literal
- Hard coded strings
- 'Magic character'
- Instantiating a SimpleDateFormat without a Locale
Naming conventions
- Constant naming convention
- Exception class name does not end with 'Exception'
- Type parameter naming convention
- Method parameter naming convention
- Interface naming convention
- Enumerated class naming convention
- Instance method naming convention
- Local variable naming convention
- Class naming convention
- Method name same as class name
- Annotation naming convention
- Static variable naming convention
- Overloaded variable argument method
- Method names differing only by case
- Parameter name differs from parameter in overridden method
- Overloaded methods with same number of parameters
- Non-constant field with upper-case name
- Non-boolean method name must not start with question word
- Questionable name
- Class name prefixed with package name
- Confusing 'main()' method
- Method name same as parent class name
- Boolean method name must start with question word
- Class name same as ancestor name
- Static method naming convention
- Non-exception class name ends with 'Exception'
- Enumerated constant naming convention
- Standard variable names
- Instance variable naming convention
- Use of '$' in identifier
Class structure
- 'final' class
- Utility class without private constructor
- Singleton
- Utility class
- Non-static initializer
- Inner class of interface
- 'static', non-'final' field
- 'static' method declared 'final'
- Constant declared in abstract class
- 'private' method declared 'final'
- 'final' method in 'final' class
- No-op method in abstract class
- 'public' constructor in non-public class
- Utility class with public constructor
- Missing @Deprecated annotation
- Class name differs from file name
- 'protected' member in 'final' class
- Limited-scope inner class
- Marker interface
- Field can be local
- Missing @Override annotation
- Empty class
- Class may be interface
- Class without package statement
- Anonymous inner class
- Multiple top level classes in single file
- 'final' method
- Constant declared in interface
Class metrics
- Anonymous inner class with too many methods
- Overly complex class
- Overly complex anonymous inner class
- Class too deep in inheritance tree
- Overly coupled class
- Class with too many fields
- Inner class too deeply nested
- Class with too many constructors
- Class with too many methods
Code style issues
- Unnecessary qualifier for 'this'
- Multiple variables in one declaration
- Unnecessary fully qualified name
- Constant on left side of comparison
- Constant on right side of comparison
- Missorted modifers
- Unnecessary 'final' for method parameter
- Redundant interface declaration
- Return of 'this'
- Unnecessary semicolon
- Variables of different types in one declaration
- Unnecessary parentheses
- Chained equality comparisons
- Nested method call
- C-style array declaration
- Control flow statement without braces
- Unnecessary code block
- expression.equals('literal') rather than 'literal'.equals(expression)
- Unnecessary 'final' for local variable
- Redundant field initialization
- Local variable or parameter can be final
- Unnecessary interface modifier
- Redundant no-arg constructor
- Implicit call to 'super()'
- Unqualified static usage
- Unnecessary 'this' qualifier
- Chained method calls
- Type parameter explicitly extends 'java.lang.Object'
- Unnecessary call to 'super()'
- Confusing octal escape sequence
- Unnecessarily qualified static usage
- Class explicitly extends java.lang.Object
- Unnecessary enum modifier
CSS inspections
Visibility issues
- Parameter hides member variable
- Method overrides private method of superclass
- Method overloads method of superclass
- Inner class field hides outer class field
- Type parameter hides visible type
- Class escapes defined scope
- Local variable hides member variable
- Method overrides static method of superclass
- Method overrides package local method of superclass located in other package
- Field name hides field in superclass
Struts Assistant
Numeric issues
- Comparison of 'short' and 'char' values
- Number constructor call with primitive argument
- Suspicious test for oddness
- Integer division in floating point context
- Confusing floating-point literal
- Comparison to Double.NaN or Float.NaN
- Pointless arithmetic expression
- Numeric cast that loses precision
- Long literal ending with 'l' instead of 'L'
- Overly complex arithmetic expression
- Floating point equality comparison
- Constant call to java.lang.Math or StrictMath
- Implicit numeric conversion
- Octal integer
- 'equals()' called on BigDecimal
- Integer multiplication or shift implicitly cast to long
- Division by zero
- Non-reproducible call to java.lang.Math
- Unary plus
Imports
- * import
- Redundant import
- Unused import
- java.lang import
- Import from same package
- Single class import
- Static import
Error handling
- Unhandled Exception in JSP
- Prohibited exception declared
- 'throw' caught by containing 'try' statement
- 'throw' inside 'catch' block which ignores the caught exception
- java.lang.ThreadDeath not rethrown
- 'return' inside 'finally' block
- Checked exception class
- 'throw' inside 'finally' block
- 'catch' generic class
- Overly broad 'catch' block
- Non-final field of exception class
- Nested 'try' statement
- Empty 'finally' block
- 'instanceof' on 'catch' parameter
- Empty 'catch' block
- Unchecked exception class
- java.lang.Error not rethrown
- Prohibited exception caught
- Empty 'try' block
- Unused 'catch' parameter
- 'finally' block which can not complete normally
- Prohibited exception thrown
- 'continue' or 'break' inside 'finally' block
Cloning issues
- 'clone()' does not call 'super.clone()'
- 'clone()' method in non-Cloneable class
- 'clone()' instantiates objects with constructor
- 'clone()' does not declare 'CloneNotSupportedException'
- Cloneable class without 'clone()'
Properties Files
JavaScript Inspections
- Unresolved Java Script Variables
- Implicitly Declared Java Script Variables
- Unresolved Java Script Functions
Verbose or redundant code constructs
JavaBeans issues
Data flow issues
Plugin DevKit
Inheritance issues
- Constructor not 'protected' in 'abstract' class
- Class extends utility class
- Method is identical to its super method
- Abstract class extends concrete class
- Interface which has no concrete subclass
- Abstract method overrides abstract method
- Class extends annotation interface
- Refused bequest
- Abstract method overrides concrete method
- Static inheritance
- Abstract class without abstract methods
- Class explicitly extends a Collection class
- Abstract method with missing implementations
- Abstract class which has no concrete subclass
Probable bugs
- Assignment used as condition
- Static method referenced via subclass
- 'equal()' instead of 'equals()'
- Confusing 'null' argument to var-arg method
- Use of index 0 in JDBC ResultSet
- Non-final field referenced in 'equals()'
- Object comparison using ==, instead of 'equals()'
- 'equals()' method which does not check class of parameter
- Constant conditions & exceptions
- Subtraction in compareTo()
- Assignment to static field from instance method
- Collection added to self
- Unused assignment
- Covariant 'equals()'
- Non-short-circuit boolean expression
- Octal and decimal integers in same array
- Non-final field referenced in 'hashCode()'
- Casting to incompatible interface
- Result of method call ignored
- Suspicious collections method calls
- Result of object allocation ignored
- 'instanceof' with incompatible interface
- 'equals()' between objects of inconvertible types
- 'hashcode()' instead of 'hashCode()'
- @NotNull/@Nullable problems
- Instantiation of utility class
- Object.equals(null)
- Call to default 'toString()'
- Mismatched query and update of collection
- Statement with empty body
- String comparison using '==', instead of 'equals()'
- Reflective access to a source-only annotation
- Text label in 'switch' statement
- Suspicious 'System.arraycopy()' call
- Infinite recursion
- Non-final field referenced in 'compareTo()'
- 'tostring()' instead of 'toString()'
- 'compareto()' instead of 'compareTo()'
- Static field referenced via subclass
- Cast conflicts with 'instanceof'
- Suspicious variable/parameter name combination
- Covariant 'compareTo()'
- Malformed regular expression
- Call to String.replaceAll('.', ...)
- 'for' loop where update or condition does not use loop variable
- == used instead of equals()
- Use of Properties object as a Hashtable
- Malformed format string
- Suspicious 'Collections.toArray()' call
- Malformed XPath expression
- Empty class initializer
- 'Iterator.hasNext()' which calls 'next()'
- Mismatched read and write of array
- Assignment to 'null'
- Comparator class not declared Serializable
- Confusing primitive array argument to var-arg method
- Return of 'null'
- 'Iterator.next()' which can't throw 'NoSuchElementException'
- Use of archaic system property accessors
- 'equals()' called on array type
Faces Model
JUnit issues
- Message missing on JUnit assertion
- JUnit test method without any assertions
- !test.method.in.product.code.display.name!
- JUnit abstract test class naming convention
- JUnit TestCase in product source
- 'teardown()' instead of 'tearDown()'
- JUnit TestCase with non-trivial constructors
- 'setUp()' does not call 'super.setUp()'
- Unconstructable JUnit TestCase
- Malformed @Before or @After method
- Test method with incorrect signature
- 'suite()' method not declared 'static'
- Misordered 'assertEquals()' parameters
- Simplifiable JUnit assertion
- 'setup()' instead of 'setUp()'
- 'setUp()' with incorrect signature
- 'tearDown()' with incorrect signature
- Malformed @BeforeClass or @AfterClass method
- 'tearDown()' does not call 'super.tearDown()'
- JUnit test class naming convention
- JUnit test case with no tests
WebLogic
Memory issues
- Static collection
- StringBuffer field
- Zero-length array allocation
- Calls to 'System.gc()' or 'Runtime.gc()'
Threading issues
- Call to 'Thread.setPriority()'
- 'notify()' without corresponding 'wait()'
- Unconditional 'wait()' call
- 'notify()' or 'notifyAll()' called on Condition object
- Call to 'Thread.run()'
- Non-synchronized method overrides synchronized method
- Synchronization on 'this'
- Call to 'Thread.sleep()' while synchronized
- Busy wait
- Call to 'Thread.yield()'
- 'wait()' not in loop
- Call to a native method while locked
- 'await()' without corresponding 'signal()'
- Field accessed in both synchronized and unsynchronized contexts
- 'await()' not in loop
- 'wait()' or 'await()' without timeout
- Class explicitly extends java.lang.Thread
- Volatile long or double field
- 'notify()' or 'notifyAll()' without corresponding state change
- Synchronization on a non-final field
- Call to 'signal()' instead of 'signalAll()'
- 'signal()' without corresponding 'await()'
- Instantiating a Thread with default 'run()' method
- While loop spins on field
- Call to 'Thread.stop()', 'suspend()' or 'resume()'
- Volatile array field
- 'wait()' while not synced
- Call to 'notify()' instead of 'notifyAll()'
- Call to 'Thread.start()' during object construction
- 'wait()' without corresponding 'notify()'
- 'notify()' or 'notifyAll()' while not synced
- Lock acquired but not safely unlocked
- Call to 'System.runFinalizersOnExit()'
- Double-checked locking
- Access to static field locked on instance data
- 'wait()' while holding two locks
- Empty 'synchronized' statement
- Synchronization on a java.util.concurrent.locks.Lock object
- Nested 'synchronized' statement
- Non-private field accessed in synchronized context
- Arithmetic operation on volatile field
- 'synchronized' method
- 'wait()' called on Condition object