Skip to content
joinery / docs

SonarQube code smells: shared packages

Closed

docs/audits/2026-09-25-sonarqube-monorepo.md · read at 88f5939

Open
0
Fixed
9
Won't fix
1

🔎 SonarQube code smells: shared packages

Context

SonarQube Cloud reported nine open code smells and one accepted code smell across packages/content, packages/i18n and packages/observability on master on 2026-09-25. The flagged lines were checked against commit 88f5939. The nine open findings have been fixed; the accepted finding needs no code change. Each issue key identifies its SonarQube finding.

Quality

IDWhereSeverity and issueWhat goes wrongFixStatus
Q1content/WordpressProvider.ts:34Major AaAah6BfpluT0KmYWf3SThe trailing-slash regex can rescan a long slash suffix.Find the last non-slash character and slice once; preserve the path of subdirectory WordPress installs.fixed
Q2content/contentKey.ts:19Major AaAah6EcpluT0KmYWf3XSorting is chained into the returned mapping expression, hiding mutation.Sort entries in its own statement or use toSorted if the runtime supports it; preserve deterministic key order.fixed
Q3content/useContent.ts:43Minor AaBoBQ8nh-ku-SWtJH3vThe resource union is repeated in several helper signatures.Name EntryResource | TermResource once and use the alias at all three call sites.fixed
Q4content/contentKey.ts:10Minor AaAah6EcpluT0KmYWf3VA global regex substitutes underscores in key segments.Use .replaceAll("_", "_u"), retaining key-collision coverage.fixed
Q5content/contentKey.ts:10Minor AaAah6EcpluT0KmYWf3WA second global regex substitutes hyphens.Use .replaceAll("-", "_d") in the same edit as Q4.fixed
Q6content/errors.ts:10Minor AaAah6D6pluT0KmYWf3THTTP passthrough membership uses an array scan.Make the status collection a Set and use .has() where the error is mapped.fixed
Q7i18n/translationsKey.ts:10Minor AaBoBQ4Ch-ku-SWtJH3tA global regex substitutes underscores in key segments.Use .replaceAll("_", "_u"), retaining encoded-key collision cases.fixed
Q8i18n/translationsKey.ts:10Minor AaBoBQ4Ch-ku-SWtJH3uA second global regex substitutes hyphens.Use .replaceAll("-", "_d") in the same edit as Q7.fixed
Q9i18n/translations.ts:1Major AZ_8etZSbSjYjv7QodyMLocale aliases string; SonarQube suggests replacing the name at its call sites with string.Retain the domain name: it distinguishes a locale value in signatures even though the current representation is a string. SonarQube already marks this issue accepted.wont-fix — accepted in SonarQube
Q10observability/node.ts:34Major AZ__HlrVjHpLikj8piLbA nested template literal builds Basic authorization inside another template literal.Build the instanceId:token credential and its encoded header in separate local values, then pass the header to the exporter; keep the existing wire value.fixed

Order

Fix Q1 with long slash-suffix and subdirectory URL cases, then Q2 to preserve content-key order. Q4–Q5 and Q7–Q8 are paired substitutions. Q3, Q6 and Q10 are local refactors. Run the affected package specs, lint and typecheck after edits; Q9 is already accepted in SonarQube.