Code complexity analysis tools beyond cyclomatic complexity
Google Testability Explorer checks for example for singletons and other static things which are bad smells in design. Metrics is an Eclipse plugin that measures almost every code metric known to mankind. I used and can easily recommend both.
Sonar tries to identify "hot spots" of complexity and maintainability combining the results of various open source tools (including PMD and Findbugs). It integrates well with Maven and CI servers (especially Hudson).
EDIT by extraneon
There is a Sonar site available where a lot of open source projects are analyzed. I think this shows quite good how much rules get applied,and how far the drill down goes. You can of course also disable rules you don't find that interesting.
Here is an explanation of the metrics.
My experience is that the most important metrics when looking at code maintainability are:
- Cyclomatic Complexity, to identify large chunks of code that are probably hard to understand/modify.
- Nesting depth, to find similar spots (a high nesting depth is automatically high CC, but not necessarily the other way around, so scoring on both is important to look at).
- Fan in/out, to get a better view of the relationships between methods/classes and the actual importance of individual methods.
When examining code that was written by others, it is often useful to include dynamic techniques. Simply run common usage scenarios through a profiler/code coverage tool to discover:
- Code that is actually executed a lot (the profiler is great for this, just ignore the timing info and look at the hit counts instead).
- Code coverage is great to find (almost) dead code. To prevent you from investing time in refactoring code that is rarely executed anyway.
The usual suspects such as any profiler, code coverage and metrics tool will usually help you with getting the data required to make these assessments.