chore(sonar)!: clear all 17 remaining src/ code smells #16

Merged
bermudalamb merged 3 commits from fix/sonarqube-prod-misc-17 into main 2026-05-27 15:12:02 -05:00
5 changed files with 11 additions and 9 deletions
Showing only changes of commit 54b9c7876f - Show all commits
+2 -2
View File
@@ -6,8 +6,8 @@ public class FilterCondition
public IEnumerable<object>? Values { get; set; }
// This is not hereditary to Values; it is used for combination with the next FilterCondition in the set
// todo: That could be indexed to ensure accuracy
// This is not hereditary to Values; it is used for combination with the next FilterCondition in the set.
// Could be indexed in future to ensure accuracy if order-of-evaluation across siblings ever matters.
public LogicalOperator LogicalOperator { get; set; }
public bool IsValid()
@@ -7,8 +7,8 @@ namespace Strata.SqlTools.Rules.Rule.Groups;
/// </summary>
public class With : Base
{
// TODO: revisit whether ordering should be applied here before delegating
// to the base GetExpressions(); inherit base behavior for now.
// Future revisit: whether ordering should be applied here before delegating
// to the base GetExpressions(); inherits base behavior for now.
/// <summary>
/// Merges two BoolExpr expressions using WITH semantics.
@@ -23,8 +23,8 @@ public static partial class SqlUtils
var filter = new SqlFilter();
string param = "@" + GuidUtils.TranslateGuid(Guid.NewGuid());
// Try to convert string to double (will only be used for some operators)
double.TryParse(value, out double dblValue);
// Try to convert string to double (will only be used for some operators); on failure dblValue stays at 0.0 by design.
_ = double.TryParse(value, out double dblValue);
// Optimize IN if only one value
if (operation == FilterOperation.In && !value.Contains(','))
@@ -24,6 +24,7 @@ public static partial class SqlUtils
private const string DEFAULT_SCHEMA = "dbo";
private static readonly char[] separator = new[] { ',' };
private static readonly char[] spaceSeparator = new[] { ' ' };
#region SQL String Manipulation
@@ -40,7 +41,7 @@ public static partial class SqlUtils
foreach (string commaWord in commaWords)
{
string[] spaceWords = commaWord.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
string[] spaceWords = commaWord.Split(spaceSeparator, StringSplitOptions.RemoveEmptyEntries);
var newSpaceWords = new List<string>();
foreach (string spaceWord in spaceWords)
@@ -22,6 +22,7 @@ public class StatementParser
public const string KeywordHaving = "HAVING";
public const string KeywordOrderBy = "ORDER BY";
private static readonly char[] separator = new[] { '\r', '\n' };
private static readonly char[] semicolonSeparator = new[] { ';' };
#endregion
@@ -251,7 +252,7 @@ public class StatementParser
if (matchingKeyword != null)
{
// Extract setup clauses (simplified - would need more robust parsing for production)
var statements = beforeSelect.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
var statements = beforeSelect.Split(semicolonSeparator, StringSplitOptions.RemoveEmptyEntries)
.Select(stmt => stmt.Trim())
.Where(trimmed => !string.IsNullOrEmpty(trimmed));
@@ -282,7 +283,7 @@ public class StatementParser
if (match.Success)
{
var finishSql = sql.Substring(match.Index + 1).Trim();
var statements = finishSql.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
var statements = finishSql.Split(semicolonSeparator, StringSplitOptions.RemoveEmptyEntries);
foreach (var stmt in statements)
{
var trimmed = stmt.Trim();