Sonar: [[ ]] in scripts, npm install --ignore-scripts, retired local-dev setup out of scope (#373)

- **shell:S7688 (43)**: `[[ ]]` in place of `[ ]` in
`script/metrics/apply_{dashboards,metric_configs,monitors}.sh`,
`script/common/frontend_preflight.sh` and
`script/website/unix_frontend_dashboard_dev.sh`. Every script has a bash
shebang and `bash -n` passes. No test uses `-a`/`-o`, escaped
parentheses or an unquoted pattern on the right of `=`. The numeric
operands are `$#`, internal flags, exit codes, a parsed Node major
version and curl's status code, so `[[ ]]`'s arithmetic reading changes
nothing.
- **shell:S6505 (4)**: `npm install --ignore-scripts` in
`frontend_preflight.sh`, `unix_frontend_webapp_dev.sh` and
`frontend/build_modules.sh`. The frontend has no install scripts of its
own, and this repo's CI already builds with `npm ci --ignore-scripts`.
Same change as storytold/artcraft#2818.
- **Scope**: `_docs/old/**` joins `sonar.exclusions`. It's the retired
local-dev setup (an old Dockerfile, `kubernetes.yml`, nginx config) that
nothing references, and it held the docker and kubernetes findings under
`_docs/old/old_localdev_setup`.

Same as the other PRs here: not merged without the owner's go-ahead
(production service).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Chores**
* Frontend dependency installation now skips package-provided lifecycle
scripts, including during development setup. This changes which scripts
run during installation but does not change the frontend’s intended
features or behavior.
* Updated internal checks used by dashboard, metric, and monitor scripts
without changing their conditions or outcomes.
* Expanded static-analysis exclusions to include archived documentation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-11 07:34:01 -05:00
1 parent 3793e5edf8
commit d903ff2e2c
8 files changed
+47 -46

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ set -euxo pipefail
echo 'TEMPORARY HACK: Build shared frontend dependencies since nx is not finding them...'
# A 'clean' will remove nx
npm install
npm install --ignore-scripts
# TODO: Temp commented out
nx build "@storyteller/api"
+8 -8
View File
@@ -16,7 +16,7 @@ FRONTEND_MINIMUM_NODE_MAJOR=20
frontend_preflight() {
local frontend_path="$1"
if [ ! -d "${frontend_path}" ]; then
if [[ ! -d "${frontend_path}" ]]; then
echo "ERROR: frontend directory not found at: ${frontend_path}"
echo "Run this script from the repository root."
exit 1
@@ -40,7 +40,7 @@ frontend_preflight() {
# --- Node must be recent enough for Nx 21 / Vite 6 ---
local node_major
node_major=$(node --version | sed -E 's/^v([0-9]+).*/\1/')
if [ "${node_major}" -lt "${FRONTEND_MINIMUM_NODE_MAJOR}" ]; then
if [[ "${node_major}" -lt "${FRONTEND_MINIMUM_NODE_MAJOR}" ]]; then
echo "ERROR: Node.js ${FRONTEND_MINIMUM_NODE_MAJOR}+ is required (found $(node --version))."
echo "Upgrade via nvm ('nvm install --lts') or https://nodejs.org."
exit 1
@@ -50,13 +50,13 @@ frontend_preflight() {
# pnpm was briefly adopted ("add pnpm to solve build issues") and then dropped
# ("fix(frontend): consume video-editor libs via nx path aliases, drop pnpm").
# A node_modules tree written by pnpm makes npm fail with ENOTEMPTY errors.
if [ -e "${frontend_path}/pnpm-lock.yaml" ] \
|| [ -e "${frontend_path}/pnpm-workspace.yaml" ] \
|| [ -d "${frontend_path}/node_modules/.pnpm" ]; then
if [[ -e "${frontend_path}/pnpm-lock.yaml" ]] \
|| [[ -e "${frontend_path}/pnpm-workspace.yaml" ]] \
|| [[ -d "${frontend_path}/node_modules/.pnpm" ]]; then
echo "ERROR: Stale pnpm artifacts detected in ${frontend_path}."
echo "The frontend uses npm (pnpm was dropped; see frontend/README.md)."
echo "Clean up with:"
echo " cd ${frontend_path} && rm -rf node_modules pnpm-lock.yaml pnpm-workspace.yaml && npm install"
echo " cd ${frontend_path} && rm -rf node_modules pnpm-lock.yaml pnpm-workspace.yaml && npm install --ignore-scripts"
exit 1
fi
}
@@ -66,7 +66,7 @@ frontend_preflight() {
# layout causing ENOTEMPTY rename errors), wipe node_modules and the nx cache
# and retry once before giving up.
frontend_npm_install() {
if npm install; then
if npm install --ignore-scripts; then
return 0
fi
@@ -77,7 +77,7 @@ frontend_npm_install() {
rm -rf node_modules .nx
if ! npm install; then
if ! npm install --ignore-scripts; then
echo ""
echo "ERROR: npm install failed again. See the npm output above and the"
echo "troubleshooting section in frontend/README.md."
+11 -11
View File
@@ -40,7 +40,7 @@ APP_KEY_FILE="secrets/datadog_app_key.txt"
DRY_RUN=0
# -------- args --------
while [ $# -gt 0 ]; do
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--site) DD_SITE="$2"; shift 2 ;;
@@ -58,11 +58,11 @@ BASE="https://${DD_SITE}"
command -v jq >/dev/null 2>&1 || { echo "jq is required" >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "curl is required" >&2; exit 1; }
if [ ! -s "$API_KEY_FILE" ]; then
if [[ ! -s "$API_KEY_FILE" ]]; then
echo "missing or empty API key file: $API_KEY_FILE" >&2
exit 1
fi
if [ ! -s "$APP_KEY_FILE" ]; then
if [[ ! -s "$APP_KEY_FILE" ]]; then
cat >&2 <<EOF
Missing or empty application key file: $APP_KEY_FILE
@@ -77,7 +77,7 @@ fi
DD_API_KEY=$(tr -d '[:space:]' < "$API_KEY_FILE")
DD_APP_KEY=$(tr -d '[:space:]' < "$APP_KEY_FILE")
if [ ! -d "$DASH_DIR" ]; then
if [[ ! -d "$DASH_DIR" ]]; then
echo "no such directory: $DASH_DIR" >&2
exit 1
fi
@@ -87,7 +87,7 @@ shopt -s nullglob
# organized by category without changing this script.
files=()
while IFS= read -r f; do files+=("$f"); done < <(find "$DASH_DIR" -type f -name '*.json' | sort)
if [ ${#files[@]} -eq 0 ]; then
if [[ ${#files[@]} -eq 0 ]]; then
echo "no dashboard JSON files in $DASH_DIR" >&2
exit 0
fi
@@ -108,7 +108,7 @@ for file in "${files[@]}"; do
existing_id=$(jq -r '.id // empty' "$file")
if [ -n "$existing_id" ]; then
if [[ -n "$existing_id" ]]; then
method="PUT"
url="${BASE}/api/v1/dashboard/${existing_id}"
echo " updating existing dashboard id=${existing_id}"
@@ -118,7 +118,7 @@ for file in "${files[@]}"; do
echo " creating new dashboard"
fi
if [ "$DRY_RUN" -eq 1 ]; then
if [[ "$DRY_RUN" -eq 1 ]]; then
echo " [dry-run] would ${method} ${url}"
continue
fi
@@ -138,14 +138,14 @@ for file in "${files[@]}"; do
--data-binary "$payload" || echo "000")
echo "$curl_status" > "$http_status_file"
if [ "$curl_status" -lt 200 ] || [ "$curl_status" -ge 300 ]; then
if [[ "$curl_status" -lt 200 ]] || [[ "$curl_status" -ge 300 ]]; then
echo " ✗ HTTP $curl_status"
sed 's/^/ /' "$response_file" >&2
exit_code=1
else
if [ "$method" = "POST" ]; then
if [[ "$method" = "POST" ]]; then
new_id=$(jq -r '.id // empty' "$response_file")
if [ -n "$new_id" ]; then
if [[ -n "$new_id" ]]; then
tmp=$(mktemp)
jq --arg id "$new_id" '. + {id: $id}' "$file" > "$tmp" && mv "$tmp" "$file"
echo " ✓ created (id=${new_id}), id written back to $file"
@@ -163,7 +163,7 @@ for file in "${files[@]}"; do
done
echo
if [ "$exit_code" -eq 0 ]; then
if [[ "$exit_code" -eq 0 ]]; then
echo "All dashboards applied."
else
echo "Finished with errors. See output above."
+12 -12
View File
@@ -47,7 +47,7 @@ APP_KEY_FILE="secrets/datadog_app_key.txt"
DRY_RUN=0
# -------- args --------
while [ $# -gt 0 ]; do
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--site) DD_SITE="$2"; shift 2 ;;
@@ -65,11 +65,11 @@ BASE="https://${DD_SITE}"
command -v jq >/dev/null 2>&1 || { echo "jq is required" >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "curl is required" >&2; exit 1; }
if [ ! -s "$API_KEY_FILE" ]; then
if [[ ! -s "$API_KEY_FILE" ]]; then
echo "missing or empty API key file: $API_KEY_FILE" >&2
exit 1
fi
if [ ! -s "$APP_KEY_FILE" ]; then
if [[ ! -s "$APP_KEY_FILE" ]]; then
cat >&2 <<EOF
Missing or empty application key file: $APP_KEY_FILE
@@ -84,14 +84,14 @@ fi
DD_API_KEY=$(tr -d '[:space:]' < "$API_KEY_FILE")
DD_APP_KEY=$(tr -d '[:space:]' < "$APP_KEY_FILE")
if [ ! -d "$CFG_DIR" ]; then
if [[ ! -d "$CFG_DIR" ]]; then
echo "no such directory: $CFG_DIR" >&2
exit 1
fi
shopt -s nullglob
files=("$CFG_DIR"/*.json)
if [ ${#files[@]} -eq 0 ]; then
if [[ ${#files[@]} -eq 0 ]]; then
echo "no metric-config JSON files in $CFG_DIR" >&2
exit 0
fi
@@ -109,7 +109,7 @@ for file in "${files[@]}"; do
fi
metric_name=$(jq -r '.metric_name // empty' "$file")
if [ -z "$metric_name" ]; then
if [[ -z "$metric_name" ]]; then
echo " missing `metric_name`, skipping" >&2
exit_code=1
continue
@@ -153,7 +153,7 @@ for file in "${files[@]}"; do
}
}')
if [ "$DRY_RUN" -eq 1 ]; then
if [[ "$DRY_RUN" -eq 1 ]]; then
echo " [dry-run] would upsert tag config for $metric_name"
echo "$post_payload" | jq '.data.attributes'
continue
@@ -166,10 +166,10 @@ for file in "${files[@]}"; do
-H "DD-API-KEY: ${DD_API_KEY}" -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
|| echo "000")
if [ "$probe_status" = "200" ]; then
if [[ "$probe_status" = "200" ]]; then
method="PATCH"
echo " updating existing tag config (include_percentiles=$include_pct)"
elif [ "$probe_status" = "404" ]; then
elif [[ "$probe_status" = "404" ]]; then
method="POST"
echo " creating tag config (include_percentiles=$include_pct)"
else
@@ -182,7 +182,7 @@ for file in "${files[@]}"; do
rm -f "$probe_file"
payload="$post_payload"
[ "$method" = "PATCH" ] && payload="$patch_payload"
[[ "$method" = "PATCH" ]] && payload="$patch_payload"
response_file=$(mktemp)
curl_status=$(curl -sS -o "$response_file" -w "%{http_code}" \
@@ -192,7 +192,7 @@ for file in "${files[@]}"; do
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
--data-binary "$payload" || echo "000")
if [ "$curl_status" -lt 200 ] || [ "$curl_status" -ge 300 ]; then
if [[ "$curl_status" -lt 200 ]] || [[ "$curl_status" -ge 300 ]]; then
echo " ✗ ${method} returned HTTP $curl_status"
sed 's/^/ /' "$response_file" >&2
exit_code=1
@@ -203,7 +203,7 @@ for file in "${files[@]}"; do
done
echo
if [ "$exit_code" -eq 0 ]; then
if [[ "$exit_code" -eq 0 ]]; then
echo "All metric configs applied."
else
echo "Finished with errors. See output above."
+11 -11
View File
@@ -34,7 +34,7 @@ APP_KEY_FILE="secrets/datadog_app_key.txt"
DRY_RUN=0
# -------- args --------
while [ $# -gt 0 ]; do
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--site) DD_SITE="$2"; shift 2 ;;
@@ -52,11 +52,11 @@ BASE="https://${DD_SITE}"
command -v jq >/dev/null 2>&1 || { echo "jq is required" >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "curl is required" >&2; exit 1; }
if [ ! -s "$API_KEY_FILE" ]; then
if [[ ! -s "$API_KEY_FILE" ]]; then
echo "missing or empty API key file: $API_KEY_FILE" >&2
exit 1
fi
if [ ! -s "$APP_KEY_FILE" ]; then
if [[ ! -s "$APP_KEY_FILE" ]]; then
cat >&2 <<EOF
Missing or empty application key file: $APP_KEY_FILE
@@ -71,14 +71,14 @@ fi
DD_API_KEY=$(tr -d '[:space:]' < "$API_KEY_FILE")
DD_APP_KEY=$(tr -d '[:space:]' < "$APP_KEY_FILE")
if [ ! -d "$MON_DIR" ]; then
if [[ ! -d "$MON_DIR" ]]; then
echo "no such directory: $MON_DIR" >&2
exit 1
fi
shopt -s nullglob
files=("$MON_DIR"/*.json)
if [ ${#files[@]} -eq 0 ]; then
if [[ ${#files[@]} -eq 0 ]]; then
echo "no monitor JSON files in $MON_DIR" >&2
exit 0
fi
@@ -97,7 +97,7 @@ for file in "${files[@]}"; do
existing_id=$(jq -r '.id // empty' "$file")
if [ -n "$existing_id" ]; then
if [[ -n "$existing_id" ]]; then
method="PUT"
url="${BASE}/api/v1/monitor/${existing_id}"
echo " updating existing monitor id=${existing_id}"
@@ -107,7 +107,7 @@ for file in "${files[@]}"; do
echo " creating new monitor"
fi
if [ "$DRY_RUN" -eq 1 ]; then
if [[ "$DRY_RUN" -eq 1 ]]; then
echo " [dry-run] would ${method} ${url}"
continue
fi
@@ -122,15 +122,15 @@ for file in "${files[@]}"; do
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
--data-binary "$payload" || echo "000")
if [ "$curl_status" -lt 200 ] || [ "$curl_status" -ge 300 ]; then
if [[ "$curl_status" -lt 200 ]] || [[ "$curl_status" -ge 300 ]]; then
echo " ✗ HTTP $curl_status"
sed 's/^/ /' "$response_file" >&2
exit_code=1
else
if [ "$method" = "POST" ]; then
if [[ "$method" = "POST" ]]; then
# Monitor ids are integers; preserve type when writing back.
new_id=$(jq -r '.id // empty' "$response_file")
if [ -n "$new_id" ]; then
if [[ -n "$new_id" ]]; then
tmp=$(mktemp)
jq --argjson id "$new_id" '. + {id: $id}' "$file" > "$tmp" && mv "$tmp" "$file"
echo " ✓ created (id=${new_id}), id written back to $file"
@@ -148,7 +148,7 @@ for file in "${files[@]}"; do
done
echo
if [ "$exit_code" -eq 0 ]; then
if [[ "$exit_code" -eq 0 ]]; then
echo "All monitors applied."
else
echo "Finished with errors. See output above."
@@ -8,7 +8,7 @@
root_dir=$(pwd)
dashboard_path="${root_dir}/frontend/apps/artcraft-dashboard"
if [ ! -d "${dashboard_path}" ]; then
if [[ ! -d "${dashboard_path}" ]]; then
echo "ERROR: dashboard directory not found at: ${dashboard_path}"
echo "Run this script from the repository root."
exit 1
+1 -1
View File
@@ -22,7 +22,7 @@ fi
cd "${frontend_path}"
npm install
npm install --ignore-scripts
export VITE_ENVIRONMENT_TYPE="production"
+2 -1
View File
@@ -5,7 +5,8 @@ sonar.organization=storytold
# crates/vendor/candle/candle-flash-attn/cutlass/ ships generated Doxygen HTML and a copied Python
# tree, which accounted for 194,232 of this project's 197,233 open findings under automatic
# analysis. They come back whenever the vendor copy is bumped and drown the real findings.
sonar.exclusions=crates/vendor/**
# _docs/old/ is the retired local-dev setup (an old Dockerfile and kubernetes.yml nothing uses).
sonar.exclusions=crates/vendor/**,_docs/old/**
# Same scope for copy-paste detection: the vendored HTML/Python is most of the duplicated lines.
sonar.cpd.exclusions=crates/vendor/**