Guys, I'm looking for a open source or free source code analysis tool for C#. The tool should be able to generate metrics from the source code such as cyclomatic complexity, number of lines, number of commented lines, SEI maintainability etc. Does any one know of any such tool? Thanks.
There are many plugins for reflector (which is also free):
I believe the CodeMetrics plugin does what you need
NDepend isn't free for non-academic or open-source software use, but it is awesome, and will give you those metrics (and many others, using its built-in Code Query Language).
This question is more or less a dupe of this one: http://stackoverflow.com/questions/60394/calculate-code-metrics, and you'll find an entire series of good suggestions there.
NDepend will give you a vast number of stats for your code:
http://codebetter.com/blogs/patricksmacchia/archive/2008/11/25/composing-code-metrics-values.aspx
There is a free 'Trial' version which contains fewer features than the Professional product, but which is free to use for Open Source and Academic development. The Trial version on the download page gets updated with a new version before the previous one runs out:
Most of these capabilities are included with Visual Studio 2008 Team System.
Under the Tools | Analyze menu there are options for Code Metrics. Most of your desired features are all there: Cyclomatic Complexity, LOC, and Microsoft's (a variant of the SEI maintainability index that instead goes from 0-100, where 100 is most maintainable) - as well as Depth of Inheritance, and Class Coupling as bonus features. It does not include number of commented lines.
Axivion Bauhaus Suite is free for academic use but not for commercial use.
It includes:
- Software Architecture visualization
- Software Architecture rule checking
- Interface analysis
- Cycle detection
- Clone (copy) detection
- Dead code detection
- Detection of code style violations
- A full set of predefined software metrics
- The ability to add your own metrics and analyses...
Supports C / C++, C#, Java on various platforms
SourceMonitor is a free C# metrics tool, it's fairly old but it could still be useful.