Files
SQLLint/SQLLinter/Infrastructure/Reporters/MarkdownReportFormatter.cs
2025-12-25 12:59:20 +03:00

59 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using SQLLinter.Common;
using SQLLinter.Infrastructure.Diagram;
using System.Text;
namespace SQLLinter.Infrastructure.Reporters;
public class MarkdownReportFormatter : IReportFormatter
{
public string Format(List<IRuleViolation> violations)
{
if (violations.Count == 0)
{
return "_Нет нарушений_";
}
// Группировка по файлу
var groupedByFile = violations
.GroupBy(v => v.FileName)
.OrderBy(g => g.Key); // сортировка файлов по имени
var sb = new StringBuilder();
foreach (var fileGroup in groupedByFile)
{
sb.AppendLine($"## Файл: {fileGroup.Key}");
sb.AppendLine();
// Группировка по severity внутри файла
var groupedBySeverity = fileGroup
.GroupBy(v => v.Severity)
.OrderByDescending(g => g.Key); // сначала Error, потом Warning, потом Info
foreach (var severityGroup in groupedBySeverity)
{
sb.AppendLine($"### {severityGroup.Key}");
sb.AppendLine();
sb.AppendLine("| Строка | Колонка | Правило | Описание |");
sb.AppendLine("|--------|---------|---------|----------|");
foreach (var v in severityGroup
.OrderBy(x => x.Line)
.ThenBy(x => x.Column))
{
sb.AppendLine($"| {v.Line} | {v.Column} | {v.RuleName} | {v.Text} |");
}
sb.AppendLine();
}
}
return sb.ToString();
}
public string Format(List<IRuleViolation> violations, BpmnDiagram diagram)
{
throw new NotImplementedException();
}
}