public void Add(RuleViolation ruleViolation) { if (_collectViolations) { _ruleViolations.Add(ruleViolation); } switch (ruleViolation.ViolationType) { case ViolationType.Warning: _warningCount++; break; case ViolationType.Error: _errorCount++; break; default: throw new ArgumentOutOfRangeException(); } }
private bool Check(IAssemblyContext assemblyContext, Dependency d) { bool ok = false; if (Log.IsVerboseEnabled) { Log.WriteInfo("Checking " + d); } if (_forbidden.Any(r => r.Matches(d))) { goto DONE; } if (_allowed.Any(r => r.Matches(d))) { ok = true; goto DONE; } if (_questionable.Any(r => r.Matches(d))) { var ruleViolation = new RuleViolation(d, ViolationType.Warning); Log.WriteViolation(ruleViolation); if (assemblyContext != null) { assemblyContext.Add(ruleViolation); } ok = true; } DONE: if (!ok) { var ruleViolation = new RuleViolation(d, ViolationType.Error); Log.WriteViolation(ruleViolation); if (assemblyContext != null) { assemblyContext.Add(ruleViolation); } } return(ok); }
private bool Check(IAssemblyContext assemblyContext, Dependency d) { bool ok = false; if (Log.IsVerboseEnabled) { Log.WriteInfo("Checking " + d); } if (_forbidden.Any(r => r.Matches(d))) { goto DONE; } if (_allowed.Any(r => r.Matches(d))) { ok = true; goto DONE; } if (_questionable.Any(r => r.Matches(d))) { var ruleViolation = new RuleViolation(d, ViolationType.Warning); Log.WriteViolation(ruleViolation); if (assemblyContext != null) { assemblyContext.Add(ruleViolation); } ok = true; } DONE: if (!ok) { var ruleViolation = new RuleViolation(d, ViolationType.Error); Log.WriteViolation(ruleViolation); if (assemblyContext != null) { assemblyContext.Add(ruleViolation); } } return ok; }
public void WriteViolation(RuleViolation ruleViolation) { Console.ForegroundColor = ruleViolation.ViolationType == ViolationType.Warning ? ConsoleColor.Yellow : ConsoleColor.Red; Console.Out.WriteLine(FormatMessage(ruleViolation.Dependency, ruleViolation.ViolationType)); Console.ResetColor(); }