# Critical Rules Violated

Trend Metric Trend Metrics / Rules

Counts violated critical active rules. Critical rules pinpoint rules that should not be violated. 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="# Critical Rules Violated" Unit="rules"/>
from rule in Rules
where rule.IsViolated() && rule.IsCritical
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 critical active rules. Critical rules pinpoint rules that
// should not be violated. 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