SLVS-2964 fix: resolve 5 SonarQube code quality issues - #6729
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
SLVS-2964 fix: resolve 5 SonarQube code quality issues#6729sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZFqcxYr7Cab0JIMjah2 for csharpsquid:S2325 rule - AWMB0jMNmtQEh111EJCt for csharpsquid:S1168 rule - AZC2zPMC3yATU8exn0Z2 for csharpsquid:S2589 rule - AYqIsIc9RlgCy-_ohqpM for csharpsquid:S2589 rule - AZFqcxBW7Cab0JIMjahj for csharpsquid:S2325 rule Generated by SonarQube Agent (task: ef450648-78d7-4bd0-8bc9-1228593e4023)
|
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.



Fixed multiple code quality violations including making three methods static to clarify independence from instance state, removing unnecessary null checks on guaranteed non-null values, and replacing a null return with an empty collection. These changes improve code clarity, performance, and maintainability while eliminating false positive warnings.
View Project in SonarCloud
Fixed Issues
csharpsquid:S2325 - Make 'ShouldHideIssue' a static method. • MINOR • View issue
Location:
src/Integration.Vsix/ErrorList/IssuesSnapshot.cs:262Why is this an issue?
Methods and properties that don’t access instance data should be marked as
staticfor the following reasons:What changed
This hunk adds the
statickeyword to theShouldHideIssuemethod. The static analysis rule flagged this method because it does not access any instance data, meaning it can and should be marked asstatic. Adding thestaticmodifier clarifies that the method is independent of instance state, avoids the overhead of passing an implicitthisreference, and improves readability and testability.csharpsquid:S2325 - Make 'Convert' a static method. • MINOR • View issue
Location:
src/IssueViz/Models/AnalysisIssueVisualizationConverter.cs:100Why is this an issue?
Methods and properties that don’t access instance data should be marked as
staticfor the following reasons:What changed
This hunk adds the 'static' modifier to the Convert method that takes IEnumerable as a parameter at line 100. The static analysis flagged this method because it does not access any instance data and should be marked as static. Adding the 'static' keyword makes it clear that the method doesn't depend on instance state, avoids the overhead of passing an instance reference, and directly resolves the code smell warning.
csharpsquid:S2589 - Remove this unnecessary check for null. • MAJOR • View issue
Location:
src/Integration.Vsix/SonarLintTagger/CancellableJobRunner.cs:163Why is this an issue?
Control flow constructs like
if-statements allow the programmer to direct the flow of a program depending on a boolean expression. However, if the condition is always true or always false, only one of the branches will ever be executed. In that case, the control flow construct and the condition no longer serve a purpose; they become gratuitous.What changed
Removes the unnecessary null-conditional operator (
?.) oncancellationSource.Dispose()at line 163. The static analyzer determined thatcancellationSourcecan never be null at this point in the code, making the null check gratuitous. ReplacingcancellationSource?.Dispose()withcancellationSource.Dispose()eliminates the unnecessary null check and resolves the code smell.csharpsquid:S2589 - Remove this unnecessary check for null. • MAJOR • View issue
Location:
src/Integration.Vsix/SonarLintTagger/CancellableJobRunner.cs:177Why is this an issue?
Control flow constructs like
if-statements allow the programmer to direct the flow of a program depending on a boolean expression. However, if the condition is always true or always false, only one of the branches will ever be executed. In that case, the control flow construct and the condition no longer serve a purpose; they become gratuitous.What changed
Removes the unnecessary null-conditional operator (
?.) oncancellationSource.Cancel()at line 177. The static analyzer determined thatcancellationSourcecan never be null at this point in the code, making the null check gratuitous. ReplacingcancellationSource?.Cancel()withcancellationSource.Cancel()eliminates the unnecessary null check and resolves the code smell.csharpsquid:S1168 - Return an empty collection instead of null. • MAJOR • View issue
Location:
src/Integration/WPF/NotifyErrorViewModelBase.cs:43Why is this an issue?
Returning
nullordefaultinstead of an actual collection forces the method callers to explicitly test for null, making the code more complex and less readable.What changed
Adds the
using System.Linqimport, which is required to useEnumerable.Empty<string>()in the fix that replaces thereturn nullstatement. Without this import, theEnumerableclass would not be available.SonarQube Remediation Agent uses AI. Check for mistakes.