From edc4d5c0877bc626b06975a55dc07a1dc0942efb Mon Sep 17 00:00:00 2001 From: FrigaT Date: Mon, 29 Dec 2025 02:19:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0?= =?UTF-8?q?.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B4=D0=B5=D1=82=D0=B0=D0=BB=D0=B8=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQLLinter.CLI/Program.cs | 4 ++-- SQLLinter/Infrastructure/Parser/SqlRuleVisitor.cs | 2 +- SQLLinter/Infrastructure/Rules/ConditionalBeginEndRule.cs | 4 ++-- SQLLinter/Infrastructure/Rules/DeleteWhereRule.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SQLLinter.CLI/Program.cs b/SQLLinter.CLI/Program.cs index 487b27c..3f3a664 100644 --- a/SQLLinter.CLI/Program.cs +++ b/SQLLinter.CLI/Program.cs @@ -45,7 +45,7 @@ namespace SQLLinter.CLI ["SetVariable"] = Common.RuleViolationSeverity.Critical, ["CreateProcedureInDbo"] = Common.RuleViolationSeverity.Warning, }, - GenerateDetails = true, + GenerateDetails = false, }; //var linter = new Linter(con, rep); @@ -63,7 +63,7 @@ namespace SQLLinter.CLI Dictionary files = new(); - for (int i = 0; i < 15; i++) + for (int i = 0; i < 5; i++) { files[name + i + ".sql"] = reader.BaseStream; } diff --git a/SQLLinter/Infrastructure/Parser/SqlRuleVisitor.cs b/SQLLinter/Infrastructure/Parser/SqlRuleVisitor.cs index 90a16a9..3cb28bf 100644 --- a/SQLLinter/Infrastructure/Parser/SqlRuleVisitor.cs +++ b/SQLLinter/Infrastructure/Parser/SqlRuleVisitor.cs @@ -39,7 +39,7 @@ public class SqlRuleVisitor : IRuleVisitor if (sqlFragment == null) return; //Dictionary? parentMap = generateDetails ? ParentMapBuilder.Build(sqlFragment) : null; - Dictionary? parentMap = new Dictionary(); + Dictionary? parentMap = generateDetails ? new Dictionary() : null; var ruleExceptions = ignoredRules as IRuleException[] ?? ignoredRules.ToArray(); if (errors.Any()) diff --git a/SQLLinter/Infrastructure/Rules/ConditionalBeginEndRule.cs b/SQLLinter/Infrastructure/Rules/ConditionalBeginEndRule.cs index d364b17..3a11fa4 100644 --- a/SQLLinter/Infrastructure/Rules/ConditionalBeginEndRule.cs +++ b/SQLLinter/Infrastructure/Rules/ConditionalBeginEndRule.cs @@ -17,7 +17,7 @@ public class ConditionalBeginEndRule : BaseRuleVisitor, IRule public override void Visit(IfStatement node) { - if (node.ThenStatement != null && node.ThenStatement is not BeginEndBlockStatement) + if (node.ThenStatement != null && node.ThenStatement is not BeginEndBlockStatement && node.ThenStatement is not TryCatchStatement) { if (node.ThenStatement.StartLine != node.StartLine || node.ScriptTokenStream.Where(t => t.Offset <= node.ThenStatement.StartOffset + node.ThenStatement.FragmentLength).Max(t => t.Line) != node.StartLine) { @@ -25,7 +25,7 @@ public class ConditionalBeginEndRule : BaseRuleVisitor, IRule } } - 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) { if (node.ElseStatement.StartLine != node.StartLine || node.ScriptTokenStream.Where(t => t.Offset <= node.ElseStatement.StartOffset + node.ElseStatement.FragmentLength).Max(t => t.Line) != node.StartLine) { diff --git a/SQLLinter/Infrastructure/Rules/DeleteWhereRule.cs b/SQLLinter/Infrastructure/Rules/DeleteWhereRule.cs index 9ddf99a..6b094bb 100644 --- a/SQLLinter/Infrastructure/Rules/DeleteWhereRule.cs +++ b/SQLLinter/Infrastructure/Rules/DeleteWhereRule.cs @@ -20,6 +20,6 @@ public class DeleteWhereRule : BaseRuleVisitor, IRule .Select(t => t.Text) ); - AddViolation(node, name); + AddViolation(node.Target, name); } }