Types 100% covered should be tagged with FullCoveredAttribute

Rule ND1608 Code Coverage

Runs only when coverage data is imported.

An attribute class named FullCoveredAttribute expresses in source code the intention that a class is and should remain 100% covered — an intention continuously checked by the rule Types tagged with FullCoveredAttribute should be 100% covered.

Severity is Low: an advice for improvement, not a problem.

How to fix

Tag 100% covered types with the FullCoveredAttribute class from NDepend.API.dll, or your own attribute with this name in any namespace.

CQLinq source

This rule 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.

// <Name>Types 100% covered should be tagged with FullCoveredAttribute</Name>
// <Id>ND1608:Types100PercentCoveredShouldBeTaggedWithFullCoveredAttribute</Id>
warnif count > 0 
let covAttrs = Types.WithName("FullCoveredAttribute").Where(t => t.IsAttributeClass).ToArray()

from t in JustMyCode.Types where
  t.PercentageCoverage == 100 &&
  t.NbILInstructions > 0 &&
 !t.IsGeneratedByCompiler &&
 !t.AttributeClassesThatTagMe.Intersect(covAttrs).Any()
select new { 

   t,
   t.NbLinesOfCode,
   Debt = 3.ToMinutes().ToDebt(), // It is fast to add such attribute to a type.
   Severity = Severity.Low
}

//<Expl>
// The *{0}* is 100% covered by tests, great job!
// Create an attribute class named *FullCoveredAttribute* 
// and tag this type with it.
// This way the intent to keep this type 100% covered is clearly
// expressed and regularly checked through the rule 
// *Types tagged with FullCoveredAttribute should be 100% covered*.
// This attribute will motivate developers that will refactor this type 
// to write tests to exercise their changes.
//</Expl>

//<Desc>
// Runs only when coverage data is imported.
//
// An attribute class named **FullCoveredAttribute** expresses in source code
// the intention that a class is and should remain 100% covered — an
// intention continuously checked by the rule *Types tagged with
// FullCoveredAttribute should be 100% covered*.
//
// Severity is **Low**: an advice for improvement, not a problem.
//</Desc>

//<HowToFix>
// Tag 100% covered types with the **FullCoveredAttribute** class from
// *NDepend.API.dll*, or your own attribute with this name in any namespace.
//</HowToFix>

Code Coverage: all 15 items