Skip to content

Fix remaining SonarCloud findings#1823

Merged
firecow merged 4 commits intomasterfrom
fix/sonarcloud-remaining-smells
Apr 3, 2026
Merged

Fix remaining SonarCloud findings#1823
firecow merged 4 commits intomasterfrom
fix/sonarcloud-remaining-smells

Conversation

@firecow
Copy link
Copy Markdown
Owner

@firecow firecow commented Apr 3, 2026

  • Remove nested template literals in docker env var escaping (S4624)
  • Fix Promise.any receiving non-Promise values (S4123)
  • Replace regex patterns with string literals in parser-includes (S7781)
  • Replace deprecated tseslint.config() with flat array export (S1874)
  • Fix eslint ignore pattern for .gitlab-ci-local directories

- Remove nested template literals in docker env var escaping
- Fix Promise.any receiving non-Promise values (filter before map)
- Replace regex patterns with string literals in parser-includes
- Replace deprecated tseslint.config() with flat array export
@firecow firecow self-assigned this Apr 3, 2026
- Remove nested template literals in docker env var escaping (S4624)
- Fix Promise.any receiving non-Promise values (S4123)
- Replace regex patterns with string literals in parser-includes (S7781)
- Replace deprecated tseslint.config() with flat array export (S1874)
- Fix eslint ignore pattern for .gitlab-ci-local directories
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

- Use node: prefixed imports for assert and path across all source files
- Replace String#replace with String#replaceAll where appropriate
- Use String.raw for backslash escaping
- Use Array.isArray() instead of instanceof Array
- Use .at(-1) instead of [length - 1]
- Use new Error() instead of Error()
- Flip negated conditions
- Compare with undefined directly instead of typeof
- Combine multiple Array#push calls into single calls
- Inline Promise.all arrays instead of separate push calls
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 14 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/variables-from-files.ts">

<violation number="1" location="src/variables-from-files.ts:75">
P2: Escape regex metacharacters in `matcher` before converting `*` to `.*`; current construction can mis-match scopes or throw on invalid patterns.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

assert(typeof content == "string", `${key}.${matcher} content must be text or multiline text`);
if (isDotEnv || type === "variable" || (type === null && !/^[/~]/.exec(content))) {
const regexp = matcher === "*" ? /.*/g : new RegExp(`^${matcher.replace(/\*/g, ".*")}$`, "g");
const regexp = matcher === "*" ? /.*/g : new RegExp(`^${matcher.replaceAll("*", ".*")}$`, "g");
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Escape regex metacharacters in matcher before converting * to .*; current construction can mis-match scopes or throw on invalid patterns.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/variables-from-files.ts, line 75:

<comment>Escape regex metacharacters in `matcher` before converting `*` to `.*`; current construction can mis-match scopes or throw on invalid patterns.</comment>

<file context>
@@ -72,20 +72,20 @@ export class VariablesFromFiles {
                 assert(typeof content == "string", `${key}.${matcher} content must be text or multiline text`);
                 if (isDotEnv || type === "variable" || (type === null && !/^[/~]/.exec(content))) {
-                    const regexp = matcher === "*" ? /.*/g : new RegExp(`^${matcher.replace(/\*/g, ".*")}$`, "g");
+                    const regexp = matcher === "*" ? /.*/g : new RegExp(`^${matcher.replaceAll("*", ".*")}$`, "g");
                     variables[key] = variables[key] ?? {type: "variable", environments: []};
                     variables[key].environments.push({content, regexp, regexpPriority: matcher.length, scopePriority});
</file context>
Fix with Cubic

Extract String.raw expressions into variables to avoid nested
template literals while still satisfying the String.raw rule.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

@firecow firecow merged commit e590d11 into master Apr 3, 2026
16 checks passed
@firecow firecow deleted the fix/sonarcloud-remaining-smells branch April 3, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant