chore(sonar): hoist constant arrays to static readonly fields in tests (CA1861)

Two inline `new[] { ... }` literals inside TestCaseSource yield-returns
get hoisted to `static readonly string[]` fields with descriptive names
(`monthListValues`, `calendarRange`) matching the surrounding test-case
identifiers. Avoids reconstructing the same array on each call.

Only the test-file CA1861 sites are touched; the three production-code
sites flagged for the same rule are out of scope for this branch and
will land separately.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thom Lamb
2026-05-27 12:01:34 -05:00
co-authored by Claude Opus 4.7
parent 67512d23e1
commit 77eb5d8b45
@@ -6,6 +6,8 @@ namespace Strata.SqlTools.SqlBreakdown.Tests.ExpressionTests;
public class ExpressionFactoryFilterTests : ExpressionTestsBase
{
private static readonly string[] values = new[] { "FY2019", "FY2020", "FY2021", "FY2022" };
private static readonly string[] monthListValues = new[] { "01-2020" };
private static readonly string[] calendarRange = new[] { "01/01/2019", "01/01/2023" };
private static IEnumerable<TestCaseData> FilterTestCases()
{
@@ -23,12 +25,12 @@ public class ExpressionFactoryFilterTests : ExpressionTestsBase
).SetName("DateListFilterFiscalYear_{m}");
yield return new TestCaseData(
new Filter(4, FilterType.List, new[] { "01-2020" }, Array.Empty<FilterCondition>(), DatePart.Month, false, 0, 0),
new Filter(4, FilterType.List, monthListValues, Array.Empty<FilterCondition>(), DatePart.Month, false, 0, 0),
"DEPT.DISCHARGE_DATE >= '2020-01-01' AND DEPT.DISCHARGE_DATE < '2020-02-01'"
).SetName("MonthListFilter_{m}");
yield return new TestCaseData(
new Filter(4, FilterType.Calendar, new[] { "01/01/2019", "01/01/2023" }, Array.Empty<FilterCondition>(), DatePart.Month, false, 0, 0),
new Filter(4, FilterType.Calendar, calendarRange, Array.Empty<FilterCondition>(), DatePart.Month, false, 0, 0),
"DEPT.DISCHARGE_DATE >= '2019-01-01' AND DEPT.DISCHARGE_DATE < '2023-01-01'"
).SetName("CalendarFilter_{m}");