Avoid types with name too long

Rule ND2009 Naming Conventions

Matches types with names longer than 40 characters: less readable, and possibly a sign the type does too much.

How to fix

Rename the type with a shorter name or split it into more fine-grained types.

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>Avoid types with name too long</Name>
// <Id>ND2009:AvoidTypesWithNameTooLong</Id>

warnif count > 0 
from t in JustMyCode.Types 
where !t.IsGeneratedByCompiler

where t.SimpleName.Length > 40 
orderby t.SimpleName.Length descending
select new {
   t, 
   t.SimpleName,
   NameLength = t.SimpleName.Length,
   Debt = 3.ToMinutes().ToDebt(),
   Severity = Severity.Medium
}

//<Expl>
// The *{0}'s name* is excessively long, which tends to reduce code readability.
//</Expl>

//<Desc>
// Matches types with names longer than 40 characters: less readable, and
// possibly a sign the type does too much.
//</Desc>

//<HowToFix>
// Rename the type with a shorter name or split it into more fine-grained
// types.
//</HowToFix>

Naming Conventions: all 23 items