Code Analysis Tools – Sample Ant Script

When you develop reusable components quality is very important. The higher a reusable asset’s usage, the higher the need for robustness. Unlike monolithic code, defects with reusable assets can rapidly impact several business processes and applications. All the more reason for the criticality of automated testing. In addition to testing, code analysis tools can detect defects, warn regarding unsafe/potentially buggy code, and also recommend various source code style/formatting improvements. All of these contribute to higher quality. I have used findbugs, pmd, and checkstyle in this space and they are very useful to analyze source code. You can also include these in your continuous integration suite.

Many readers have requested that I post sample code and scripts – so here is a sample apache ant build script that you can use with your code. Just be sure to modify the properties file to point to appropriate folders. The script will produce html reports for pmd and checkstyle as well as a find bugs output file (for viewing it with the findbugs client).

Code Analysis Script

Pre-requisites prior to running this script:

Set JAVA_HOME to your JDK 1.5 or above folder

Install apache ant 1.6+, findbugs, pmd, and checkstyle in your environment

Make sure the findbugs, pmd, and checkstyle jar files are in ant’s CLASSPATH.

Let me know if you have issues with using this script. Enjoy!

 

Like this post? Subscribe to RSS feed or get blog updates via email.

tweet this add to del.icio.us post to facebook

Advertisements

2 Responses to Code Analysis Tools – Sample Ant Script

  1. Seban says:

    If you have some assets written in Ruby you can use tools such as roodi for analyze code, rcov to check test coverage, saikuro for cyclomatic complexity. I recommed to read about meric_fu wich you can connect to you contonous integration tool.

  2. Thanks Seban! If you have links or scripts that you think would be useful, please post here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: