fix: remove nested template literals in exposedMetricsChallenge_3_correct.ts#26
Open
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
Open
fix: remove nested template literals in exposedMetricsChallenge_3_correct.ts#26sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
Conversation
Fixed issues: - AZWU-tYxYJSZqVQVbSdV for typescript:S4624 rule Generated by SonarQube Agent (task: b01349c2-dd28-4008-8d48-a4ca06937306)
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.
Refactored nested template literals in exposedMetricsChallenge_3_correct.ts to improve code readability. Extracted the bold port formatting into a separate variable to eliminate the nested template literal pattern, resolving the SonarQube code smell issue and making the code easier to maintain.
View Project in SonarCloud
Fixed Issues
typescript:S4624 - Refactor this code to not use nested template literals. • MAJOR • View issue
Location:
data/static/codefixes/exposedMetricsChallenge_3_correct.ts:18Why is this an issue?
Template literals, also known as template strings, allow for string interpolation and multiline strings in JavaScript. They provide a more convenient and flexible way to work with strings compared to traditional string concatenation or manipulation.
What changed
This hunk directly fixes the nested template literal code smell reported at line 18 of exposedMetricsChallenge_3_correct.ts. The original code had
colors.bold(${port})nested insidecolors.cyan(Server listening on port ${...}), creating a hard-to-read nested template literal. By extractingcolors.bold(String(port))into a separate variableboldPortand then referencing it as${boldPort}in the outer template literal, the nesting is eliminated, improving readability and resolving the rule violation against nested template literals.SonarQube Remediation Agent uses AI. Check for mistakes.