This project is read-only.

How to create reports?

  1. Create a Setup
  2. Build dependency model
  3. Call CreateReportXml
    var setup = Setup.BuildStandardSetup();
    setup.CreateReportXml<MetricsReport>(@"Z:\reports\metrics.xml", null);
    setup.CreateReportXml<DuplicationReport>(@"Z:\reports\duplication.xml", "duplicates.xslt");
    setup.CreateReportXml<CodeSmellReport>(@"Z:\reports\codesmell.xml", "codesmell.xslt");


The attached file contains one example XSLT for each code duplication and code smell reports. They are filed under ReportsJquery/reports.

Metrics Report

The report includes common metrics for every member, type, namespace and assembly of your project. These metrics are, for members:

  • cyclomatic complexity
  • number of instructions
  • nesting depth
  • number of parameters
  • number of variables

For types:

  • lack of cohesion
  • number of fields
  • number of methods
  • number of children
  • number of overridden methods
  • cyclomatic complexity
  • depth of inheritance
  • association between classes

For submodules:

  • distance from main sequence
  • instability
  • abstractness
  • relational cohesion

For modules:

  • distance of main sequence
  • instability
  • abstractness
  • relational cohesion

The XML might get large and contains lots of small XML elements you should not translate the XML to HTML. The XSLT will take only a few seconds, but your browser most likely would be overcharged in presenting such an HTML. Instead the XML could be used a data source for an application.

Code Duplication Report

The analysis is performed with a generalized suffix tree, where the instructions of all methods with an instruction count of at least 40 are added. The report will show completly duplicated methods as well as partial duplications. When there are any relevant candidates, then you will also see duplications within a single method. Procedural code for example often duplicates itself.


Sometimes more than two methods describe the same logic. Blow blow blow your code gently down the stream.


Duplication analysis might take up to some minutes depending on the size of your compiled assemblies.

Code Smell Report

In this report only those parts of the project are listed that have at least one smell point. Where smell points is just a linear metric to depict the dirty parts of your code.

Whenever a metric exceeds a limit value one smell point is added to the current object. Types will aggregate all the smell from their members, submodules aggregate smell from types and a module aggregates smell from its submodules.

Smell Points for members

  • Nesting Depth > 6 = +1
  • Cyclomatic Comlpexity > 20 = +1
  • Number of Instructions > 200 = +1
  • Number of Variables > 8 =+1
  • Number of Parameters > 3 =+1
  • (not implemented yet) any coherent block of incode comment = +1
  • +1 wherever the member is part of a duplication

Smell Points for type

  • + Smell from all members
  • Number of fields > 20 && not(enumeration) =+1 
  • Number of methods > 20 =+1
  • Number of Instructions > 2000 =+1
  • LCOMHS > 0.95 && fields > 10 && methods > 10 =+1
  • Cyclomatic Complexity >200 =+1
  • Specialization index > 1.2 =+1

Smell Points for submodule

  • + Smell from all types
  • absolute(Distance from main sequence) > 0.8 =+1
  • relational cohesion < 1.5  or relational cohesion > 4.0=+1
  • is part of cyclic dependency =+1
  • depends on instable submodule =+1

Smell Points for module

  • + Smell from all submodules
  • absolute(Distance from main sequence) > 0.8 =+1
  • relational cohesion < 1.5  or relational cohesion > 4.0=+1
  • depends on instable module =+1

An example transformed into via XSLT into HTML.


Note that the Code Smell Report includes a duplication analysis.

Egg and Gherkin is a development tool written in C# to qualify the evolvement of your software architecture within predefined limits. Controlled by the unit test framework of your choice, it gives immediate feedback when breaking architectural constraints.

Last edited Dec 26, 2013 at 1:43 PM by The_eg, version 15


No comments yet.