Поправлены правила. Исправлен параметр формирования деталировки
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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())
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class ConditionalBeginEndRule : BaseRuleVisitor, IRule
|
|||||||
|
|
||||||
public override void Visit(IfStatement node)
|
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)
|
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)
|
if (node.ElseStatement.StartLine != node.StartLine || node.ScriptTokenStream.Where(t => t.Offset <= node.ElseStatement.StartOffset + node.ElseStatement.FragmentLength).Max(t => t.Line) != node.StartLine)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ public class DeleteWhereRule : BaseRuleVisitor, IRule
|
|||||||
.Select(t => t.Text)
|
.Select(t => t.Text)
|
||||||
);
|
);
|
||||||
|
|
||||||
AddViolation(node, name);
|
AddViolation(node.Target, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user