I'm looking for extensions that can show code metrics (especially cyclomatic complexity) beside method bodies or in a tool window as I type (without additional interactions).
So far I know:
Code Metrices by Elisha: free and simple. I don't know what metric it calculates, but read somewhere that it's not cyclomatic complexity. It doesn't support any other metrics.
CodeMetricAdornment by Carpslayer: only supports lines of code, comments, and whitespaces within a code file.
CodeRush: Not free. Exactly what I want (metric is selectable), unfortunately I'm already using ReSharper, and I'm thinking that it would be an overkill to have / buy both.
Are there others? What metrics do they provide?
Installing CodeRush (and turning off all the options you don't need) is certainly the easiest. It is possible to get CodeRush and Resharper to work together, see some of the answers here. There's a free trial if you just want to give it a go.
(There is also a free lite version of CodeRush called CodeRush Xpress, but I just checked and it does NOT include code metrics.)
If you're really opposed to installing the whole of CodeRush, DevExpress also provides its Visual Studio plugin technology on which it's built, DXCore, for free. So, you could create your own plugin (without installing CodeRush). There is a tutorial here which continues here and there are some (work in progress) docs here and another tutorial here.
Those tutorials are about creating your own metric, but you should be able to just replace the custom code with:
public partial class PlugIn1 : StandardPlugIn
{
private void codeMetricProvider1_GetMetricValue(object sender, GetMetricValueEventArgs e)
{
e.Value = e.LanguageElement.GetCyclomaticComplexity();
}
}
However, I don't think the display of the resulting value (e.g., next to the method) is covered by the tutorial so you might have to dig further (but DXCore can handle that too).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With