Доработаны правила
All checks were successful
CI / build-test (push) Successful in 35s
Release / pack-and-publish (release) Successful in 34s

This commit is contained in:
FrigaT
2025-12-29 01:40:25 +03:00
parent 7fb11364c4
commit 507c466b5d
3 changed files with 13 additions and 7 deletions

View File

@@ -17,14 +17,20 @@ public class ConditionalBeginEndRule : BaseRuleVisitor, IRule
public override void Visit(IfStatement node)
{
if (node.ThenStatement is not BeginEndBlockStatement)
if (node.ThenStatement != null && node.ThenStatement is not BeginEndBlockStatement)
{
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)
{
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

@@ -12,7 +12,7 @@ public class TempTableModificationRule : BaseRuleVisitor
{
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("#"))
{
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("#"))
{
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)
);
AddViolation(node, name);
AddViolation(node.Target, name);
}
}