ccm
ccm is a tool that analyzes c/c++ and c# code and reports back on Cyclomatic Complexity, a metric introduced by Thomas McCabe back in the mid 70's. The metric states the number of independent linear paths through a unit of code and is useful to determine how complex the unit of code is. For this particular tool, a unit is a function or a method.
Over at TAC, where I work as a Software Manager, we make extensive use of Continuous Integration. Upon each commit, we build, test, analyze and publish. One on the things we analyze as part of the static code analysis is Cyclomatic Complexity. It helps us identify code that may need special attention, such as refactoring, code review (if the code was developed in a pairing session, you'd rarely find it to be complex), etc. Since we work in both c/c++ and c#, on both Linux and Windows, and I was unable to find a decent tool that could to the job, including outputting into XML, I threw one together myself.
Usage
ccm is a command line tool that accepts one argument; the path to a configuration file structured like below.
<ccm>
<analyze>
<folder>..\source1</folder>
<folder>..\source2</folder>
</analyze>
<exclude>
<file>file1.cpp</file>
<file>file2.cpp</file>
<folder>Folder1</folder>
<folder>Folder2</folder>
</exclude>
<recursive>yes</recursive>
<outputXML>no</outputXML>
<numMetrics>10</numMetrics>
</ccm>
The path in the analyze element is relative to the location of the configuration file (passed as the only argument to ccm.exe).
Download
This zip-file contains the binaries you'll need to run ccm. You'll need the .NET 2.0 framework installed to be able to run it. I have succesfully used this application on Linux (Ubuntu) running Mono 1.2.3.1.
Limitations
This version does not deal with pre processor flags except for #ifdef 0.
Disclaimer
ccm, AND ANY AND ALL ACCOMPANYING SOFTWARE, FILES, DATA AND MATERIALS, ARE DISTRIBUTED AND PROVIDED "AS IS" AND WITH NO WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED.