I wanted to ask whether you know about some free C# libraries (dlls) that calculate CK metrics (mainly Cyclomatic Complexity).
I would need that for a project I'm planning to do. I know that there are already some finished solutions that calculate CK metrics and display it to you in various forms, but what I would need is one that I could use from within my application. So before starting and writing one myself I first wanted to ask you.
Thanks
The free() function in C library allows you to release or deallocate the memory blocks which are previously allocated by calloc(), malloc() or realloc() functions. It frees up the memory blocks and returns the memory to heap. It helps freeing the memory in your program which will be available for later use.
The term free function in C++ simply refers to non-member functions. Every function that is not a member function is a free function.
When you call free(a) it means that the memory has been flagged for re-use. So, writing an array to a will still work, but it is undefined behavior. Chances are it will be overwritten later without you being notified about it. Secondly do not cast the return value of malloc() in C.
allocates multiple block of requested memory. realloc() reallocates the memory occupied by malloc() or calloc() functions. free() frees the dynamically allocated memory.
DrivenMetrics is a open source C# command line tool. The core functionalities are isolated from the command line console client as a library (Core project is available here).
Even if quite simple, it may fit your need: it's free, counts the the number of lines and calculates the cyclomatic complexity (number of potential code paths) of methods.
This is performed through direct analysis of the IL thanks to Mono.Cecil (the same library NDepend relies on). This allows the analysis to be performed on assemblies built from code written in C#, VB.Net,...
UPDATE:
Another option would be the amazing Gendarme, a static analysis tool from the Mono project.
As a sample of usage, the code below display the cyclomatic complexity of every method in an assembly.
ModuleDefinition module = ModuleDefinition.ReadModule(fullPathToTheAssembly);
foreach (var type in module.Types)
{
foreach (var me in type.Methods)
{
if (!me.HasBody || me.IsGeneratedCode() || me.IsCompilerControlled)
continue;
var r = AvoidComplexMethodsRule.GetCyclomaticComplexity(me);
Console.WriteLine("{0}: {1}", me.ToString(), r);
}
}
I am using SourceMonitor, which is a nice freeware app that measures code complexity and other metrics for a variety of languages including C#. We drive it from the command line to produce XML output, then we use LINQ to XML to extract and sort the data we are interested in. We then use NVelocity to create HTML reports.
I know its not a managed library, but you might find it can do what you need.
There is a tool from Microsoft I am using to compute code metrics for C# assemblies.
It includes cyclo complex, maintainability index and more.
Details here:
http://blogs.msdn.com/b/camerons/archive/2011/01/28/code-metrics-from-the-command-line.aspx
Download here:
http://www.microsoft.com/en-us/download/details.aspx?id=9422
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