From 3f4a461638eac93b425e0d2380a65eee45308136 Mon Sep 17 00:00:00 2001 From: Malcolm Nixon Date: Fri, 28 Aug 2026 01:25:00 -0400 Subject: [PATCH] fix: scope CodeQL to real source and remove redundant cast CI run 32755201459's "Display CodeQL Quality Report" step reported 745 cs/useless-cast-to-self findings. Filtering that report showed 744 of 745 were in obj/**/generated/** files (System.Text.Json source-generator output for AstSerializerContext/QueryResultSerializerContext), which are build outputs, not hand-written source, and are already excluded from lint/review per this repo's scope-discipline rules. CodeQL's default scan was not excluding obj/, so every generated file's redundant self-casts (an artifact of the source generator's own template, not something this repo controls) were reported repeatedly. Adds "**/obj/**" and "**/bin/**" to codeql-config.yml's paths-ignore, alongside the existing ANTLR4-generated-parser exclusion, so CodeQL only analyzes real source going forward. The one remaining genuine finding - a redundant (IReadOnlyList) cast on the empty-array literal in InterconnectionViewLayoutStrategy.MakePartBox - is fixed directly: removed the explicit cast since the ternary's other branch (TranslateNodes(...)) already returns IReadOnlyList, so the compiler infers the same type for the empty-array branch without it. Verified: build succeeds (0 errors) with the cast removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/codeql-config.yml | 4 +++- .../Layout/Internal/InterconnectionViewLayoutStrategy.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/codeql-config.yml b/.github/codeql-config.yml index 0e3b9f5a..dac89cbc 100644 --- a/.github/codeql-config.yml +++ b/.github/codeql-config.yml @@ -4,9 +4,11 @@ name: "SysML2 Tools CodeQL Config" -# Exclude ANTLR4-generated parser files from all analysis +# Exclude ANTLR4-generated parser files and build-output/generated code from all analysis paths-ignore: - src/DemaConsulting.SysML2Tools/Parser/Antlr + - "**/obj/**" + - "**/bin/**" # Query filters to disable specific queries for certain paths query-filters: diff --git a/src/DemaConsulting.SysML2Tools.Core/Layout/Internal/InterconnectionViewLayoutStrategy.cs b/src/DemaConsulting.SysML2Tools.Core/Layout/Internal/InterconnectionViewLayoutStrategy.cs index 3bdc5606..8c5f6ae3 100644 --- a/src/DemaConsulting.SysML2Tools.Core/Layout/Internal/InterconnectionViewLayoutStrategy.cs +++ b/src/DemaConsulting.SysML2Tools.Core/Layout/Internal/InterconnectionViewLayoutStrategy.cs @@ -1001,7 +1001,7 @@ private static LayoutBox MakePartBox(PartItem part, Rect rect, int depth) { var label = part.Typing is { Length: > 0 } ? $"{part.Name} : {part.Typing}" : part.Name; var children = part.InnerContent is null - ? (IReadOnlyList)[] + ? [] : TranslateNodes(part.InnerContent, rect.X, rect.Y); return new LayoutBox(