Java Hints

(Difference between revisions)
m
m
 
(17 intermediate revisions not shown)
Line 1: Line 1:
-
There are 163 total hints/inspections, 3 of them in current development version only.
+
There are 261 total hints/inspections, 0 of them in current development version only.
-
There are 13 total suggestions/actions, 3 of them in current development version only.
+
There are 26 total suggestions/actions, 0 of them in current development version only.
===APIs===
===APIs===
-
;Be aware that this API will be optional in Java EE 7 platform.
+
;'''Be aware that this API will be optional in Java EE 7 platform.'''
-
:Warn user about usage of APIs from technologies which will be made optional in Java EE 7 specification. These APIs are not deprecated and can be used but because they will be optional they may or may not be available in future Java EE 7 compliant platforms. '''Since NetBeans 7.0'''
+
:Warn user about usage of APIs from technologies which will be made optional in Java EE 7 specification. These APIs are not deprecated and can be used but because they will be optional they may or may not be available in future Java EE 7 compliant platforms.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
-
;Exporting non-public type through public API
+
;'''Exporting non-public type through public API'''
-
:Checks that return types and parameter types of all public methods and all types of public fields are publicly available from other packages. Having private or package private types in a package API is useless. '''In NetBeans 6.8 or earlier'''
+
:Checks that return types and parameter types of all public methods and all types of public fields are publicly available from other packages. Having private or package private types in a package API is useless.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Utility class with visible constructor
+
;'''Utility class with visible constructor'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Finds out classes containing only static elements with public or protected constructors. '''In NetBeans 6.8 or earlier'''
+
:Finds out classes containing only static elements with public or protected constructors.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Utility class without constructor
+
;'''Utility class without constructor'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Finds out classes containing only static elements and still being instantiable. '''In NetBeans 6.8 or earlier'''
+
:Finds out classes containing only static elements and still being instantiable.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
 +
 
 +
===Abstraction===
 +
;'''Type cast is too strong'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports type casts, which are too strict and casting to a more general type would be sufficient for the actual expression. Sometimes, an instance is casted to a specific subtype, but methods invoked or fields used from the casted instance are actually defined by some supertype. In that case cast to too specific type introduces an unnecessary coupling to the code and limits its extensibility. <p/>This inspection will suggest to use the most general type which would satisfy the expression's needs. <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
===Assignment Issues===
===Assignment Issues===
-
;Assignment replaceable with operator-assignment
+
;'''Assignment replaceable with operator-assignment'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports instances of assignment operations which can be replaced by operator-assignment. Code using operator-assignment may be clearer, and theoretically more performant. '''Since NetBeans 6.9'''
+
:Reports instances of assignment operations which can be replaced by operator-assignment. Code using operator-assignment may be clearer, and theoretically more performant.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Assignment to catch-block parameter
+
;'''Assignment to catch-block parameter'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of assignment to variable declared as a catch block parameter. While occasionally intended, this construct can be confusing. '''Since NetBeans 6.9'''
+
:Reports any instances of assignment to variable declared as a catch block parameter. While occasionally intended, this construct can be confusing.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Assignment to for-loop parameter
+
;'''Assignment to for-loop parameter'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of assignment to variable declared in a for statement in the body of that statement. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo. '''Since NetBeans 6.9'''
+
:Reports any instances of assignment to variable declared in a for statement in the body of that statement. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Assignment to method parameter
+
;'''Assignment to method parameter'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of assignment to a variable declared as a method parameter. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo. '''Since NetBeans 6.9'''
+
:Reports any instances of assignment to a variable declared as a method parameter. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Nested assignment
+
;'''Nested assignment'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of assignment expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing. '''Since NetBeans 6.9'''
+
:Reports any instances of assignment expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Value of increment/decrement expression used
+
;'''Value of increment/decrement expression used'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of increment or decrement expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing. '''Since NetBeans 6.9'''
+
:Reports any instances of increment or decrement expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Bitwise Operations===
===Bitwise Operations===
-
;Incompatible mask
+
;'''Incompatible mask'''
-
:This inspection reports any instances of bitwise mask expressions which are guaranteed to evaluate to false. Expressions checked are of the form (var & constant1) == constant2 or (var | constant1) == constant2, where constant1and constant2 are incompatible bitmask constants. '''Since NetBeans 6.9'''
+
:This inspection reports any instances of bitwise mask expressions which are guaranteed to evaluate to false. Expressions checked are of the form (var & constant1) == constant2 or (var | constant1) == constant2, where constant1and constant2 are incompatible bitmask constants.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Pointless bitwise expression
+
;'''Pointless bitwise expression'''
-
:This inspection reports any instances of pointless bitwise expressions. Such expressions include anding with zero, oring by zero, and shift by zero. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do. '''Since NetBeans 6.9'''
+
:This inspection reports any instances of pointless bitwise expressions. Such expressions include anding with zero, oring by zero, and shift by zero. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Shift operation outside of the reasonable range
+
;'''Shift operation outside of the reasonable range'''
-
:This inspection reports any instances of shift operations where the value shifted by is constant and outside of the reasonable range. Integer shift operations outside of the range 0..31 and long shift operations outside of therange 0..63 are reported. Shifting by negative or overly large values is almost certainly a coding error. '''Since NetBeans 6.9'''
+
:This inspection reports any instances of shift operations where the value shifted by is constant and outside of the reasonable range. Integer shift operations outside of the range 0..31 and long shift operations outside of therange 0..63 are reported. Shifting by negative or overly large values is almost certainly a coding error.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Braces===
===Braces===
-
;Do-While Loops Must Use Braces
+
;'''Do-While Loops Should Use Braces'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Do-While Loops Must Use Braces '''In NetBeans 6.8 or earlier'''
+
:Do-While Loops Should Use Braces<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;For Loops Must Use Braces
+
;'''For Loops Should Use Braces'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns if a <CODE>for</CODE> loop does not have its body wrapped in curly braces.<BR> '''In NetBeans 6.8 or earlier'''
+
:Warns if a <CODE>for</CODE> loop does not have its body wrapped in curly braces.<BR><span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;If-Else Statements Must Use Braces
+
;'''If-Else Statements Should Use Braces'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:If-Else Statements Must Use Braces '''In NetBeans 6.8 or earlier'''
+
:If-Else Statements Should Use Braces<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;While Loops Must Use Braces
+
;'''While Loops Should Use Braces'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:While Loops Must Use Braces '''In NetBeans 6.8 or earlier'''
+
:While Loops Should Use Braces<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
===Class Structure===
===Class Structure===
-
;Class may be interface
+
;'''Class may be interface'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any concrete or abstract classes which may be simplified to be interfaces. This occurs if the class has no superclass (other than Object), has no fields declared that are not static, final, and public, and has no methods declared that are not public and abstract, and no inner classes that cannot themselves be interfaces. '''Since NetBeans 6.9'''
+
:Reports any concrete or abstract classes which may be simplified to be interfaces. This occurs if the class has no superclass (other than Object), has no fields declared that are not static, final, and public, and has no methods declared that are not public and abstract, and no inner classes that cannot themselves be interfaces.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Final class
+
;'''Final class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of classes being declared final. Some coding standards discourage final classes. '''Since NetBeans 6.9'''
+
:Reports any instances of classes being declared final. Some coding standards discourage final classes.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Final method
+
;'''Final method'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of methods being declared final. Some coding standards discourage final classes. '''Since NetBeans 6.9'''
+
:Reports any instances of methods being declared final. Some coding standards discourage final classes.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Final method in final class
+
;'''Final method in final class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of methods being declared final in classes that are declared final. This is unnecessary, and may be confusing. '''Since NetBeans 6.9'''
+
:Reports any instances of methods being declared final in classes that are declared final. This is unnecessary, and may be confusing.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Final private method
+
;'''Final private method'''
-
:Reports any instances of methods being declared final and private. As private methods cannot be meaningfully overridden, declaring them final is redundant. '''Since NetBeans 6.9'''
+
:Reports any instances of methods being declared final and private. As private methods cannot be meaningfully overridden, declaring them final is redundant.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Final static method
+
;'''Initializer may be static'''
-
:Reports any instances of methods being declared final and static. As static methods cannot be meaningfully overridden, declaring them final is redundant. '''Since NetBeans 6.9'''
+
:The initializer does not access any instance variables or methods, it can be static and execute just once, not during each instance creation.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Marker interface
+
;'''Marker interface'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports marker interfaces which have no methods or fields. Such interfaces may be confusing, and normally indicate a design failure. Interfaces which extend two or more other interfaces will not be reported. '''Since NetBeans 6.9'''
+
:Reports marker interfaces which have no methods or fields. Such interfaces may be confusing, and normally indicate a design failure. Interfaces which extend two or more other interfaces will not be reported.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Multiple top-level classes in file
+
;'''Multiple top-level classes in file'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of multiple top-level classes in a single java file. Putting multiple top-level classes in a file can be confusing, and may degrade the usefulness of various software tools. '''Since NetBeans 6.9'''
+
:Reports any instances of multiple top-level classes in a single java file. Putting multiple top-level classes in a file can be confusing, and may degrade the usefulness of various software tools.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;No-op method in abstract class
+
;'''No-op method in abstract class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of no-op methods in abstract classes. It is usually a better design to make such methods abstract themselves, so that classes which inherit the methods will not forget to provide their own implementations. '''Since NetBeans 6.9'''
+
:Reports any instances of no-op methods in abstract classes. It is usually a better design to make such methods abstract themselves, so that classes which inherit the methods will not forget to provide their own implementations.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Organize members
+
;'''Organize members'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Checks whether members order corresponds to the specified code style rules '''In current development version'''
+
:Checks whether members order corresponds to the specified code style rules <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.3''</span>
-
;Protected member in final class
+
;'''Protected member in final class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports any instances of members being declared protected in classes that are declared final. Such members may be declared private or package-visible instead. '''Since NetBeans 6.9'''
+
:Reports any instances of members being declared protected in classes that are declared final. Such members may be declared private or package-visible instead.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Public constructor in non-public class
+
;'''Public constructor in non-public class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Reports all constructors in non-public classes that are declared public. '''Since NetBeans 6.9'''
+
:Reports all constructors in non-public classes that are declared public.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Code Maturity Issues===
===Code Maturity Issues===
-
;Obsolete Collection
+
;'''Obsolete Collection'''
-
:This inspection reports any uses of java.util.Vector or java.util.Hashtable. While still supported, these classes were made obsolete by the JDK1.2 collection classes, and should probably not be used in new development. '''Since NetBeans 6.9'''
+
:This inspection reports any uses of java.util.Vector or java.util.Hashtable. While still supported, these classes were made obsolete by the JDK1.2 collection classes, and should probably not be used in new development.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Print Stack Trace
+
;'''Print Stack Trace'''
-
:This inspection reports any uses Throwable.printStackTrace() without arguments. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility. '''Since NetBeans 6.9'''
+
:This inspection reports any uses Throwable.printStackTrace() without arguments. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;System out / err
+
;'''System out / err'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:This inspection reports any uses of System.out or System.err. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility. '''Since NetBeans 6.9'''
+
:This inspection reports any uses of System.out or System.err. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Thread Dump Stack
+
;'''Thread Dump Stack'''
-
:This inspection reports any uses Thread.dumpStack(). These are often temporary debugging statements, and should probably be either removed from production code,or replaced by a more robust logging facility. '''Since NetBeans 6.9'''
+
:This inspection reports any uses Thread.dumpStack(). These are often temporary debugging statements, and should probably be either removed from production code,or replaced by a more robust logging facility.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Empty Statements===
===Empty Statements===
-
;
+
;''''''
-
: '''In NetBeans 6.8 or earlier'''
+
:<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Empty statement
+
;'''Empty statement'''
-
:Checks for empty statements in blocks usually represented as superfluous semicolon. '''Since NetBeans 6.9'''
+
:Checks for empty statements in blocks usually represented as superfluous semicolon.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Empty statement after 'do'
+
;'''Empty statement after 'do''''
-
:Checks for 'do/while' statements in form<BR><CODE>do;<BR>while</CODE>. '''Since NetBeans 6.9'''
+
:Checks for 'do/while' statements in form<BR><CODE>do;<BR>while</CODE>.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Empty statement after 'for'
+
;'''Empty statement after 'for''''
-
:Checks for 'for' statements in form<BR><CODE>for(...);</CODE>. '''Since NetBeans 6.9'''
+
:Checks for 'for' statements in form<BR><CODE>for(...);</CODE>.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Empty statement after 'if/else'
+
;'''Empty statement after 'if/else''''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Checks for 'if/else' statements in form<BR><CODE>if(...);<BR>else;</CODE>. '''Since NetBeans 6.9'''
+
:Checks for 'if/else' statements in form<BR><CODE>if(...);<BR>else;</CODE>.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Empty statement after 'while'
+
;'''Empty statement after 'while''''
-
:Checks for 'while' statements in form<BR><CODE>while(...);</CODE>. '''Since NetBeans 6.9'''
+
:Checks for 'while' statements in form<BR><CODE>while(...);</CODE>.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Encapsulation===
===Encapsulation===
-
;Access of Private Field of Another Object
+
;'''Access of Private Field of Another Object'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about access of private fields of another objects '''Since NetBeans 6.9'''
+
:Warns about access of private fields of another objects<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Assignment to Array Field from Parameter
+
;'''Assignment to Array Field from Parameter'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about assignment of array into fields '''Since NetBeans 6.9'''
+
:Warns about assignment of array into fields<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Assignment to Collection Field from Parameter
+
;'''Assignment to Collection Field from Parameter'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about assignment of java.util.Collection into fields '''Since NetBeans 6.9'''
+
:Warns about assignment of java.util.Collection into fields<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Assignment to Date or Calendar Field from Parameter
+
;'''Assignment to Date or Calendar Field from Parameter'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about assignment of java.util.Date or java.util.Calendar into fields '''Since NetBeans 6.9'''
+
:Warns about assignment of java.util.Date or java.util.Calendar into fields<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Package Field
+
;'''Package Field'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about existence of package visible variables '''Since NetBeans 6.9'''
+
:Warns about existence of package visible variables<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Package Visible Inner Class
+
;'''Package Visible Inner Class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about existence of package visible inner class '''Since NetBeans 6.9'''
+
:Warns about existence of package visible inner class<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Protected Field
+
;'''Protected Field'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about existence of protected variables '''Since NetBeans 6.9'''
+
:Warns about existence of protected variables<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Protected Inner Class
+
;'''Protected Inner Class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about existence of protected visible inner class '''Since NetBeans 6.9'''
+
:Warns about existence of protected visible inner class<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Public Field
+
;'''Public Field'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about existence of public variables '''Since NetBeans 6.9'''
+
:Warns about existence of public variables<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Public Inner Class
+
;'''Public Inner Class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about existence of public visible inner class '''Since NetBeans 6.9'''
+
:Warns about existence of public visible inner class<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Return of Array Field
+
;'''Return of Array Field'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about return of array fields '''Since NetBeans 6.9'''
+
:Warns about return of array fields<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Return of Collection Field
+
;'''Return of Collection Field'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about return of collection fields '''Since NetBeans 6.9'''
+
:Warns about return of collection fields<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Return of Date or Calendar Field
+
;'''Return of Date or Calendar Field'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about return of java.util.Date or java.util.Calendar fields '''Since NetBeans 6.9'''
+
:Warns about return of java.util.Date or java.util.Calendar fields<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
===Enterprise Java Beans===
 +
;'''@Remote uses value in business interface'''
 +
:If an interface is annotated with @Remote, then value attribute must not be specified. In other words, if value is specified for @Remote, then it must be annotating a class (not an interface).<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Annotation @PostConstruct'''
 +
:Checks usage of @PostConstruct annotation. Its return value, singularity per class, parameters etc.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Asynchronous method invocation'''
 +
:Checks usage of @Asynchronous. Tests whether it's used within supported project and interface type.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Bean doesn't implement business interface'''
 +
:It is recommended that a bean class implement its business interface.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Inheritance of session beans'''
 +
:A session bean must not extend another session bean.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Instantiation replaceable with @EJB injection'''
 +
:Finds instantiations of a bean which can be injected by @EJB annotation<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Local and Remote business inteface together'''
 +
:The same business interface cannot be both a local and a remote business interface of the bean.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method definition in local and remote interface'''
 +
:When a session bean has remote and local business interfaces, there should not be method common to both of them.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method not exposed in business interface.'''
 +
:Method is not exposed in any business interface.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Modifiers of the EJB bean'''
 +
:Checks whether the defined EJB beans have correct modifiers - are public, not final and not abstract.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''No-arg contructor in the EJB bean'''
 +
:EJB class must have a public or protected no-arg constructor.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Persistent timer within EJB Lite'''
 +
:Persistent timer (@Schedule annotation) can't be used in case of EJB 3.2 Lite and timer can't be used at all within EJB 3.1 Lite targeting project.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''SessionSynchronization implemted by non-SFSB'''
 +
:Only stateful session bean (SFSB) can implement SessionSynchronization interface.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Uncomplete LBI Session bean'''
 +
:If a session bean is annotated as @Local, then it must have a local business interface.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Uncomplete RBI Session bean'''
 +
:If a session bean is annotated as @Remote, then it must have a remote business interface.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''WebService must be designated as session bean'''
 +
:If a class is part of ejb-jar and is annotated as @WebService, then it must be designated as a stateless or as a singleton session bean.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
===Error Fixes===
===Error Fixes===
-
;Create Field
+
;'''Create Field'''
-
:Settings for Create Field Fix '''Since NetBeans 6.9'''
+
:Settings for Create Field Fix<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Create Local Variable
+
;'''Create Local Variable'''
-
:Settings for the Create Local Variable error fix '''Since NetBeans 6.9'''
+
:Settings for the Create Local Variable error fix<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Implementation of EJBContainer is missing on project's classpath
+
;'''Implementation of EJBContainer is missing on project's classpath'''
-
:Find out whether implementation of EJBContainer necessary for successful execution of unit test is available. '''Since NetBeans 7.0'''
+
:Find out whether implementation of EJBContainer necessary for successful execution of unit test is available.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
-
;Java EE API is missing on project classpath.
+
;'''Java EE API is missing on project classpath.'''
-
:Find out whether Java EE API is available on project classpath. Java EE API is necessary for successful test execution. This hint also warns about incorrect usage of javaee-web-api artifact - that artifact is suitable only for compilation but not for test execution because body of all API methods was removed from the bytecode. '''Since NetBeans 7.0'''
+
:Find out whether Java EE API is available on project classpath. Java EE API is necessary for successful test execution. This hint also warns about incorrect usage of javaee-web-api artifact - that artifact is suitable only for compilation but not for test execution because body of all API methods was removed from the bytecode.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
-
;Surround with try-catch
+
;'''Surround with try-catch'''
-
:Settings for the Surround with try-catch error fix '''Since NetBeans 6.9'''
+
:Settings for the Surround with try-catch error fix<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Finalization===
===Finalization===
-
;finalize() called explicitly
+
;'''finalize() called explicitly'''
-
:Warns about an explicit call of the Object.finalize() '''Since NetBeans 6.9'''
+
:Warns about an explicit call of the Object.finalize()<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;finalize() declared
+
;'''finalize() declared'''
-
:Warns about implementations of Object.finalize() '''Since NetBeans 6.9'''
+
:Warns about implementations of Object.finalize()<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;finalize() does not call super.finalize()
+
;'''finalize() does not call super.finalize()'''
-
:Warns about implementations of Object.finalize() which do not call supertype implementation '''Since NetBeans 6.9'''
+
:Warns about implementations of Object.finalize() which do not call supertype implementation<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;finalize() not declared protected
+
;'''finalize() not declared protected'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warns about non protected implementations of Object.finalize() '''Since NetBeans 6.9'''
+
:Warns about non protected implementations of Object.finalize()<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===General===
===General===
-
;.equals Method not Checking Type
+
;'''.equals Method not Checking Type'''
-
:Implementation of .equals methods not checking the type of the input parameter '''In NetBeans 6.8 or earlier'''
+
:Implementation of .equals methods not checking the type of the input parameter<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Accessing static via reference
+
;'''Accessing static via reference'''
-
:Java language allows access to static fields thru instance variables, however this is often misleading and harder to read. '''In NetBeans 6.8 or earlier'''
+
:Java language allows access to static fields thru instance variables, however this is often misleading and harder to read.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Assignment To Itself
+
;'''Assignment To Itself'''
-
:Assignment To Itself '''In NetBeans 6.8 or earlier'''
+
:Assignment To Itself<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Comparing Strings using == or !=
+
;'''Comparing Strings using == or !='''
-
:Checks for usages of == or != operator for comparing Strings.<BR>String comparisons should generally be done using the equals() method. '''In NetBeans 6.8 or earlier'''
+
:Checks for usages of == or != operator for comparing Strings.<BR>String comparisons should generally be done using the equals() method.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Field hides another field
+
;'''Field hides another field'''
-
:Declaration of a field in a class can hide declaration of another field in superclasses. Although possible, this is not very good programming style. '''In NetBeans 6.8 or earlier'''
+
:Declaration of a field in a class can hide declaration of another field in superclasses. Although possible, this is not very good programming style.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Generate missing hashCode or equals
+
;'''Generate missing hashCode or equals'''
-
:Checks whether a class which overrides equals method also overrides hashCode. '''In NetBeans 6.8 or earlier'''
+
:Checks whether a class which overrides equals method also overrides hashCode.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Local variable hides a field
+
;'''Local variable hides a field'''
-
:Declaration of a variable in a method can hide declaration of a field declared in the surrounding class. Although possible, this is not very good programming style. '''In NetBeans 6.8 or earlier'''
+
:Declaration of a variable in a method can hide declaration of a field declared in the surrounding class. Although possible, this is not very good programming style.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Remove Unnecessary Return Statement
+
;'''Redundant conditional statement'''
-
:Remove Unnecessary Return Statement '''Since NetBeans 7.1'''
+
:Redundant conditional statement<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Unnecessary Throwable.initCause
+
;'''Redundant if statement'''
-
:Finds invocations of Throwable.initCause which can be replaced with simple constructor invocation. When the "Never alter result of getMessage()" checkbox is unchecked, <code>(IllegalStateException) new IllegalStateException().initCause(ex)</code> will be rewritten to <code>new IllegalStateException(ex)</code>, which will alter the value of getMessage(). When the checkbox is checked, the code will become <code>new IllegalStateException(null, ex)</code>. Similar rule holds for creating the exception from <code>getMessage()</code> or <code>getLocalizedMessage()</code> of the cause. '''Since NetBeans 6.9'''
+
:Redundant if statement<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Wrong Package
+
;'''Remove Unnecessary Continue Statement'''
-
:Wrong Package '''In NetBeans 6.8 or earlier'''
+
:Remove Unnecessary Continue Statement<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Remove Unnecessary Label in break'''
 +
:Remove Unnecessary Label in break statement<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Remove Unnecessary Label in continue'''
 +
:Remove Unnecessary Label in continue statement<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Remove Unnecessary Return Statement'''
 +
:Remove Unnecessary Return Statement<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
 +
 
 +
;'''Unnecessary Throwable.initCause'''
 +
:Finds invocations of Throwable.initCause which can be replaced with simple constructor invocation. When the "Never alter result of getMessage()" checkbox is unchecked, <code>(IllegalStateException) new IllegalStateException().initCause(ex)</code> will be rewritten to <code>new IllegalStateException(ex)</code>, which will alter the value of getMessage(). When the checkbox is checked, the code will become <code>new IllegalStateException(null, ex)</code>. Similar rule holds for creating the exception from <code>getMessage()</code> or <code>getLocalizedMessage()</code> of the cause.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Use Functional Operations'''
 +
:Use functional operations instead of imperative style loop.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Wrong Package'''
 +
:Wrong Package<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
===Imports===
===Imports===
-
;Import From The Same Package
+
;'''Import From The Same Package'''
-
:Import From The Same Package '''In NetBeans 6.8 or earlier'''
+
:Import From The Same Package<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Import From java.lang Package
+
;'''Import From java.lang Package'''
-
:Import From java.lang Package '''In NetBeans 6.8 or earlier'''
+
:Import From java.lang Package<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Import from Excluded
+
;'''Import from Excluded'''
-
:Import from package or class which has been labelled "Excluded" in the Code Completer '''In NetBeans 6.8 or earlier'''
+
:Import from package or class which has been labelled "Excluded" in the Code Completer<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Organize imports
+
;'''Organize imports'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Checks whether import statements correspond to the specified code style rules '''Since NetBeans 7.1'''
+
:Checks whether import statements correspond to the specified code style rules <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
-
;Star import
+
;'''Star import'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Star import '''In NetBeans 6.8 or earlier'''
+
:Star import<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Unused Import
+
;'''Unused Import'''
-
:Unused Import '''In NetBeans 6.8 or earlier'''
+
:Unused Import<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
===Initialization===
===Initialization===
-
;Passing suspicious parameter in the constructor
+
;'''Passing suspicious parameter in the constructor'''
-
:Using this as parameter can be dangerous in the contructor because the object is not fully initialized. '''Since NetBeans 6.9'''
+
:Using this as parameter can be dangerous in the contructor because the object is not fully initialized.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Problematic call in the constructor
+
;'''Problematic call in the constructor'''
-
:Calling methods that can be overridden can be dangerous in the contructor because in the moment when the overridden method is called the object is not fully initialized. '''Since NetBeans 6.9'''
+
:Calling methods that can be overridden can be dangerous in the contructor because in the moment when the overridden method is called the object is not fully initialized.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Static non-final variable used during initialization
+
;'''Static non-final variable used during initialization'''
-
:Using static non-final variables can be dangerous in the initialization code because their values may depend on the order of initialization statements '''Since NetBeans 6.9'''
+
:Using static non-final variables can be dangerous in the initialization code because their values may depend on the order of initialization statements<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
===JDK 1.5 and later===
+
===JDK Migration Support===
-
;AbstractProcessor.getSupportedAnnotationTypes() is overridden
+
;'''AbstractProcessor.getSupportedAnnotationTypes() is overridden'''
-
:Overriding Processor.getSupportedAnnotationTypes() may lead to unnecessary classloading during development, and may prevent important optimalizations. consider using @javax.annotation.processing.SupportedAnnotationTypes '''Since NetBeans 7.2'''
+
:Overriding Processor.getSupportedAnnotationTypes() may lead to unnecessary classloading during development, and may prevent important optimalizations. consider using @javax.annotation.processing.SupportedAnnotationTypes<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
-
;Add @Override Annotation
+
;'''Add @Override Annotation'''
-
:Add @Override Annotation '''In NetBeans 6.8 or earlier'''
+
:Add @Override Annotation<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Add Underscores
+
;'''Add Underscores'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Proposed to add underscores to integer literals to improve their readability '''Since NetBeans 7.2'''
+
:Proposed to add underscores to integer literals to improve their readability<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
-
;Can Use Diamond
+
;'''Can Use Diamond'''
-
:Warns about places where the diamond operator in JDK 7 can be used instead of explicit type parameters '''Since NetBeans 7.1'''
+
:Warns about places where the diamond operator in JDK 7 can be used instead of explicit type parameters<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
-
;Convert to try-with-resources
+
;'''Convert to Lambda or Member Reference'''
-
:Converts try finally block to try-with-resources '''Since NetBeans 7.0'''
+
:Converts anonymous inner classes to lambda expressions or member references<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Don't use Annotation as super interface
+
;'''Convert to try-with-resources'''
-
:Despite the compiler permitting such constructs, Annotations should not be used as superinterfaces. '''In NetBeans 6.8 or earlier'''
+
:Converts try finally block to try-with-resources<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
-
;Join catch sections using multicatch
+
;'''Don't use Annotation as super interface'''
-
:Join catch sections using multicatch '''Since NetBeans 7.0'''
+
:Despite the compiler permitting such constructs, Annotations should not be used as superinterfaces.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Static imports
+
;'''Join catch sections using multicatch'''
-
:Convert method to static import. Feedback to http://www.netbeans.org/issues/show_bug.cgi?id=89258 '''Since NetBeans 6.9'''
+
:Join catch sections using multicatch<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
-
;Use JDK 5 for-loop
+
;'''Static imports'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Replaces simple uses of Iterator with a corresponding for-loop. '''In current development version'''
+
:Convert method to static import. Feedback to http://www.netbeans.org/issues/show_bug.cgi?id=89258<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Use specific catch
+
;'''String.indexOf can be replaced with String.contains'''
-
:Converts catch (Throwable) or catch (Exception) to multicatch catching the exceptions thrown by the try body. '''Since NetBeans 7.0'''
+
:Finds usages of String.indexOf that can be replaced with String.contains<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Use switch over Strings where possible.
+
;'''Too broad 'catch' clause'''
-
:Marks cascades of ifs which can be converted to switch over Strings . '''Since NetBeans 6.9'''
+
:Reports <b>catch</b> clauses, which catch a supertype rather than the actually thrown exception type. Such broad catches may provide inappropriate reports or overly general exception handling. <p/>Sometimes the method produces <b>more than one</b> exception type which can be handled by catching their common supertype. "<i>Report common supertypes</i>" option controls whether such situations will be reported. The <i>generic exceptions</i> configured for the <b>Use Specific Catch</b> hint are always reported. <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
===JavaEE===
+
;'''Unnecessary boxing'''
-
;Instantiation replaceable with @EJB injection
+
:Explicit boxing using e.g. <b>new Integer(x)</b> or <b>Integer.valueOf(x)</b> is not necessary in JDK 5+. This hint detects such situations, and suggest to remove the boxing call.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
:Finds instantiations of a bean which can be injected by @EJB annotation '''Since NetBeans 7.2'''
+
-
===Javadoc===
+
;'''Unnecessary unboxing'''
-
;Create Javadoc
+
:Explicit unboxing using e.g. <b>x.intValue()</b> is not necessary under JDK 5+. The hint finds such calls and suggests the removal.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
:Create Javadoc '''In NetBeans 6.8 or earlier'''
+
-
;Error in Javadoc
+
;'''Use JDK 5 for-loop'''
-
:Error in Javadoc '''In NetBeans 6.8 or earlier'''
+
:Replaces simple uses of Iterator with a corresponding for-loop.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.3''</span>
 +
 
 +
;'''Use specific catch'''
 +
:Converts catch (Throwable) or catch (Exception) to multicatch (when java source level is 7 and above) or to several catch clauses (for earlier Java platforms) catching the exceptions thrown by the try body. The watched exception types can be configured; fully qualified names must be used.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
 +
 
 +
;'''Use switch over Strings where possible.'''
 +
:Marks cascades of ifs which can be converted to switch over Strings .<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
===Java Code Metrics===
 +
;'''Anonymous class has too many methods'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports anonymous class with many methods. Anonymous classes typically implement a very simple interface, and should be very simple. It is recommended to create at least named local class, if the anonymous class' complexity grows.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Anonymous class is too complex'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports anonymous classes, whose cyclomatic complexity exceeds the configured limit. The complexity of a class is computed as a sum of complexities of its methods. Anonymous classes should have far less responsibilities and lower complexity than a regular class<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Arithmetic expression too complex'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports arithmetic expressions, which include more than the defined number of operations. Expression with many operands are harder to read and often could be split into several assignment statements to interim result variables.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Class has too many constructors'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports classes which define too many constructors. <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Class has too many fields'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports a class which holds too many fields. The state kept by the class is too large and it should be investigated if the state can be split into several state classes, often also separating manipulation methods and reduce the overall class complexity.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Class has too many methods'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports class, which contains too many methods. The options allows to ignore simple bean property accessors - lazy getters, or setters which fire change events are not considered 'simple'. Implementations of superclass (not implementation of interface methods) abstract methods can be also ignored.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Class is too complex'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports classes, whose cyclomatic complexity exceeds the configured limit. The complexity of a class is computed as a sum of complexities of its methods.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Class is too coupled'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports classes which are too coupled (use too many) other types. References to Java system libraries (<code>java.**</code> and <code>javax.**</code>) can be ignored.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Constructor declares too many parameters'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports constructor that take too many parameters. Constructors typically take more parameters than a regular method, especially when initializing a large object.<p/>Large number of parameters indicate a bad design. It's likely that yet more parameters will be added in the future, so creational patterns like Builder should be considered.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Logical expression too complex'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports logical expressions, which include more than the defined number of operations. Expression with many operands are harder to read and often could be split into several assignment statements to interim result variables.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method body is too long'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports methods, which have too long body. Longer methods require scrolling back and forth, and typically can be refactored into several methods called from a mediating method. Splitting a long method into several named pieces may also help code reuse. Some coding practices even demand that a method should fit a screen size, so it can be easily scanned and understood by the developer.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method declares too many parameters'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports method that take too many parameters. Methods with large number of parameters indicate a bad design. It's likely that yet more parameters will be added in the future, so the parameters should be grouped into a Command Object, improving maintenance costs. Alternatively, the method could be refactored into several methods, each doing part of the task and requiring less parameters at input.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method is too complex'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:The inspection reports method, whose <b>Cyclomatic Complexity</b> exceeds a configurable value. The <i>Cyclomatic Complexity</i> measures a number of potential branching points (or cycles) in a method. It is believed that methods with high cyclomatic complexity usually do too much and should be split to several, more focused, methods. Such complex methods are also prone to code duplication between their execution paths and are hard to sustain. Usually it is recommended that cyclomatic complexity of a method is 5 or below; less than 10 may be also acceptable for more elaborate algorithms. <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method or constructor declares too many exceptions'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports methods which declare many exceptions in their <b>throws</b> clause. Method that produce a large number of exception types are hard to use, as the caller must handle all the outcomes or complicate its own declaration with exceptions. The error handling code grows more complex. <p/>The inspection also processes constructors.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method with multiple loops'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Methods that contains multiple loop statements. <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method with multiple negations'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Methods with multiple negated expressions (unary <b>!</b> or <b>!=</b>) are said to confuse readers, true (non-negated) expressions are considered easier to read and understand. Consider to change the logic to use true instead of false values.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Method with multiple return points'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports methods, which exit at multiple places using <b>return</b> statement. Such methods may be confusing and are harder to refactor. The inspection can ignore conditional <b>guard returns</b> - a <b>return</b> statement, which is the sole statement in an <b>if</b> branch. Optionally, all <b>equals</b> methods can be ignored, as contents of <b>equals</b> is traditionally generated using early returns on type or value mismatch.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Too coupled method'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports methods which are too coupled - that refer to too many other types. Methods that refer to large number of types are <i>fragile</i>: they tend to fail or require refactoring if the referenced type(s) change. It is also more difficult to move the method which has many dependencies to another module. <p/>References to the method class' itself and its superclasses are ignored. With <i>Ignore dependencies on Java Platform</i>, references to <code>java.**</code> and <code>javax.**</code> classes are also ignored.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Too deep nesting'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Reports methods whose bodies contain statements nested <i>too deep</i>. Such methods are less readable, contain indent space and allow less screen space for code reading. Methods can be often refactored and split to improve code readability.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
===Java Persistence API===
 +
;'''Check access types for jpa classes'''
 +
:JPA classes need to have consistent access types for fields/properties<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Default public/protected constructor'''
 +
:JPA classes need to have default public/protected no arg constructor<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Entity impleents Serializable verification'''
 +
:If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Entity table name verification'''
 +
:Entity table name must be valid QL intentifier<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''JPQL validation'''
 +
:Parse and find errors in a jpql query<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Presece of persistence.xml'''
 +
:Check if project with jpa usage contain persistence.xml with persistence unit<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''The IdClass must override equals(Object o) and hashCode() method.'''
 +
:The IdClass must override equals(Object o) and hashCode() method.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify @IdClass location'''
 +
:Only Entity or MappedSuperclass can use IdClass.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify IdClass in entity subclass'''
 +
:An entity sub-class cannot have IdClass because it will result in multiple IDs in the entity hierarchy.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify access level for IdClass'''
 +
:IdClass need to be public<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify attributes of jpa classes'''
 +
:This validation cover nimber of issues like valid column name, valid attribute modifiers, valid basic type, relationships etc<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify combinations of jpa annitations'''
 +
:Some JPA annotations may not be applied to the same element at the same time<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify entity have defined promary key'''
 +
:Id is required for entities<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify entity name is unique'''
 +
:Entity names must not be the same in one persistence unit<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify jpa annotations on accessors'''
 +
:JPA annotations should be applied to getter methods only<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify jpa class is top level class'''
 +
:JPA classes must not be inner classes<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify jpa class isn't final'''
 +
:JPA classes must not be final<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Verify named query location'''
 +
:Named queries can be defined only on an Entity or MappedSuperclass class.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
===JavaDoc===
 +
;'''Create Javadoc'''
 +
:Create Javadoc<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
 +
 
 +
;'''Error in Javadoc'''
 +
:Error in Javadoc<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
 +
 
 +
===JavaServer Faces===
 +
;'''@FlowScoped bean in the non-CDI capable project'''
 +
:@FlowScoped bean in the non-CDI capable project<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Classes of javax.faces.bean are gonna be deprecated'''
 +
:Annotations from the package javax.faces.bean will be deprecated in the next JSF version. CDI and Java EE ones are recommended instead.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
===Logging===
===Logging===
-
;Logger declaration is not static final
+
;'''Logger declaration is not static final'''
-
:Each class should have one unique logger. If declared as a field it should be static and final. '''Since NetBeans 6.9'''
+
:Each class should have one unique logger. If declared as a field it should be static and final.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Multiple loggers
+
;'''Multiple loggers'''
-
:There are several loggers declared for a single class. '''Since NetBeans 6.9'''
+
:There are several loggers declared for a single class.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;No loggers
+
;'''No loggers'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:There is no logger declared for a class. '''Since NetBeans 6.9'''
+
:There is no logger declared for a class.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;String concatenation in logger
+
;'''String concatenation in logger'''
-
:It is not performance efficient to concatenate strings in logger messages. It is better to use a template message with placeholders that are replaced by concrete values only when the message is really going to be logged. '''Since NetBeans 6.9'''
+
:It is not performance efficient to concatenate strings in logger messages. It is better to use a template message with placeholders that are replaced by concrete values only when the message is really going to be logged.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Maven===
===Maven===
-
;Resolve Missing Class Dependency
+
;'''Resolve Missing Class Dependency'''
-
:Resolve missing class dependency and add to project POM '''Since NetBeans 6.9'''
+
:Resolve missing class dependency and add to project POM<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===NetBeans Development===
===NetBeans Development===
-
;Empty cancel() for cancelable tasks
+
;'''Empty cancel() for cancelable tasks'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn about empty cancel() methods for cancelable tasks '''In NetBeans 6.8 or earlier'''
+
:Warn about empty cancel() methods for cancelable tasks<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;HelpCtx issues
+
;'''HelpCtx issues'''
-
:Warnings about misuse of org.openide.util.HelpCtx. '''Since NetBeans 7.2'''
+
:Warnings about misuse of org.openide.util.HelpCtx.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
-
;Illegal Use of instanceOf operator
+
;'''Illegal Use of instanceOf operator'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Show illegal use of instanceof on javax.lang.model.elements, javax.lang.model.type and com.sun.source.tree '''In NetBeans 6.8 or earlier'''
+
:Show illegal use of instanceof on javax.lang.model.elements, javax.lang.model.type and com.sun.source.tree<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Use @NbBundle.Messages
+
;'''Use @NbBundle.Messages'''
-
:Use @NbBundle.Messages in preference to Bundle.properties plus NbBundle.getMessage(...). '''Since NetBeans 7.0'''
+
:Use @NbBundle.Messages in preference to Bundle.properties plus NbBundle.getMessage(...).<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
===Performance===
===Performance===
-
;.getClass() replaceable with .class
+
;'''.getClass() replaceable with .class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Finds instantions of a class directly followed by invocation of .getClass() on the newly constructed object '''Since NetBeans 6.9'''
+
:Finds instantions of a class directly followed by invocation of .getClass() on the newly constructed object<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Collections without initial capacity
+
;'''Boxing of already boxed value'''
-
:Looks for instatiations of collections with missing initial capacity. Only collections backed-up with an array are tested. '''Since NetBeans 6.9'''
+
:Reports boxing of already boxed value. Constructor or <i>valueOf</i> take a primitive parameter, so a boxed value is unboxed first, then boxed again, which may create an extra instance of the wrapper and impact the performance.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Creating new Boolean
+
;'''Collections without initial capacity'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Creating new Boolean is inefficient and typically useless. '''Since NetBeans 6.9'''
+
:Looks for instatiations of collections with missing initial capacity. Only collections backed-up with an array are tested.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Length one String in String.indexOf
+
;'''Creating new Boolean'''
-
:Length one String literal in String.indexOf can be replaced with a character literal '''Since NetBeans 6.9'''
+
:Creating new Boolean is inefficient and typically useless.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Manual array copy
+
;'''Length one String in String.indexOf'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Finds occurrences of manual array copying via for loop '''Since NetBeans 6.9'''
+
:Length one String literal in String.indexOf can be replaced with a character literal<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Map replaceable with EnumMap
+
;'''Manual array copy'''
-
:Finds instantiations of Maps that can be replaced with EnumMap '''Since NetBeans 6.9'''
+
:Finds occurrences of manual array copying via for loop<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Set replaceable with EnumSet
+
;'''Map replaceable with EnumMap'''
-
:Finds instantiations of Sets that can be replaced with EnumSet '''Since NetBeans 6.9'''
+
:Finds instantiations of Maps that can be replaced with EnumMap<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;String concatenation in StringBuilder.append
+
;'''Redundant String.toString()'''
-
:Looks for string concatenation in the parameter of an invocation of the append method of StringBuilder or StringBuffer. '''Since NetBeans 6.9'''
+
:Reports calls of String.toString(), which is entirely useless, the String can be used directly.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;String constructor
+
;'''Replace StringBuffer/StringBuilder by String'''
-
:Use of java.lang.String constructor is usually useless. '''Since NetBeans 6.9'''
+
:The hint will find and offer to replace instances of <b>StringBuffer</b> or <b>StringBuilder</b> which are accessed using ordinary <b>String</b> methods and are never passed out of the method, or assigned to another variable. Keeping such data in StringBuffer/Builder is pointless, and String would be more efficient.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;String.equals("")
+
;'''Set replaceable with EnumSet'''
-
:Use of String.equals("") can be replaced with with String.length() == 0 (for JDK5 and lower) or String.isEmpty() (for JDK6 and higher) '''Since NetBeans 6.9'''
+
:Finds instantiations of Sets that can be replaced with EnumSet<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;String.intern() called on constant
+
;'''String concatenation in StringBuilder.append'''
-
:Invocations of String.intern() on compile-time constants are superfluous. '''Since NetBeans 6.9'''
+
:Looks for string concatenation in the parameter of an invocation of the append method of StringBuilder or StringBuffer.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;StringBuilder without initial capacity
+
;'''String constructor'''
-
:Looks for instantiations of StringBuilder or StringBuffer with missing initial capacity. '''Since NetBeans 6.9'''
+
:Use of java.lang.String constructor is usually useless.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Usage of .size() == 0
+
;'''String.equals("")'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Use .isEmpty() or !.isEmpty() instead of .size() == 0 or .size() != 0 where possible. '''Since NetBeans 6.9'''
+
:Use of String.equals("") can be replaced with with String.length() == 0 (for JDK5 and lower) or String.isEmpty() (for JDK6 and higher)<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Useless use of StringBuffer
+
;'''String.intern() called on constant'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Use StringBuilder instead of StringBuffer where possible. '''Since NetBeans 6.9'''
+
:Invocations of String.intern() on compile-time constants are superfluous.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Zero element array passed to Collection.toArray
+
;'''StringBuilder without initial capacity'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Passing zero element array to Collection.toArray may affect performance '''Since NetBeans 7.2'''
+
:Looks for instantiations of StringBuilder or StringBuffer with missing initial capacity.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Unnecessary temporary during conversion from String'''
 +
:Finds occurrences of <i>new Integer("111").intValue()</i> and similar constructions, where the boxed instance is created just to parse the String parameter. Boxing types have <i>parseXXX</i> methods, which perform the conversion without creating the temporary instance.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Unnecessary temporary during conversion to String'''
 +
:Finds places like <i>new Integer(11).toString()</i> where a temporary boxed instance is created to just produce a String representation of a primitive. The boxed types have <i>toString()</i> static method just for that purpose.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Usage of .size() == 0'''
 +
:Use .isEmpty() or !.isEmpty() instead of .size() == 0 or .size() != 0 where possible.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Useless use of StringBuffer'''
 +
:Use StringBuilder instead of StringBuffer where possible.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Zero element array passed to Collection.toArray'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Passing zero element array to Collection.toArray may affect performance<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
===Probable Bugs===
===Probable Bugs===
-
;.equals on Array
+
;''''finally' block suppresses exceptions'''
-
:.equals on array '''Since NetBeans 6.9'''
+
:Reports usage of <b>return</b> statements in <b>finally</b> block. Such <b>return</b> discards the exception being thrown and causes the whole method to complete normally, which is usually not the desired outcome. <b>Break</b> and <b>continue</b> statements, which break out of the <b>finally</b> block are also reported.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;.equals on Incompatible Types
+
;''''throw' inside 'finally' block'''
-
:.equals on incompatible types '''In NetBeans 6.8 or earlier'''
+
:Throwing an exception inside <b>finally</b> block will hide the original exception thrown from the associated <b>try</b> or <b>catch</b> blocks from enclosing exception handlers. Note that the exception can be still inspected using <b>Throwable.getSuppressedException()</b>, although it cannot be directly caught by a <b>catch</b> block.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;.equals(null)
+
;'''.equals on Array'''
-
:Finds invocations of the Object.equals method with literal parameter 'null'. '''Since NetBeans 6.9'''
+
:.equals on array<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;@CheckReturnValue
+
;'''.equals on Incompatible Types'''
-
:Verifies that a result of method marked with @CheckReturnValue is really checked. '''Since NetBeans 7.2'''
+
:.equals on incompatible types<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Annotations without runtime Retention
+
;'''.equals(null)'''
-
:Warns about reflective access to annotations with CLASS or SOURCE retentions '''Since NetBeans 6.9'''
+
:Finds invocations of the Object.equals method with literal parameter 'null'.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Dead Branch
+
;'''@CheckReturnValue'''
-
:Dead Branch '''Since NetBeans 7.1'''
+
:Verifies that a result of method marked with @CheckReturnValue is really checked.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
-
;Incompatible cast/instanceof
+
;'''Annotations without runtime Retention'''
-
:Incompatible cast surrounded with incompatible instanceof '''Since NetBeans 6.9'''
+
:Warns about reflective access to annotations with CLASS or SOURCE retentions<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Incorrect column index in ResultSet
+
;'''Assert with side effects'''
-
:Reports Iincorrect column indices passed to various methods of java.sql.ResultSet '''Since NetBeans 6.9'''
+
:Identifies assert statements whose condition reportedly causes some side effects. The hint checks assignments to local variables and fields made from within the condition expression. If the expression calls a method, the hint checks whether the method assigns to some fields. Only the <b>directly called</b> methods are checked. For performance reasons, although the called method may resolve to some overrides in subclasses at runtime, only the base class method body is inspected. Calls to interface type methods are ingored completely. Inspection of all possible overrides of a method would greatly hurt performance.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Malformed regular expression
+
;'''Boxed value identity comparison'''
-
:Warns about malformed regular expressions '''Since NetBeans 6.9'''
+
:If two boxed values are compared using <i>==</i> or <i>!=</i>, identity of the boxed object's identity is compared instead of the boxed value. The inspection suggests a fix, which performs a null-safe comparison using <b>java.util.Objects.equals()</b>.<p/>The fix is only available for source level >= 7, since a conditional expression would require multiple evaluation of one of the operands, which may not be possible because of potential expression's side effects.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Null Pointer Dereference
+
;'''Cloneable class does not implement clone().'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Checks various problems related to dereferencing nulls '''In current development version'''
+
:<html><b>Cloneable</b> class should override clone(). If it does not, the clone operation uses the default <b>java.lang.Object.clone()</b>, which is usually not suitable. Lack of overridden <b>clone</b> indicate a possible error.</html><span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Result of new Object ignored
+
;'''Comparator.compare() does not use its parameter {0}'''
-
:Result of new Object ignored. '''Since NetBeans 6.9'''
+
:The Comparator is expected to compare the arguments to its compare method. If one of the parameters is not used for comparison, it indicates that the other argument might be compared to self or some other error in the implementation.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;String.replaceAll(".", )
+
;'''Confusing indentation'''
-
:Finds occurrences of calls to String.replaceAll(".", $target), which would replace all characters of the source string with $target. '''Since NetBeans 6.9'''
+
:Warns about indentation that suggests possible missing surrounding block<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Suspicious invocation of System.arraycopy
+
;'''Confusing primitive array passed to varargs method'''
-
:Finds invocations of System.arraycopy with negative offsets, length or used on non-array objects. '''Since NetBeans 6.9'''
+
:A primitive array passed to variable-argument method will not be unwrapped and its items will not be seen as items of the variable-length argument in the called method. Instead, the array will be passed as a single item.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Suspicious method call
+
;'''Created Throwable not thrown'''
-
:Warns about suspicious calls to Collection.remove/contains and Map.containsKey/containsValue/remove '''Since NetBeans 6.9'''
+
:The hint detects creation of a Throwable, which is then discarded. Throwable creation is rather expensive, and not using a created Throwable may indicate an unfinished error handling code. The Throwable is considered <i>used</i>, if it is thrown, passed to a method as a parameter, returned as a method's result or assigned to a field. Possible assignments through local variables are also inspected to determine whether the value will be finally <i>used</i>.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Synchronizing on this in anonymous class
+
;'''Dead Branch'''
-
:<html>Synchronizing on <tt>this</tt> in anonymous or local class is probably a result of refactoring and possibly a mistake '''Since NetBeans 6.9'''
+
:Dead Branch<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
-
;Unbalanced read/write with arrays
+
;'''Incompatible cast/instanceof'''
-
:Unbalanced read/write with arrays '''Since NetBeans 7.1'''
+
:Incompatible cast surrounded with incompatible instanceof<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Unbalanced read/write with collections
+
;'''Incorrect column index in ResultSet'''
-
:Unbalanced read/write with collections '''Since NetBeans 7.1'''
+
:Reports Iincorrect column indices passed to various methods of java.sql.ResultSet<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Unused Assignment
+
;'''Infinite recursion'''
-
:Unused Assignment '''Since NetBeans 7.1'''
+
:Detects methods which must recurse infinitely and could only terminate by throwing an exception. Only definitively recursions are reported, not possibilities. The recursion only inspected across the single method (so recursion like a -> b -> a is not reported). Recursion through several instances of the class is also not reported. The hint can be disabled for the case the recursing method could be overriden in subclasses, since subclass implementations could avoid the recursion. However if some subclass does not override and fix the method, recursion may still happen. By default the inspection warns even for the overridable case.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Malformed XPath expression'''
 +
:The hint check syntax of the XPath expression passed to JAXP XPath evaluator. The calls checked are:<ul><li>JAXP XPath compile and evaluate calls,<li>Xalan-J XPath creation and XPathAPI usage,<li>Apache Common's JXPath calls</ul><span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Malformed format string'''
 +
:Reports format strings passed to String.format, printf-style methods. Checks that the number of arguments correspond to the number of % specifiers, and the arguments have the correct type. <span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Malformed regular expression'''
 +
:Warns about malformed regular expressions<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Math.random() casted to int'''
 +
:Math.random produces a double in range 0..1. If the value is immediately cast to int, it is always rounded down to 0, which is probably not intended. The fix will move the cast so the enclosing arithmetic expression is casted and possibly rounded.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Null Pointer Dereference'''
 +
:Checks various problems related to dereferencing nulls<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.3''</span>
 +
 
 +
;'''Possibly missing switch "case" statement'''
 +
:The hint detects a typo made in a <b>switch statement</b> a label without a <b>case</b> statement.<p/>While it may be a intended label for the following statement, it could be also an intended <b>case</b> branch with the keyword forgotten.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Result of new Object ignored'''
 +
:Result of new Object ignored.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''String.replaceAll(".", )'''
 +
:Finds occurrences of calls to String.replaceAll(".", $target), which would replace all characters of the source string with $target.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''StringBuffer constructor called with `char'' argument'''
 +
:<b>StringBuffer</b> and <b>StringBuilder</b> constructors accept <i>int</i> as a parameter. If a <i>char</i> is passed, it is silently promoted to int, and the call creates a <b>StringBuffer</b> instance with a defined initial capacity, rather than a StringBuffer that initially contains a single (the passed one) character.<p/>The offered fix will add an <i>append</i> that actually adds the character.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Suspicious Collections.toArray() call'''
 +
:Detects such calls, whose array type parameter does not match the Collection's type parameter. The collection's type parameter should be assignable to the array type.  For raw Collections, the hint checks that the array type is actually assignable to the casted-to array type.<p/>The hint offers to change the newly created array type, or to change the <b>toArray</b> parameter to <i>new Type[]</i>,but the fix is not available if the collection expression may have some side effects.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Suspicious Names Combination'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:Suspicious Names Combination<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Suspicious invocation of System.arraycopy'''
 +
:Finds invocations of System.arraycopy with negative offsets, length or used on non-array objects.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Suspicious method call'''
 +
:Warns about suspicious calls to Collection.remove/contains and Map.containsKey/containsValue/remove<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Synchronizing on this in anonymous class'''
 +
:<html>Synchronizing on <tt>this</tt> in anonymous or local class is probably a result of refactoring and possibly a mistake<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Throwable method result is ignored'''
 +
:If a Throwable is returned from a method call as a <i>return value</i> (as an oppposite to be thrown), it is usually somehow recorded (assigned), further processed (passed to another method call), or thrown. Ignoring such Throwable or using in some simple comparison indicates either a defect in error handling, or that the method should return a different value to save time for Throwable's stacktrace creation.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''Unbalanced read/write with arrays'''
 +
:Unbalanced read/write with arrays<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
 +
 
 +
;'''Unbalanced read/write with collections'''
 +
:Unbalanced read/write with collections<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
 +
 
 +
;'''Unused Assignment'''
 +
:Unused Assignment<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
 +
 
 +
;'''clone() does not call super.clone()'''
 +
:Cloned instances should be allocated using <b>super.clone()</b> so fields are initialized properly.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''clone() does not throw CloneNotSupportedException'''
 +
:If clone() is not declared to throw <b>CloneNotSupportedException</b> subclasses cannot prohibit cloning using standard <b>Cloneable</b> contract.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''clone() in a non-Cloneable class'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
 +
:The contract for <b>Object.clone()</b> requires, that a class must implement <b>Cloneable</b> marker interface. If not, the clone() method will raise <b>CloneNotSupportedException</b>. Declaring <b>Cloneable</b> interface is often overlooked.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''hashCode() used on array instance'''
 +
:hashCode for array instances is inherited from java.lang.Object, and it is based on the array's reference rather than on array's contents.<p>In order to obtain a more reasonable hashCode, which reflects contained objects or values, use <b>Arrays.hashCode</b>or <b>Arrays.deepHashCode()</b><span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
 +
 
 +
;'''toString() used on array instance'''
 +
:toString() implementation for arrays does not convert array contents to String, rather it will print array's type and hash code (defined as identity hash code). To get string representation of contents of the array, the array could be for example wrapped into Arrays.asList(), as Collections produce content representation in their toString().<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
===Standard Javac Warnings===
===Standard Javac Warnings===
-
;Deprecated
+
;'''Deprecated'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn when code uses deprecated API. '''Since NetBeans 6.9'''
+
:Warn when code uses deprecated API.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Division By Zero
+
;'''Division By Zero'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Division By Zero '''Since NetBeans 6.9'''
+
:Division By Zero<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Empty Statement After If
+
;'''Empty Statement After If'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Empty Statement After If '''Since NetBeans 6.9'''
+
:Empty Statement After If<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Fallthrough
+
;'''Fallthrough'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn when a case can fall through to the next case. '''Since NetBeans 6.9'''
+
:Warn when a case can fall through to the next case.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Finally  
+
;'''Finally '''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn when a finally block interrupts flow of a try/catch block. '''Since NetBeans 6.9'''
+
:Warn when a finally block interrupts flow of a try/catch block.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Overrides
+
;'''Overrides'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn when an overriding method is not annotated with @Overrides '''Since NetBeans 6.9'''
+
:Warn when an overriding method is not annotated with @Overrides<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Raw Types
+
;'''Raw Types'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Raw Types '''Since NetBeans 6.9'''
+
:Raw Types<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Serialization
+
;'''Serialization'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn when a class which implements java.io.Serializable does not declare a serialVersionUID. '''Since NetBeans 6.9'''
+
:Warn when a class which implements java.io.Serializable does not declare a serialVersionUID.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Unchecked
+
;'''Unchecked'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn when unchecked conversions may cause ClassCastExceptions at runtime. '''Since NetBeans 6.9'''
+
:Warn when unchecked conversions may cause ClassCastExceptions at runtime.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Unnecessary Cast
+
;'''Unnecessary Cast'''<span style='padding-left: 3em;font-size: 80%;color: #204a87'>[ Disabled by default ]</span>
-
:Warn when an object is cast unnecessarily to the same type or a supertype. '''Since NetBeans 6.9'''
+
:Warn when an object is cast unnecessarily to the same type or a supertype.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
===Suggestions===
===Suggestions===
-
;Assign Return Value To New Variable
+
;'''Assign Return Value To New Variable'''
-
:Assign Return Value To New Variable '''In NetBeans 6.8 or earlier'''
+
:Assign Return Value To New Variable<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Assign Unused Constructor Parameter to Field
+
;'''Assign Unused Constructor Parameter to Field'''
-
:Assign Unused Constructor Parameter to Field '''In NetBeans 6.8 or earlier'''
+
:Assign Unused Constructor Parameter to Field<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Convert Anonymous to Member
+
;'''Combine nested if statements'''
-
:Convert Anonymous to Member '''In NetBeans 6.8 or earlier'''
+
:Combines two nested if statements, like <code>if (cond1) if (cond2) statement;</code>, into one if statement, like <code>if (cond1 && cond2) statement;</code>.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Convert integer constant to different base
+
;'''Convert Anonymous to Member'''
-
:Convert integer constant to different base '''Since NetBeans 7.0'''
+
:Convert Anonymous to Member<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Create Subclass
+
;'''Convert Lambda Body to Use a Block'''
-
:Create Subclass '''Since NetBeans 7.2'''
+
:Converts lambda bodies to use blocks rather than expressions<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Declaration for instanceof
+
;'''Convert Lambda Expression to Anonymous Innerclass'''
-
:Declaration for instanceof '''In NetBeans 6.8 or earlier'''
+
:Converts lambda expressions to anonymous inner classes<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Expand Enhanced For Loop
+
;'''Convert Lambda Expression to Member Reference'''
-
:Expand Enhanced For Loop '''Since NetBeans 7.1'''
+
:Converts lambda expressions to member references<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 8.0''</span>
-
;Fill Missing Cases to Switch
+
;'''Convert Lambda to Use Explicit Parameter Types'''
-
:Adds missing cases to switch statement. The default clause template should be one Java statement, occurrences of $expression will be replaced with the expression over which the switch statement works. '''Since NetBeans 7.2'''
+
:Converts lambdas to use explicit parameter types<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Flip .equals
+
;'''Convert Member Reference to Lambda Expression'''
-
:Allows to flip .equals parameter and call site '''Since NetBeans 6.9'''
+
:Converts member references to lambda expressions<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Implement Abstract Methods
+
;'''Convert integer constant to different base'''
-
:Implement Abstract Methods. '''In current development version'''
+
:Convert integer constant to different base<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.0''</span>
-
;Invert If
+
;'''Create Subclass'''
-
:Will invert an if statement; negate the condition and switch the statements from the then and else sections. '''In current development version'''
+
:Create Subclass<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
-
;Move initilization to constructor
+
;'''Create Test Class'''
-
:Moves a fields initilization expression to the constructors. '''In current development version'''
+
:Create a test class for the selected source class.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Split Declaration
+
;'''Declaration for instanceof'''
-
:Splits declaration with initializer to a declaration and assignment '''Since NetBeans 7.2'''
+
:Declaration for instanceof<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
 +
 
 +
;'''Expand Enhanced For Loop'''
 +
:Expand Enhanced For Loop<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.1''</span>
 +
 
 +
;'''Fill Missing Cases to Switch'''
 +
:Adds missing cases to switch statement. The default clause template should be one Java statement, occurrences of $expression will be replaced with the expression over which the switch statement works.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
 +
 
 +
;'''Flip .equals'''
 +
:Allows to flip .equals parameter and call site<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''Flip operands of the binary operator'''
 +
:Flip operands of the binary operator<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Generate All Test Methods'''
 +
:Generate all test methods for the selected source class.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Implement Abstract Methods'''
 +
:Implement Abstract Methods.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.3''</span>
 +
 
 +
;'''Invert If'''
 +
:Will invert an if statement; negate the condition and switch the statements from the then and else sections.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.3''</span>
 +
 
 +
;'''Join consecutive ifs into if-else'''
 +
:Converts cases like <code>if - else { if }</code> info <code>if - else if</code><span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Join if conditions using ||'''
 +
:Converts cases like <code>if (cond1) statement; else if (cond2) statement;</code> into <code>if (cond1 || cond2) statement;</code><span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Move initialization to constructor'''
 +
:Moves a fields initialization expression to the constructors.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.3''</span>
 +
 
 +
;'''Split Declaration'''
 +
:Splits declaration with initializer to a declaration and assignment<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.2''</span>
 +
 
 +
;'''Split if condition'''
 +
:Splits if whose condition is || into two ifs<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Split if statement condition'''
 +
:Splits an if statement with a complex condition, like <code>if (cond1 || cond2) statement;</code>, into two if statements, like <code>if (cond1) statement; else if (cond2) statement;</code>.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
===Testing===
 +
;'''Inconvertible parameters of Assert.assertEquals'''
 +
:Inconvertible parameters of Assert.assertEquals<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''Incorrect order of parameters of Assert.assertEquals'''
 +
:Incorrect order of parameters of Assert.assertEquals<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
 +
 
 +
;'''assertEquals for array parameters'''
 +
:Warns about assertEquals whose parameters are arrays<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
===Threading===
===Threading===
-
;.wait invoked outside a synchronized context
+
;'''.notify invoked outside a synchronized context'''
-
:.wait invoked outside a synchronized context '''Since NetBeans 6.9'''
+
:.notify invoked outside a synchronized context<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
 +
 
 +
;'''.wait invoked outside a synchronized context'''
 +
:.wait invoked outside a synchronized context<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;.wait invoked outside a synchronized context
+
;'''Double-checked locking'''
-
:.wait invoked outside a synchronized context '''Since NetBeans 6.9'''
+
:Searches for examples of double checked locking - e.g. when a variable is tested before as well as inside a synchronized block.<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Double-checked locking
+
;'''Empty synchronized block'''
-
:Searches for examples of double checked locking - e.g. when a variable is tested before as well as inside a synchronized block. '''In NetBeans 6.8 or earlier'''
+
:Empty synchronized block are usually useless<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Empty synchronized block
+
;'''Field Can Be Final'''
-
:Empty synchronized block are usually useless '''Since NetBeans 6.9'''
+
:Finds fields that can be made final, which can simplify synchronization and clarity<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 7.4''</span>
-
;Invoking Condition.notify()
+
;'''Invoking Condition.notify()'''
-
:Invoking notify or notifyAll on java.util.concurrent.locks.Condition should probably be replaced with invoking signal or signalAll. '''Since NetBeans 6.9'''
+
:Invoking notify or notifyAll on java.util.concurrent.locks.Condition should probably be replaced with invoking signal or signalAll.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Invoking Condition.wait()
+
;'''Invoking Condition.wait()'''
-
:Invoking notify or notifyAll on java.util.concurrent.locks.Condition is probably unintended. '''Since NetBeans 6.9'''
+
:Invoking wait on java.util.concurrent.locks.Condition is probably unintended.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Invoking Thread.run()
+
;'''Invoking Thread.run()'''
-
:Invoking run on java.lang.Thread should be probably replaced with invocation of method start() '''Since NetBeans 6.9'''
+
:Invoking run on java.lang.Thread should be probably replaced with invocation of method start()<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Invoking Thread.stop()/suspend()/resume()
+
;'''Invoking Thread.stop()/suspend()/resume()'''
-
:Methods stop(), suspend() and resume() of java.lang.Thread are dangerous and should not be used. '''Since NetBeans 6.9'''
+
:Methods stop(), suspend() and resume() of java.lang.Thread are dangerous and should not be used.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Invoking Thread.yield()
+
;'''Invoking Thread.yield()'''
-
:Invocation of method yield() on java.lang.Thread is usually used to masquerade synchronization problems and should be avoided. '''Since NetBeans 6.9'''
+
:Invocation of method yield() on java.lang.Thread is usually used to masquerade synchronization problems and should be avoided.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Lock not unlocked in finally
+
;'''Lock not unlocked in finally'''
-
:Finds occurrences of Lock.lock()-Lock.unlock() not properly wrapped in try-finally. '''Since NetBeans 6.9'''
+
:Finds occurrences of Lock.lock()-Lock.unlock() not properly wrapped in try-finally.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Nested synchronized blocks
+
;'''Nested synchronized blocks'''
-
:Nesting synchronized blocks is either useless (if they use the same lock object) or dangerous. '''Since NetBeans 6.9'''
+
:Nesting synchronized blocks is either useless (if they use the same lock object) or dangerous.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Starting Thread in constructor
+
;'''Starting Thread in constructor'''
-
:Starting a new Thread in constructor is dangerous and should be prevented. '''Since NetBeans 6.9'''
+
:Starting a new Thread in constructor is dangerous and should be prevented.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Synchronization on non-final field
+
;'''Synchronization on non-final field'''
-
:Synchronization on non-final field '''In NetBeans 6.8 or earlier'''
+
:Synchronization on non-final field<span style='padding-left: 1em; font-size: 90%'> ''In NetBeans 6.8 or earlier''</span>
-
;Synchronizing on Lock
+
;'''Synchronizing on Lock'''
-
:Synchronizing on java.util.concurrent.locks.Lock is usually unintended and should be replaced with Lock.lock()-Lock.unlock() '''Since NetBeans 6.9'''
+
:Synchronizing on java.util.concurrent.locks.Lock is usually unintended and should be replaced with Lock.lock()-Lock.unlock()<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Thread.sleep in loop
+
;'''Thread.sleep in loop'''
-
:Invoking Thread.sleep in loop can cause performance problems '''Since NetBeans 6.9'''
+
:Invoking Thread.sleep in loop can cause performance problems<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Thread.sleep in synchronized context
+
;'''Thread.sleep in synchronized context'''
-
:Invoking Thread.sleep in synchronized context can cause performance problems '''Since NetBeans 6.9'''
+
:Invoking Thread.sleep in synchronized context can cause performance problems<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>
-
;Volatile array field
+
;'''Volatile array field'''
-
:Finds declarations of volatile array fields. '''Since NetBeans 6.9'''
+
:Finds declarations of volatile array fields.<span style='padding-left: 1em; font-size: 90%'> ''Since NetBeans 6.9''</span>

Current revision as of 09:33, 21 March 2014

There are 261 total hints/inspections, 0 of them in current development version only.

There are 26 total suggestions/actions, 0 of them in current development version only.

Contents

APIs

Be aware that this API will be optional in Java EE 7 platform.
Warn user about usage of APIs from technologies which will be made optional in Java EE 7 specification. These APIs are not deprecated and can be used but because they will be optional they may or may not be available in future Java EE 7 compliant platforms. Since NetBeans 7.0
Exporting non-public type through public API
Checks that return types and parameter types of all public methods and all types of public fields are publicly available from other packages. Having private or package private types in a package API is useless. In NetBeans 6.8 or earlier
Utility class with visible constructor[ Disabled by default ]
Finds out classes containing only static elements with public or protected constructors. In NetBeans 6.8 or earlier
Utility class without constructor[ Disabled by default ]
Finds out classes containing only static elements and still being instantiable. In NetBeans 6.8 or earlier

Abstraction

Type cast is too strong[ Disabled by default ]
Reports type casts, which are too strict and casting to a more general type would be sufficient for the actual expression. Sometimes, an instance is casted to a specific subtype, but methods invoked or fields used from the casted instance are actually defined by some supertype. In that case cast to too specific type introduces an unnecessary coupling to the code and limits its extensibility. <p/>This inspection will suggest to use the most general type which would satisfy the expression's needs. Since NetBeans 7.4

Assignment Issues

Assignment replaceable with operator-assignment[ Disabled by default ]
Reports instances of assignment operations which can be replaced by operator-assignment. Code using operator-assignment may be clearer, and theoretically more performant. Since NetBeans 6.9
Assignment to catch-block parameter[ Disabled by default ]
Reports any instances of assignment to variable declared as a catch block parameter. While occasionally intended, this construct can be confusing. Since NetBeans 6.9
Assignment to for-loop parameter[ Disabled by default ]
Reports any instances of assignment to variable declared in a for statement in the body of that statement. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo. Since NetBeans 6.9
Assignment to method parameter[ Disabled by default ]
Reports any instances of assignment to a variable declared as a method parameter. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo. Since NetBeans 6.9
Nested assignment[ Disabled by default ]
Reports any instances of assignment expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing. Since NetBeans 6.9
Value of increment/decrement expression used[ Disabled by default ]
Reports any instances of increment or decrement expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing. Since NetBeans 6.9

Bitwise Operations

Incompatible mask
This inspection reports any instances of bitwise mask expressions which are guaranteed to evaluate to false. Expressions checked are of the form (var & constant1) == constant2 or (var | constant1) == constant2, where constant1and constant2 are incompatible bitmask constants. Since NetBeans 6.9
Pointless bitwise expression
This inspection reports any instances of pointless bitwise expressions. Such expressions include anding with zero, oring by zero, and shift by zero. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do. Since NetBeans 6.9
Shift operation outside of the reasonable range
This inspection reports any instances of shift operations where the value shifted by is constant and outside of the reasonable range. Integer shift operations outside of the range 0..31 and long shift operations outside of therange 0..63 are reported. Shifting by negative or overly large values is almost certainly a coding error. Since NetBeans 6.9

Braces

Do-While Loops Should Use Braces[ Disabled by default ]
Do-While Loops Should Use Braces In NetBeans 6.8 or earlier
For Loops Should Use Braces[ Disabled by default ]
Warns if a for loop does not have its body wrapped in curly braces.
In NetBeans 6.8 or earlier
If-Else Statements Should Use Braces[ Disabled by default ]
If-Else Statements Should Use Braces In NetBeans 6.8 or earlier
While Loops Should Use Braces[ Disabled by default ]
While Loops Should Use Braces In NetBeans 6.8 or earlier

Class Structure

Class may be interface[ Disabled by default ]
Reports any concrete or abstract classes which may be simplified to be interfaces. This occurs if the class has no superclass (other than Object), has no fields declared that are not static, final, and public, and has no methods declared that are not public and abstract, and no inner classes that cannot themselves be interfaces. Since NetBeans 6.9
Final class[ Disabled by default ]
Reports any instances of classes being declared final. Some coding standards discourage final classes. Since NetBeans 6.9
Final method[ Disabled by default ]
Reports any instances of methods being declared final. Some coding standards discourage final classes. Since NetBeans 6.9
Final method in final class[ Disabled by default ]
Reports any instances of methods being declared final in classes that are declared final. This is unnecessary, and may be confusing. Since NetBeans 6.9
Final private method
Reports any instances of methods being declared final and private. As private methods cannot be meaningfully overridden, declaring them final is redundant. Since NetBeans 6.9
Initializer may be static
The initializer does not access any instance variables or methods, it can be static and execute just once, not during each instance creation. Since NetBeans 8.0
Marker interface[ Disabled by default ]
Reports marker interfaces which have no methods or fields. Such interfaces may be confusing, and normally indicate a design failure. Interfaces which extend two or more other interfaces will not be reported. Since NetBeans 6.9
Multiple top-level classes in file[ Disabled by default ]
Reports any instances of multiple top-level classes in a single java file. Putting multiple top-level classes in a file can be confusing, and may degrade the usefulness of various software tools. Since NetBeans 6.9
No-op method in abstract class[ Disabled by default ]
Reports any instances of no-op methods in abstract classes. It is usually a better design to make such methods abstract themselves, so that classes which inherit the methods will not forget to provide their own implementations. Since NetBeans 6.9
Organize members[ Disabled by default ]
Checks whether members order corresponds to the specified code style rules Since NetBeans 7.3
Protected member in final class[ Disabled by default ]
Reports any instances of members being declared protected in classes that are declared final. Such members may be declared private or package-visible instead. Since NetBeans 6.9
Public constructor in non-public class[ Disabled by default ]
Reports all constructors in non-public classes that are declared public. Since NetBeans 6.9

Code Maturity Issues

Obsolete Collection
This inspection reports any uses of java.util.Vector or java.util.Hashtable. While still supported, these classes were made obsolete by the JDK1.2 collection classes, and should probably not be used in new development. Since NetBeans 6.9
Print Stack Trace
This inspection reports any uses Throwable.printStackTrace() without arguments. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility. Since NetBeans 6.9
System out / err[ Disabled by default ]
This inspection reports any uses of System.out or System.err. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility. Since NetBeans 6.9
Thread Dump Stack
This inspection reports any uses Thread.dumpStack(). These are often temporary debugging statements, and should probably be either removed from production code,or replaced by a more robust logging facility. Since NetBeans 6.9

Empty Statements

'
In NetBeans 6.8 or earlier
Empty statement
Checks for empty statements in blocks usually represented as superfluous semicolon. Since NetBeans 6.9
Empty statement after 'do'
Checks for 'do/while' statements in form
do;
while
. Since NetBeans 6.9
Empty statement after 'for'
Checks for 'for' statements in form
for(...);. Since NetBeans 6.9
Empty statement after 'if/else'[ Disabled by default ]
Checks for 'if/else' statements in form
if(...);
else;
. Since NetBeans 6.9
Empty statement after 'while'
Checks for 'while' statements in form
while(...);. Since NetBeans 6.9

Encapsulation

Access of Private Field of Another Object[ Disabled by default ]
Warns about access of private fields of another objects Since NetBeans 6.9
Assignment to Array Field from Parameter[ Disabled by default ]
Warns about assignment of array into fields Since NetBeans 6.9
Assignment to Collection Field from Parameter[ Disabled by default ]
Warns about assignment of java.util.Collection into fields Since NetBeans 6.9
Assignment to Date or Calendar Field from Parameter[ Disabled by default ]
Warns about assignment of java.util.Date or java.util.Calendar into fields Since NetBeans 6.9
Package Field[ Disabled by default ]
Warns about existence of package visible variables Since NetBeans 6.9
Package Visible Inner Class[ Disabled by default ]
Warns about existence of package visible inner class Since NetBeans 6.9
Protected Field[ Disabled by default ]
Warns about existence of protected variables Since NetBeans 6.9
Protected Inner Class[ Disabled by default ]
Warns about existence of protected visible inner class Since NetBeans 6.9
Public Field[ Disabled by default ]
Warns about existence of public variables Since NetBeans 6.9
Public Inner Class[ Disabled by default ]
Warns about existence of public visible inner class Since NetBeans 6.9
Return of Array Field[ Disabled by default ]
Warns about return of array fields Since NetBeans 6.9
Return of Collection Field[ Disabled by default ]
Warns about return of collection fields Since NetBeans 6.9
Return of Date or Calendar Field[ Disabled by default ]
Warns about return of java.util.Date or java.util.Calendar fields Since NetBeans 6.9

Enterprise Java Beans

@Remote uses value in business interface
If an interface is annotated with @Remote, then value attribute must not be specified. In other words, if value is specified for @Remote, then it must be annotating a class (not an interface). Since NetBeans 7.4
Annotation @PostConstruct
Checks usage of @PostConstruct annotation. Its return value, singularity per class, parameters etc. Since NetBeans 7.4
Asynchronous method invocation
Checks usage of @Asynchronous. Tests whether it's used within supported project and interface type. Since NetBeans 7.4
Bean doesn't implement business interface
It is recommended that a bean class implement its business interface. Since NetBeans 7.4
Inheritance of session beans
A session bean must not extend another session bean. Since NetBeans 7.4
Instantiation replaceable with @EJB injection
Finds instantiations of a bean which can be injected by @EJB annotation Since NetBeans 7.4
Local and Remote business inteface together
The same business interface cannot be both a local and a remote business interface of the bean. Since NetBeans 7.4
Method definition in local and remote interface
When a session bean has remote and local business interfaces, there should not be method common to both of them. Since NetBeans 7.4
Method not exposed in business interface.
Method is not exposed in any business interface. Since NetBeans 7.4
Modifiers of the EJB bean
Checks whether the defined EJB beans have correct modifiers - are public, not final and not abstract. Since NetBeans 7.4
No-arg contructor in the EJB bean
EJB class must have a public or protected no-arg constructor. Since NetBeans 7.4
Persistent timer within EJB Lite
Persistent timer (@Schedule annotation) can't be used in case of EJB 3.2 Lite and timer can't be used at all within EJB 3.1 Lite targeting project. Since NetBeans 7.4
SessionSynchronization implemted by non-SFSB
Only stateful session bean (SFSB) can implement SessionSynchronization interface. Since NetBeans 7.4
Uncomplete LBI Session bean
If a session bean is annotated as @Local, then it must have a local business interface. Since NetBeans 7.4
Uncomplete RBI Session bean
If a session bean is annotated as @Remote, then it must have a remote business interface. Since NetBeans 7.4
WebService must be designated as session bean
If a class is part of ejb-jar and is annotated as @WebService, then it must be designated as a stateless or as a singleton session bean. Since NetBeans 7.4

Error Fixes

Create Field
Settings for Create Field Fix Since NetBeans 6.9
Create Local Variable
Settings for the Create Local Variable error fix Since NetBeans 6.9
Implementation of EJBContainer is missing on project's classpath
Find out whether implementation of EJBContainer necessary for successful execution of unit test is available. Since NetBeans 7.0
Java EE API is missing on project classpath.
Find out whether Java EE API is available on project classpath. Java EE API is necessary for successful test execution. This hint also warns about incorrect usage of javaee-web-api artifact - that artifact is suitable only for compilation but not for test execution because body of all API methods was removed from the bytecode. Since NetBeans 7.0
Surround with try-catch
Settings for the Surround with try-catch error fix Since NetBeans 6.9

Finalization

finalize() called explicitly
Warns about an explicit call of the Object.finalize() Since NetBeans 6.9
finalize() declared
Warns about implementations of Object.finalize() Since NetBeans 6.9
finalize() does not call super.finalize()
Warns about implementations of Object.finalize() which do not call supertype implementation Since NetBeans 6.9
finalize() not declared protected[ Disabled by default ]
Warns about non protected implementations of Object.finalize() Since NetBeans 6.9

General

.equals Method not Checking Type
Implementation of .equals methods not checking the type of the input parameter In NetBeans 6.8 or earlier
Accessing static via reference
Java language allows access to static fields thru instance variables, however this is often misleading and harder to read. In NetBeans 6.8 or earlier
Assignment To Itself
Assignment To Itself In NetBeans 6.8 or earlier
Comparing Strings using == or !=
Checks for usages of == or != operator for comparing Strings.
String comparisons should generally be done using the equals() method. In NetBeans 6.8 or earlier
Field hides another field
Declaration of a field in a class can hide declaration of another field in superclasses. Although possible, this is not very good programming style. In NetBeans 6.8 or earlier
Generate missing hashCode or equals
Checks whether a class which overrides equals method also overrides hashCode. In NetBeans 6.8 or earlier
Local variable hides a field
Declaration of a variable in a method can hide declaration of a field declared in the surrounding class. Although possible, this is not very good programming style. In NetBeans 6.8 or earlier
Redundant conditional statement
Redundant conditional statement Since NetBeans 7.4
Redundant if statement
Redundant if statement Since NetBeans 7.4
Remove Unnecessary Continue Statement
Remove Unnecessary Continue Statement Since NetBeans 7.4
Remove Unnecessary Label in break
Remove Unnecessary Label in break statement Since NetBeans 7.4
Remove Unnecessary Label in continue
Remove Unnecessary Label in continue statement Since NetBeans 7.4
Remove Unnecessary Return Statement
Remove Unnecessary Return Statement Since NetBeans 7.1
Unnecessary Throwable.initCause
Finds invocations of Throwable.initCause which can be replaced with simple constructor invocation. When the "Never alter result of getMessage()" checkbox is unchecked, (IllegalStateException) new IllegalStateException().initCause(ex) will be rewritten to new IllegalStateException(ex), which will alter the value of getMessage(). When the checkbox is checked, the code will become new IllegalStateException(null, ex). Similar rule holds for creating the exception from getMessage() or getLocalizedMessage() of the cause. Since NetBeans 6.9
Use Functional Operations
Use functional operations instead of imperative style loop. Since NetBeans 7.4
Wrong Package
Wrong Package In NetBeans 6.8 or earlier

Imports

Import From The Same Package
Import From The Same Package In NetBeans 6.8 or earlier
Import From java.lang Package
Import From java.lang Package In NetBeans 6.8 or earlier
Import from Excluded
Import from package or class which has been labelled "Excluded" in the Code Completer In NetBeans 6.8 or earlier
Organize imports[ Disabled by default ]
Checks whether import statements correspond to the specified code style rules Since NetBeans 7.1
Star import[ Disabled by default ]
Star import In NetBeans 6.8 or earlier
Unused Import
Unused Import In NetBeans 6.8 or earlier

Initialization

Passing suspicious parameter in the constructor
Using this as parameter can be dangerous in the contructor because the object is not fully initialized. Since NetBeans 6.9
Problematic call in the constructor
Calling methods that can be overridden can be dangerous in the contructor because in the moment when the overridden method is called the object is not fully initialized. Since NetBeans 6.9
Static non-final variable used during initialization
Using static non-final variables can be dangerous in the initialization code because their values may depend on the order of initialization statements Since NetBeans 6.9

JDK Migration Support

AbstractProcessor.getSupportedAnnotationTypes() is overridden
Overriding Processor.getSupportedAnnotationTypes() may lead to unnecessary classloading during development, and may prevent important optimalizations. consider using @javax.annotation.processing.SupportedAnnotationTypes Since NetBeans 7.2
Add @Override Annotation
Add @Override Annotation In NetBeans 6.8 or earlier
Add Underscores[ Disabled by default ]
Proposed to add underscores to integer literals to improve their readability Since NetBeans 7.2
Can Use Diamond
Warns about places where the diamond operator in JDK 7 can be used instead of explicit type parameters Since NetBeans 7.1
Convert to Lambda or Member Reference
Converts anonymous inner classes to lambda expressions or member references Since NetBeans 7.4
Convert to try-with-resources
Converts try finally block to try-with-resources Since NetBeans 7.0
Don't use Annotation as super interface
Despite the compiler permitting such constructs, Annotations should not be used as superinterfaces. In NetBeans 6.8 or earlier
Join catch sections using multicatch
Join catch sections using multicatch Since NetBeans 7.0
Static imports[ Disabled by default ]
Convert method to static import. Feedback to http://www.netbeans.org/issues/show_bug.cgi?id=89258 Since NetBeans 6.9
String.indexOf can be replaced with String.contains
Finds usages of String.indexOf that can be replaced with String.contains Since NetBeans 8.0
Too broad 'catch' clause
Reports catch clauses, which catch a supertype rather than the actually thrown exception type. Such broad catches may provide inappropriate reports or overly general exception handling. <p/>Sometimes the method produces more than one exception type which can be handled by catching their common supertype. "Report common supertypes" option controls whether such situations will be reported. The generic exceptions configured for the Use Specific Catch hint are always reported. Since NetBeans 7.4
Unnecessary boxing
Explicit boxing using e.g. new Integer(x) or Integer.valueOf(x) is not necessary in JDK 5+. This hint detects such situations, and suggest to remove the boxing call. Since NetBeans 8.0
Unnecessary unboxing
Explicit unboxing using e.g. x.intValue() is not necessary under JDK 5+. The hint finds such calls and suggests the removal. Since NetBeans 8.0
Use JDK 5 for-loop
Replaces simple uses of Iterator with a corresponding for-loop. Since NetBeans 7.3
Use specific catch
Converts catch (Throwable) or catch (Exception) to multicatch (when java source level is 7 and above) or to several catch clauses (for earlier Java platforms) catching the exceptions thrown by the try body. The watched exception types can be configured; fully qualified names must be used. Since NetBeans 7.0
Use switch over Strings where possible.
Marks cascades of ifs which can be converted to switch over Strings . Since NetBeans 6.9

Java Code Metrics

Anonymous class has too many methods[ Disabled by default ]
Reports anonymous class with many methods. Anonymous classes typically implement a very simple interface, and should be very simple. It is recommended to create at least named local class, if the anonymous class' complexity grows. Since NetBeans 7.4
Anonymous class is too complex[ Disabled by default ]
Reports anonymous classes, whose cyclomatic complexity exceeds the configured limit. The complexity of a class is computed as a sum of complexities of its methods. Anonymous classes should have far less responsibilities and lower complexity than a regular class Since NetBeans 7.4
Arithmetic expression too complex[ Disabled by default ]
Reports arithmetic expressions, which include more than the defined number of operations. Expression with many operands are harder to read and often could be split into several assignment statements to interim result variables. Since NetBeans 7.4
Class has too many constructors[ Disabled by default ]
Reports classes which define too many constructors. Since NetBeans 7.4
Class has too many fields[ Disabled by default ]
Reports a class which holds too many fields. The state kept by the class is too large and it should be investigated if the state can be split into several state classes, often also separating manipulation methods and reduce the overall class complexity. Since NetBeans 7.4
Class has too many methods[ Disabled by default ]
Reports class, which contains too many methods. The options allows to ignore simple bean property accessors - lazy getters, or setters which fire change events are not considered 'simple'. Implementations of superclass (not implementation of interface methods) abstract methods can be also ignored. Since NetBeans 7.4
Class is too complex[ Disabled by default ]
Reports classes, whose cyclomatic complexity exceeds the configured limit. The complexity of a class is computed as a sum of complexities of its methods. Since NetBeans 7.4
Class is too coupled[ Disabled by default ]
Reports classes which are too coupled (use too many) other types. References to Java system libraries (java.** and javax.**) can be ignored. Since NetBeans 7.4
Constructor declares too many parameters[ Disabled by default ]
Reports constructor that take too many parameters. Constructors typically take more parameters than a regular method, especially when initializing a large object.<p/>Large number of parameters indicate a bad design. It's likely that yet more parameters will be added in the future, so creational patterns like Builder should be considered. Since NetBeans 7.4
Logical expression too complex[ Disabled by default ]
Reports logical expressions, which include more than the defined number of operations. Expression with many operands are harder to read and often could be split into several assignment statements to interim result variables. Since NetBeans 7.4
Method body is too long[ Disabled by default ]
Reports methods, which have too long body. Longer methods require scrolling back and forth, and typically can be refactored into several methods called from a mediating method. Splitting a long method into several named pieces may also help code reuse. Some coding practices even demand that a method should fit a screen size, so it can be easily scanned and understood by the developer. Since NetBeans 7.4
Method declares too many parameters[ Disabled by default ]
Reports method that take too many parameters. Methods with large number of parameters indicate a bad design. It's likely that yet more parameters will be added in the future, so the parameters should be grouped into a Command Object, improving maintenance costs. Alternatively, the method could be refactored into several methods, each doing part of the task and requiring less parameters at input. Since NetBeans 7.4
Method is too complex[ Disabled by default ]
The inspection reports method, whose Cyclomatic Complexity exceeds a configurable value. The Cyclomatic Complexity measures a number of potential branching points (or cycles) in a method. It is believed that methods with high cyclomatic complexity usually do too much and should be split to several, more focused, methods. Such complex methods are also prone to code duplication between their execution paths and are hard to sustain. Usually it is recommended that cyclomatic complexity of a method is 5 or below; less than 10 may be also acceptable for more elaborate algorithms. Since NetBeans 7.4
Method or constructor declares too many exceptions[ Disabled by default ]
Reports methods which declare many exceptions in their throws clause. Method that produce a large number of exception types are hard to use, as the caller must handle all the outcomes or complicate its own declaration with exceptions. The error handling code grows more complex. <p/>The inspection also processes constructors. Since NetBeans 7.4
Method with multiple loops[ Disabled by default ]
Methods that contains multiple loop statements. Since NetBeans 7.4
Method with multiple negations[ Disabled by default ]
Methods with multiple negated expressions (unary ! or !=) are said to confuse readers, true (non-negated) expressions are considered easier to read and understand. Consider to change the logic to use true instead of false values. Since NetBeans 7.4
Method with multiple return points[ Disabled by default ]
Reports methods, which exit at multiple places using return statement. Such methods may be confusing and are harder to refactor. The inspection can ignore conditional guard returns - a return statement, which is the sole statement in an if branch. Optionally, all equals methods can be ignored, as contents of equals is traditionally generated using early returns on type or value mismatch. Since NetBeans 7.4
Too coupled method[ Disabled by default ]
Reports methods which are too coupled - that refer to too many other types. Methods that refer to large number of types are fragile: they tend to fail or require refactoring if the referenced type(s) change. It is also more difficult to move the method which has many dependencies to another module. <p/>References to the method class' itself and its superclasses are ignored. With Ignore dependencies on Java Platform, references to java.** and javax.** classes are also ignored. Since NetBeans 7.4
Too deep nesting[ Disabled by default ]
Reports methods whose bodies contain statements nested too deep. Such methods are less readable, contain indent space and allow less screen space for code reading. Methods can be often refactored and split to improve code readability. Since NetBeans 7.4

Java Persistence API

Check access types for jpa classes
JPA classes need to have consistent access types for fields/properties Since NetBeans 8.0
Default public/protected constructor
JPA classes need to have default public/protected no arg constructor Since NetBeans 8.0
Entity impleents Serializable verification
If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface. Since NetBeans 8.0
Entity table name verification
Entity table name must be valid QL intentifier Since NetBeans 8.0
JPQL validation
Parse and find errors in a jpql query Since NetBeans 8.0
Presece of persistence.xml
Check if project with jpa usage contain persistence.xml with persistence unit Since NetBeans 8.0
The IdClass must override equals(Object o) and hashCode() method.
The IdClass must override equals(Object o) and hashCode() method. Since NetBeans 8.0
Verify @IdClass location
Only Entity or MappedSuperclass can use IdClass. Since NetBeans 8.0
Verify IdClass in entity subclass
An entity sub-class cannot have IdClass because it will result in multiple IDs in the entity hierarchy. Since NetBeans 8.0
Verify access level for IdClass
IdClass need to be public Since NetBeans 8.0
Verify attributes of jpa classes
This validation cover nimber of issues like valid column name, valid attribute modifiers, valid basic type, relationships etc Since NetBeans 8.0
Verify combinations of jpa annitations
Some JPA annotations may not be applied to the same element at the same time Since NetBeans 8.0
Verify entity have defined promary key
Id is required for entities Since NetBeans 8.0
Verify entity name is unique
Entity names must not be the same in one persistence unit Since NetBeans 8.0
Verify jpa annotations on accessors
JPA annotations should be applied to getter methods only Since NetBeans 8.0
Verify jpa class is top level class
JPA classes must not be inner classes Since NetBeans 8.0
Verify jpa class isn't final
JPA classes must not be final Since NetBeans 8.0
Verify named query location
Named queries can be defined only on an Entity or MappedSuperclass class. Since NetBeans 8.0

JavaDoc

Create Javadoc
Create Javadoc In NetBeans 6.8 or earlier
Error in Javadoc
Error in Javadoc In NetBeans 6.8 or earlier

JavaServer Faces

@FlowScoped bean in the non-CDI capable project
@FlowScoped bean in the non-CDI capable project Since NetBeans 8.0
Classes of javax.faces.bean are gonna be deprecated
Annotations from the package javax.faces.bean will be deprecated in the next JSF version. CDI and Java EE ones are recommended instead. Since NetBeans 8.0

Logging

Logger declaration is not static final
Each class should have one unique logger. If declared as a field it should be static and final. Since NetBeans 6.9
Multiple loggers
There are several loggers declared for a single class. Since NetBeans 6.9
No loggers[ Disabled by default ]
There is no logger declared for a class. Since NetBeans 6.9
String concatenation in logger
It is not performance efficient to concatenate strings in logger messages. It is better to use a template message with placeholders that are replaced by concrete values only when the message is really going to be logged. Since NetBeans 6.9

Maven

Resolve Missing Class Dependency
Resolve missing class dependency and add to project POM Since NetBeans 6.9

NetBeans Development

Empty cancel() for cancelable tasks[ Disabled by default ]
Warn about empty cancel() methods for cancelable tasks In NetBeans 6.8 or earlier
HelpCtx issues
Warnings about misuse of org.openide.util.HelpCtx. Since NetBeans 7.2
Illegal Use of instanceOf operator[ Disabled by default ]
Show illegal use of instanceof on javax.lang.model.elements, javax.lang.model.type and com.sun.source.tree In NetBeans 6.8 or earlier
Use @NbBundle.Messages
Use @NbBundle.Messages in preference to Bundle.properties plus NbBundle.getMessage(...). Since NetBeans 7.0

Performance

.getClass() replaceable with .class[ Disabled by default ]
Finds instantions of a class directly followed by invocation of .getClass() on the newly constructed object Since NetBeans 6.9
Boxing of already boxed value
Reports boxing of already boxed value. Constructor or valueOf take a primitive parameter, so a boxed value is unboxed first, then boxed again, which may create an extra instance of the wrapper and impact the performance. Since NetBeans 8.0
Collections without initial capacity[ Disabled by default ]
Looks for instatiations of collections with missing initial capacity. Only collections backed-up with an array are tested. Since NetBeans 6.9
Creating new Boolean
Creating new Boolean is inefficient and typically useless. Since NetBeans 6.9
Length one String in String.indexOf[ Disabled by default ]
Length one String literal in String.indexOf can be replaced with a character literal Since NetBeans 6.9
Manual array copy
Finds occurrences of manual array copying via for loop Since NetBeans 6.9
Map replaceable with EnumMap
Finds instantiations of Maps that can be replaced with EnumMap Since NetBeans 6.9
Redundant String.toString()
Reports calls of String.toString(), which is entirely useless, the String can be used directly. Since NetBeans 8.0
Replace StringBuffer/StringBuilder by String
The hint will find and offer to replace instances of StringBuffer or StringBuilder which are accessed using ordinary String methods and are never passed out of the method, or assigned to another variable. Keeping such data in StringBuffer/Builder is pointless, and String would be more efficient. Since NetBeans 8.0
Set replaceable with EnumSet
Finds instantiations of Sets that can be replaced with EnumSet Since NetBeans 6.9
String concatenation in StringBuilder.append
Looks for string concatenation in the parameter of an invocation of the append method of StringBuilder or StringBuffer. Since NetBeans 6.9
String constructor
Use of java.lang.String constructor is usually useless. Since NetBeans 6.9
String.equals("")[ Disabled by default ]
Use of String.equals("") can be replaced with with String.length() == 0 (for JDK5 and lower) or String.isEmpty() (for JDK6 and higher) Since NetBeans 6.9
String.intern() called on constant[ Disabled by default ]
Invocations of String.intern() on compile-time constants are superfluous. Since NetBeans 6.9
StringBuilder without initial capacity[ Disabled by default ]
Looks for instantiations of StringBuilder or StringBuffer with missing initial capacity. Since NetBeans 6.9
Unnecessary temporary during conversion from String
Finds occurrences of new Integer("111").intValue() and similar constructions, where the boxed instance is created just to parse the String parameter. Boxing types have parseXXX methods, which perform the conversion without creating the temporary instance. Since NetBeans 8.0
Unnecessary temporary during conversion to String
Finds places like new Integer(11).toString() where a temporary boxed instance is created to just produce a String representation of a primitive. The boxed types have toString() static method just for that purpose. Since NetBeans 8.0
Usage of .size() == 0
Use .isEmpty() or !.isEmpty() instead of .size() == 0 or .size() != 0 where possible. Since NetBeans 6.9
Useless use of StringBuffer
Use StringBuilder instead of StringBuffer where possible. Since NetBeans 6.9
Zero element array passed to Collection.toArray[ Disabled by default ]
Passing zero element array to Collection.toArray may affect performance Since NetBeans 7.2

Probable Bugs

'finally' block suppresses exceptions
Reports usage of return statements in finally block. Such return discards the exception being thrown and causes the whole method to complete normally, which is usually not the desired outcome. Break and continue statements, which break out of the finally block are also reported. Since NetBeans 7.4
'throw' inside 'finally' block
Throwing an exception inside finally block will hide the original exception thrown from the associated try or catch blocks from enclosing exception handlers. Note that the exception can be still inspected using Throwable.getSuppressedException(), although it cannot be directly caught by a catch block. Since NetBeans 7.4
.equals on Array
.equals on array Since NetBeans 6.9
.equals on Incompatible Types
.equals on incompatible types In NetBeans 6.8 or earlier
.equals(null)
Finds invocations of the Object.equals method with literal parameter 'null'. Since NetBeans 6.9
@CheckReturnValue
Verifies that a result of method marked with @CheckReturnValue is really checked. Since NetBeans 7.2
Annotations without runtime Retention
Warns about reflective access to annotations with CLASS or SOURCE retentions Since NetBeans 6.9
Assert with side effects
Identifies assert statements whose condition reportedly causes some side effects. The hint checks assignments to local variables and fields made from within the condition expression. If the expression calls a method, the hint checks whether the method assigns to some fields. Only the directly called methods are checked. For performance reasons, although the called method may resolve to some overrides in subclasses at runtime, only the base class method body is inspected. Calls to interface type methods are ingored completely. Inspection of all possible overrides of a method would greatly hurt performance. Since NetBeans 8.0
Boxed value identity comparison
If two boxed values are compared using == or !=, identity of the boxed object's identity is compared instead of the boxed value. The inspection suggests a fix, which performs a null-safe comparison using java.util.Objects.equals().<p/>The fix is only available for source level >= 7, since a conditional expression would require multiple evaluation of one of the operands, which may not be possible because of potential expression's side effects. Since NetBeans 8.0
Cloneable class does not implement clone().[ Disabled by default ]
<html>Cloneable class should override clone(). If it does not, the clone operation uses the default java.lang.Object.clone(), which is usually not suitable. Lack of overridden clone indicate a possible error.</html> Since NetBeans 7.4
Comparator.compare() does not use its parameter {0}
The Comparator is expected to compare the arguments to its compare method. If one of the parameters is not used for comparison, it indicates that the other argument might be compared to self or some other error in the implementation. Since NetBeans 8.0
Confusing indentation
Warns about indentation that suggests possible missing surrounding block Since NetBeans 7.4
Confusing primitive array passed to varargs method
A primitive array passed to variable-argument method will not be unwrapped and its items will not be seen as items of the variable-length argument in the called method. Instead, the array will be passed as a single item. Since NetBeans 8.0
Created Throwable not thrown
The hint detects creation of a Throwable, which is then discarded. Throwable creation is rather expensive, and not using a created Throwable may indicate an unfinished error handling code. The Throwable is considered used, if it is thrown, passed to a method as a parameter, returned as a method's result or assigned to a field. Possible assignments through local variables are also inspected to determine whether the value will be finally used. Since NetBeans 8.0
Dead Branch
Dead Branch Since NetBeans 7.1
Incompatible cast/instanceof
Incompatible cast surrounded with incompatible instanceof Since NetBeans 6.9
Incorrect column index in ResultSet
Reports Iincorrect column indices passed to various methods of java.sql.ResultSet Since NetBeans 6.9
Infinite recursion
Detects methods which must recurse infinitely and could only terminate by throwing an exception. Only definitively recursions are reported, not possibilities. The recursion only inspected across the single method (so recursion like a -> b -> a is not reported). Recursion through several instances of the class is also not reported. The hint can be disabled for the case the recursing method could be overriden in subclasses, since subclass implementations could avoid the recursion. However if some subclass does not override and fix the method, recursion may still happen. By default the inspection warns even for the overridable case. Since NetBeans 8.0
Malformed XPath expression
The hint check syntax of the XPath expression passed to JAXP XPath evaluator. The calls checked are:
  • JAXP XPath compile and evaluate calls,
  • Xalan-J XPath creation and XPathAPI usage,
  • Apache Common's JXPath calls
Since NetBeans 8.0
Malformed format string
Reports format strings passed to String.format, printf-style methods. Checks that the number of arguments correspond to the number of % specifiers, and the arguments have the correct type. Since NetBeans 8.0
Malformed regular expression
Warns about malformed regular expressions Since NetBeans 6.9
Math.random() casted to int
Math.random produces a double in range 0..1. If the value is immediately cast to int, it is always rounded down to 0, which is probably not intended. The fix will move the cast so the enclosing arithmetic expression is casted and possibly rounded. Since NetBeans 8.0
Null Pointer Dereference
Checks various problems related to dereferencing nulls Since NetBeans 7.3
Possibly missing switch "case" statement
The hint detects a typo made in a switch statement a label without a case statement.<p/>While it may be a intended label for the following statement, it could be also an intended case branch with the keyword forgotten. Since NetBeans 8.0
Result of new Object ignored
Result of new Object ignored. Since NetBeans 6.9
String.replaceAll(".", )
Finds occurrences of calls to String.replaceAll(".", $target), which would replace all characters of the source string with $target. Since NetBeans 6.9
StringBuffer constructor called with `char argument
StringBuffer and StringBuilder constructors accept int as a parameter. If a char is passed, it is silently promoted to int, and the call creates a StringBuffer instance with a defined initial capacity, rather than a StringBuffer that initially contains a single (the passed one) character.<p/>The offered fix will add an append that actually adds the character. Since NetBeans 8.0
Suspicious Collections.toArray() call
Detects such calls, whose array type parameter does not match the Collection's type parameter. The collection's type parameter should be assignable to the array type. For raw Collections, the hint checks that the array type is actually assignable to the casted-to array type.<p/>The hint offers to change the newly created array type, or to change the toArray parameter to new Type[],but the fix is not available if the collection expression may have some side effects. Since NetBeans 8.0
Suspicious Names Combination[ Disabled by default ]
Suspicious Names Combination Since NetBeans 8.0
Suspicious invocation of System.arraycopy
Finds invocations of System.arraycopy with negative offsets, length or used on non-array objects. Since NetBeans 6.9
Suspicious method call
Warns about suspicious calls to Collection.remove/contains and Map.containsKey/containsValue/remove Since NetBeans 6.9
Synchronizing on this in anonymous class
<html>Synchronizing on this in anonymous or local class is probably a result of refactoring and possibly a mistake Since NetBeans 6.9
Throwable method result is ignored
If a Throwable is returned from a method call as a return value (as an oppposite to be thrown), it is usually somehow recorded (assigned), further processed (passed to another method call), or thrown. Ignoring such Throwable or using in some simple comparison indicates either a defect in error handling, or that the method should return a different value to save time for Throwable's stacktrace creation. Since NetBeans 8.0
Unbalanced read/write with arrays
Unbalanced read/write with arrays Since NetBeans 7.1
Unbalanced read/write with collections
Unbalanced read/write with collections Since NetBeans 7.1
Unused Assignment
Unused Assignment Since NetBeans 7.1
clone() does not call super.clone()
Cloned instances should be allocated using super.clone() so fields are initialized properly. Since NetBeans 7.4
clone() does not throw CloneNotSupportedException
If clone() is not declared to throw CloneNotSupportedException subclasses cannot prohibit cloning using standard Cloneable contract. Since NetBeans 7.4
clone() in a non-Cloneable class[ Disabled by default ]
The contract for Object.clone() requires, that a class must implement Cloneable marker interface. If not, the clone() method will raise CloneNotSupportedException. Declaring Cloneable interface is often overlooked. Since NetBeans 7.4
hashCode() used on array instance
hashCode for array instances is inherited from java.lang.Object, and it is based on the array's reference rather than on array's contents.

In order to obtain a more reasonable hashCode, which reflects contained objects or values, use Arrays.hashCodeor Arrays.deepHashCode() Since NetBeans 8.0

toString() used on array instance
toString() implementation for arrays does not convert array contents to String, rather it will print array's type and hash code (defined as identity hash code). To get string representation of contents of the array, the array could be for example wrapped into Arrays.asList(), as Collections produce content representation in their toString(). Since NetBeans 8.0

Standard Javac Warnings

Deprecated[ Disabled by default ]
Warn when code uses deprecated API. Since NetBeans 6.9
Division By Zero[ Disabled by default ]
Division By Zero Since NetBeans 6.9
Empty Statement After If[ Disabled by default ]
Empty Statement After If Since NetBeans 6.9
Fallthrough[ Disabled by default ]
Warn when a case can fall through to the next case. Since NetBeans 6.9
Finally [ Disabled by default ]
Warn when a finally block interrupts flow of a try/catch block. Since NetBeans 6.9
Overrides[ Disabled by default ]
Warn when an overriding method is not annotated with @Overrides Since NetBeans 6.9
Raw Types[ Disabled by default ]
Raw Types Since NetBeans 6.9
Serialization[ Disabled by default ]
Warn when a class which implements java.io.Serializable does not declare a serialVersionUID. Since NetBeans 6.9
Unchecked[ Disabled by default ]
Warn when unchecked conversions may cause ClassCastExceptions at runtime. Since NetBeans 6.9
Unnecessary Cast[ Disabled by default ]
Warn when an object is cast unnecessarily to the same type or a supertype. Since NetBeans 6.9

Suggestions

Assign Return Value To New Variable
Assign Return Value To New Variable In NetBeans 6.8 or earlier
Assign Unused Constructor Parameter to Field
Assign Unused Constructor Parameter to Field In NetBeans 6.8 or earlier
Combine nested if statements
Combines two nested if statements, like if (cond1) if (cond2) statement;, into one if statement, like if (cond1 && cond2) statement;. Since NetBeans 7.4
Convert Anonymous to Member
Convert Anonymous to Member In NetBeans 6.8 or earlier
Convert Lambda Body to Use a Block
Converts lambda bodies to use blocks rather than expressions Since NetBeans 7.4
Convert Lambda Expression to Anonymous Innerclass
Converts lambda expressions to anonymous inner classes Since NetBeans 7.4
Convert Lambda Expression to Member Reference
Converts lambda expressions to member references Since NetBeans 8.0
Convert Lambda to Use Explicit Parameter Types
Converts lambdas to use explicit parameter types Since NetBeans 7.4
Convert Member Reference to Lambda Expression
Converts member references to lambda expressions Since NetBeans 7.4
Convert integer constant to different base
Convert integer constant to different base Since NetBeans 7.0
Create Subclass
Create Subclass Since NetBeans 7.2
Create Test Class
Create a test class for the selected source class. Since NetBeans 7.4
Declaration for instanceof
Declaration for instanceof In NetBeans 6.8 or earlier
Expand Enhanced For Loop
Expand Enhanced For Loop Since NetBeans 7.1
Fill Missing Cases to Switch
Adds missing cases to switch statement. The default clause template should be one Java statement, occurrences of $expression will be replaced with the expression over which the switch statement works. Since NetBeans 7.2
Flip .equals
Allows to flip .equals parameter and call site Since NetBeans 6.9
Flip operands of the binary operator
Flip operands of the binary operator Since NetBeans 7.4
Generate All Test Methods
Generate all test methods for the selected source class. Since NetBeans 7.4
Implement Abstract Methods
Implement Abstract Methods. Since NetBeans 7.3
Invert If
Will invert an if statement; negate the condition and switch the statements from the then and else sections. Since NetBeans 7.3
Join consecutive ifs into if-else
Converts cases like if - else { if } info if - else if Since NetBeans 7.4
Join if conditions using ||
Converts cases like if (cond1) statement; else if (cond2) statement; into if (cond1 || cond2) statement; Since NetBeans 7.4
Move initialization to constructor
Moves a fields initialization expression to the constructors. Since NetBeans 7.3
Split Declaration
Splits declaration with initializer to a declaration and assignment Since NetBeans 7.2
Split if condition
Splits if whose condition is || into two ifs Since NetBeans 7.4
Split if statement condition
Splits an if statement with a complex condition, like if (cond1 || cond2) statement;, into two if statements, like if (cond1) statement; else if (cond2) statement;. Since NetBeans 7.4

Testing

Inconvertible parameters of Assert.assertEquals
Inconvertible parameters of Assert.assertEquals Since NetBeans 7.4
Incorrect order of parameters of Assert.assertEquals
Incorrect order of parameters of Assert.assertEquals Since NetBeans 7.4
assertEquals for array parameters
Warns about assertEquals whose parameters are arrays Since NetBeans 7.4

Threading

.notify invoked outside a synchronized context
.notify invoked outside a synchronized context Since NetBeans 6.9
.wait invoked outside a synchronized context
.wait invoked outside a synchronized context Since NetBeans 6.9
Double-checked locking
Searches for examples of double checked locking - e.g. when a variable is tested before as well as inside a synchronized block. In NetBeans 6.8 or earlier
Empty synchronized block
Empty synchronized block are usually useless Since NetBeans 6.9
Field Can Be Final
Finds fields that can be made final, which can simplify synchronization and clarity Since NetBeans 7.4
Invoking Condition.notify()
Invoking notify or notifyAll on java.util.concurrent.locks.Condition should probably be replaced with invoking signal or signalAll. Since NetBeans 6.9
Invoking Condition.wait()
Invoking wait on java.util.concurrent.locks.Condition is probably unintended. Since NetBeans 6.9
Invoking Thread.run()
Invoking run on java.lang.Thread should be probably replaced with invocation of method start() Since NetBeans 6.9
Invoking Thread.stop()/suspend()/resume()
Methods stop(), suspend() and resume() of java.lang.Thread are dangerous and should not be used. Since NetBeans 6.9
Invoking Thread.yield()
Invocation of method yield() on java.lang.Thread is usually used to masquerade synchronization problems and should be avoided. Since NetBeans 6.9
Lock not unlocked in finally
Finds occurrences of Lock.lock()-Lock.unlock() not properly wrapped in try-finally. Since NetBeans 6.9
Nested synchronized blocks
Nesting synchronized blocks is either useless (if they use the same lock object) or dangerous. Since NetBeans 6.9
Starting Thread in constructor
Starting a new Thread in constructor is dangerous and should be prevented. Since NetBeans 6.9
Synchronization on non-final field
Synchronization on non-final field In NetBeans 6.8 or earlier
Synchronizing on Lock
Synchronizing on java.util.concurrent.locks.Lock is usually unintended and should be replaced with Lock.lock()-Lock.unlock() Since NetBeans 6.9
Thread.sleep in loop
Invoking Thread.sleep in loop can cause performance problems Since NetBeans 6.9
Thread.sleep in synchronized context
Invoking Thread.sleep in synchronized context can cause performance problems Since NetBeans 6.9
Volatile array field
Finds declarations of volatile array fields. Since NetBeans 6.9

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo