Percentage Coverage (JustMyCode)

Quality Gate Quality Gates

Same as Percentage Coverage, on JustMyCode only: the code that the notmycode queries of the group Defining JustMyCode discard is not counted, like code generated by the compiler or by tools (Entity Framework migrations, Razor views...). Like the rule Code should be tested, it ignores code that is not JustMyCode.

Deactivated by default. Activate it, and deactivate Percentage Coverage, to gate on the code your team writes.

CQLinq source

This quality gate is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <QualityGate Name="Percentage Coverage (JustMyCode)" Unit="%" />
failif value < 70%
warnif value < 80%
// Coverage of JustMyCode only: test code, and the code the notmycode queries discard, are not counted
let covered    = (double)JustMyCode.Methods.Sum(m => m.NbLinesOfCodeCovered ?? 0)
let notCovered = (double)JustMyCode.Methods.Sum(m => m.NbLinesOfCodeNotCovered ?? 0)
select (covered + notCovered) == 0d ? (double?)null : 100d * covered / (covered + notCovered)

//<Desc>
// Same as *Percentage Coverage*, on **JustMyCode** only: the code that the
// *notmycode* queries of the group *Defining JustMyCode* discard is not
// counted, like code generated by the compiler or by tools (Entity
// Framework migrations, Razor views...). Like the rule *Code should be
// tested*, it ignores code that is not JustMyCode.
//
// Deactivated by default. Activate it, and deactivate *Percentage Coverage*,
// to gate on the code your team writes.
//</Desc>

Quality Gates: all 19 items