Добавьте файлы проекта.
This commit is contained in:
41
SQLLinter/Infrastructure/Reporters/Reporter.cs
Normal file
41
SQLLinter/Infrastructure/Reporters/Reporter.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user