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

1. Check Style
2. JTest
3. FindBugs
4. PMD
5. SonarJ
6. ucdetector

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:

Static analysis in eclipse

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.

Related Posts

Static Analysis in Eclipse using Java admin Core 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...
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. <h2>Common features of static analysis</h2> 1. Conformance to naming conventions. 2. Violation of maximum number of lines in a method 3. <a href="http://www.javaexperience.com/eclipse-get-access-modifier-suggestions-using-ucdetector-plugin/" title="Get access modifier suggestions using Eclipse ucdetector plugin">Redundant access modifiers</a> like final for variables declared in an interface 4. Using the <a href="http://www.javaexperience.com/operator-and-equals-method-in-java/" title="Difference between == operator and equals method in Java">equals method</a> for comparison of string literals 5. Suggestions to make complex expressions simpler. 6. Detection of duplicate code. 7. Generation of <a href="http://www.javaexperience.com/junit-test-case-lifecycle/" title="JUnit Test case lifecycle">JUnit based unit test cases</a> which can be further enhanced. As you have noticed that plug-ins or software <strong>also perform the job of code review</strong>. <h2>Static code analysis software for Java</h2> 1. <a href="http://checkstyle.sourceforge.net/" rel="nofollow">Check Style</a> 2. <a href="http://www.parasoft.com/jsp/products/jtest.jsp" rel="nofollow">JTest</a> 3. <a href="http://findbugs.sourceforge.net/" rel="nofollow">FindBugs</a> 4. <a href="http://pmd.sourceforge.net/" rel="nofollow">PMD</a> 5. <a href="http://www.hello2morrow.com/products/sonarj" rel="nofollow">SonarJ</a> 6. <a href="http://www.ucdetector.org/" rel="nofollow">ucdetector</a> 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 <strong>they can be customized in many ways</strong>. 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 <strong>how to install an Eclipse plug-in</strong> for any of these SA software: <img src="http://www.javaexperience.com/wp-content/uploads/2012/12/eclipse-SA-plugin.png" alt="Static analysis in eclipse" width="569" height="703" class="alignnone size-full wp-image-2077" /> 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.
Choosing between constructor and setter methods
Exception Handling features in JDK 7
The following two tabs change content below.
I run this blog with lots of passion. In this website, you will find tutorials on Core Java, Spring, Struts, Web Applications, Portals and Database. Please support me and the website by sharing the posts on your facebook / twitter. You can tap the share button at the top of each post. Thanks for the support.

Latest posts by admin (see all)

Comments

comments