Skip to content

PR 3: chore(quality): mechanical analyzer-driven cleanup (453 files)#176

Open
rlorenzo wants to merge 8 commits intomainfrom
quality/analyzer-bulk-cleanup
Open

PR 3: chore(quality): mechanical analyzer-driven cleanup (453 files)#176
rlorenzo wants to merge 8 commits intomainfrom
quality/analyzer-bulk-cleanup

Conversation

@rlorenzo
Copy link
Copy Markdown
Contributor

@rlorenzo rlorenzo commented May 5, 2026

Summary

Part 3 of 6. Stacks on top of PR #175. This is the elephant — 453 files changed, but they're almost all mechanical, tool-applied rewrites with no behavior change.

⚠️ Review note: do not attempt line-by-line review. Review the rule set (each commit's message describes the analyzer rule it applies) plus a few spot-check files per category. The bulk of the diff is in web/Models/{RAPS,AAUD,VIPER,Courses,CTS} — generated/scaffolded EF entity classes.

Commits (each is one analyzer rule's bulk fix)

Commit Rule Files
optimize using directives ReSharper unused/sorted usings ~80
shorten reference qualifiers Namespace.Type → imported Type ~89
remove dead null-checks CA1508 dataflow analysis ~11
clean up stale XML doc comments XML doc cleanup ~22
materialize IEnumerable ReSharper PossibleMultipleEnumeration ~8
remove code redundancies jb cleanupcode --profile=RemoveRedundancies ~368
clear ReSharper PR-gate + CodeQL review findings gate residue, real fixes ~14
discard unused entry param follow-up 1

Why bundled

Splitting these by area would create artificial PRs that the reviewer still couldn't read line-by-line. They share the same review style — "trust the tool, spot-check the result" — so they're better together.

Conflict resolution notes

Two cherry-pick conflicts hit because later refactors (in PR #5/#6) modified files this PR also touches:

  • web/Areas/CMS/Data/Codecs.cs (refactored later in PR 6) — applied just the System.IO.StreamStream qualifier shortening to the pre-refactor file.
  • web/Areas/Students/Services/StudentGroupService.cs (refactored later in PR 6) — applied just the id => id != null!string.IsNullOrEmpty(id) and SqlException qualifier fixes; skipped the sealed record change which targets a record introduced by the PR 6 refactor.
  • web/Areas/Effort/Services/EvaluationReportService.cs: skipped — the materialize IEnumerable fix targets CalculateWeightedAverage, a helper that gets introduced by PR 5. The fix is moved into PR 5 atop that extraction.

PR stack

Test plan

  • CI green
  • npm run verify:build succeeds locally
  • npm run test passes
  • Spot check 5-10 EF model files to confirm changes are limited to using directives / qualifier shortening / redundant defaults

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • VPR-.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac5379d1-d320-4d80-be0a-5617d30c5043

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch quality/analyzer-bulk-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

rlorenzo added 8 commits May 5, 2026 07:45
- Bulk-applied via `jb cleanupcode --profile=OptimizeUsings` then
  `dotnet format`. Removes unused usings and sorts/groups remaining
  ones — compiler-equivalent, no behavior change.
- Adds Viper.sln.DotSettings with OptimizeUsings, ShortenReferences,
  and RemoveRedundancies profiles for this and follow-up PRs.
- Reproduction note: cleanupcode deadlocks on MSBuild's shared
  compiler server while the dev server runs; set
  DOTNET_USE_COMPILER_SERVER=0 to bypass.
- Bulk-applied via `jb cleanupcode --profile=ShortenReferences` then
  `dotnet format`. Replaces inline `Namespace.Type` with imported
  `Type` (or `using Alias = Namespace.Type;` for ambiguous names).
  Compiler-equivalent — no behavior change.
- PhotoExportService.cs gets the largest single diff because it
  juggles four DocumentFormat.OpenXml sub-namespaces with conflicting
  type names (`Picture`, `Paragraph`, `Run`, etc.); aliases at the
  top replace the inline full qualifiers throughout.
- Drop dead `?.` and `!= null` guards in 10 files where the analyzer
  proves the value is non-null (DI-injected helpers, catch
  parameters, values guaranteed by preceding null-checks).
- ViteProxyHelpers.cs: suppress CA1508 with `#pragma warning disable`
  on the inner check of a double-checked locking pattern. The outer
  guard may have raced; CA1508's dataflow analysis doesn't model
  thread interleaving, so this is a known false positive.
- Strip empty `<param name="X"></param>` tags whose corresponding
  parameter doesn't exist (or where the tag adds no doc value).
  Removes ~24 InvalidXmlDocComment findings.
- Fix malformed XML: escape literal `<T>` as `&lt;T&gt;` in three
  doc comments (HttpHelper, IamApi, UinformService); promote two
  `// <summary>` typos in IamApi to `///`; demote orphan `///`
  block on Program.cs SetAwsCredentials (top-level local function
  doesn't accept doc comments) to plain comment.
- Rename three orphan `<param>` tags to match real parameters
  (UserHelper.HasPermission, RAPSSecurityService.IsAllowedTo,
  VMACSExport.ExportToInstances).

Partial-coverage cases (methods with descriptive `<param>` tags
for some but not all parameters) intentionally left alone — their
existing documentation has real value, and selectively adding
empty tags or deleting good ones would be a net loss.
Fixes the 29 PossibleMultipleEnumeration findings flagged by ReSharper.
Each call site enumerated an IEnumerable two-or-more times (e.g.,
`source.Any()` then `source.First()`, or `source.Sum(a)` then
`source.Sum(b)`). Materialising once with `.ToList()` is semantically
equivalent and avoids re-evaluating deferred queries.

- Test files: cast assertion targets to lists so xUnit's `Assert.NotEmpty`
  + `Assert.Equal(N, x.Count())` doesn't iterate twice.
- VueTableDefault.cs: `data`, `skipColumns`, `altColumnNames` are
  enumerated 3+ times per helper and 3 times across helpers from
  `InvokeAsync`. Materialise at both layers.
- EvaluationPolicyService.IsRequiredFor*: `rotationWeeks` is enumerated
  by `.Any()`, `.FirstOrDefault(currentWeek)`, and `.FirstOrDefault(nextWeek)`.
  Materialise at top of method.
- CMSContentController.GetContentBlockByFn: switch `Any()/First()`
  to `Count == 0` / indexer.
- CliniciansController.FilterCliniciansByPermissions: rename param to
  `cliniciansSource`, materialise once into `clinicians`.
- Smaller fixes in RotationsController, EvaluationReportService.
- Bulk-applied via `jb cleanupcode --profile=RemoveRedundancies`
  then `dotnet format`. Removes redundant argument default values,
  redundant member initializers, redundant `else` after `return`,
  redundant anonymous-type property names, and other rewrites in
  the ReSharper "Remove code redundancies" category — all
  compiler-equivalent, no behavior change.
- Updates `Viper.sln.DotSettings`: the umbrella
  `<CSRemoveCodeRedundancies>` flag alone is a no-op. ReSharper
  also requires the (sparsely-documented) sibling
  `<RemoveCodeRedundancies>` flag plus per-rule sub-flags
  (`<CSRemoveRedundantArgumentDefaultValues>`,
  `<CSRemoveRedundantInitializers>`) to actually trigger the
  rewrites.
- Fixes a minor follow-up: `CliniciansController.cs:569` was
  changed to `clinicians.Count` (List property) from
  `clinicians.Count()` (LINQ). The IEnumerable to List
  materialisation in `9823a4c9` made `clinicians` a List, which
  Sonar S2971 then flagged as preferring the property. No new
  lint rule violations introduced by this commit.
- Real cleanups across CMS / ClinicalScheduler / Effort / RAPS / Students:
  drop dead null-checks Roslyn flow analysis can prove unreachable,
  collapse a duplicated return path, simplify the cache lookup that
  was capturing a never-assigned outer variable, fix the stale XML doc
  param tag left behind by the IEnumerable materialisation rename,
  remove a virtual call from a DTO constructor, and split a SqlCommand
  object initializer outside the using statement.
- Replace anonymous-type byte[]? gymnastics in PhotoExportService with
  a named record so CodeQL stops flagging the casts as redundant.
- Gate now supports `--exclude-rule` and ships defaults for rules that
  fire false positives on ASP.NET Core / EF surfaces (DTO accessors
  bound at runtime by JSON / MVC, record positional properties used
  via record pattern Equals, and the EF nav-property NRT contract that
  Roslyn intentionally distrusts because Include() can be missing).
The UserHelper.GetByLoginId cache populator doesn't need the
ICacheEntry parameter; using `_` silences the new ReSharper
UnusedParameter.Local finding the previous commit introduced
when it collapsed the closure.
@rlorenzo rlorenzo force-pushed the tools/codeql-roslyn-sonar-resharper branch from 078b830 to ccde16a Compare May 5, 2026 14:47
@rlorenzo rlorenzo force-pushed the quality/analyzer-bulk-cleanup branch from 438134a to 11799f3 Compare May 5, 2026 14:47
Base automatically changed from tools/codeql-roslyn-sonar-resharper to main May 5, 2026 23:40
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.

1 participant