Static Analysis in Eclipse using Java
Static analysis is used to check for any common programming mistakes made while writing the code. This kind of analysis scans the code and looks for issues like missing finally block, unused variables and other areas for improvement in the code. Static analysis software is a program which performs white box scan of the code. There are multiple static analyses software available in the market for any kind of programming language.
Common features of static analysis
1. Conformance to naming conventions.
2. Violation of maximum number of lines in a method
3. Redundant access modifiers like final for variables declared in an interface
4. Using the equals method for comparison of string literals
5. Suggestions to make complex expressions simpler.
6. Detection of duplicate code.
7. Generation of JUnit based unit test cases which can be further enhanced.
As you have noticed that plug-ins or software also perform the job of code review.
Static code analysis software for Java
Most of the above listed static analysis software come as plug-ins for popular Java based IDE.
The best part of using these plugins is that they can be customized in many ways. For example we can write a listener which shall be invoked when a code violation is found. We can also configure these plugins with ANT/MAVEN so that static analysis of whole application code is done when an ANT or MAVEN build is run.
The following screenshot shows how to install an Eclipse plug-in for any of these SA software:
A related term to static analysis is dynamic code analysis in which the runtime behavior of an application is analyzed and appropriate suggestions are made by the dynamic code analysis software.