Skip to content

docs(rules): document the eight missing languages, and keep the table honest - #1857

Closed
abhisheksharma2411 wants to merge 2 commits into
alibaba:mainfrom
abhisheksharma2411:docs/complete-rule-table
Closed

abhisheksharma2411 wants to merge 2 commits into
alibaba:mainfrom
abhisheksharma2411:docs/complete-rule-table

Conversation

@abhisheksharma2411

Copy link
Copy Markdown
Contributor

Description

The rule table in review-rules.md is the only place a user can find out which rule doc their file will be reviewed against, and it is kept in step by hand.

Eight languages have reached the resolver without ever reaching it:

pattern rule
**/*.pug pug.md
**/*.nix nix.md
**/*.{hs,lhs} haskell.md
**/*.{nim,nims,nimble} nim.md
**/*.swift swift.md
**/*.zig zig.md
**/*.{ml,mli} ocaml.md
**/*.{re,rei} ocaml.md

This adds all eight to en, ja, ko, ru and zh, each in its matching-order position, following the shape of #1448 (F#), which updated the JSON, the tests and all five translations together.

It also adds a test, because remembering has not worked. TestRuleTableDocumentsEveryPattern compares path_rule_map against every locale's table in both directions — a pattern the docs do not list, and a row the JSON no longer has. Against the current docs it fails naming exactly those eight, per locale:

--- FAIL: TestRuleTableDocumentsEveryPattern/en
    review-rules.md (en) does not list 8 pattern(s) from system_rules.json:
      **/*.pug
      **/*.nix
      ...

So someone adding a language finds out from go test rather than from review.

Type of Change

  • Documentation update
  • New feature (non-breaking change that adds functionality)

How Has This Been Tested?

go test ./internal/config/... -count=1 passes; go vet ./internal/config/rules/ is clean.

I checked the test can fail rather than assuming it: reverting the five doc files and re-running reports the eight missing patterns for each locale. It also fails if the JSON and the table ever disagree the other way.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI/LLM disclosure: AI-assisted (Claude). I reviewed the wording and ran the tests
myself.

A note on the non-English rows: they are short and factual, and I matched each
file's existing separator and padding. Corrections from native speakers are very
welcome — please just push over them or tell me and I will fix.

Related Issues

Follows the documentation point raised on #1840.

… honest

The rule table in review-rules.md is the only place a user can find out
which rule doc their file will be reviewed against, and it is maintained
by hand. Eight languages had reached the resolver without ever reaching
it: pug, nix, haskell, nim, swift, zig, ocaml and reason. They are added
here in all five translations, each in its matching-order position.

Keeping it in step by remembering has not worked, so this also adds a
test that compares path_rule_map with every locale's table in both
directions -- a pattern the docs do not list, and a row the JSON no
longer has. On the current docs it fails naming those exact eight per
locale; the message says which rows to add, so a contributor adding a
language finds out from `go test` rather than from review.

No rule content changes, and no behaviour: the test reads the JSON
directly rather than through LoadDefault, which replaces each rule name
with the rule file's contents.

Signed-off-by: Abhishek Sharma <[email protected]>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review skipped: no items were selected.

@abhisheksharma2411 abhisheksharma2411 mentioned this pull request Nov 3, 2026
10 tasks done
main gained scala, C#, erb, ejs/liquid/njk, haml/slim, jsonc and starlark
while this branch sat, so the five tables were rebuilt from path_rule_map
rather than hand-merged -- hand-merging two orderings is the mistake this
PR exists to prevent.

Three things fall out of the merge:

- Starlark arrived as one row carrying two globs. patternsFromDoc only read
  the first backticked span per row, so '**/{BUILD,WORKSPACE}' would have
  been reported undocumented against a table that does document it. The
  regex now reads the whole first column, and the row is split in two so
  every row carries one pattern, as the rest of the table does.
- '**/*.R' and the shader row were already out of matching order in main.
  The table says it is in matching order, so they are moved. Neither
  overlaps anything in between, so no file changes which rule it matches.
- The eight new rows keep their position from path_rule_map.

Both failure modes verified by reverting them, not assumed.

Signed-off-by: Abhishek Sharma <[email protected]>

@NanaseInori NanaseInori left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original documentation gap was real, but the principal change is now covered by the earlier #1785, merged on 2026-11-10 at a763998.

I compared the eight missing pattern entries and the new guard here with the merged implementation. #1785 already adds the Pug, Nix, Haskell, Nim, Swift, Zig, OCaml and ReasonML mappings to the five locale tables. Its TestReviewRulesGuideListsEverySystemRulePattern also checks missing/stale patterns and verifies the referenced rule-document filename; the new test here checks pattern membership only.

I recommend closing this as superseded unless a distinct follow-up remains. The table ordering and splitting the two Starlark patterns into separate rows are separable presentation changes; they do not require a second independent guard. Any additional guard coverage should extend the existing rule_docs_table_test.go after rebasing onto main.

References: merged predecessor, merged guard.

This is an overlap/source assessment, not a new runtime-defect finding. I did not run the repository test suite, and this comment does not close or otherwise modify the PR.

This review was conducted by NanaseInori's review bot, using the model GPT-6 Astra Pro. If you need a human review, please manually @NanaseInori.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Thank you for the contribution! The core changes are already covered by #1785, which has been merged. It documents the same eight missing mappings across all five locales and adds consistency checks for missing or stale patterns as well as the referenced rule documents. Closing this PR as superseded by #1785.

@abhisheksharma2411

Copy link
Copy Markdown
Contributor Author

Appreciate you double-checking it against the merged commit instead of just the overlap. You're spot on, so I'm gonna go ahead and close this out.

I checked a763998 and all eight patterns are definitely in the five locale tables. Plus, TestReviewRulesGuideListsEverySystemRulePattern is way stricter than what I originally wrote because it checks the rule-document filename too (which mine missed).

One minor thing is actually worth fixing though: two patterns were out of order in the table, meaning the docs didn't match the order the matcher actually runs them in. I'll push that as a separate PR with a test to lock down the ordering, just like you suggested.

@abhisheksharma2411

Copy link
Copy Markdown
Contributor Author

Follow-up for the ordering is #1902.

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.

3 participants