Skip to content

Remove unnecessary String.raw usage from shell fragments#521

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260629-050105-a0ab799e
Open

Remove unnecessary String.raw usage from shell fragments#521
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260629-050105-a0ab799e

Conversation

@sonarqube-agent

Copy link
Copy Markdown
Contributor

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Why these issues? Both issues are instances of the same SonarQube rule (typescript:S7780) applied to related shell-fragment files, representing a straightforward and safe cleanup. The fix is highly automatable with minimal risk, and grouping these similar issues together creates a coherent, focused change that improves code clarity.

This change removes redundant String.raw tags from two shell-fragment files where the template strings contain no backslash characters. String.raw is only necessary when a string contains backslashes that need to be preserved literally; removing it from these strings eliminates unnecessary code and resolves SonarQube code smell warnings.

View Project in SonarCloud


Fixed Issues

typescript:S7780 - Using `String.raw` is unnecessary as the string does not contain any `\`. • MINORView issue

Location: src/cli/commands/integrate/git/tools/husky/shell-fragments.ts:44

Why 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

This hunk replaces String.raw template literal usage with a plain string literal. The static analysis warning flagged that String.raw was unnecessary on line 44 because the string 'SONAR_BIN=$(PATH=$CLEAN_PATH command -v sonar 2>/dev/null || :)' does not contain any backslash characters, making the String.raw tag redundant. By converting it to a simple quoted string, the unnecessary String.raw usage is removed.

--- a/src/cli/commands/integrate/git/tools/husky/shell-fragments.ts
+++ b/src/cli/commands/integrate/git/tools/husky/shell-fragments.ts
@@ -44,1 +44,1 @@ function huskyBinBlock(): string {
-    String.raw`SONAR_BIN=$(PATH=$CLEAN_PATH command -v sonar 2>/dev/null || :)`,
+    'SONAR_BIN=$(PATH=$CLEAN_PATH command -v sonar 2>/dev/null || :)',
typescript:S7780 - Using `String.raw` is unnecessary as the string does not contain any `\`. • MINORView issue

Location: src/cli/commands/integrate/git/tools/native/shell-fragments.ts:47

Why 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

This hunk removes the unnecessary String.raw tag from a template literal that does not contain any backslash characters. The string SONAR_BIN=$(command -v sonar 2>/dev/null || :) has no backslashes, so wrapping it in String.raw serves no purpose and triggers a code smell warning. By converting it from String.raw...`` to a plain template literal (backtick string), the unnecessary usage of String.raw is eliminated, making the code cleaner and resolving the static analysis warning.

--- a/src/cli/commands/integrate/git/tools/native/shell-fragments.ts
+++ b/src/cli/commands/integrate/git/tools/native/shell-fragments.ts
@@ -47,1 +47,1 @@ function nativeBinBlock(): string {
-    String.raw`SONAR_BIN=$(command -v sonar 2>/dev/null || :)`,
+    `SONAR_BIN=$(command -v sonar 2>/dev/null || :)`,

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZ7wF1S9I9TVtwnJfdRg for typescript:S7780 rule
- AZ7wF1UnI9TVtwnJfdRh for typescript:S7780 rule

Generated by SonarQube Agent (task: c3035933-50ce-45be-89bf-50d2c834f6ef)
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for sonarqube-cli canceled.

Name Link
🔨 Latest commit bb347a3
🔍 Latest deploy log https://app.netlify.com/projects/sonarqube-cli/deploys/6a41fcca1bb7ae0008e17c90

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.

1 participant