Skip to content

fix: replace nested if with else-if in difficulty selection pipe#23

Open
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260330-075801-c818927e
Open

fix: replace nested if with else-if in difficulty selection pipe#23
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260330-075801-c818927e

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Replaced a nested if statement that was the only statement in an else block with an else-if clause to improve code readability and follow SonarQube best practices. This eliminates unnecessary nesting and makes the control flow more straightforward.

View Project in SonarCloud


Fixed Issues

typescript:S6660 - 'If' statement should not be the only statement in 'else' block • MAJORView issue

Location: frontend/src/app/score-board/components/filter-settings/pipes/difficulty-selection-summary.pipe.ts:30

Why is this an issue?

When if is the only statement in the else block, it is better to use else if because it simplifies the code and makes it more readable.

What changed

This hunk introduces the 'else if' branch that replaces the nested 'if' inside the 'else' block. By adding '} else if (difficulty === currentGroup.end + 1) { currentGroup.end = difficulty' directly at the same level as the preceding 'if', it eliminates the pattern where an 'if' statement was the only statement inside an 'else' block, which was flagged as a code smell for reduced readability.

--- a/frontend/src/app/score-board/components/filter-settings/pipes/difficulty-selection-summary.pipe.ts
+++ b/frontend/src/app/score-board/components/filter-settings/pipes/difficulty-selection-summary.pipe.ts
@@ -28,0 +29,2 @@ function breakDifficultiesIntoNeighboringGroups (difficulties: Array<1 | 2 | 3 |
+    } else if (difficulty === currentGroup.end + 1) {
+      currentGroup.end = difficulty

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZWU-s_VYJSZqVQVbSbc for typescript:S6660 rule

Generated by SonarQube Agent (task: e6d5d42d-2586-49d5-81b4-952a38619d2d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants