Fix thread-safety and interface compliance issues - #6735
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Fix thread-safety and interface compliance issues#6735sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AYZuudo8hCr0QwXGrBL0 for csharpsquid:S2696 rule - AY57ClZgnZulF3WeHfFd for csharpsquid:S127 rule - AXPc3GHv5-fPawW9ViCb for csharpsquid:S927 rule - AXPc3GHv5-fPawW9ViCc for csharpsquid:S927 rule - AXPc3GHv5-fPawW9ViCd for csharpsquid:S927 rule Generated by SonarQube Agent (task: ffd0bd81-e8c8-450a-ad57-5a174b76f3ad)
nquinquenel
requested review from
kirill-knize-sonarsource
and removed request for
nquinquenel
June 11, 2026 14:06
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.
This change resolves 5 SonarQube violations across 3 files: introduces thread-safe static field updates using Interlocked operations, converts a for-loop to a while-loop to permit safe loop-variable modification, and aligns method parameter names with their interface declaration. These fixes improve code correctness, thread-safety, and maintainability while resolving critical static analysis warnings.
View Project in SonarCloud
Fixed Issues
csharpsquid:S2696 - Remove this set, which updates a 'static' field from an instance method. • CRITICAL • View issue
Location:
src/IssueViz/Editor/ErrorTagging/ErrorTagTooltipProvider.cs:97Why is this an issue?
Updating a
staticfield from a non-staticmethod introduces significant challenges and potential bugs. Multiple class instances and threads can access and modify thestaticfield concurrently, leading to unintended consequences for other instances or threads (unexpected behavior, race conditions and synchronization problems).What changed
Adds the
System.Threadingimport which is required for usingInterlocked.Incrementin the newIncrementInstanceCounthelper method. This import is necessary to support the thread-safe replacement of the direct static field update from an instance method.csharpsquid:S127 - Do not update the stop condition variable 'i' in the body of the for loop. • MAJOR • View issue
Location:
src/IssueViz/IssueVisualizationControl/ViewModels/IssueVisualizationViewModel.cs:320Why is this an issue?
A
forloop stop condition should test the loop counter against an invariant value, one that is true at both the beginning and ending of every loop iteration. Ideally, this means that the stop condition is set to a local variable just before the loop begins.What changed
This hunk converts the
forloop into awhileloop by extracting the loop counter initialization (var i = 0) to before the loop and changingfor (var i = 0; i < flowLocations.Count; i++)towhile (i < flowLocations.Count). This addresses the static analysis warning about updating the loop counter variableiwithin the body of aforloop. By using awhileloop instead, the iteration logic is expected to be more complex, and modifyingiinside the loop body is acceptable and idiomatic.csharpsquid:S927 - Rename parameter 'elementId' to 'elementid' to match the interface declaration. • CRITICAL • View issue
Location:
src/Infrastructure.VS/DocumentEvents/ActiveDocumentTracker.cs:96Why is this an issue?
Parameters are part of the method signature and its identity.
What changed
This hunk renames all three parameters of the
OnElementValueChangedmethod to match the interface declaration ofIVsSelectionEvents. It renameselementIdtoelementid(fixing the parameter name mismatch where the interface declareselementid),oldValuetovarValueOld(fixing the parameter name mismatch where the interface declaresvarValueOld), andnewValuetovarValueNew(fixing the parameter name mismatch where the interface declaresvarValueNew). All three parameter names now match the interface's declared parameter names, resolving all three S927 warnings about mismatched parameter names.csharpsquid:S927 - Rename parameter 'oldValue' to 'varValueOld' to match the interface declaration. • CRITICAL • View issue
Location:
src/Infrastructure.VS/DocumentEvents/ActiveDocumentTracker.cs:96Why is this an issue?
Parameters are part of the method signature and its identity.
What changed
This hunk renames all three parameters of the
OnElementValueChangedmethod to match the interface declaration ofIVsSelectionEvents. It renameselementIdtoelementid(fixing the parameter name mismatch where the interface declareselementid),oldValuetovarValueOld(fixing the parameter name mismatch where the interface declaresvarValueOld), andnewValuetovarValueNew(fixing the parameter name mismatch where the interface declaresvarValueNew). All three parameter names now match the interface's declared parameter names, resolving all three S927 warnings about mismatched parameter names.csharpsquid:S927 - Rename parameter 'newValue' to 'varValueNew' to match the interface declaration. • CRITICAL • View issue
Location:
src/Infrastructure.VS/DocumentEvents/ActiveDocumentTracker.cs:96Why is this an issue?
Parameters are part of the method signature and its identity.
What changed
This hunk renames all three parameters of the
OnElementValueChangedmethod to match the interface declaration ofIVsSelectionEvents. It renameselementIdtoelementid(fixing the parameter name mismatch where the interface declareselementid),oldValuetovarValueOld(fixing the parameter name mismatch where the interface declaresvarValueOld), andnewValuetovarValueNew(fixing the parameter name mismatch where the interface declaresvarValueNew). All three parameter names now match the interface's declared parameter names, resolving all three S927 warnings about mismatched parameter names.SonarQube Remediation Agent uses AI. Check for mistakes.