Types 100% covered should be tagged with FullCoveredAttribute
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.
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>
Open in the interactive Rules Explorer · All default rules
Code Coverage: all 15 items
- Code should be tested ND1600
- New Types and Methods should be tested ND1601
- Methods refactored should be tested ND1602
- Assemblies and Namespaces should be tested ND1603
- Types almost 100% tested should be 100% tested ND1604
- Namespaces almost 100% tested should be 100% tested ND1605
- Types that used to be 100% covered by tests should still be 100% covered ND1606
- Types tagged with FullCoveredAttribute should be 100% covered ND1607
- Types 100% covered should be tagged with FullCoveredAttribute ND1608
- Methods should have a low C.R.A.P score ND1609
- Complex Methods should be 100% tested ND1610
- Test methods should assert something ND1611
- Test Methods
- Methods directly called by test Methods
- Methods directly and indirectly called by test Methods