Skip to content

Fix remaining SonarCloud findings - #1823

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

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

Conversation

@firecow

@firecow firecow commented Apr 3, 2026

Copy link
Copy Markdown
Owner
  • 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

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

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
Contributor

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");

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

Copy link
Copy Markdown
Contributor

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

sonarqubecloud Bot commented Apr 3, 2026

Copy link
Copy Markdown

@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
kevingerman pushed a commit to kevingerman/gitlab-ci-local that referenced this pull request Apr 10, 2026
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 7, 2026
This MR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Adoption](https://docs.renovatebot.com/merge-confidence/) | [Passing](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|---|---|
| [npm:gitlab-ci-local](https://github.com/firecow/gitlab-ci-local) | `4.70.1` → `4.71.0` | ![age](https://developer.mend.io/api/mc/badges/age/npm/gitlab-ci-local/4.71.0?slim=true) | ![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/gitlab-ci-local/4.71.0?slim=true) | ![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/gitlab-ci-local/4.70.1/4.71.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/gitlab-ci-local/4.70.1/4.71.0?slim=true) |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>firecow/gitlab-ci-local (npm:gitlab-ci-local)</summary>

### [`v4.71.0`](https://github.com/firecow/gitlab-ci-local/releases/tag/4.71.0)

[Compare Source](firecow/gitlab-ci-local@4.70.1...4.71.0)

#### What's Changed

- Fix remaining SonarCloud findings by [@&#8203;firecow](https://github.com/firecow) in [#&#8203;1823](firecow/gitlab-ci-local#1823)
- fix(windows): skip id -u on Windows to avoid confusing startup error by [@&#8203;bcouetil](https://github.com/bcouetil) in [#&#8203;1824](firecow/gitlab-ci-local#1824)
- fix: --completion outputs wrong script name when run via Bun by [@&#8203;Paul-Goulpie](https://github.com/Paul-Goulpie) in [#&#8203;1826](firecow/gitlab-ci-local#1826)
- feat: improve --list-csv and --list output by [@&#8203;bcouetil](https://github.com/bcouetil) in [#&#8203;1810](firecow/gitlab-ci-local#1810)
- chore(deps): update all non-major by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1830](firecow/gitlab-ci-local#1830)
- chore(deps): lock file maintenance by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1827](firecow/gitlab-ci-local#1827)
- fix(deps): update dependency re2js to v2 by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1828](firecow/gitlab-ci-local#1828)

#### New Contributors

- [@&#8203;Paul-Goulpie](https://github.com/Paul-Goulpie) made their first contribution in [#&#8203;1826](firecow/gitlab-ci-local#1826)

**Full Changelog**: <firecow/gitlab-ci-local@4.70.1...4.71.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMzkuMSIsInVwZGF0ZWRJblZlciI6IjQzLjE0MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
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