Skip to content

fix: stop reporting locale and config objects as clones - #34

Merged
machado144 merged 1 commit into
mainfrom
fix/locale-tables-not-clones
Oct 13, 2026
Merged

machado144 merged 1 commit into
mainfrom
fix/locale-tables-not-clones

Conversation

@machado144

Copy link
Copy Markdown
Contributor

What

Found by running the merged main on our own repositories before tagging a release.

File scope (the new default) reported JS/TS locale files as clones of each other: es.ts, ja-JP.ts and the rest share every key and differ only in the translated strings.

qorder-app v0.1.1 main this PR
Duplication 13.0% 27.0% 14.8%
Duplicate lines in locale files – 17,280 166

How

An object literal outside any function (const es = { … }, export default { … }, defineMessages({ … })) is data, so its values must match for it to count as a copy. Arrays, maps and PHP tables already worked this way; JS/TS objects were missed because { also opens a block.

  • A locale object copied verbatim is still reported.
  • A function written inside an object literal is still compared as logic, so renamed copies are still found.

Checked

  • Three failing tests first (typed const, default export, call argument), plus a guard test for methods inside objects.
  • nest against SonarQube: still 98% of Sonar's duplicated lines.
  • webpack: 5,837 → 5,783 clones; the ones dropped are config objects with different values.
  • go test -race ./..., golangci-lint, govulncheck pass; the self-scan reports no duplicates.

Not covered

Only JavaScript and TypeScript. Ruby hashes, Dart maps and Go struct literals outside functions can show the same pattern and are not handled here.

… values as clones

* A JS/TS object literal outside any function is data: its values must
  match for it to be a copy, as already required for arrays and maps
* Found on a real app after file scope became the default: locale files
  sharing keys were reported as 2,600-line clones (27% -> 14.8% dup)
@github-actions

Copy link
Copy Markdown

✅ PR title follows the required format

Current title: fix: stop reporting locale and config objects as clones

@machado144
machado144 merged commit 183665c into main Oct 13, 2026
4 checks passed
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

⌂ 换网址