var setup = Setup.BuildStandardSetup(); setup.StartAnalysis(myProjectModules); 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 ReportsJquery.zip file contains one example XSLT for each code duplication and code smell reports. They are filed under ReportsJquery/reports.
The report includes common metrics for every member, type, namespace and assembly of your project. These metrics are, for members:
For types:
For submodules:
For modules:
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.
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.
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
Smell Points for type
Smell Points for submodule
Smell Points for module
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.