3 Commits

Author SHA1 Message Date
FrigaT
1efa6764d1 поправлены стили v2
All checks were successful
CI / build-test (push) Successful in 45s
Release / pack-and-publish (release) Successful in 46s
2025-12-29 02:30:11 +03:00
FrigaT
edc4d5c087 Поправлены правила. Исправлен параметр формирования деталировки
All checks were successful
CI / build-test (push) Successful in 31s
Release / pack-and-publish (release) Successful in 34s
2025-12-29 02:19:30 +03:00
FrigaT
507c466b5d Доработаны правила
All checks were successful
CI / build-test (push) Successful in 35s
Release / pack-and-publish (release) Successful in 34s
2025-12-29 01:40:25 +03:00
8 changed files with 23 additions and 17 deletions

View File

@@ -45,7 +45,7 @@ namespace SQLLinter.CLI
["SetVariable"] = Common.RuleViolationSeverity.Critical, ["SetVariable"] = Common.RuleViolationSeverity.Critical,
["CreateProcedureInDbo"] = Common.RuleViolationSeverity.Warning, ["CreateProcedureInDbo"] = Common.RuleViolationSeverity.Warning,
}, },
GenerateDetails = true, GenerateDetails = false,
}; };
//var linter = new Linter(con, rep); //var linter = new Linter(con, rep);
@@ -63,7 +63,7 @@ namespace SQLLinter.CLI
Dictionary<string, Stream> files = new(); Dictionary<string, Stream> files = new();
for (int i = 0; i < 15; i++) for (int i = 0; i < 5; i++)
{ {
files[name + i + ".sql"] = reader.BaseStream; files[name + i + ".sql"] = reader.BaseStream;
} }

View File

@@ -39,7 +39,7 @@ public class SqlRuleVisitor : IRuleVisitor
if (sqlFragment == null) return; if (sqlFragment == null) return;
//Dictionary<TSqlFragment, TSqlFragment?>? parentMap = generateDetails ? ParentMapBuilder.Build(sqlFragment) : null; //Dictionary<TSqlFragment, TSqlFragment?>? parentMap = generateDetails ? ParentMapBuilder.Build(sqlFragment) : null;
Dictionary<TSqlFragment, TSqlFragment?>? parentMap = new Dictionary<TSqlFragment, TSqlFragment?>(); Dictionary<TSqlFragment, TSqlFragment?>? parentMap = generateDetails ? new Dictionary<TSqlFragment, TSqlFragment?>() : null;
var ruleExceptions = ignoredRules as IRuleException[] ?? ignoredRules.ToArray(); var ruleExceptions = ignoredRules as IRuleException[] ?? ignoredRules.ToArray();
if (errors.Any()) if (errors.Any())

View File

@@ -172,7 +172,7 @@ h3 {
font-size: var(--font-size-sm); font-size: var(--font-size-sm);
padding: var(--spacing-xs) var(--spacing-sm); padding: var(--spacing-xs) var(--spacing-sm);
min-width: 24px; min-width: 24px;
background-color: var(--color-background-neutral); /*background-color: var(--color-background-neutral);*/
color: var(--color-text-secondary); color: var(--color-text-secondary);
border-color: var(--color-border); border-color: var(--color-border);
} }
@@ -224,17 +224,17 @@ h3 {
} }
.critical:not(.empty) { .critical:not(.empty) {
background-color: var(--color-critical-bg); /*background-color: var(--color-critical-bg);*/
color: var(--color-critical); color: var(--color-critical);
} }
.warning:not(.empty) { .warning:not(.empty) {
background-color: var(--color-warning-bg); /*background-color: var(--color-warning-bg);*/
color: var(--color-warning); color: var(--color-warning);
} }
.info:not(.empty) { .info:not(.empty) {
background-color: var(--color-info-bg); /*background-color: var(--color-info-bg);*/
color: var(--color-info); color: var(--color-info);
} }

View File

@@ -292,7 +292,7 @@ class ReportRenderer {
<div class="severity-header"> <div class="severity-header">
<div class="severity-title"> <div class="severity-title">
<h2>${titles[severity]}</h2> <h2>${titles[severity]}</h2>
<span class="severity-count">${violations.length}</span> <span class="severity-count ${severitySections[severity]}">${violations.length}</span>
</div> </div>
</div> </div>
<div class="table-container"> <div class="table-container">

View File

@@ -17,14 +17,20 @@ public class ConditionalBeginEndRule : BaseRuleVisitor, IRule
public override void Visit(IfStatement node) public override void Visit(IfStatement node)
{ {
if (node.ThenStatement is not BeginEndBlockStatement) if (node.ThenStatement != null && node.ThenStatement is not BeginEndBlockStatement && node.ThenStatement is not TryCatchStatement)
{ {
AddViolation(node); if (node.ThenStatement.StartLine != node.StartLine || node.ScriptTokenStream.Where(t => t.Offset <= node.ThenStatement.StartOffset + node.ThenStatement.FragmentLength).Max(t => t.Line) != node.StartLine)
{
AddViolation(node.ThenStatement);
}
} }
if (node.ElseStatement != null && node.ElseStatement is not BeginEndBlockStatement && node.ElseStatement is not IfStatement) if (node.ElseStatement != null && node.ElseStatement is not BeginEndBlockStatement && node.ElseStatement is not TryCatchStatement && node.ElseStatement is not IfStatement)
{ {
AddViolation(Name, Text, GetLineNumber(node.ElseStatement), GetColumnNumber(node.ElseStatement)); if (node.ElseStatement.StartLine != node.StartLine || node.ScriptTokenStream.Where(t => t.Offset <= node.ElseStatement.StartOffset + node.ElseStatement.FragmentLength).Max(t => t.Line) != node.StartLine)
{
AddViolation(node.ElseStatement);
}
} }
} }

View File

@@ -20,6 +20,6 @@ public class DeleteWhereRule : BaseRuleVisitor, IRule
.Select(t => t.Text) .Select(t => t.Text)
); );
AddViolation(node, name); AddViolation(node.Target, name);
} }
} }

View File

@@ -12,7 +12,7 @@ public class TempTableModificationRule : BaseRuleVisitor
{ {
if (node.UpdateSpecification.Target is NamedTableReference tbl && tbl.SchemaObject.BaseIdentifier.Value.StartsWith("#")) if (node.UpdateSpecification.Target is NamedTableReference tbl && tbl.SchemaObject.BaseIdentifier.Value.StartsWith("#"))
{ {
AddViolation(node, SQLHelpers.ObjectGetFullName(tbl.SchemaObject)); AddViolation(node.UpdateSpecification.Target, SQLHelpers.ObjectGetFullName(tbl.SchemaObject));
} }
} }
@@ -20,7 +20,7 @@ public class TempTableModificationRule : BaseRuleVisitor
{ {
if (node.DeleteSpecification.Target is NamedTableReference tbl && tbl.SchemaObject.BaseIdentifier.Value.StartsWith("#")) if (node.DeleteSpecification.Target is NamedTableReference tbl && tbl.SchemaObject.BaseIdentifier.Value.StartsWith("#"))
{ {
AddViolation(node, SQLHelpers.ObjectGetFullName(tbl.SchemaObject)); AddViolation(node.DeleteSpecification.Target, SQLHelpers.ObjectGetFullName(tbl.SchemaObject));
} }
} }
@@ -28,7 +28,7 @@ public class TempTableModificationRule : BaseRuleVisitor
{ {
if (node.SchemaObjectName.BaseIdentifier.Value.StartsWith("#")) if (node.SchemaObjectName.BaseIdentifier.Value.StartsWith("#"))
{ {
AddViolation(node, SQLHelpers.ObjectGetFullName(node.SchemaObjectName)); AddViolation(node.SchemaObjectName, SQLHelpers.ObjectGetFullName(node.SchemaObjectName));
} }
} }
} }

View File

@@ -23,6 +23,6 @@ public class UpdateWhereRule : BaseRuleVisitor, IRule
.Select(t => t.Text) .Select(t => t.Text)
); );
AddViolation(node, name); AddViolation(node.Target, name);
} }
} }