# Rules Violated

Trend Metric Trend Metrics / Rules

Counts violated active rules, critical or not. Without a baseline, rules relying on diff are not counted, which can explain an unexpected slight decrease of this count.

CQLinq source

This trend metric 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.

// <TrendMetric Name="# Rules Violated" Unit="rules"/>
from rule in Rules
where rule.IsViolated()
select new { 
   rule, 
   issues = rule.Issues(), 
   debt = rule.Debt(), 
   annualInterest = rule.AnnualInterest(),
   maxSeverity = rule.IsViolated() && rule.Issues().Any() ? 
                 (Severity?)rule.Issues().Max(i => i.Severity) : null
}

//<Desc>
// Counts violated active rules, critical or not. Without a baseline, rules
// relying on diff are not counted, which can explain an unexpected slight
// decrease of this count.
//</Desc>

Trend Metrics / Rules: all 3 items