Skip to content

Commit 4182984

Browse files
committed
refactor(lint): clear shellcheck and regexp findings ahead of enabling the rules (#9586)
* ci(workflows): quote shell expansions in workflow steps Unquoted expansions split on whitespace, so a runner path, a packed filename, or a version string containing a space becomes two words. `rm -rf *` additionally hands any dash-prefixed filename to `rm` as an option. The redundant `exit` in the actionlint summary step goes too: `fail-on-error` already fails the job, and the step only runs once the exit code is nonzero, so the extra `exit` could only pass a value outside 0-255 back to the shell. * refactor(regexp): drop no-op flags, groups, and escapes The removed pieces cannot affect which strings match: `m` needs an anchor, `i` needs a letter, a non-capturing group around a whole pattern or a single alternative adds nothing, `.*` padding inside a lookahead reached only through `test()` is unreachable work, a lazy quantifier immediately before `$` has one possible length, and `{` / `]` are literals either way. The URL segment matcher gains a case for the 20-character `{param:str}` threshold, which nothing pinned. * refactor(regexp): match delimiters without repeated rescanning Each of these matchers walks the same characters again for every start position the engine tries, on values whose length is set by whatever produced them. The replacements examine each character once. 1. Trailing-delimiter trims (`kebabcase` dashes, the cypress source-map query strip) drop their quantifiers. 2. `stripColonWhitespace` and `splitHeader` split once and trim each part. `splitHeader` now also trims the first and last entry, which the previous pattern left alone. 3. The telemetry stack-frame filter bounds its indent to spaces and tabs, so a frame can no longer be matched starting from an earlier line. 4. The `@fast-check/jest` seed suffix and the cucumber attempt suffix bound their separator to the single space each library emits.
1 parent 9360892 commit 4182984

32 files changed

Lines changed: 149 additions & 71 deletions

File tree

.github/workflows/flakiness.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
- run: node scripts/flakiness.mjs
5050
env:
5151
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
52-
- run: cat flakiness.md >> $GITHUB_STEP_SUMMARY
52+
- run: cat flakiness.md >> "$GITHUB_STEP_SUMMARY"
5353
- id: slack
54-
run: echo "report=$(cat flakiness.txt)" >> $GITHUB_OUTPUT
54+
run: echo "report=$(cat flakiness.txt)" >> "$GITHUB_OUTPUT"
5555
- uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v2.1.0
5656
if: github.event_name == 'schedule'
5757
with:

.github/workflows/mirror-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
REPOSITORY: ${{ github.repository }}
4141
run: |
4242
GHCR_TARGET="$(echo "ghcr.io/${REPOSITORY}/${IMAGE}" | tr '[:upper:]' '[:lower:]')"
43-
echo "GHCR_TARGET=${GHCR_TARGET}" >> $GITHUB_ENV
43+
echo "GHCR_TARGET=${GHCR_TARGET}" >> "$GITHUB_ENV"
4444
4545
- name: Mirror manifest to GHCR
4646
env:

.github/workflows/platform.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5757
- uses: ./.github/actions/node/active-lts
5858
- uses: ./.github/actions/install
59-
- run: FILENAME=$(npm pack --silent --pack-destination /tmp) && mv /tmp/$FILENAME /tmp/dd-trace.tgz
59+
- run: FILENAME=$(npm pack --silent --pack-destination /tmp) && mv "/tmp/$FILENAME" /tmp/dd-trace.tgz
6060
- run: mkdir -p /tmp/app
6161
- run: npm i -g pnpm
6262
if: matrix.manager.name == 'pnpm'
@@ -71,7 +71,7 @@ jobs:
7171
- uses: ./.github/actions/node/active-lts
7272
- uses: ./.github/actions/install
7373
- run: mkdir npm bun
74-
- run: FILENAME=$(npm pack --silent) && tar -zxf $FILENAME -C npm
74+
- run: FILENAME=$(npm pack --silent) && tar -zxf "$FILENAME" -C npm
7575
- run: ./node_modules/.bin/bun pm pack --gzip-level 0 --filename bun.tgz && tar -zxf bun.tgz -C bun
7676
- run: diff -r npm bun
7777

.github/workflows/project.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
echo "actionlint found ${{ steps.actionlint.outputs.total-errors }} errors"
3535
echo "actionlint checked ${{ steps.actionlint.outputs.total-files }} files"
3636
echo "actionlint cache used: ${{ steps.actionlint.outputs.cache-hit }}"
37-
exit ${{ steps.actionlint.outputs.exit-code }}
3837
3938
lint:
4039
runs-on: ubuntu-latest
@@ -48,7 +47,7 @@ jobs:
4847
runs-on: ubuntu-latest
4948
steps:
5049
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
51-
- run: docker build -q -t ec .github/editorconfig-checker && docker run --rm --volume=$PWD:/check ec
50+
- run: docker build -q -t ec .github/editorconfig-checker && docker run --rm --volume="$PWD":/check ec
5251

5352
release-scripts:
5453
runs-on: ubuntu-latest
@@ -96,9 +95,9 @@ jobs:
9695
policy: package-size-report
9796
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
9897
- uses: ./.github/actions/node/latest
99-
- run: FILENAME=$(npm pack --silent --pack-destination /tmp) && mv /tmp/$FILENAME /tmp/dd-trace.tgz
100-
- run: rm -rf *
101-
- run: tar -zxf /tmp/dd-trace.tgz -C $(pwd) --strip-components=1
98+
- run: FILENAME=$(npm pack --silent --pack-destination /tmp) && mv /tmp/"$FILENAME" /tmp/dd-trace.tgz
99+
- run: rm -rf ./*
100+
- run: tar -zxf /tmp/dd-trace.tgz -C "$(pwd)" --strip-components=1
102101
- run: yarn --prod --ignore-optional
103102
- run: ls -lisa
104103
- name: Compute module size tree and report
@@ -174,7 +173,7 @@ jobs:
174173
set -euo pipefail
175174
176175
if git diff --quiet; then
177-
echo "has_changes=false" >> $GITHUB_OUTPUT
176+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
178177
exit 0
179178
fi
180179
@@ -211,7 +210,7 @@ jobs:
211210
fi
212211
213212
cp yarn.lock "${RUNNER_TEMP}/yarn.lock"
214-
echo "has_changes=true" >> $GITHUB_OUTPUT
213+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
215214
216215
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
217216
if: steps.diff.outputs.has_changes == 'true'

.github/workflows/release.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ jobs:
8787
registry-url: https://registry.npmjs.org
8888
- id: pkg
8989
run: |
90-
content=`cat ./package.json | tr '\n' ' '`
91-
echo "json=$content" >> $GITHUB_OUTPUT
90+
content=$(tr '\n' ' ' < ./package.json)
91+
echo "json=$content" >> "$GITHUB_OUTPUT"
9292
- name: Publish
9393
run: |
9494
version="${{ fromJson(steps.pkg.outputs.json).version }}"
@@ -159,8 +159,8 @@ jobs:
159159
- uses: ./.github/actions/node
160160
- id: pkg
161161
run: |
162-
content=`cat ./package.json | tr '\n' ' '`
163-
echo "json=$content" >> $GITHUB_OUTPUT
162+
content=$(tr '\n' ' ' < ./package.json)
163+
echo "json=$content" >> "$GITHUB_OUTPUT"
164164
- run: yarn
165165
- name: Build
166166
working-directory: docs
@@ -173,7 +173,7 @@ jobs:
173173
ref: gh-pages
174174
- name: Deploy
175175
run: |
176-
rm -rf *
176+
rm -rf ./*
177177
mv /tmp/out/* .
178178
git config user.name github-actions
179179
git config user.email github-actions@github.com
@@ -205,9 +205,9 @@ jobs:
205205
- uses: ./.github/actions/install
206206
- id: pkg
207207
run: |
208-
content=`cat ./package.json | tr '\n' ' '`
209-
echo "json=$content" >> $GITHUB_OUTPUT
210-
- run: npm version --no-git-tag-version ${{ fromJson(steps.pkg.outputs.json).version }}-$(git rev-parse --short HEAD)+${{ github.run_id }}.${{ github.run_attempt }}
208+
content=$(tr '\n' ' ' < ./package.json)
209+
echo "json=$content" >> "$GITHUB_OUTPUT"
210+
- run: npm version --no-git-tag-version "${{ fromJson(steps.pkg.outputs.json).version }}-$(git rev-parse --short HEAD)+${{ github.run_id }}.${{ github.run_attempt }}"
211211
- run: npm publish --tag dev
212212
- run: |
213213
git tag --force dev
@@ -233,7 +233,7 @@ jobs:
233233
- uses: ./.github/actions/install
234234
- id: pkg
235235
run: |
236-
content=`cat ./package.json | tr '\n' ' '`
237-
echo "json=$content" >> $GITHUB_OUTPUT
238-
- run: npm version --no-git-tag-version ${{ fromJson(steps.pkg.outputs.json).version }}-$(git rev-parse --short HEAD)+${{ github.run_id }}.${{ github.run_attempt }}
236+
content=$(tr '\n' ' ' < ./package.json)
237+
echo "json=$content" >> "$GITHUB_OUTPUT"
238+
- run: npm version --no-git-tag-version "${{ fromJson(steps.pkg.outputs.json).version }}-$(git rev-parse --short HEAD)+${{ github.run_id }}.${{ github.run_attempt }}"
239239
- run: node scripts/release/publish-electron.js --tag dev

.github/workflows/system-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
path: dd-trace-js
2424
- name: Pack dd-trace-js
25-
run: mkdir -p ./binaries && echo /binaries/$(npm pack --silent --pack-destination ./binaries ./dd-trace-js) > ./binaries/nodejs-load-from-npm
25+
run: mkdir -p ./binaries && echo "/binaries/$(npm pack --silent --pack-destination ./binaries ./dd-trace-js)" > ./binaries/nodejs-load-from-npm
2626
- name: Upload artifact
2727
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
2828
with:

.github/workflows/test-optimization.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
versions.getLatestPlaywrightSpecifier() === 'latest' \
6262
? versions.latest \
6363
: versions.latestSupportedByNode18")
64-
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
64+
echo "version=$PLAYWRIGHT_VERSION" >> "$GITHUB_OUTPUT"
6565
echo "Playwright version: $PLAYWRIGHT_VERSION"
6666
- name: Cache Playwright browsers
6767
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
@@ -117,9 +117,11 @@ jobs:
117117
IMAGE_TAG="$OLDEST_TAG"
118118
;;
119119
esac
120-
echo "images=$IMAGES" >> $GITHUB_OUTPUT
121-
echo "pw-version=$PW_VERSION" >> $GITHUB_OUTPUT
122-
echo "image-tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
120+
{
121+
echo "images=$IMAGES"
122+
echo "pw-version=$PW_VERSION"
123+
echo "image-tag=$IMAGE_TAG"
124+
} >> "$GITHUB_OUTPUT"
123125
- name: Log in to GHCR
124126
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
125127
with:
@@ -352,7 +354,7 @@ jobs:
352354
run: |
353355
DOCKER_HASH=$(sha256sum .github/selenium/Dockerfile | cut -c1-8)
354356
IMAGE="ghcr.io/datadog/dd-trace-js/selenium-tools:${DOCKER_HASH}"
355-
echo "image=$IMAGE" >> $GITHUB_OUTPUT
357+
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
356358
- name: Log in to GHCR
357359
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
358360
with:
@@ -472,7 +474,7 @@ jobs:
472474
else
473475
RESOLVED="${{ matrix.cypress-version }}"
474476
fi
475-
echo "resolved=$RESOLVED" >> $GITHUB_OUTPUT
477+
echo "resolved=$RESOLVED" >> "$GITHUB_OUTPUT"
476478
- name: Cache Cypress binary
477479
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
478480
with:

.github/workflows/update-3rdparty-licenses.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ jobs:
9090
run: |
9191
set -e
9292
93-
echo "head_oid=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
93+
echo "head_oid=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
9494
9595
if git diff --ignore-space-at-eol --exit-code LICENSE-3rdparty.csv; then
9696
echo "✅ LICENSE-3rdparty.csv is already up to date"
97-
echo "needs_update=false" >> $GITHUB_OUTPUT
97+
echo "needs_update=false" >> "$GITHUB_OUTPUT"
9898
else
9999
echo "📝 LICENSE-3rdparty.csv was modified by license attribution command"
100-
echo "needs_update=true" >> $GITHUB_OUTPUT
100+
echo "needs_update=true" >> "$GITHUB_OUTPUT"
101101
fi
102102
103103
if [[ "$PR_USER_TYPE" == "Bot" ]] && [[ "$PR_HEAD_REPO" == "$BASE_REPO" ]]; then
104-
echo "is_bot_same_repo=true" >> $GITHUB_OUTPUT
104+
echo "is_bot_same_repo=true" >> "$GITHUB_OUTPUT"
105105
else
106-
echo "is_bot_same_repo=false" >> $GITHUB_OUTPUT
106+
echo "is_bot_same_repo=false" >> "$GITHUB_OUTPUT"
107107
fi
108108
109109
# Release proposal branches are built by cherry-picking master onto a release
@@ -113,9 +113,9 @@ jobs:
113113
# fail loudly instead — the license CSV is already correct on master and should
114114
# never need attribution work done directly on a proposal branch.
115115
if [[ "$HEAD_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-proposal$ ]]; then
116-
echo "is_release_proposal=true" >> $GITHUB_OUTPUT
116+
echo "is_release_proposal=true" >> "$GITHUB_OUTPUT"
117117
else
118-
echo "is_release_proposal=false" >> $GITHUB_OUTPUT
118+
echo "is_release_proposal=false" >> "$GITHUB_OUTPUT"
119119
fi
120120
121121
- name: Upload updated LICENSE-3rdparty.csv

integration-tests/esbuild/index.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ esbuildVersions.forEach((version) => {
145145
})
146146

147147
const builtFile = readFileSync('./out.mjs').toString()
148-
assert.match(builtFile, /\/\* js test \*\//m)
148+
assert.match(builtFile, /\/\* js test \*\//)
149149
})
150150

151151
it('should contain the definitions when esm is inferred from outfile', () => {
@@ -154,7 +154,7 @@ esbuildVersions.forEach((version) => {
154154
})
155155

156156
const builtFile = readFileSync('./out.mjs').toString()
157-
assert.match(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/m)
157+
assert.match(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/)
158158
})
159159

160160
it('should contain the definitions when esm is inferred from format', () => {
@@ -163,7 +163,7 @@ esbuildVersions.forEach((version) => {
163163
})
164164

165165
const builtFile = readFileSync('./out.mjs').toString()
166-
assert.match(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/m)
166+
assert.match(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/)
167167
})
168168

169169
it('should contain the definitions when format is inferred from out extension', () => {
@@ -172,7 +172,7 @@ esbuildVersions.forEach((version) => {
172172
})
173173

174174
const builtFile = readFileSync('./basic-test.mjs').toString()
175-
assert.match(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/m)
175+
assert.match(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/)
176176
})
177177

178178
it('should not contain the definitions when no esm is specified', () => {
@@ -181,7 +181,7 @@ esbuildVersions.forEach((version) => {
181181
})
182182

183183
const builtFile = readFileSync('./out.js').toString()
184-
assert.doesNotMatch(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/m)
184+
assert.doesNotMatch(builtFile, /globalThis\.__filename \?\?= \$dd_fileURLToPath\(import\.meta\.url\);/)
185185
})
186186

187187
it('should not crash when it is already patched using global', () => {

integration-tests/package-guardrails.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ addHook({ name: 'bluebird', versions: ['*'] }, Promise => {
136136
log => {
137137
assert.match(
138138
log,
139-
/\nError during ddtrace instrumentation of application, aborting.\nReferenceError: this is a test error\n {4}at /m
139+
/\nError during ddtrace instrumentation of application, aborting.\nReferenceError: this is a test error\n {4}at /
140140
)
141141
assert.match(log, /\nfalse\n/)
142142
}, []))

0 commit comments

Comments
 (0)