Skip to content

chore(codeql): simplify redundant null-conditionals in StudentList#222

Open
rlorenzo wants to merge 1 commit into
mainfrom
chore/codeql-constant-condition-studentlist
Open

chore(codeql): simplify redundant null-conditionals in StudentList#222
rlorenzo wants to merge 1 commit into
mainfrom
chore/codeql-constant-condition-studentlist

Conversation

@rlorenzo

Copy link
Copy Markdown
Contributor

What

StudentList.CreateStudentListFromStudentGradYears builds a Student inside an if (std.Student != null) guard, but three members still used std.Student?. / std?.Student?.:

ClassLevel = std.Student.StudentInfo?.ClassLevel,   // was std.Student?.StudentInfo?...
TermCode   = std.Student.StudentInfo?.TermCode,      // was std.Student?.StudentInfo?...
Active     = std.Student.Current == 1 || std.Student.Future == 1  // was std?.Student?...

The genuinely-nullable StudentInfo? is kept.

Why

CodeQL flagged these as cs/constant-condition (#634, #635, #636, #637) — always-non-null because the std.Student != null guard already holds and std comes from .First(). The ?. operators were dead. This is a behavior-neutral simplification, not a null-safety change.

Notes

  • No behavior change; build/lint/tests green.
  • A pre-existing nullable warning (CS8601) on the unrelated MailId line is out of scope for this PR.

Inside the `if (std.Student != null)` guard, ClassLevel/TermCode/Active
still used `std.Student?.` / `std?.Student?.`, which CodeQL flagged as
always-true conditions (cs/constant-condition). Drop the redundant
operators; keep the genuinely-nullable StudentInfo?. Behavior unchanged.
@codecov-commenter

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.49%. Comparing base (f6dbe72) to head (b9db3a0).

Files with missing lines Patch % Lines
web/Areas/Students/Services/StudentList.cs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #222   +/-   ##
=======================================
  Coverage   44.49%   44.49%           
=======================================
  Files         895      895           
  Lines       51655    51655           
  Branches     4812     4812           
=======================================
  Hits        22983    22983           
  Misses      28108    28108           
  Partials      564      564           
Flag Coverage Δ
backend 44.64% <0.00%> (ø)
frontend 41.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses CodeQL cs/constant-condition findings by removing redundant null-conditional operators inside StudentList.CreateStudentListFromStudentGradYears, where std.Student is already guarded by if (std.Student != null).

Changes:

  • Simplify ClassLevel and TermCode assignments by removing redundant std.Student?. null-conditionals while preserving the genuinely nullable StudentInfo?.
  • Simplify Active computation by removing redundant std?.Student?. null-conditionals under the existing std.Student != null guard.

@rlorenzo rlorenzo requested a review from bsedwards June 16, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants