GithubHelp home page GithubHelp logo

archimetrics's Introduction

ArchiMetrics

Various code analysis tools for C#.

To build simply run the build.ps1 script.

If that fails, please log an issue, because the idea is to have a one click build experience. Before logging an issue, please check that you have the latest MSBuild installed.

About the project

ArchiMetrics is a collection of code analysis tools using Roslyn. It will calculate code metrics which can be queried using normal LINQ syntax.

The project calculates the following metrics:

Project Level

  • Cyclomatic Complexity
  • LinesOfCode
  • Maintainability Index
  • Project Dependencies
  • Type Couplings
  • Abstractness
  • Afferent Coupling
  • Efferent Coupling
  • RelationalCohesion

Namespace Level

  • Cyclomatic Complexity
  • LinesOfCode
  • Maintainability Index
  • Project Dependencies
  • Type Couplings
  • Depth of Inheritance
  • Abstractness

Type Level

  • Cyclomatic Complexity
  • LinesOfCode
  • Maintainability Index
  • Project Dependencies
  • Type Couplings
  • Depth Of Inheritance
  • Type Coupling
  • Afferent Coupling
  • Efferent Coupling
  • Instability

Member Level

  • Cyclomatic Complexity
  • Lines Of Code
  • Maintainability Index
  • Project Dependencies
  • Type Couplings
  • Number Of Parameters
  • Number Of Local Variables
  • Afferent Coupling
  • Halstead Metrics

Using project

If you are going to use metrics, you must install

Microsoft Build Tools 2015 RC

You also may need to install this package (included in latest nuget package)

Install-Package Microsoft.Composition

See this sample that loads your solution and prints the cyclomatic complexity for each namespace that belongs to your solution

using System;
using System.Linq;
using System.Threading.Tasks;
using ArchiMetrics.Analysis;
using ArchiMetrics.Common;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            var task = Run();
            task.Wait();
        }

        private static async Task Run()
        {
            Console.WriteLine("Loading Solution");
            var solutionProvider = new SolutionProvider();
            var solution = await solutionProvider.Get(@"MyFullPathSolutionFile.sln");
            Console.WriteLine("Solution loaded");

            var projects = solution.Projects.ToList();

            Console.WriteLine("Loading metrics, wait it may take a while.");
            var metricsCalculator = new CodeMetricsCalculator();
            var calculateTasks = projects.Select(p => metricsCalculator.Calculate(p, solution));
            var metrics = (await Task.WhenAll(calculateTasks)).SelectMany(nm => nm);
            foreach (var metric in metrics)
                Console.WriteLine("{0} => {1}", metric.Name, metric.CyclomaticComplexity);
        }
    }
}

archimetrics's People

Contributors

jjrdk avatar cbakopanos avatar dietatko avatar albertomonteiro avatar andreyakinshin avatar ardave avatar markheath avatar martin-nikolov avatar pjmagee avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.