Now I've finished my
code analysis tool I'm going to integrate this into my nightly build. If you want to do the same, just follow these instructions!
1. Firstly I generate a list file of all the assemblies I want to include in my analysis. Personally I'm going to generate this manually but you could also generate this from a quick "dir *.dll /b > files.lst" command.
Then I want to run
CCMetrics on the list. Running CCMetrics without any arguments provides you with a list of the possible arguments:
CCMetrics v0.2 beta, (c) 2004, 2005 J. Wood Software Services LLC
Experimental Software - Use At Your Own Risk!
Usage: CCMetrics filename.dll [/x] [/b] [/f path]
CCMetrics takes a .Net DLL (or .EXE) and determines the cyclometric
complexity of the projects contained therein.
filename.dll is the name of the assembly or executable to analyze.
A *.lst file can be supplied that contains a list of assemblies to
analyze.
/m specify the number of methods to display, the default is 6.
/x generates XML output.
/b suppresses the banner.
/f can be used to override the folder to the .Net Framework SDK.
The XML output (/x) generally gives you a lot more detail and might be useful when you want to delve into a particular problem, but for the nightly build just the summary will do for me.
My basic requirement is to create a file containing summary statistics of the files, and then mail this out to me every night. So I think I'll end up using a command like this:
CCMetrics files.lst /b /m 10 > analysis.txt
Note that I've upped the number of method stats from the default (6) to 10. This is just personal preference. I've also included /b to suppress outputting the banner, so I can concentrate on just the data.
2. Before I run this command, I want to back up yesterday's analysis.txt so I can compare the values each day. I'll use a simple rename to call the old file "analysis_old.txt".
3. I'll then concatenate these two files together (a dos command such as "type analysis_old.txt >> report.txt" would do this), and send the resultant report.txt file via
email. To send it from the build I'll be using this tool.
And we're done. Hopefully I should get an email each day of both today and yesterday's code statistics so that I can compare the values, monitor trends in changes, and be alerted to project changes that add unusual complexity. All in all, I really hope this will help me keep on top of things.
I think it would be really cool if I could graph this data, keeping a history of the analysis taken each day, and then mail out the graph or put it up on a project web page. In the meantime, though, I think this simple text report will suffice.
I hope you find it useful.