Pages

Monday, October 20, 2014

One of the great features of ConQAT is its ability to detect code clones (duplicates). On the other hand, CI servers like Jenkins enables you to automatically check for code quality attributes. If we can merge both, this will become an invaluable tool for technical team leaders and will save them a lot of review effort.

Here is how you can do this:

Step 1: Define Your Policy of Preventing Code Clones

This is done by specifying the ConQat Run configuration files (.cqr) using eclipse. That is, create a cqr file which detects kinds of duplicates that you don't want to see in the code altogether.

For example, you may define a cqr file which detects exact code clones of length greater than 10 lines of code. This is a screen shot of a cqr file which does exactly this job:

Check the file named in the property file.to.check (the clons.xml
file) to see

if there are any clones.

The way this works is to find all lines containing the text
"cloneClass" and putthem into a separate file.Then it checks to see if this file has non-zero length. If so, then there are errors, and it sets the property
clones.found. Then it calls the fail-if-clones-found target, which doesn't
execute if the clones.found property isn't set.

-->

<targetname="check-clones-file"

description="Checks the file
(specified in ${file.to.check}) for clones">

<propertyname="file.to.check"description="The file to hold the clones"/>

Search This Blog

Software Developer's Primary Suffering!

I have a strong belief that the software developers’ primary suffering is due to bad software engineering practices. This blog is trying to highlight these practices, and make an effort to resolve them.

This blog is a pure practical one. Every post corresponds to a personal experience that I gained during my software development life, and effectively resolves one of the sufferings which, one day, a software engineer will suffer from!