Java Reference
In-Depth Information
Declaration redundancy
The Declaration Redundancy group of inspections examines field and method
declarations for potential problems. It points out methods whose return values
are never used or that declare impossible exceptions. It also looks for optimiza-
tions—for instance, fields, methods, and parameters that could be declared final.
Fields and methods that are declared as final enjoy a slight runtime speed advan-
tage because the VM doesn't have to check for overriding values in a subclass.
Local code
The Local Code Analysis group of inspections look for problems in the expected
code execution. For example, if you retrieve an item from a collection and cast it
to type Object, this is considered a redundant cast because the item is already of
type Object. Other inspections in this group include finding unused assignments,
potential null pointer problems, and conditions that are always constant.
JavaDoc problems
The Declaration has javadoc problems option alerts you to the presence of bad
or missing JavaDoc comments. The options for this inspection allow you to fine-
tune the check to include only the type of tags you require and the scope within
each type of element that requires JavaDoc.
Locating deprecated API usages
The Deprecated API usage inspection performs the same sort of deprecation
checks that your compiler would. Any attempt to use a deprecated symbol (such
as a method or constant) is flagged for inspection. In general, you should avoid
using deprecated code. Most of the time, the reason for the deprecation and sug-
gested alternatives can be found in the JavaDoc of the deprecated symbol.
Unpaired equals/hash code methods
Many developers either aren't aware of or forget about the following Java rule: A
class must always implement the equals() and hashCode() methods together to
ensure that the object is handled correctly when placed into a collection. The
equals() and hashCode() not parsed test locates instances where a class overrides
one of these methods but not the other. You can use IDEA 's code generation facil-
ity to create these methods for you, as discussed in chapter 3.
Probable bugs
The inspections within the Probable Bugs inspection group make IDEA search
for many types of common programming problems. Some of the items within this
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search