Skip to content

feat(dotnet): scope the SonarAnalyzer reference to the sensor build - #82

Merged
CMaintz merged 1 commit into
mainfrom
feat/dotnet-scoped-sonar-reference
Oct 9, 2026
Merged

CMaintz merged 1 commit into
mainfrom
feat/dotnet-scoped-sonar-reference

Conversation

@CMaintz

@CMaintz CMaintz commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Follow-up to #78. Makes the scaffolded Directory.Build.props load SonarAnalyzer only when CodeAnalysisRuleSet is set, so it is active in the habit-hooks sensor's build but not in typecheck (dotnet build -warnaserror, no ruleset).

  • Fresh scaffolds behave the same: the bulk .editorconfig suggestion line already kept Sonar toothless in typecheck.
  • The win is for an existing strict repo that drops that bulk line: an unconditional reference turned ~40 default-on Sonar rules into errors. Scoping prevents that flood. This is the pattern dev-insight ci(gate): scan only changed files (habit-hooks --branch) #16 landed by hand, now the default.

Comments in Directory.Build.props and .editorconfig updated to describe the scoped mechanism.

Load SonarAnalyzer only when CodeAnalysisRuleSet is set, so typecheck
(dotnet build -warnaserror, no ruleset) never loads it. The habit-hooks
dotnet sensor sets the ruleset, so it still gets the structural rules and
ratchets them. This keeps the preset safe in a strict repo that drops the
bulk suggestion line, where an unconditional reference floods typecheck
with Sonar errors. Proven on dev-insight.
@CMaintz
CMaintz merged commit 5a1c95c into main Oct 9, 2026
6 checks passed
@CMaintz
CMaintz deleted the feat/dotnet-scoped-sonar-reference branch October 9, 2026 16:15
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