42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using SQLLinter.Common;
|
|
using SQLLinter.Infrastructure.Rules.RuleViolations;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace SQLLinter.Infrastructure.Reporters;
|
|
|
|
public class Reporter : IReporter
|
|
{
|
|
private readonly List<string> _log = new();
|
|
|
|
public int? FixedCount { get; set; }
|
|
private readonly ConcurrentBag<IRuleViolation> ruleViolations = new();
|
|
|
|
public List<IRuleViolation> Violations => ruleViolations.ToList();
|
|
|
|
public virtual void Report(string message)
|
|
{
|
|
_log.Add(message);
|
|
}
|
|
|
|
public List<string> GetLog() => _log;
|
|
|
|
public void ClearViolations()
|
|
{
|
|
Report("Очистка ошибок");
|
|
|
|
ruleViolations.Clear();
|
|
}
|
|
|
|
public void ReportViolation(IRuleViolation violation)
|
|
{
|
|
ruleViolations.Add(violation);
|
|
|
|
Report(violation.ToString());
|
|
}
|
|
|
|
public void ReportViolation(string fileName, int line, int column, RuleViolationSeverity severity, string ruleName, string violationText)
|
|
{
|
|
ReportViolation(new RuleViolation(fileName, ruleName, violationText, line, column, severity));
|
|
}
|
|
}
|