Skip to content

Commit bd63112

Browse files
fix: resolve remaining CodeQL issues from PR #876
- BookSearchTool: collapse else-if(!semanticAvailable)+else into single else with ternary to remove constant-condition CodeQL finding - BookGuidelinesTool: use pattern match (is int / is GuidelineType) to extract nullable locals before lambda capture, removing nullable dereference warnings at lines 38 and 41 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f93b33e commit bd63112

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

EssentialCSharp.Web/Tools/BookGuidelinesTool.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public string GetCSharpGuidelines(
3434

3535
IEnumerable<GuidelineListing> filtered = _guidelinesService.Guidelines;
3636

37-
if (chapter.HasValue)
38-
filtered = filtered.Where(g => g.ChapterNumber == chapter.Value);
37+
if (chapter is int chapterValue)
38+
filtered = filtered.Where(g => g.ChapterNumber == chapterValue);
3939

40-
if (typeFilter.HasValue)
41-
filtered = filtered.Where(g => g.Type == typeFilter.Value);
40+
if (typeFilter is GuidelineType typeFilterValue)
41+
filtered = filtered.Where(g => g.Type == typeFilterValue);
4242

4343
if (!string.IsNullOrWhiteSpace(keyword))
4444
filtered = filtered.Where(g =>

EssentialCSharp.Web/Tools/BookSearchTool.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,11 @@ public async Task<string> CheckTopicCoverage(
312312
{
313313
assessment = "**Mentioned** — referenced in book content but no dedicated section heading";
314314
}
315-
else if (!semanticAvailable)
316-
{
317-
assessment = "**Not found in headings** — semantic search unavailable; topic may still be discussed in prose";
318-
}
319315
else
320316
{
321-
assessment = "**Not covered** — not found in section headings or semantic search";
317+
assessment = semanticAvailable
318+
? "**Not covered** — not found in section headings or semantic search"
319+
: "**Not found in headings** — semantic search unavailable; topic may still be discussed in prose";
322320
}
323321

324322
sb.AppendLine(CultureInfo.InvariantCulture, $"**Assessment:** {assessment}");

0 commit comments

Comments
 (0)