Sunday, November 20, 2011

Calculating Code Toxicity

Are you dealing with legacy code and wondering how to calculate how toxic is your code ? Most importantly do you want to measure this on every checkin of your code using CI. There aren't many (as am aware of) tools which automates the toxicity calculation which you can hook up to CI. So decided I will write one as you might have guessed, am dealing with legacy code and obviously wanted to measure the toxicity of the code and how are we are tackling it over a period of time. You can find the code at github which has a detailed instructions on how to use the tool.

In short this tool is java based and works based on the checkstyle report of your code. It prints the aggregated toxicity for each of the checks on your console and generates a csv as an output which has toxicity values for all the files against each of the check.

Thanks to Erik's blog which helped me understand the toxicity calculation.