Java Reference
In-Depth Information
problems as they arise. In chapter 6, you learned how to use the debugger to
hunt down errors of logic. However, there is one other type of problems that we
haven't talked about yet—problems with your program's design or structure.
IDEA
's code inspector feature will help you with that. It can spot something as
simple as the usage of a deprecated method or more subtle issues like unused
method parameters or fields and methods that could have weaker access decla-
rations.
IDEA
provides more than 200 code inspections for this purpose.
IDEA
5.0 includes more than 540 code inspections. We won't list them all here,
but be warned that
IDEA
has
many
new ways to find problems with your code. Are
you ready?
The
IDEA
inspector is unique in that it can actually be run either through the
main
IDEA
interface or outside
IDEA
as a command-line application. Either way,
you'll actually review the results in
IDEA
.
9.2.1
Launching the inspector
You launch the inspector from
Analyze | Inspect Code
or through the
Project
and
Commander
windows' context menus. When you select it from the main
menu, you're requesting an inspection of the editor's current class or the entire
project (
IDEA
asks you which). When you select it from the
Project
window, you
can choose to inspect multiple files, packages, or the entire source tree. When the
inspector launches, you see the
Inspect
dialog shown in figure 9.7, where you tell
the inspector the type of problems you would like it to search for and report on.
Managing inspection profiles
Once you've created a configuration, you can save these settings as an inspection
profile. Creating an inspection profile lets you rerun the tests without having to
go through the configuration process again. You can save several inspection pro-
files—perhaps a quick test and a more thorough test. Use the controls at the
top of the
Inspect
dialog to create, remove, and save your settings as an inspec-
tion profile.
Launching the inspector from the command line
You can also launch the inspector from the command line, which lets you use it
outside of
IDEA
—perhaps as part of an automated build process. If you have a
particularly big source tree, inspection can take a while, so moving it offline is