From a648561f63ebb6854da873237fa7685d86f6554a Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Thu, 3 Sep 2026 18:00:45 -0700 Subject: [PATCH] =?UTF-8?q?TODO=20=C2=A734=20planned=20in=20detail:=20per-?= =?UTF-8?q?rule=20lint=20options=20end=20to=20end,=20options=20on=20the=20?= =?UTF-8?q?naming=20rules,=20the=20first=20eighteen=20Style=20rules;=20the?= =?UTF-8?q?=20rest=20deferred=20to=20=C2=A735?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- TODO.md | 144 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 123 insertions(+), 21 deletions(-) diff --git a/TODO.md b/TODO.md index 0f746f3..3bdba8c 100644 --- a/TODO.md +++ b/TODO.md @@ -3647,28 +3647,130 @@ linter-expansion-1/README.md (new), TODO §33. Worktree `lint-1`. near-misses; the false-positive census re-read; toggles exercised through the real server (`workspace/didChangeConfiguration`) -## 34. Linter expansion, wave 2 (planned 2026-09-02, after §33) — the Style class and per-rule options +## 34. Linter expansion, wave 2 (planned 2026-09-03) — per-rule options, and the first eighteen Style rules -The style family from Verible, with the per-rule configuration the -naming rules need: `signal-name-style`, `interface-name-style`, -`macro-name-style`, `constraint-name-style`, `parameter-type-name-style`, -`dff-name-style`, `port-name-suffix`, `banned-declared-name-patterns` -(each with a `pattern`/style option), `line-length` (reads the -formatter's `line-length`), `posix-eof` (safe fix), `endif-comment`, -`forbid-line-continuations`, `one-module-per-file`, `package-filename`, -`typedef-enums`, `typedef-structs-unions`, `module-begin-block`, -`generate-label` + `generate-label-prefix`, `always-comb` (`@*` → -`always_comb`, safe fix), `legacy-generate-region`, -`legacy-genvar-declaration`, `v2001-generate-begin`, +After §33 (36 rules, severities, toggles). Two things this wave adds: +the **option plumbing** every configurable rule needs, and the Style +rules from Verible's list that carry the most weight in a style guide +(naming, file layout, generate labels, typedefs, line length). Dev +Opus 5, QA Sonnet 5. Feature README: `docs/features/linter-expansion-2/ +README.md`. Mapped: `lucisv_core::config` parses one table, `[lint]`, +with `select`/`ignore`, and rejects `[lint.]` by name +(`config.rs::parse_entry`: "per-rule lint settings … are not supported +yet"); the editor has `lucisv.lint.select/ignore/severity.*/rules.*`; +`Rule` has no notion of options; `LintContext` carries source, tokens, +tree, semantics slot and the oracle; `line-length` already lives in +`FileConfig` for the formatter. + +**34.0 Options, end to end.** +(a) `vlog_linter`: `pub struct OptionSpec { name: &'static str, kind: +OptionKind (Bool | Int { min, max } | Str | Regex | List), default: +OptionValue, doc: &'static str }` and `Rule::options(&self) -> +&'static [OptionSpec]` (default empty); `RuleOptions` — a validated +map `rule → key → OptionValue` built by `RuleOptions::parse(rule, key, +raw)` that rejects an unknown key ("rule `x` has no option `y`; it has: +…"), a wrong kind, an out-of-range int or an invalid regex, each with +the message the two front ends print with file and line. `LintContext` +carries `&RuleOptions`; a rule reads `ctx.option_str(NAME, "pattern")` +etc. with the spec's default as the fallback, so a rule never sees +"unset". (b) `lucisv_core::config`: `[lint.]` tables accepted — +`key = value` for bool/int/string, `key = ["a", "b"]` for lists — +stored raw in `FileConfig::lint_options: Vec<(rule, key, raw, line)>` +(the core crate does not know the rules); the CLI resolves them +against the registry per file the way `[lint] select` names are +checked, failing the run with file:line on the first bad entry. (c) +Editor: `lucisv.lint.options` (object; `{"": {"": value}}`, +`additionalProperties`), parsed in `settings.rs`, validated the same +way — a bad entry is a `window/logMessage` warning and is ignored, so +one typo cannot switch the linter off; republish on change. (d) +Precedence: editor options over `lucisv.toml` options over the spec +default, key by key (the same ladder `lucisv.lineLength` uses — cite +`format::settings_for`). (e) `--rules-doc` lists each rule's options +with kind, default and doc; the VS Code generator emits nothing per +option (the object setting covers them) but its description names the +options each rule takes. (f) Pins: parse/validate table tests; a +`lucisv.toml` with `[lint.line-length] length = 120` changes the +verdict; the editor object does the same over the wire; a bad key +fails the CLI naming file:line and only logs in the editor. + +**34.1 Options on the existing naming rules** (so the family is +consistent before the new members arrive): `enum-name-style`, +`struct-union-name-style`, `module-name-style`, `parameter-name-style` +gain the option Verible gives them (`style_regex`; `parameter-name- +style` gets `localparam_style`/`parameter_style` with Verible's +`CamelCase|ALL_CAPS` vocabulary plus the `_regex` overrides); defaults +reproduce today's behaviour exactly (pin: the corpus and opentitan +finding lists are byte-identical with no options set). + +**34.2 New Style rules** (Verible name; default there → here; options): +- `line-length` (on; `length`, default = the formatter's configured + `line-length`, else 100) — a token-aware check that ignores a line + that is one unbreakable token (a long string or macro invocation), + as Verible does. +- `posix-eof` (on; safe fix appends the newline). +- `forbid-consecutive-null-statements` (on; safe fix) — `;;` at + statement level, the statement twin of `empty-item`. +- `generate-label` (on) and `generate-label-prefix` (on; `prefix` + list, default `g_`/`gen_`). +- `package-filename` (on; `allow-dash-for-underscore`, same as + `module-filename`). +- `one-module-per-file` (off). +- `signal-name-style` (off; `style_regex`, default `[a-z_0-9]+`). +- `interface-name-style` (on; `style_regex`, default `[a-z_0-9]+(_if)`). +- `macro-name-style` (on; `style_regex`, default `[A-Z_0-9]+`; the + macro's own name from the `` `define`` table). +- `constraint-name-style` (on; `pattern`, default `([a-z0-9]+_)+c`). +- `parameter-type-name-style` (off; lower_snake + `_t`). +- `port-name-suffix` (off; `_i`/`_o`/`_io`/`_ni`/`_no`/`_nio` per + Verible; option `suffixes` list). +- `banned-declared-name-patterns` (off; `patterns` list of regexes). +- `typedef-enums` (on) and `typedef-structs-unions` (on; + `allow_anonymous_nested`). +- `always-comb` (on; **unsafe** fix rewriting `always @*`/`@(*)` to + `always_comb` — the two are not identical at time zero, so the fix is + offered but not applied by default). +- `explicit-begin` (off; the eleven `*_enable` bool options Verible + has; safe fix wraps the body in `begin`/`end`). +Each: its own file, true positives and near-misses, a `.lint` case, +corpus + opentitan counts with ten findings read and classified; +opentitan is Verible-clean for its `dvsim` filesets, so a +Verible-default rule that fires inside them needs an explanation. + +**34.3 Docs and toggles.** The VS Code generator regenerates the 18 new +`lucisv.lint.rules.*` entries (the drift test enforces it); README.md +"Linting" gains the options section and the rows; `editors/vscode/ +README.md` documents `lucisv.lint.options`; the docs-site rules page +gains the sections; CHANGELOG untouched (the lead writes it). +Remaining Verible rules — `module-begin-block`, `legacy-generate- +region`, `legacy-genvar-declaration`, `v2001-generate-begin`, `explicit-function-lifetime`/`explicit-task-lifetime`, `positive-meaning-parameter-name`, `suggest-parentheses`, -`forbid-consecutive-null-statements`, `unpacked-dimensions-range- -ordering`, `uvm-macro-semicolon`, `create-object-name-match`, -`numeric-format-string-style`, `macro-string-concatenation`, -`disable-statement`, `forbidden-macro`/`forbidden-symbol` (list -options). Options: `[lint.]` tables in `lucisv.toml` (today -rejected by name — the parser exists) and `lucisv.lint.options.` -in the editor, validated against a per-rule option schema declared by -the rule (`Rule::options() -> &[OptionSpec]`), shown in `--rules-doc`. -Detailed plan to be written when §33 lands. +`unpacked-dimensions-range-ordering`, `uvm-macro-semicolon`, +`create-object-name-match`, `numeric-format-string-style`, +`macro-string-concatenation`, `disable-statement`, `forbidden-macro`/ +`forbidden-symbol`, `endif-comment`, `forbid-line-continuations`, +`dff-name-style`, `proper-parameter-declaration` — are §35, wave 3. + +Files: crates/vlog_linter/src/{registry.rs (OptionSpec, options()), +options.rs (new: OptionKind/OptionValue/RuleOptions), context.rs, +rule_docs.rs, vscode.rs, lib.rs, rules/.rs, rules/.rs} ++ tests/cases/*.lint, crates/lucisv_core/src/config.rs (+ tests), +crates/lucisv/src/{lint.rs, args.rs?} + tests, crates/lucisv_server/ +src/{settings.rs, lint.rs} + tests, editors/vscode/{package.json, +README.md}, README.md "Linting", docs/site/.../reference/rules.md, +docs/features/linter-expansion-2/README.md (new), TODO §34. Worktree +`lint-2`; disjoint from §32 (parser) so the two may run in parallel. +Every suite and sweep under `tools/guard.sh`. +- [ ] 34.0 options end to end (spec, validation, toml table, editor + object, precedence, --rules-doc); pins +- [ ] 34.1 options on the four existing naming rules; defaults + byte-identical +- [ ] 34.2 the eighteen Style rules, each with tests, counts and ten + classified findings +- [ ] 34.3 docs + regenerated toggles +- [ ] Gates (guarded): fmt/clippy/`cargo test --workspace`; corpus + 814/820 byte-identical; vsix smoke; opentitan read-only census + + timing vs 0.36.0 +- [ ] QA: options attacked (bad key/kind/range/regex on both front + ends), every rule with near-misses, the census re-read