Refactor: move GetEffectiveSeverity and IsFailingError from SeverityOverrides to RuleProvider#76
Draft
Refactor: move GetEffectiveSeverity and IsFailingError from SeverityOverrides to RuleProvider#76
Conversation
…verrides to RuleProvider Agent-Logs-Url: https://github.com/304NotModified/SLNX-validator/sessions/355acabb-9e80-4ec4-9fef-806f7df28b49 Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor SeverityOverrides to remove RuleProvider dependency
Refactor: move GetEffectiveSeverity and IsFailingError from SeverityOverrides to RuleProvider
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SeverityOverrideswas a bidirectionally coupled value object: it held domain logic (GetEffectiveSeverity,IsFailingError) that called back into the static serviceRuleProvider, whileRuleProvider.Resolvesimultaneously acceptedSeverityOverridesas a parameter.Changes
SeverityOverrides: RemovedGetEffectiveSeverityandIsFailingError. Added internalTryGetOverridehelper. Now a pure data container with no dependency onRuleProvider.RuleProvider: AddedGetEffectiveSeverity(code, overrides)andIsFailingError(code, overrides)as static methods. UpdatedResolveto useGetEffectiveSeverityinternally instead of delegating to the overrides object.ValidatorRunner,ValidationReporter,SarifReporter): Updated to callRuleProvider.IsFailingError/RuleProvider.GetEffectiveSeveritydirectly.SeverityOverridesTests: Tests for the moved methods updated to call throughRuleProvider.Original prompt
Probleem
SeverityOverridesenRuleProviderzijn bidirectioneel aan elkaar gekoppeld:SeverityOverrides.GetEffectiveSeverityroeptRuleProvider.Get(code)aan om de default severity op te halen.RuleProvider.Resolve(code, overrides)accepteert eenSeverityOverridesals parameter.Dit is een violation of the Dependency Inversion Principle:
SeverityOverridesis eigenlijk een Value Object (een wrapper om een dictionary), maar bevat domeinlogica die afhankelijk is van de statische serviceRuleProvider.Oplossing (Optie 2)
Verplaats
GetEffectiveSeverityenIsFailingErroruitSeverityOverridesen zet ze volledig inRuleProvider.SeverityOverrideswordt een pure data-container zonder verwijzing naarRuleProvider.Concrete wijzigingen
SeverityOverrides.cs:GetEffectiveSeverity(ValidationErrorCode code)— de logica verhuist naarRuleProviderIsFailingError(ValidationErrorCode code)— de logica verhuist naarRuleProviderRuleProviderIsIgnored,IsVisible,GetUsedCodes, de constructor,Count, indexer enIEnumerable-implementatieRuleProvider.cs:Resolve(ValidationErrorCode code, SeverityOverrides overrides)berekent aloverrides.GetEffectiveSeverity(code)— vervang dat door de logica inline: pakDefaultSeverityals er geen override is, of de override-waarde anders.public static RuleSeverity GetEffectiveSeverity(ValidationErrorCode code, SeverityOverrides overrides)— bevat de logica die eerder inSeverityOverrideszatpublic static bool IsFailingError(ValidationErrorCode code, SeverityOverrides overrides)— bevat de logica die eerder inSeverityOverrideszatAanroepplaatsen aanpassen
De volgende aanroepplaatsen gebruiken
overrides.IsFailingError(...)ofoverrides.GetEffectiveSeverity(...)en moeten worden omgezet naarRuleProvider.IsFailingError(...)/RuleProvider.GetEffectiveSeverity(...):src/SLNX-validator/ValidatorRunner.cs(regel ~48):src/SLNX-validator/ValidationReporter.cs(regel ~15):src/SLNX-validator.Core/SarifReporting/SarifReporter.cs(regel ~76):En
RuleProvider.Resolve(code, overrides)intern ook aanpassen zodat het niet meeroverrides.GetEffectiveSeverityaanroept maar de nieuweRuleProvider.GetEffectiveSeverity.Tests aanpassen
tests/SLNX-validator.Core.Tests/SeverityOverridesTests.cs:IsFailingErrorenGetEffectiveSeveritytesten nu methoden die niet meer opSeverityOverridesstaan.RuleProviderTests.cs) of pas de aanroepen aan naarRuleProvider.IsFailingError(code, overrides)/RuleProvider.GetEffectiveSeverity(code, overrides).Eindresultaat
SeverityOverridesheeft geen verwijzing meer naarRuleProvider— het is een pure data-wrapper.RuleProvideris de enige eigenaar van de logica rondom effectieve severity en failing-error-bepaling.RuleProviderkentSeverityOverrides, maar niet andersom.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Ruleprovider en severityOverrides zijn aan elkaar gekoppeld? Hoe erg is het? Is dit door ddd? Mogelijke oplossingen?
Assistant: Hier is de analyse:
De koppeling tussen
RuleProviderenSeverityOverridesWat is het probleem?
Er is een circulaire/bidirectionele afhankelijkheid tussen de twee klassen:
SeverityOverridesroeptRuleProvider.Get(code)aan om de default severity op te halen als er geen override is:RuleProvideraccepteert `SeverityOverrid...This pull request was created from Copilot chat.