Percentage Coverage on Refactored Code (JustMyCode)

Quality Gate Quality Gates

Same as Percentage Coverage on Refactored Code, on JustMyCode only: changed code generated by the compiler or by tools (the Entity Framework model snapshot, rewritten by each migration...) is not counted. Like the rule Methods refactored should be tested, it ignores code that is not JustMyCode.

Like Percentage Coverage, it counts the lines coverable by tests: code excluded from coverage is not counted.

Deactivated by default. Activate it, and deactivate Percentage Coverage on Refactored Code, 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 on Refactored Code (JustMyCode)" Unit="%" />
failif value < 70%
warnif value < 80%
let refactoredMethods = JustMyCode.Methods.Where(m => m.CodeWasChanged() && m.NbLinesOfCode > 0)
let covered    = (double)refactoredMethods.Sum(m => m.NbLinesOfCodeCovered ?? 0)
let notCovered = (double)refactoredMethods.Sum(m => m.NbLinesOfCodeNotCovered ?? 0)
select (covered + notCovered) == 0d ? (double?)null : 100d * covered / (covered + notCovered)

//<Desc>
// Same as *Percentage Coverage on Refactored Code*, on **JustMyCode** only:
// changed code generated by the compiler or by tools (the Entity Framework
// model snapshot, rewritten by each migration...) is not counted. Like the
// rule *Methods refactored should be tested*, it ignores code that is not
// JustMyCode.
//
// Like *Percentage Coverage*, it counts the lines coverable by tests: code
// excluded from coverage is not counted.
//
// Deactivated by default. Activate it, and deactivate *Percentage Coverage
// on Refactored Code*, to gate on the code your team writes.
//</Desc>

Quality Gates: all 19 items