Question

I'm interested in finding some software that can analyze some C# files or an entire C# project/solution and give it a score which rates its ease or difficulty to maintain. Are there products or methods out there that do this?

Was it helpful?

Solution

There is a Tool called SourceMonitor. It scans and analyzes your source code and rates it. You can find it here http://www.campwoodsw.com/

OTHER TIPS

There is actually a software metric called maintainability index. developed by SEI-CMU.

It is based on Halstead Metrics, Cyclomatic complexity, LOC and Percent comments.

In short the formula is 171 - 5.2 * ln(aveV) - 0.23 * aveV(g') - 16.2 * ln (aveLOC) + 50 * sin (sqrt(2.4 * perCM))

More details : http://www.sei.cmu.edu/str/descriptions/mitmpm.html

Cyclomatic complexity is a good indication of maintainability. It is a measurement of the number of different paths through your source code.

For C#, take a look at these examples and links for tools.

If you use Visual Studio 2008 many metrics are built right into the IDE. If you use Visual Studio 2005, or would like a stand alone system. devAdvantage/devMetrics is your answer. All of these tools produce multiple measures, including Cyclomatic Complexity that @Kevin discussed.

while reading the code to determine the complexity you can have someone count your WTFs per minute ;-)

Code Coplexity is taking into account as well as some other things (coupling, cohesion, inheritance levels) to formulate a Maintainability Score in the Team System tools. If you are running a Team System SKU of Visual Studio, that is the bombshell you are after.

You should check out cyclomatic complexity. I dont know if there is a tool for .net, but if you do a search on it, i bet you'll find results.

cyclomatic complexity i.e. the number of logic branches can give you a measure of how difficult a module is to test and maintain.

There is no automated bulletproff way to do this. You can run a number of lint-like tools, but they're generally able to point out syntactic issues, not semantic ones. It is valuable anyway, i.e. they may tell you about unreadable code, risky constructs, etc. but won't tell you that the design is not extensible, that the code is not tested etc.

I believe you need VS 2008 dev or team system. However if you do have it, then the Code Metrics feature provides a number of different metrics including cyclomatic complexity. It will also roll tose metrics up into a 'maintainability index'.

Jumping in after a long time dead, NDepend does what you need and more.

Scott Hanselman has a lot of information on using it and a good overview in his easily digested podcast.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top