TODO §33/§34 planned: linter expansion — severities, per-rule VS Code toggles, Error/Warning-class rules (wave 1); the Style class and per-rule options (wave 2)
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
999edd0203
commit
965c4ee25a
1 file changed
+197
@@ -3468,3 +3468,200 @@ formatter collide with §30's tf.rs/module.rs at merge; sequential).
|
||||
an opentitan file and read the published diagnostics and the
|
||||
outline; the fuzzers re-run; strict-mode parity re-derived
|
||||
|
||||
## 33. Linter expansion, wave 1 (planned 2026-09-02) — severities, per-rule editor toggles, and the Error/Warning-class rules
|
||||
|
||||
Owner's ask: expand the linter toward what Verible's linter covers (62
|
||||
rules, https://chipsalliance.github.io/verible/lint.html), expose every
|
||||
rule in VS Code as a toggle grouped by severity so a user can enable or
|
||||
disable rules one at a time or a whole severity at once, and put the
|
||||
style rules and the "would likely fail to compile or synthesize" rules
|
||||
first. Today: 17 rules, no severity notion (`Rule` has `name`,
|
||||
`summary`, `doc`, `default_on`, `needs_workspace`, `fix`, `check`), every
|
||||
editor diagnostic is `WARNING`, the editor surface is
|
||||
`lucisv.lint.select`/`ignore` lists. Dev Opus 5, QA Sonnet 5. Feature
|
||||
README: `docs/features/linter-expansion-1/README.md`. Runs in a
|
||||
worktree in parallel with §31 (fences: `vlog_formatter`, README.md's
|
||||
"Turning the formatter off" section only); this lane owns
|
||||
`vlog_linter`, `lucisv/src/lint.rs` + args, `lucisv_server/src/
|
||||
{settings,lint}.rs`, `editors/vscode/{package.json,README.md}`, README.md's
|
||||
"Linting" section, `docs/site/.../reference/rules.md`.
|
||||
|
||||
**33.0 Severity, end to end.**
|
||||
(a) `vlog_linter`: `pub enum Severity { Error, Warning, Style }` with
|
||||
`as_str` (`error`/`warning`/`style`) and `Rule::severity(&self) ->
|
||||
Severity` (no default — every rule states it; the reason goes in the
|
||||
rule's `doc`). Assignments for the 17: **Error** — `multiply-driven`
|
||||
(two procedural drivers of one variable is an elaboration error in
|
||||
SystemVerilog), `wire-reg-mixup` (a procedural assignment to a net is a
|
||||
compile error); **Warning** — `always-comb-blocking`,
|
||||
`always-ff-non-blocking`, `case-missing-default`, `undriven-net`,
|
||||
`unused-signal`; **Style** — `empty-item`, `enum-name-style`,
|
||||
`explicit-parameter-storage-type`, `module-filename`,
|
||||
`module-name-style`, `no-tabs`, `no-trailing-whitespace`,
|
||||
`parameter-name-style`, `struct-union-name-style`, `unused-waiver`.
|
||||
`Violation` carries the severity (set by the runner from the rule, not
|
||||
by each rule). (b) `select_rules(select, ignore, …)` accepts a severity
|
||||
name wherever a rule name is accepted — `--select style`, `--ignore
|
||||
warning`, `[lint] ignore = ["style"]` — expanding to every rule of that
|
||||
severity; an unknown name still fails naming the file. (c) CLI text
|
||||
output becomes `FILE:LINE:COL: error|warning|style: message [rule]`
|
||||
(the severity word is new; pin the old tests to the new shape); JSON
|
||||
gains `"severity"`. Exit codes unchanged. (d) Editor:
|
||||
`DiagnosticSeverity::ERROR` / `WARNING` / `INFORMATION` respectively;
|
||||
`source` unchanged. (e) `--rules-doc` and `rules_markdown()`: a
|
||||
Severity column, sections grouped by severity, the intro explaining the
|
||||
three words.
|
||||
|
||||
**33.1 Editor toggles, generated from the registry.** In
|
||||
`editors/vscode/package.json`: three master switches
|
||||
`lucisv.lint.severity.error`, `.warning`, `.style` (boolean, default
|
||||
true, `order` 10/11/12, description naming what each class means), and
|
||||
one boolean per rule `lucisv.lint.rules.<rule-name>` (default = the
|
||||
rule's default; `markdownDescription` = `**severity** — summary`; the
|
||||
project-only rules say "on where lucisv can see the project"; `order`
|
||||
sorted by severity then name so the Settings UI groups them; the
|
||||
existing `lucisv.lint.select`/`ignore` stay, documented as the
|
||||
power-user spelling). Generated, not hand-written: a
|
||||
`crates/vlog_linter/examples/vscode_lint_settings.rs` (or a `tools/`
|
||||
script driving `cargo run --example`) that prints the JSON fragment,
|
||||
and a `crates/lucisv_server` test that parses package.json and asserts
|
||||
the `lucisv.lint.rules.*` set, defaults and descriptions equal the
|
||||
registry — the drift guard, so a new rule cannot ship without its
|
||||
toggle. The server (`settings.rs`) reads all of them; the enabled set
|
||||
is computed in one documented function `enabled_rules(settings,
|
||||
has_oracle)` with this precedence, top to bottom: (1) the base set is
|
||||
the defaults (`default_on`, and `needs_workspace` rules only with an
|
||||
oracle); (2) a non-empty `select` replaces the base set; (3) a severity
|
||||
switch that is off removes every rule of that severity; (4) an
|
||||
explicitly set per-rule toggle sets or clears that rule; (5) `ignore`
|
||||
removes — the off switch of last resort. Pinned by a table test.
|
||||
Changing any of them republishes every open file, as select/ignore do.
|
||||
The CLI has parity through select/ignore with severity names; no
|
||||
per-rule flags (`--ignore rule` is that).
|
||||
|
||||
**33.2 New rules, Error class** (each a file under `rules/`, its own
|
||||
tests, its doc with the Verible name where one exists, and a measured
|
||||
false-positive count on opentitan — see QA):
|
||||
- `mismatched-labels` (Verible, off there; **on** here, Error): an end
|
||||
label that does not match its block's name (`end : wrong`, `endmodule
|
||||
: other`) — a compile error. Reuse what linked-editing already pairs.
|
||||
- `duplicate-declaration` (Error): the same name declared twice in one
|
||||
scope (port and signal, two signals, two params). Ask the binder:
|
||||
`Binder::declare` sees the second declaration — record it (a
|
||||
`Semantics` query `duplicates()` or a per-scope check), skip generate
|
||||
scopes and macro-expanded text; no false positive on `input clk`
|
||||
+ `logic clk` non-ANSI redeclaration (legal) — pin it.
|
||||
- `undeclared-identifier` (Error, `needs_workspace`): a use the file
|
||||
did not resolve and the workspace overlay left `StillUnresolved`/
|
||||
`NotFound`, excluding: names inside macro invocations, system names,
|
||||
names a `` `define`` in scope produces, names the file's macro-word
|
||||
census contains, hierarchical tails, names in a package this file
|
||||
wildcard-imports when that package is not indexed. Measured on
|
||||
opentitan; ships default-on only if the count of unexplained
|
||||
findings on that tree is 0 — otherwise default-off with the
|
||||
measurement and the reason in the doc.
|
||||
- `unknown-port` and `unknown-parameter` (Error, `needs_workspace`): a
|
||||
named connection `.x(…)` / override `.P(…)` naming a port or
|
||||
parameter the instantiated module does not declare (the index
|
||||
exports both). Silent when the module is not indexed or is declared
|
||||
twice with different shapes.
|
||||
|
||||
**33.3 New rules, Warning class** (Verible name, default there → here):
|
||||
- `forbid-defparam` (on → on): `defparam` is deprecated and rejected by
|
||||
some tools.
|
||||
- `invalid-system-task-function` (on → on): `$psprintf`, `$random`
|
||||
(use `$urandom`), `$dist_*`, `$srandom` … Verible's list, cited.
|
||||
- `truncated-numeric-literal` (on → on): a sized literal whose value
|
||||
does not fit its width (`4'hFFF`).
|
||||
- `undersized-binary-literal` (on → on, safe fix pads): `8'b1`; binary
|
||||
only by default, as Verible.
|
||||
- `suspicious-semicolon` (off → **on**): `if (x);`, `for (…);`,
|
||||
`while (…);` — a body that is a null statement.
|
||||
- `packed-dimensions-range-ordering` (on → on): a packed dimension
|
||||
written `[0:N-1]`.
|
||||
- `module-port` and `module-parameter` (on → on): positional
|
||||
connections/overrides when more than one port/parameter.
|
||||
- `explicit-function-task-parameter-type` (on → on): an untyped tf
|
||||
argument is a 1-bit `logic` — a silent truncation.
|
||||
- `plusarg-assignment` (on → on): `$value$plusargs` result unused /
|
||||
`$test$plusargs` misuse, as Verible defines it.
|
||||
- `instance-shadowing` (off → **on**): a declaration shadowing one in
|
||||
an enclosing scope of the same unit (the binder knows).
|
||||
- `forbid-negative-array-dim` (off → on): a negative literal in a
|
||||
dimension.
|
||||
- `void-cast` (on → on): `void'(…)` around anything but a function
|
||||
call that has a return value (Verible's rule).
|
||||
- `incomplete-assignment` (no Verible equivalent; Warning): in an
|
||||
`always_comb`, a variable assigned in the `then` branch of an `if`
|
||||
with no `else` (or in some `case` items, not `default`) and not
|
||||
assigned unconditionally earlier in the block — latch inference.
|
||||
Conservative by construction: only flag when the block has no
|
||||
unconditional assignment to that variable before the `if`/`case`;
|
||||
measured on opentitan.
|
||||
|
||||
**33.4 Docs and measurement.** README.md "Linting" (severities, the
|
||||
toggles, select/ignore with severity names), `editors/vscode/README.md`
|
||||
settings table, the docs-site rules page (hand-written prose today —
|
||||
add the new rules with their severity and a note that `--rules-doc` is
|
||||
the generated truth), CHANGELOG untouched (the lead writes it). For
|
||||
every new rule: findings on the corpus and on opentitan `hw/`
|
||||
(read-only `lucisv check`), with ten findings read and classified per
|
||||
rule (true / false positive / needs judgment); opentitan is lint-clean
|
||||
under Verible, so a Verible-equivalent rule that fires there needs an
|
||||
explanation (their config disables it, or our reading differs — say
|
||||
which). Timing: `lucisv check` over opentitan before/after (the
|
||||
semantic rules already dominate; the new ones must not add more than a
|
||||
few percent).
|
||||
|
||||
Files: crates/vlog_linter/src/{registry.rs, rule_docs.rs, violation.rs,
|
||||
lib.rs, rules/mod.rs, rules/<new>.rs, context.rs (if a semantics query
|
||||
is needed), visit.rs (new walkers)} + tests/cases/*.lint,
|
||||
crates/vlog_linter/examples/vscode_lint_settings.rs (new),
|
||||
crates/vlog_semantic (only if `duplicates()`/shadowing needs a query —
|
||||
additive, say so in Handshakes), 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/src/content/docs/reference/rules.md, docs/features/
|
||||
linter-expansion-1/README.md (new), TODO §33. Worktree `lint-1`.
|
||||
- [ ] 33.0 `Severity` on every rule; select/ignore by severity; CLI
|
||||
text/JSON; editor severities; `--rules-doc` grouped
|
||||
- [ ] 33.1 package.json toggles generated + drift test; `enabled_rules`
|
||||
precedence pinned; republish on change
|
||||
- [ ] 33.2 Error rules: mismatched-labels, duplicate-declaration,
|
||||
undeclared-identifier (measured; default decided by the count),
|
||||
unknown-port, unknown-parameter
|
||||
- [ ] 33.3 Warning rules: the thirteen listed, each with tests and an
|
||||
opentitan count
|
||||
- [ ] 33.4 docs; measurements table in the README
|
||||
- [ ] Gates: fmt/clippy/`cargo test --workspace`; corpus 814/820
|
||||
byte-identical (formatter untouched); opentitan read-only
|
||||
`lucisv check` census + timing
|
||||
- [ ] QA: every new rule attacked with hand-written true positives and
|
||||
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
|
||||
|
||||
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`,
|
||||
`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.<rule>]` tables in `lucisv.toml` (today
|
||||
rejected by name — the parser exists) and `lucisv.lint.options.<rule>`
|
||||
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.
|
||||
|
||||
Reference in new issue
Block a user