Files
poli0981andClaude Opus 5.5 0c56acd806 ci: Qodana analysis and a licence check over the whole dependency tree (#135)
* ci: Qodana analysis and a licence check over the whole dependency tree

- Qodana (JetBrains, Qodana for JS) runs on every PR, on main and by hand
  (.github/workflows/qodana.yml, settings in qodana.yaml): native mode on the runner's
  Node 26 after `npm ci --ignore-scripts` and the generated types, profile
  qodana.recommended over the whole repository, build output, generated files, the
  content submodule and the design docs excluded, spelling/grammar checks off (they do
  not read Vietnamese). Results go to Qodana Cloud and, for main, to code scanning as
  SARIF. Dependabot and fork PRs skip it (no secrets), so it stays advisory.
- Licences: the allowlist moves to scripts/license-policy.mjs, shared by gen-notices
  (direct dependencies, THIRD-PARTY-NOTICES.md) and a new check-licenses step in the
  build job that reads every package in package-lock.json — transitive ones and every
  platform binary — with a small SPDX evaluator (OR, AND, WITH, parentheses). Packages
  with no licence fail; reviews are per package with a reason instead of per licence
  (an MPL note written for satori used to clear @axe-core/playwright too). Today:
  735 packages, 42 cleared (MPL-2.0 build/test tools, sharp's LGPL libvips).
- README badges and Quality row, THIRD-PARTY-NOTICES tool list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: Qodana's first findings, and a zero-problem quality gate

The first Qodana run reported 11 problems; all are handled:
- scripts/smoke-worker.mjs: the forged Access JWT is now built from its JSON parts at run
  time (same bytes) instead of sitting in the source as a token literal, which secret
  scanners rightly flag; the "did not come up" case reports through the same helper as
  any other failure instead of throwing into its own catch.
- scripts/check-csp-hashes.mjs: ("|') → ["'] in the JSON-LD matcher.
- src/lib/format.ts: drop the two escapes of `]` outside a character class (a lone `]`
  is a literal there); the classes keep theirs.
- src/lib/legal-lang.ts: the heading → language table is a Map, so "Tiếng Việt" is data,
  not a property name mixing scripts.
- qodana.yaml: ES6PreferShortImport off, with the reason — the build scripts and
  astro.config.mjs run under plain Node, where the `@/` alias doesn't resolve and a
  TypeScript import keeps its `.ts`.
- failThreshold: 0, so any new problem turns the check red.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: sort the licence report with an explicit compare function

Sonar S2871: Array#sort() without a compare function sorts by UTF-16 code units, which
is not alphabetical for every name. Both lists now sort with localeCompare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 07:55:31 +07:00

46 lines
1.9 KiB
YAML

# JetBrains Qodana — run by .github/workflows/qodana.yml on every PR and on main
# (docs 08 §0). Reference: https://www.jetbrains.com/help/qodana/configuration-reference.html
#
# Qodana for JS is WebStorm's inspection engine. It reads .ts/.js/.mjs, CSS, JSON, YAML and
# Markdown — not .astro or .svelte, which stay with astro check, eslint-plugin-astro/-svelte
# and Prettier in ci.yml.
version: "1.0"
linter: qodana-js
# Native mode: the workflow sets up Node from .nvmrc and runs `npm ci` itself, so the analysis
# resolves the same Node 26 and node_modules as the build (the Docker image ships its own Node).
withinDocker: false
# Quality gate: the first run's 11 findings were fixed or, for one inspection, switched off
# below with the reason, so any problem now is a new one and turns the check red.
failThreshold: 0
profile:
name: qodana.recommended
inspections:
# Not source code: build output, coverage, generated types, the content submodule (prose,
# in its own repo), the design docs and the frontmatter templates.
- group: ALL
ignore:
- "dist/**"
- "coverage/**"
- ".astro/**"
- ".wrangler/**"
- "src/content/**"
- "poli0981.dev-docs/**"
- "docs/templates/**"
- "public/pagefind/**"
- "worker-configuration.d.ts"
- "workers/widgets/worker-configuration.d.ts"
# Prose checkers don't read Vietnamese: every other word of the bilingual UI strings,
# comments and docs would be a "typo".
- inspection: SpellCheckingInspection
enabled: false
- inspection: GrazieInspection
enabled: false
# "Import can be shortened" wants tsconfig's `@/` alias or extensionless paths. The build
# scripts and astro.config.mjs run under plain Node, where `@/` doesn't resolve and a
# TypeScript import needs its `.ts`; in src/ relative vs alias imports are a style choice.
- inspection: ES6PreferShortImport
enabled: false