Remove unnecessary String.raw tags from template literals - #7731
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Remove unnecessary String.raw tags from template literals#7731sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZ7yEvPohshm9reY56At for typescript:S7780 rule - AZ7yEvPohshm9reY56Au for typescript:S7780 rule - AZ7yEvPohshm9reY56Av for typescript:S7780 rule - AZ7yEvPohshm9reY56Aw for typescript:S7780 rule - AZ7yEvPohshm9reY56Ax for typescript:S7780 rule Generated by SonarQube Agent (task: e426fe3a-df44-48de-aa61-bf796dee5842)
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 5 SonarQube code smells in locations.ts by removing unnecessary String.raw tags from template literals that don't contain backslash characters. String.raw is only needed when a string contains literal backslashes that require escaping, so removing it from these regex pattern strings simplifies the code without changing behavior.
View Project in SonarCloud
Fixed Issues
typescript:S7780 - Using `String.raw` is unnecessary as the string does not contain any `\`. • MINOR • View issue
Location:
packages/analysis/tests/jsts/tools/testers/comment-based/helpers/locations.ts:28Why is this an issue?
String literals with escaped backslashes can be difficult to read and maintain. Each backslash character must be escaped with another backslash, creating sequences like
\\that are hard to interpret at a glance.What changed
Removes the unnecessary
String.rawtag from the template literal*(?:on line 33. This string contains no backslash characters, soString.rawis not needed. Replacing it with a regular string fixes the code smell.typescript:S7780 - Using `String.raw` is unnecessary as the string does not contain any `\`. • MINOR • View issue
Location:
packages/analysis/tests/jsts/tools/testers/comment-based/helpers/locations.ts:33Why is this an issue?
String literals with escaped backslashes can be difficult to read and maintain. Each backslash character must be escaped with another backslash, creating sequences like
\\that are hard to interpret at a glance.What changed
Removes the unnecessary
String.rawtag from the template literal|on line 35. Since the pipe character does not involve any backslash escaping,String.rawis unnecessary here. Using a plain string resolves the warning.typescript:S7780 - Using `String.raw` is unnecessary as the string does not contain any `\`. • MINOR • View issue
Location:
packages/analysis/tests/jsts/tools/testers/comment-based/helpers/locations.ts:35Why is this an issue?
String literals with escaped backslashes can be difficult to read and maintain. Each backslash character must be escaped with another backslash, creating sequences like
\\that are hard to interpret at a glance.What changed
Removes the unnecessary
String.rawtag from the template literal)?on line 37. This string has no backslash characters, makingString.rawredundant. Switching to a regular string eliminates the code smell.typescript:S7780 - Using `String.raw` is unnecessary as the string does not contain any `\`. • MINOR • View issue 1
typescript:S7780 - Using `String.raw` is unnecessary as the string does not contain any `\`. • MINOR • View issue 2
Location:
packages/analysis/tests/jsts/tools/testers/comment-based/helpers/locations.ts:37Why is this an issue?
String literals with escaped backslashes can be difficult to read and maintain. Each backslash character must be escaped with another backslash, creating sequences like
\\that are hard to interpret at a glance.What changed
Removes the unnecessary
String.rawtag from the template literal(?<message>${MESSAGE_CONTENT})on line 40. This string contains no literal backslash characters — the${MESSAGE_CONTENT}is a template interpolation, not an escape sequence. UsingString.rawhere is unnecessary and flagged as a code smell. Additionally, this fixes the related warning about the unnecessaryString.rawusage with(?<on the same line, since the named capture group syntax(?<message>...)does not contain backslashes either. Switching to a plain template literal resolves both warnings.SonarQube Remediation Agent uses AI. Check for mistakes.