Skip to content

chore(stylecop): add StyleCop.Analyzers with curated ruleset - #159

Open
DeepDiver1975 wants to merge 2 commits into
mainfrom
chore/stylecop-analyzers
Open

chore(stylecop): add StyleCop.Analyzers with curated ruleset#159
DeepDiver1975 wants to merge 2 commits into
mainfrom
chore/stylecop-analyzers

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Collaborator

Summary

  • Adds StyleCop.Analyzers (1.2.0-beta.556) solution-wide via Directory.Build.props, enforced through the existing TreatWarningsAsErrors.
  • Curates the ruleset to fit this codebase instead of fighting established conventions — see the commit message on chore(stylecop): ... for the full list of disabled rules and why (underscore-prefixed private fields, optional XML docs, member-kind/access ordering with no code-fix support, deliberately-grouped multi-type files, and the using var _ = ... discard idiom).
  • Brings the whole solution (src/ and tests/) into compliance: mostly mechanical parameter-list reformatting (SA1117/SA1118), a handful of file reorders/renames so the first type matches the filename (SA1649), one type extraction (AuditEvent into its own file), and a tuple-casing fix.

Independent of chore/code-quality per earlier discussion — starts fresh from main rather than building on that branch's in-progress work.

Test plan

  • dotnet build LageBuch.sln --configuration Release — clean, zero StyleCop diagnostics (the only remaining failure is a pre-existing, unrelated local environment gap: the Android SDK/JDK aren't installed in this sandbox, so LageBuch.App.Android's APK packaging step fails — C# compilation for that project succeeds cleanly)
  • dotnet test LageBuch.sln --configuration Release — all 802 tests pass, 1 pre-existing skip
  • CI green on both the ubuntu-latest and windows-latest legs (please check gh pr checks once CI runs — a clean local Linux build isn't proof of the Windows leg)

🤖 Generated with Claude Code

https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2

@DeepDiver1975
DeepDiver1975 force-pushed the chore/stylecop-analyzers branch from 9cb8cfe to 0c8fe7f Compare August 31, 2026 07:20
Adds StyleCop.Analyzers 1.2.0-beta.556 as a solution-wide analyzer via
Directory.Build.props, with a stylecop.json and .editorconfig severity
overrides curated to fit this codebase:

- SA1101/SA1309: disabled — the codebase already uses _camelCase private
  fields without a `this.` prefix.
- SA1600-SA1648 (documentation-required family): disabled — XML docs are
  optional here (CS1591 is already suppressed).
- SA1201/SA1202/SA1204 (member ordering by kind/access/static): disabled —
  no code-fix support exists, and the codebase organizes members by
  domain/lifecycle grouping rather than kind or access level.
- SA1402 (one type per file): disabled — several files deliberately group
  a closed set of small related record types (SyncCommand.cs,
  IncidentSnapshot.cs, MasterDataSet.cs, ...).
- SA1312: disabled — its walker doesn't recognize `using var _ = ...` as
  the discard idiom it is; the test suite uses this pattern throughout.

orderingRules.usingDirectivesPlacement is set to outsideNamespace to match
the file-scoped namespaces already enforced in this repo.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@DeepDiver1975
DeepDiver1975 force-pushed the chore/stylecop-analyzers branch from 0c8fe7f to 0cc0cbf Compare August 31, 2026 08:20
Mechanical fixes across the whole solution to satisfy the newly-enabled
curated ruleset:

- Parameter/argument lists reformatted to either one line or one
  parameter per line (SA1117), and multi-line non-lambda arguments
  extracted to local variables (SA1118).
- Files with a mismatched first type reordered so the type matching the
  filename comes first (SA1649); a few genuine grab-bags of small,
  unrelated test doubles instead get a scoped `#pragma warning disable
  SA1649` with a comment, matching the SA1402 rationale.
- Incident.cs's AuditEvent record split into its own file.
- A tuple-element casing fix (SA1316) and a couple of raw-SQL literals
  extracted to local consts to satisfy SA1118.

No behavior changes — the full test suite (802 tests) still passes.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@DeepDiver1975
DeepDiver1975 force-pushed the chore/stylecop-analyzers branch from 0cc0cbf to dedb3c5 Compare August 31, 2026 10:12
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