External waiver files: Verible's format from lucisv.toml, --waiver-file and the editor, union with inline waivers, honoured by quick fixes
TODO §39 (docs/features/waiver-files). Closes §4's last waiver item. `vlog_linter::waiver_file`: `waive --rule=<rule> [--line=N|N-M] [--location=<pattern>]`, `#` comments, BOM tolerated; `--location` is the `--exclude` matcher (`lucisv_core::walk::is_excluded`, a new vlog_linter → lucisv_core edge), a regex-looking pattern refused by name. `lint_with(ctx, rules, external)` applies inline and external waivers as a union and reports which external directives fired; `lucisv check` reports the dead ones under `unused-waiver` at the waiver file's line after the whole run. Discovery: `[lint] waivers` (relative to the toml), `--waiver-file` (repeatable), `lucisv.lint.waivers` (first workspace root); bad lines fail the CLI run with file:line and are dropped and logged once by the server. Review rework (QA's HIGH): the server's code-action path now lints with the buffer's `LintRun` — its enabled rules and external waivers — so a quick fix is never offered, nor applied by fix-on-save, for a waived finding. Docs: Waivers sections in README and the linter guide, cli and configuration rows, topo edge, site rebuilt. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
f6f18de10d
commit
8a92e79fc0
44 files changed
+2257
-125
No files matched your search
@@ -393,8 +393,42 @@ wire a; // lucisv: waive no-tabs suppresses that rule on this line
|
||||
works unedited — including waivers naming Verible rules lucisv has not
|
||||
implemented, which are ignored rather than reported. A waiver of lucisv's own
|
||||
that suppresses nothing, names an unknown rule or is malformed is reported
|
||||
under `unused-waiver`. External waiver files are not supported in v0.41.0
|
||||
(planned in TODO §39).
|
||||
under `unused-waiver`.
|
||||
|
||||
Findings can also be suppressed from **outside** the RTL, in Verible's
|
||||
waiver-file format — one directive per line, `#` comments and blank lines
|
||||
ignored:
|
||||
|
||||
```text
|
||||
# every line of every file
|
||||
waive --rule=no-tabs
|
||||
# one line, or a range with both ends included
|
||||
waive --rule=line-length --line=12
|
||||
waive --rule=line-length --line=12-20
|
||||
# only the files a pattern names
|
||||
waive --rule=no-tabs --location=legacy/top.sv
|
||||
```
|
||||
|
||||
`--rule` is required and names exactly one rule (a severity word is not
|
||||
accepted). `--line` is 1-based. `--location` is matched the way an
|
||||
`--exclude` pattern is — `*` within one path component, a pattern with `/`
|
||||
matching a path suffix, one without matching the file name at any depth — and
|
||||
**not** as a regular expression; a pattern that looks like one (`.*`, `\.`,
|
||||
`[…]`) is an error naming the difference.
|
||||
|
||||
Waiver files come from three places, and they add up: `lucisv check
|
||||
--waiver-file <path>` (repeatable, relative to the working directory),
|
||||
`waivers` under `[lint]` in `lucisv.toml` (relative to that file; read by the
|
||||
CLI and the editor), and the editor setting `lucisv.lint.waivers` (relative to
|
||||
the first workspace folder). External and inline waivers are a union: a
|
||||
finding either covers is suppressed, and one both cover leaves neither
|
||||
reported as dead. A missing file or an unparsable directive fails `lucisv
|
||||
check` with `<file>:<line>: <message>` and exit 2; in an editor the bad line
|
||||
is dropped and the rest of the file applies — a bad line in a file named by
|
||||
the editor setting is written once to the lucisv log, one named by
|
||||
`lucisv.toml` is not (run `lucisv check` to see it). Unused external waivers
|
||||
are reported under `unused-waiver` at their line of the waiver file, by
|
||||
`lucisv check` only and only after the whole run.
|
||||
The server currently selects rules from `lucisv.lint.*` editor settings;
|
||||
project `[lint] select/ignore` lists affect the CLI only. Project per-rule
|
||||
options are read by both front ends. Full rules:
|
||||
@@ -420,7 +454,9 @@ of document layout from language rules:
|
||||
|
||||
`vlog_parser` and `lucisv_core` have no dependencies. The formatter depends
|
||||
only on the parser; semantic analysis also depends only on the parser.
|
||||
Linting and refactoring consume the parser and semantics. The CLI reaches
|
||||
Linting consumes the parser, semantics and `lucisv_core` (for the one
|
||||
`--exclude`-style matcher a waiver file's `--location` shares with the CLI);
|
||||
refactoring consumes the parser and semantics. The CLI reaches
|
||||
semantics through the linter and has no refactoring dependency. The server
|
||||
composes all six libraries. See [topo.md](docs/topo.md) for the full graph,
|
||||
including the linter's formatter dependency used only by tests.
|
||||
|
||||
@@ -218,7 +218,7 @@ Verible's rule ergonomics (waivers, configurable rules).
|
||||
→ `Fix { edits, applicability: Safe | Unsafe }` and `--fix` /
|
||||
`--unsafe-fixes`. Only `no-tabs` and `no-trailing-whitespace` ship fixes
|
||||
(both Safe); the unsafe path is plumbed and tested but no rule uses it yet.
|
||||
- [ ] **[V] Waiver mechanisms:** inline `// lucisv: waive rule-name` (accept
|
||||
- [x] **[V] Waiver mechanisms:** inline `// lucisv: waive rule-name` (accept
|
||||
`verilog_lint: waive` for migration), `waive-start`/`waive-stop` ranges,
|
||||
and external waiver files (`waive --rule=X --line=N --location=glob`) for
|
||||
code you can't touch. ruff's lesson: also warn about *unused* waivers.
|
||||
@@ -226,8 +226,11 @@ Verible's rule ergonomics (waivers, configurable rules).
|
||||
`unused-waiver` pseudo-rule (unused, unknown rule, malformed, unmatched
|
||||
`waive-stop`). A `verilog_lint:` waiver naming a rule lucisv lacks is
|
||||
ignored rather than reported, so Verible-annotated code lints unedited.
|
||||
- [ ] external waiver files — needs a file format, a discovery rule and a
|
||||
precedence story against inline waivers.
|
||||
- [x] external waiver files — needs a file format, a discovery rule and a
|
||||
precedence story against inline waivers. **Delivered by §39**: Verible's
|
||||
format, discovered from `[lint] waivers`, `--waiver-file` and
|
||||
`lucisv.lint.waivers`, union with the inline waivers, unused ones
|
||||
reported by the CLI after the whole run.
|
||||
- [x] **[V] Configurable naming rules via regex** (module/instance/
|
||||
parameter/enum naming), with named presets like Verible's
|
||||
(snake_case, ALL_CAPS, etc.).
|
||||
@@ -4318,14 +4321,26 @@ lines (221, 229), this section.
|
||||
e2e case over the wire; CLI: `--waiver-file` twice, toml + CLI combined,
|
||||
exit codes.
|
||||
|
||||
- [ ] 39.1 `waiver_file.rs` + application in `lib.rs`
|
||||
- [ ] 39.2 discovery: toml, CLI flag, editor setting
|
||||
- [ ] 39.3 unused reporting (CLI), errors (both front ends)
|
||||
- [ ] docs: feature README; README/site "Waivers" section; §4 lines ticked
|
||||
- [ ] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged; smoke
|
||||
- [ ] QA: every directive shape and error attacked on both front ends;
|
||||
- [x] 39.1 `waiver_file.rs` + application in `lib.rs` — the union lives in
|
||||
`lib.rs::waive`, which asks both waiver kinds about every violation and
|
||||
never short-circuits, so a finding two waivers cover marks both used;
|
||||
`waiver.rs`'s `filter` became `covers`
|
||||
- [x] 39.2 discovery: toml (`[lint] waivers`, resolved against that toml),
|
||||
CLI flag (`--waiver-file`, repeatable, adds to it), editor setting
|
||||
(`lucisv.lint.waivers`, hand-written in `package.json` — the generator
|
||||
and its drift test cover only `severity.*` and `rules.*`)
|
||||
- [x] 39.3 unused reporting (CLI, after the whole run, at the waiver file's
|
||||
own line); errors `<file>:<line>: message` — exit 2 on the CLI, dropped
|
||||
line by line and logged once on the server
|
||||
- [x] docs: feature README; §4 lines ticked. The README/site "Waivers"
|
||||
section is ready to paste in the feature README under "Docs to apply at
|
||||
merge (lead)" — those files were being edited by another process
|
||||
- [x] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged; smoke
|
||||
- [x] QA: every directive shape and error attacked on both front ends;
|
||||
precedence attacked; an opentitan run with a waiver file that waives
|
||||
one real finding, read-only, counts re-derived
|
||||
one real finding, read-only, counts re-derived — verdict REWORK, one
|
||||
HIGH finding (code-action/fixAll does not honor external waivers); see
|
||||
the feature README's QA log
|
||||
|
||||
## 40. Performance take 3 on opentitan (owner request 2026-09-04) — after §38 and §39 merge
|
||||
|
||||
@@ -4367,3 +4382,159 @@ pre-existing modified files stay as they are). Every run under
|
||||
- [ ] CLI sweeps, three binaries, RSS included
|
||||
- [ ] `docs/performance_take3.md` + perf README entry
|
||||
- [ ] opentitan status unchanged after every run
|
||||
|
||||
## 41. Repository-analysis fix 1 (planned 2026-09-04) — same-target atomic writers (topo §2.9-26)
|
||||
|
||||
From `docs/repository-analysis.md` finding 1 and topo handshake 26. One
|
||||
lane after §39 merges, §36's protocol. Feature README:
|
||||
`docs/features/atomic-write-coordination/README.md`. Ships in 0.43.0 with
|
||||
§42 and §43.
|
||||
|
||||
The audit's probe: two threads writing 1 MiB each through `write_atomic` to
|
||||
one target collided on the temp name (canonical target + pid — the *same*
|
||||
process, so the same name) — 100 write errors in 200 calls, no mixed bytes.
|
||||
Two ways in: the CLI's `dedup` (`lucisv/src/main.rs`) folds `.`/`..` but
|
||||
leaves symlinks unresolved, so two spellings of one file reach two rayon
|
||||
workers; and any two threads in one process writing one path.
|
||||
|
||||
- **Exclusive, unique temp files.** `atomic::temp_path` gains a per-process
|
||||
counter (`AtomicU64`) beside the pid: `.{name}.{pid}.{n}.lucisv-tmp`; the
|
||||
temp is opened with `OpenOptions::new().write(true).create_new(true)`
|
||||
(O_EXCL) so a collision is an `AlreadyExists` error that retries with the
|
||||
next counter value, never a shared file. The temp's mode is set before
|
||||
the bytes are written (a 0600 target must not spend a moment world-
|
||||
readable).
|
||||
- **Dedup by target identity.** `dedup` keys on the canonical path when the
|
||||
file exists (`fs::canonicalize`), falling back to today's lexical key
|
||||
when it does not; the *reported* path stays the user's spelling (the
|
||||
first seen). That closes the symlink alias without changing any output.
|
||||
- **Last-writer semantics stated.** Two processes writing one target still
|
||||
race (rename is atomic, the later rename wins); both write formatted
|
||||
bytes of the same input, and the formatter is idempotent, so the result
|
||||
is whole and correct either way. Say so in the README and the atomic.rs
|
||||
module doc; do not build a lock.
|
||||
- Tests: the audit's probe as a real test (two barrier-started threads ×
|
||||
100 rounds, 1 MiB each, **0 write errors**, final bytes always one
|
||||
writer's whole buffer); a symlink alias through the real CLI (`lucisv
|
||||
format dir/` where `dir/b.sv -> a.sv`: one write, one report line);
|
||||
`dedup` with a symlink and with a missing file; the counter's
|
||||
uniqueness; the 0600 window (the temp is never readable by others —
|
||||
assert its mode right after creation in the test's own thread).
|
||||
|
||||
- [ ] 41.1 exclusive unique temps, mode before bytes
|
||||
- [ ] 41.2 dedup by canonical identity, reported path unchanged
|
||||
- [ ] docs: feature README; topo §2.9-26 struck (lead); analysis finding
|
||||
1 annotated "fixed by §41" (lead)
|
||||
- [ ] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged;
|
||||
byte-identity vs 0.42.0
|
||||
- [ ] QA: the probe re-run under the guard at 4 threads; alias attacks
|
||||
through the CLI (relative/absolute/`..` spellings + symlink); a
|
||||
target that is itself a symlink into another directory; RSS of the
|
||||
100-round probe
|
||||
|
||||
## 42. Repository-analysis fix 2 (planned 2026-09-04) — one lint-configuration contract for project and editor (topo §2.9-28)
|
||||
|
||||
Finding 2 / handshake 28. One lane after §41. Feature README:
|
||||
`docs/features/lint-config-contract/README.md`. Ships in 0.43.0.
|
||||
|
||||
**Contract (lead's ruling), which is the CLI's today applied to the
|
||||
editor:** the editor's settings play the role the CLI's flags play.
|
||||
`lucisv/src/lint.rs` already does `pick(--select, toml select)` — the flag
|
||||
when given, else the project file. The server does the same, key by key:
|
||||
|
||||
- rung 2 of `enabled_rules`'s ladder becomes: `lucisv.lint.select` when
|
||||
non-empty, else `[lint] select` from the buffer's `lucisv.toml`, else
|
||||
the base set;
|
||||
- rung 5: `lucisv.lint.ignore` when non-empty, else `[lint] ignore`;
|
||||
- rungs 3 and 4 (class switches, per-rule tri-states) are editor-only and
|
||||
unchanged — the project file has no such keys;
|
||||
- rule options: unchanged (project options, editor overlay key by key).
|
||||
- **Rejected project rule options are surfaced**, not dropped: a
|
||||
`[lint.<rule>]` entry `set_raw` refuses — and, from §39's QA, a bad
|
||||
directive line in a file named by `[lint] waivers`, which the server
|
||||
today drops silently where the editor-setting path logs it — is logged
|
||||
once per
|
||||
(config file, entry) through `notification.rs` as
|
||||
`<toml>:<line>: <message>`, exactly the wording `lucisv check` prints
|
||||
before failing the run. The server keeps linting with the entry
|
||||
dropped (an editor cannot "fail the run"); say so.
|
||||
- `enabled_rules` therefore takes the project's selection as an argument
|
||||
(a small struct `ProjectLint { select, ignore }` read by `configured`
|
||||
from the discovered file) — no second discovery, one read per buffer
|
||||
per settings generation, cached the way `configured` already caches or
|
||||
not at all if it does not (measure: it must not add a file read per
|
||||
diagnostic pass — the `Discovery` result is already computed there).
|
||||
- Docs: the README/site sentence the audit wrote ("project selection
|
||||
controls CLI runs; editor selection requires `lucisv.lint.*`") becomes
|
||||
the new contract in both places (lead applies to README/site at merge;
|
||||
the dev writes the text in the feature README).
|
||||
- Tests: unit — every combination of {toml select, editor select} ×
|
||||
{toml ignore, editor ignore} against the ladder; severity words in the
|
||||
toml's lists; a rejected project option logged once and the lint still
|
||||
running; wire-level e2e — a workspace with `[lint] select = ["no-tabs"]`
|
||||
and no editor settings publishes only `no-tabs` diagnostics; adding
|
||||
`lucisv.lint.select` over the wire replaces it; `didChangeConfiguration`
|
||||
back to empty restores the project's; the CLI's and the server's rule
|
||||
lists for the same buffer are asserted **equal** for three configs.
|
||||
|
||||
- [ ] 42.1 project selection into the ladder, editor-when-set-else-project
|
||||
- [ ] 42.2 rejected project options logged with file:line
|
||||
- [ ] docs + tests above; topo §2.9-28 struck (lead); finding 2 annotated
|
||||
- [ ] Gates (guarded); e2e green
|
||||
- [ ] QA: the four-way matrix over the wire; the CLI/server equality on
|
||||
an opentitan IP (read-only) with its real `lucisv.toml` if one
|
||||
exists, else a scratch one
|
||||
|
||||
## 43. Repository-analysis fix 3 (planned 2026-09-04) — a cycle policy for the walker (topo §2.9-8), and the net-delay comment slot (§2.9-27)
|
||||
|
||||
Finding 3 / handshakes 8 and 27. One lane after §42. Feature README:
|
||||
`docs/features/walk-cycles/README.md`. Ships in 0.43.0.
|
||||
|
||||
### 43.1 Walker cycle policy
|
||||
|
||||
`lucisv_core/src/walk.rs` recurses on `Path::is_dir()` with no visited set;
|
||||
a symlink cycle (`a/loop -> ..`) runs until the OS refuses. Policy (lead's
|
||||
ruling): **each directory is entered once by identity**, and a symlink to a
|
||||
directory already on the current path is skipped silently. Identity is
|
||||
`(dev, ino)` from `fs::metadata` on unix and the canonical path elsewhere.
|
||||
A symlinked directory that is *not* an ancestor is still followed once
|
||||
(today's behaviour for `rtl -> ../shared/rtl` stays). No traversal budget:
|
||||
identity is the policy, and a budget would be a second, weaker rule.
|
||||
|
||||
- `Walker` gains `visited: HashSet<Identity>`; `dir()` checks-and-inserts
|
||||
before reading. The same file reached twice through two symlinked
|
||||
directories is reported once (the first spelling), which also removes
|
||||
the dedup case §41.2 would otherwise catch late.
|
||||
- Tests: `a/loop -> a` terminates and yields `a`'s files once; `a/up -> ..`
|
||||
from a nested start; two symlinked dirs to one target yield its files
|
||||
once; a symlink to a *sibling* directory is still followed; a dangling
|
||||
symlink is skipped; the gitignore interplay is unchanged (a cycle inside
|
||||
an ignored dir never runs). Both front ends: the CLI walks it, the
|
||||
server's index scan (`lucisv_server` uses the same walk — confirm with
|
||||
grep) opens a cyclic workspace and finishes.
|
||||
|
||||
### 43.2 Comment before a net delay's `#`
|
||||
|
||||
`wire /* c */ #5 w;` and `wire [7:0] /* c */ #5 w;` are refused by the
|
||||
verifier because `NetDelay` has no comment slot. Add `before_hash:
|
||||
Vec<Comment>` on `NetDelay` (parser takes the gap before `#` the way other
|
||||
slots do — see `docs/features/comment-slots/README.md` for the house
|
||||
mechanism and its gap fuzzer), the formatter prints it inline before `#`,
|
||||
the `#SKIP` in `net_delay_position.cases` goes live, the gap fuzzer covers
|
||||
the new slot.
|
||||
|
||||
- [ ] 43.1 visited-by-identity walker, both front ends, tests
|
||||
- [ ] 43.2 `NetDelay::before_hash`, the `#SKIP` retired
|
||||
- [ ] docs; topo §2.9-8 and §2.9-27 struck (lead); finding 3 annotated
|
||||
- [ ] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged;
|
||||
byte-identity vs 0.42.0; a cyclic scratch tree through both binaries
|
||||
- [ ] QA: cycles of depth 1–3 through the CLI and the server (guarded,
|
||||
time-limited); the comment slot attacked with every comment shape
|
||||
and position; the gap fuzzer re-run
|
||||
|
||||
## Loop order (2026-09-04, owner: "follow the repository analysis")
|
||||
|
||||
§39 (in flight) → 0.42.0 → §41 → §42 → §43 → 0.43.0 → §40 performance
|
||||
take 3 on opentitan. The audit's own doc edits (README, topo, site) are
|
||||
committed by the lead as one "docs: repository analysis" commit once that
|
||||
process is finished, before §41 starts.
|
||||
@@ -71,6 +71,12 @@ pub struct Options {
|
||||
pub select: Vec<String>,
|
||||
/// `check` only: rules to drop from whatever `--select` left.
|
||||
pub ignore: Vec<String>,
|
||||
/// `check` only: external waiver files, relative to the current
|
||||
/// directory. They *add* to whatever `[lint] waivers` in a `lucisv.toml`
|
||||
/// names — a waiver file suppresses findings and can only ever suppress
|
||||
/// fewer of them by being left out, so there is nothing here for a
|
||||
/// command line flag to override.
|
||||
pub waiver_files: Vec<String>,
|
||||
/// `check` only: print the generated rule reference and exit, reading no
|
||||
/// file at all.
|
||||
pub rules_doc: bool,
|
||||
@@ -203,6 +209,9 @@ CHECK OPTIONS (`lucisv check` only):
|
||||
--fix apply safe fixes and write the files back
|
||||
--unsafe-fixes let --fix apply unsafe fixes too (no rule ships
|
||||
one yet, so today this changes nothing)
|
||||
--waiver-file <PATH> read waiver directives from this file; may be
|
||||
repeated, and adds to whatever `[lint] waivers`
|
||||
in a lucisv.toml already names
|
||||
--rules-doc print the rule reference — every rule, what it
|
||||
reports and whether it has a fix — as Markdown on
|
||||
stdout and exit 0. Generated from the registry, so
|
||||
@@ -215,6 +224,31 @@ CHECK OPTIONS (`lucisv check` only):
|
||||
accepted in place of `lucisv:`. A waiver that suppresses nothing is
|
||||
reported under the `unused-waiver` rule.
|
||||
|
||||
WAIVER FILES:
|
||||
Findings can also be suppressed from outside the RTL, in Verible's waiver
|
||||
file format — one directive per line, `#` comments and blank lines ignored:
|
||||
|
||||
waive --rule=<rule> every line of every file
|
||||
waive --rule=<rule> --line=12 one line
|
||||
waive --rule=<rule> --line=12-20 a range, both ends included
|
||||
waive --rule=<rule> --location=legacy.sv the files that pattern names
|
||||
|
||||
`--rule` is required and names one rule (a severity word is not accepted);
|
||||
`--line` is 1-based and a range includes both ends; `--location` is matched
|
||||
the way an `--exclude` pattern is — `*` within one path component, a
|
||||
pattern with `/` against a path suffix and one without against the file
|
||||
name. Unlike Verible's, it is **not** a regular expression, and a pattern
|
||||
that looks like one is an error rather than a silent mismatch.
|
||||
|
||||
lucisv reads `--waiver-file <PATH>` (relative to the current directory) and
|
||||
every path in `waivers` under `[lint]` in a `lucisv.toml` (relative to that
|
||||
file). An external waiver and an inline one are a union: a finding either
|
||||
covers is suppressed, and neither is then reported as dead. A file that
|
||||
does not exist, or a directive that does not parse, fails the run with
|
||||
`<file>:<line>: message` and exit 2. An external waiver that suppressed
|
||||
nothing anywhere in the run is reported under `unused-waiver`, at the line
|
||||
of the waiver file it was written on.
|
||||
|
||||
IGNORE FILES:
|
||||
While walking a directory, lucisv reads a `.gitignore` in every directory it
|
||||
enters and skips what it names; a deeper file overrides a shallower one and
|
||||
@@ -250,8 +284,11 @@ CONFIGURATION:
|
||||
read by lucisv-server only — the CLI reads a filelist only when `-f` names
|
||||
one, so `lucisv rtl/` always means the directory it was given). One table
|
||||
is recognized, `[lint]`, with `select` and `ignore` (arrays of rule names,
|
||||
`--select`/`--ignore` semantics). A command line flag overrides the file's
|
||||
corresponding key; the other keys still apply.
|
||||
`--select`/`--ignore` semantics) and `waivers` (an array of waiver file
|
||||
paths, resolved against the config file's own directory). A command line
|
||||
flag overrides the file's corresponding key; the other keys still apply —
|
||||
`--waiver-file` is the exception, and adds to `waivers` rather than
|
||||
replacing it.
|
||||
|
||||
RANGE FORMATTING:
|
||||
`--lines` formats one construct at a time: an item whose lines meet a range
|
||||
@@ -298,6 +335,7 @@ fn parse_from(args: impl Iterator<Item = String>) -> Result<Options, String> {
|
||||
unsafe_fixes: false,
|
||||
select: Vec::new(),
|
||||
ignore: Vec::new(),
|
||||
waiver_files: Vec::new(),
|
||||
rules_doc: false,
|
||||
inputs: Vec::new(),
|
||||
filelists: Vec::new(),
|
||||
@@ -378,6 +416,10 @@ fn parse_from(args: impl Iterator<Item = String>) -> Result<Options, String> {
|
||||
let v = args.next().ok_or("--ignore requires a value")?;
|
||||
opts.ignore.extend(split_rules(&v));
|
||||
}
|
||||
"--waiver-file" => {
|
||||
let v = args.next().ok_or("--waiver-file requires a value")?;
|
||||
opts.waiver_files.push(v);
|
||||
}
|
||||
"--rules-doc" => opts.rules_doc = true,
|
||||
"-h" | "--help" => {
|
||||
print_help();
|
||||
@@ -444,6 +486,7 @@ fn check_flag_scopes(opts: &Options) -> Result<(), String> {
|
||||
(opts.output_format != OutputFormat::Text, "--output-format"),
|
||||
(!opts.select.is_empty(), "--select"),
|
||||
(!opts.ignore.is_empty(), "--ignore"),
|
||||
(!opts.waiver_files.is_empty(), "--waiver-file"),
|
||||
(opts.rules_doc, "--rules-doc"),
|
||||
];
|
||||
let format_only = [
|
||||
@@ -614,6 +657,16 @@ mod tests {
|
||||
assert!(parse(&["--no-gitignore", "rtl"]).unwrap().no_gitignore);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn waiver_files_are_collected_in_order_and_are_lint_only() {
|
||||
let opts = parse(&["check", "--waiver-file", "a.waiver", "--waiver-file", "b", "rtl"])
|
||||
.expect("parsed");
|
||||
assert_eq!(opts.waiver_files, vec!["a.waiver", "b"]);
|
||||
assert!(parse(&["check", "rtl"]).unwrap().waiver_files.is_empty());
|
||||
assert!(parse(&["check", "--waiver-file"]).is_err(), "a value is required");
|
||||
assert!(parse(&["--waiver-file", "a.waiver", "rtl"]).is_err(), "not a formatter flag");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rules_doc_is_the_one_check_that_needs_no_input() {
|
||||
assert!(parse(&["check", "--rules-doc"]).unwrap().rules_doc);
|
||||
|
||||
+163
-40
@@ -16,7 +16,8 @@ use vlog_formatter::fence::{self, Region};
|
||||
use vlog_formatter::Config;
|
||||
use vlog_linter::words;
|
||||
use vlog_linter::{
|
||||
apply_fixes, lint, Fix, MentionOracle, ParsedSource, Rule, RuleOptions, Violation,
|
||||
apply_fixes, lint_with, ExternalWaivers, Fix, MentionOracle, ParsedSource, Rule, RuleOptions,
|
||||
Violation, WaiverUse,
|
||||
};
|
||||
use vlog_parser::LineIndex;
|
||||
|
||||
@@ -46,6 +47,15 @@ pub struct Plan {
|
||||
/// The project's identifier census, built when at least one selected rule
|
||||
/// asks for a workspace and there is more than one file to ask about.
|
||||
census: Option<Census>,
|
||||
/// Every external waiver file the run reads, applied to every job.
|
||||
///
|
||||
/// One set for the whole run rather than one per file, because a
|
||||
/// `--location` pattern names files and a waiver is only *unused* when no
|
||||
/// file in the run matched it — a question only the whole run can answer.
|
||||
external: ExternalWaivers,
|
||||
/// Every rule name any job in the run has switched on, for deciding which
|
||||
/// external waivers never had a chance to fire.
|
||||
enabled: Vec<&'static str>,
|
||||
}
|
||||
|
||||
/// How many of the run's files write each identifier down.
|
||||
@@ -163,6 +173,7 @@ impl MentionOracle for Elsewhere<'_> {
|
||||
/// already says about itself.
|
||||
pub fn plan(opts: &Options, gathered: Vec<(PathBuf, Config, FileConfig)>) -> Result<Plan, String> {
|
||||
let workspace = gathered.len() > 1;
|
||||
let external = external_waivers(opts, gathered.iter().map(|(_, _, file)| file))?;
|
||||
let mut jobs = Vec::with_capacity(gathered.len());
|
||||
for (path, config, file_config) in gathered {
|
||||
let select = pick(&opts.select, file_config.lint_select.as_deref());
|
||||
@@ -175,7 +186,56 @@ pub fn plan(opts: &Options, gathered: Vec<(PathBuf, Config, FileConfig)>) -> Res
|
||||
let wanted = jobs.iter().any(|job| job.rules.iter().any(|rule| rule.needs_workspace()));
|
||||
let interfaces = jobs.iter().any(|job| job.rules.iter().any(|rule| reads_interfaces(*rule)));
|
||||
let census = (workspace && wanted).then(|| Census::of(&jobs, workspace && interfaces));
|
||||
Ok(Plan { jobs, census })
|
||||
let mut enabled: Vec<&'static str> =
|
||||
jobs.iter().flat_map(|job| job.rules.iter().map(|rule| rule.name())).collect();
|
||||
enabled.sort_unstable();
|
||||
enabled.dedup();
|
||||
Ok(Plan { jobs, census, external, enabled })
|
||||
}
|
||||
|
||||
/// The run's external waiver files, read once each: `--waiver-file` in flag
|
||||
/// order, then every `[lint] waivers` entry of a config file governing an
|
||||
/// input.
|
||||
///
|
||||
/// The two **add up** rather than override: a waiver file only ever suppresses
|
||||
/// findings, so there is nothing for a command line to take back. A file named
|
||||
/// twice over — the flag and a `lucisv.toml`, or one `lucisv.toml` governing
|
||||
/// five hundred files — is read once, or its directives would each be reported
|
||||
/// unused as many times as the file was read.
|
||||
///
|
||||
/// A file that cannot be read, or a directive that does not parse, fails the
|
||||
/// run naming the file and the line, exactly as a bad `[lint.<rule>]` entry
|
||||
/// does and for the same reason: a user wrote it and is watching.
|
||||
pub fn external_waivers<'a>(
|
||||
opts: &Options,
|
||||
configs: impl Iterator<Item = &'a FileConfig>,
|
||||
) -> Result<ExternalWaivers, String> {
|
||||
let mut paths: Vec<PathBuf> = opts.waiver_files.iter().map(PathBuf::from).collect();
|
||||
for config in configs {
|
||||
for path in config.lint_waivers.iter().flatten() {
|
||||
paths.push(path.clone());
|
||||
}
|
||||
}
|
||||
let mut read: Vec<PathBuf> = Vec::new();
|
||||
let mut waivers = ExternalWaivers::default();
|
||||
for path in paths {
|
||||
// Compared canonically, because the flag's path is relative to the
|
||||
// working directory and a `lucisv.toml`'s is absolute: the same file
|
||||
// named both ways is still one file, and reading it twice would report
|
||||
// each of its dead directives twice. Only the *comparison* is
|
||||
// canonical — the path a diagnostic names stays the one written.
|
||||
let key = std::fs::canonicalize(&path).unwrap_or_else(|_| path.clone());
|
||||
if read.contains(&key) {
|
||||
continue;
|
||||
}
|
||||
let (file, problems) = ExternalWaivers::read(&path)?;
|
||||
if let Some(problem) = problems.first() {
|
||||
return Err(problem.clone());
|
||||
}
|
||||
waivers.absorb(file);
|
||||
read.push(key);
|
||||
}
|
||||
Ok(waivers)
|
||||
}
|
||||
|
||||
/// The `[lint.<rule>]` entries of one file's config, resolved against the
|
||||
@@ -234,12 +294,30 @@ struct Report {
|
||||
violations: Vec<Violation>,
|
||||
/// Violations whose fix was applied and written back.
|
||||
fixed: usize,
|
||||
/// Which of the run's external waivers suppressed something in this file.
|
||||
/// Merged across every file before the dead ones are reported.
|
||||
used: WaiverUse,
|
||||
/// Set when the file could not be fully checked: unreadable, unwritable,
|
||||
/// or — because the lexer is all-or-nothing — unlexable, in which case
|
||||
/// only the text-level rules saw it.
|
||||
error: Option<String>,
|
||||
}
|
||||
|
||||
/// Everything one file's lint pass reads besides the file itself.
|
||||
///
|
||||
/// One value rather than six parameters: every function below the driver
|
||||
/// needs the same set, and the `--fix` loop passes it down another level
|
||||
/// again.
|
||||
struct Pass<'a> {
|
||||
config: &'a Config,
|
||||
rules: &'a [&'static dyn Rule],
|
||||
options: &'a RuleOptions,
|
||||
census: Option<&'a Census>,
|
||||
/// The run's external waiver files. Empty unless `--waiver-file` or a
|
||||
/// `[lint] waivers` named one, and then costing nothing.
|
||||
external: &'a ExternalWaivers,
|
||||
}
|
||||
|
||||
/// Lints every gathered file and reports. Exit 1 if anything is left over,
|
||||
/// 2 if a file could not be read, written, or lexed.
|
||||
pub fn check_files(opts: &Options, plan: &Plan) -> ExitCode {
|
||||
@@ -247,9 +325,20 @@ pub fn check_files(opts: &Options, plan: &Plan) -> ExitCode {
|
||||
.jobs
|
||||
.par_iter()
|
||||
.map(|job| {
|
||||
check_one(&job.path, &job.config, opts, &job.rules, &job.options, plan.census.as_ref())
|
||||
let pass = Pass {
|
||||
config: &job.config,
|
||||
rules: &job.rules,
|
||||
options: &job.options,
|
||||
census: plan.census.as_ref(),
|
||||
external: &plan.external,
|
||||
};
|
||||
check_one(&job.path, opts, &pass)
|
||||
})
|
||||
.collect();
|
||||
// The dead external waivers are found once every file has been linted,
|
||||
// and reported against the waiver file, which then sorts in among the
|
||||
// sources like any other path.
|
||||
reports.extend(dead_waivers(&plan.external, &reports, &plan.enabled));
|
||||
// Diagnostics are printed sorted by path, then by position within the
|
||||
// file (`lint` already sorts those), so a run over a directory reads
|
||||
// top to bottom whatever order the walk or the worker pool produced.
|
||||
@@ -257,6 +346,37 @@ pub fn check_files(opts: &Options, plan: &Plan) -> ExitCode {
|
||||
finish(opts, reports)
|
||||
}
|
||||
|
||||
/// The `unused-waiver` reports for external waivers no file in the run used.
|
||||
///
|
||||
/// **After the whole run**, which is the whole reason this is the CLI's job
|
||||
/// and not the linter's: a `--location` pattern may match a file the run has
|
||||
/// not reached yet, so a waiver is only dead once every file has been asked.
|
||||
fn dead_waivers(
|
||||
external: &ExternalWaivers,
|
||||
reports: &[Report],
|
||||
enabled: &[&'static str],
|
||||
) -> Vec<Report> {
|
||||
if external.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut used = WaiverUse::default();
|
||||
for report in reports {
|
||||
used.merge(&report.used);
|
||||
}
|
||||
external
|
||||
.unused(&used, enabled)
|
||||
.into_iter()
|
||||
.map(|dead| Report {
|
||||
path: dead.path.display().to_string(),
|
||||
index: LineIndex::new(&dead.text),
|
||||
violations: dead.violations,
|
||||
fixed: 0,
|
||||
used: WaiverUse::default(),
|
||||
error: None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Lints a buffer piped in on stdin. `--stdin-filename` names it, and is
|
||||
/// what the rules that need a file name see.
|
||||
pub fn check_stdin(
|
||||
@@ -265,32 +385,34 @@ pub fn check_stdin(
|
||||
config: &Config,
|
||||
rules: &[&'static dyn Rule],
|
||||
options: &RuleOptions,
|
||||
external: &ExternalWaivers,
|
||||
) -> ExitCode {
|
||||
let name = opts.stdin_filename.clone().unwrap_or_else(|| "<stdin>".to_string());
|
||||
let path = opts.stdin_filename.as_ref().map(PathBuf::from);
|
||||
let (violations, lex_error) = run_rules(src, path, config, rules, options, None);
|
||||
let pass = Pass { config, rules, options, census: None, external };
|
||||
let (violations, used, lex_error) = run_rules(src, path, &pass);
|
||||
// Nothing is ever written back for stdin, so `--fix` has nothing to do
|
||||
// here; the violations are reported as they are.
|
||||
let error = lex_error.map(|e| format!("{name}: {e}"));
|
||||
let report = Report { path: name, index: LineIndex::new(src), violations, fixed: 0, error };
|
||||
finish(opts, vec![report])
|
||||
let report =
|
||||
Report { path: name, index: LineIndex::new(src), violations, fixed: 0, used, error };
|
||||
// One buffer is a whole run too, so a waiver that covered nothing in it is
|
||||
// as dead as one that covered nothing in a directory.
|
||||
let names: Vec<&'static str> = rules.iter().map(|rule| rule.name()).collect();
|
||||
let mut reports = vec![report];
|
||||
reports.extend(dead_waivers(external, &reports, &names));
|
||||
finish(opts, reports)
|
||||
}
|
||||
|
||||
/// Lints one file, optionally fixing it, and never panics out of its worker.
|
||||
fn check_one(
|
||||
file: &Path,
|
||||
config: &Config,
|
||||
opts: &Options,
|
||||
rules: &[&'static dyn Rule],
|
||||
options: &RuleOptions,
|
||||
census: Option<&Census>,
|
||||
) -> Report {
|
||||
fn check_one(file: &Path, opts: &Options, pass: &Pass) -> Report {
|
||||
let path = file.display().to_string();
|
||||
let failed = |error: String| Report {
|
||||
path: path.clone(),
|
||||
index: LineIndex::new(""),
|
||||
violations: Vec::new(),
|
||||
fixed: 0,
|
||||
used: WaiverUse::default(),
|
||||
error: Some(error),
|
||||
};
|
||||
|
||||
@@ -300,14 +422,13 @@ fn check_one(
|
||||
};
|
||||
let outcome = crate::catch_panic(|| {
|
||||
if opts.fix {
|
||||
fix_source(&src, file, config, opts, rules, options, census)
|
||||
fix_source(&src, file, opts, pass)
|
||||
} else {
|
||||
let (violations, lex_error) =
|
||||
run_rules(&src, Some(file.to_path_buf()), config, rules, options, census);
|
||||
(violations, None, 0, lex_error)
|
||||
let (violations, used, lex_error) = run_rules(&src, Some(file.to_path_buf()), pass);
|
||||
(violations, used, None, 0, lex_error)
|
||||
}
|
||||
});
|
||||
let (violations, rewritten, fixed, lex_error) = match outcome {
|
||||
let (violations, used, rewritten, fixed, lex_error) = match outcome {
|
||||
Ok(outcome) => outcome,
|
||||
Err(msg) => return failed(format!("{path}: panicked while linting: {msg}")),
|
||||
};
|
||||
@@ -322,21 +443,20 @@ fn check_one(
|
||||
// so the file must not pass as checked. It is an error (exit 2), exactly
|
||||
// as `lucisv format` treats the same file.
|
||||
let error = lex_error.map(|e| format!("{path}: {e}"));
|
||||
Report { path, index, violations, fixed, error }
|
||||
Report { path, index, violations, fixed, used, error }
|
||||
}
|
||||
|
||||
/// Runs the rules over one text. The second half of the answer is the lex
|
||||
/// error when the text does not lex — rendered `line:col: message`, ready
|
||||
/// for a path prefix — because a file with no tokens was only text-linted
|
||||
/// and must be reported as an error, not passed off as clean.
|
||||
/// Runs the rules over one text, reporting which external waivers fired. The
|
||||
/// last part of the answer is the lex error when the text does not lex —
|
||||
/// rendered `line:col: message`, ready for a path prefix — because a file with
|
||||
/// no tokens was only text-linted and must be reported as an error, not passed
|
||||
/// off as clean.
|
||||
fn run_rules(
|
||||
src: &str,
|
||||
path: Option<PathBuf>,
|
||||
config: &Config,
|
||||
rules: &[&'static dyn Rule],
|
||||
options: &RuleOptions,
|
||||
census: Option<&Census>,
|
||||
) -> (Vec<Violation>, Option<String>) {
|
||||
pass: &Pass,
|
||||
) -> (Vec<Violation>, WaiverUse, Option<String>) {
|
||||
let Pass { config, rules, options, census, external } = *pass;
|
||||
// One parse per file (TODO §4): the products are built here, once, and
|
||||
// lent to the context. Under `--fix` each *round* re-enters through this
|
||||
// function with rewritten text — that re-parse is inherent (the old
|
||||
@@ -360,7 +480,8 @@ fn run_rules(
|
||||
Some(elsewhere) => ctx.with_oracle(elsewhere),
|
||||
None => ctx,
|
||||
};
|
||||
(lint(&ctx, rules), lex_error)
|
||||
let (violations, used) = lint_with(&ctx, rules, external);
|
||||
(violations, used, lex_error)
|
||||
}
|
||||
|
||||
/// The violations whose fix may be applied: everything except a fix that
|
||||
@@ -399,16 +520,15 @@ fn touches_fence(fix: &Fix, regions: &[Region]) -> bool {
|
||||
fn fix_source(
|
||||
src: &str,
|
||||
file: &Path,
|
||||
config: &Config,
|
||||
opts: &Options,
|
||||
rules: &[&'static dyn Rule],
|
||||
options: &RuleOptions,
|
||||
census: Option<&Census>,
|
||||
) -> (Vec<Violation>, Option<String>, usize, Option<String>) {
|
||||
pass: &Pass,
|
||||
) -> (Vec<Violation>, WaiverUse, Option<String>, usize, Option<String>) {
|
||||
let mut text = src.to_string();
|
||||
let mut fixed = 0;
|
||||
let (mut violations, mut lex_error) =
|
||||
run_rules(&text, Some(file.to_path_buf()), config, rules, options, census);
|
||||
let mut used = WaiverUse::default();
|
||||
let (mut violations, mut round_used, mut lex_error) =
|
||||
run_rules(&text, Some(file.to_path_buf()), pass);
|
||||
used.merge(&round_used);
|
||||
for _ in 0..MAX_FIX_ROUNDS {
|
||||
let round =
|
||||
apply_fixes(&text, &fixable_outside_fences(&text, &violations), opts.unsafe_fixes);
|
||||
@@ -417,11 +537,14 @@ fn fix_source(
|
||||
}
|
||||
fixed += round.applied;
|
||||
text = round.output;
|
||||
(violations, lex_error) =
|
||||
run_rules(&text, Some(file.to_path_buf()), config, rules, options, census);
|
||||
(violations, round_used, lex_error) = run_rules(&text, Some(file.to_path_buf()), pass);
|
||||
// A waiver that covered a finding in an earlier round did its job even
|
||||
// though the fix then removed the finding, so usage accumulates over
|
||||
// the rounds rather than being the last round's.
|
||||
used.merge(&round_used);
|
||||
}
|
||||
let rewritten = (text != src).then_some(text);
|
||||
(violations, rewritten, fixed, lex_error)
|
||||
(violations, used, rewritten, fixed, lex_error)
|
||||
}
|
||||
|
||||
/// Prints the run and turns it into an exit code.
|
||||
|
||||
@@ -128,7 +128,17 @@ fn run_check(opts: &Options) -> ExitCode {
|
||||
return ExitCode::from(2);
|
||||
}
|
||||
};
|
||||
return lint::check_stdin(opts, &src, &config, &rules, &options);
|
||||
// A stdin buffer has one config file too — the one governing
|
||||
// `--stdin-filename`, or the working directory's — so `[lint] waivers`
|
||||
// reaches it exactly as `[lint] select` does.
|
||||
let external = match lint::external_waivers(opts, std::iter::once(&file_config)) {
|
||||
Ok(external) => external,
|
||||
Err(e) => {
|
||||
eprintln!("error: {e}");
|
||||
return ExitCode::from(2);
|
||||
}
|
||||
};
|
||||
return lint::check_stdin(opts, &src, &config, &rules, &options, &external);
|
||||
}
|
||||
let jobs = match gather(opts).and_then(|jobs| build_pool(opts).map(|()| jobs)) {
|
||||
Ok(jobs) => jobs,
|
||||
|
||||
@@ -935,6 +935,89 @@ fn check_honors_inline_waivers_and_reports_dead_ones() {
|
||||
assert!(stdout(&out).contains("[unused-waiver]"), "{}", stdout(&out));
|
||||
}
|
||||
|
||||
/// Two tabbed lines, one of which a waiver file's `--line` covers.
|
||||
const TABBED: &str = "module foo;\n\twire a;\n\twire b;\nendmodule\n";
|
||||
|
||||
/// `--waiver-file`: the suppression, the flag repeated, and the dead directive
|
||||
/// reported at the waiver file's own line. TODO §39.
|
||||
#[test]
|
||||
fn check_reads_external_waiver_files() {
|
||||
let dir = TempDir::new("check-waiver-file");
|
||||
let path = dir.write("foo.sv", TABBED);
|
||||
let one = dir.write("one.waiver", "# just line 2\nwaive --rule=no-tabs --line=2\n");
|
||||
let out = run(&["check", "--waiver-file", &one, &path]);
|
||||
assert_eq!(code(&out), 1, "{}", stdout(&out));
|
||||
assert_eq!(stdout(&out).lines().count(), 1, "one tab left: {}", stdout(&out));
|
||||
assert!(stdout(&out).contains("foo.sv:3:1"), "{}", stdout(&out));
|
||||
|
||||
// A second file adds to the first rather than replacing it, and both are
|
||||
// then used, so neither is reported.
|
||||
let two = dir.write("two.waiver", "waive --rule=no-tabs --line=3 --location=foo.sv\n");
|
||||
let out = run(&["check", "--waiver-file", &one, "--waiver-file", &two, &path]);
|
||||
assert_eq!(code(&out), 0, "{}", stdout(&out));
|
||||
|
||||
// A directive that covered nothing is reported against the waiver file.
|
||||
let dead = dir.write("dead.waiver", "waive --rule=no-tabs --location=elsewhere.sv\n");
|
||||
let out = run(&["check", "--waiver-file", &dead, &path]);
|
||||
assert_eq!(code(&out), 1);
|
||||
let text = stdout(&out);
|
||||
assert!(text.contains("dead.waiver:1:1: style: unused waiver for `no-tabs`"), "{text}");
|
||||
assert!(text.contains("[unused-waiver]"), "{text}");
|
||||
}
|
||||
|
||||
/// The `[lint] waivers` key, and that `--waiver-file` adds to it. TODO §39.
|
||||
#[test]
|
||||
fn check_reads_the_waiver_files_a_config_file_names() {
|
||||
let dir = TempDir::new("check-waiver-toml");
|
||||
let path = dir.write("rtl/foo.sv", TABBED);
|
||||
dir.write("lucisv.toml", "[lint]\nwaivers = [ \"project.waiver\" ]\n");
|
||||
dir.write("project.waiver", "waive --rule=no-tabs --line=2\n");
|
||||
// Relative to the config file, not to the working directory.
|
||||
let out = run_raw(&["check", "--no-cache", &path]);
|
||||
assert_eq!(code(&out), 1, "{}", stdout(&out));
|
||||
assert!(stdout(&out).contains("foo.sv:3:1"), "only line 3 survives: {}", stdout(&out));
|
||||
|
||||
let extra = dir.write("extra.waiver", "waive --rule=no-tabs --line=3\n");
|
||||
let out = run_raw(&["check", "--no-cache", "--waiver-file", &extra, &path]);
|
||||
assert_eq!(code(&out), 0, "the two lists add up: {}", stdout(&out));
|
||||
|
||||
// `--no-config` drops the config file's list with everything else in it.
|
||||
let out = run_raw(&["check", "--no-cache", "--no-config", &path]);
|
||||
assert_eq!(code(&out), 1);
|
||||
assert_eq!(stdout(&out).lines().count(), 2, "both tabs are back: {}", stdout(&out));
|
||||
}
|
||||
|
||||
/// A waiver file that cannot be read, or that has a line that does not parse,
|
||||
/// fails the run with `<file>:<line>: message` and exit 2. TODO §39.
|
||||
#[test]
|
||||
fn a_broken_waiver_file_fails_the_run() {
|
||||
let dir = TempDir::new("check-waiver-bad");
|
||||
let path = dir.write("foo.sv", TABBED);
|
||||
|
||||
let out = run(&["check", "--waiver-file", &dir.write("x.waiver", "hush\n"), &path]);
|
||||
assert_eq!(code(&out), 2, "{}", stderr(&out));
|
||||
assert!(stderr(&out).contains("x.waiver:1: expected a `waive` directive"), "{}", stderr(&out));
|
||||
|
||||
let bad = dir.write("y.waiver", "# fine\nwaive --rule=no-such-rule\n");
|
||||
let out = run(&["check", "--waiver-file", &bad, &path]);
|
||||
assert_eq!(code(&out), 2);
|
||||
assert!(stderr(&out).contains("y.waiver:2: unknown rule"), "{}", stderr(&out));
|
||||
|
||||
let regexy = dir.write("z.waiver", "waive --rule=no-tabs --location=.*foo.sv\n");
|
||||
let out = run(&["check", "--waiver-file", ®exy, &path]);
|
||||
assert_eq!(code(&out), 2);
|
||||
assert!(stderr(&out).contains("looks like a regular expression"), "{}", stderr(&out));
|
||||
|
||||
let out = run(&[
|
||||
"check",
|
||||
"--waiver-file",
|
||||
&dir.path.join("gone.waiver").display().to_string(),
|
||||
&path,
|
||||
]);
|
||||
assert_eq!(code(&out), 2);
|
||||
assert!(stderr(&out).contains("gone.waiver:"), "{}", stderr(&out));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_reads_stdin_and_names_it() {
|
||||
let out = run_with_stdin(&["check", "--stdin-filename", "rtl/z.sv", "-"], LINTY);
|
||||
|
||||
@@ -37,6 +37,15 @@ pub struct FileConfig {
|
||||
pub lint_select: Option<Vec<String>>,
|
||||
/// `[lint] ignore`: rules dropped from whatever `select` left.
|
||||
pub lint_ignore: Option<Vec<String>>,
|
||||
/// `[lint] waivers`: external waiver files, in the order written.
|
||||
///
|
||||
/// Like [`FileConfig::filelist`], these name *other files*: [`parse`]
|
||||
/// records them exactly as written and [`Discovery`] resolves each one
|
||||
/// against the config file's own directory, so every `FileConfig` a
|
||||
/// `Discovery` hands out carries usable paths. Nothing here reads them —
|
||||
/// their contents name lint rules, and this crate does not know the rule
|
||||
/// registry any more than it does for `select`.
|
||||
pub lint_waivers: Option<Vec<PathBuf>>,
|
||||
/// `[lint.<rule>]` tables, **as written**: one entry per key, in file
|
||||
/// order.
|
||||
///
|
||||
@@ -93,7 +102,7 @@ pub fn parse(text: &str) -> Result<FileConfig, String> {
|
||||
enum Table {
|
||||
/// Before any header: the formatter's own keys.
|
||||
Top,
|
||||
/// `[lint]`: `select` and `ignore`.
|
||||
/// `[lint]`: `select`, `ignore` and `waivers`.
|
||||
Lint,
|
||||
/// `[lint.<rule>]`: that rule's options.
|
||||
Rule(String),
|
||||
@@ -106,7 +115,7 @@ fn parse_entry(
|
||||
number: usize,
|
||||
) -> Result<(), String> {
|
||||
if line.starts_with('[') {
|
||||
// `[lint]` carries `select`/`ignore`; `[lint.<rule>]` carries that
|
||||
// `[lint]` carries `select`/`ignore`/`waivers`; `[lint.<rule>]` carries that
|
||||
// rule's options, which are stored raw and checked by whoever knows
|
||||
// the registry.
|
||||
if line == "[lint]" {
|
||||
@@ -155,19 +164,28 @@ fn parse_entry(
|
||||
}
|
||||
_ => Err(format!(
|
||||
"unknown key `{key}` (known keys: line-length, indent, exclude, filelist; \
|
||||
select, ignore under `[lint]`; and a rule's own options under \
|
||||
`[lint.<rule-name>]`)"
|
||||
select, ignore, waivers under `[lint]`; and a rule's own options \
|
||||
under `[lint.<rule-name>]`)"
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// One key of the `[lint]` table.
|
||||
fn parse_lint_entry(key: &str, value: &str, config: &mut FileConfig) -> Result<(), String> {
|
||||
if key == "waivers" {
|
||||
if config.lint_waivers.is_some() {
|
||||
return Err(format!("duplicate key `{key}`"));
|
||||
}
|
||||
config.lint_waivers = Some(parse_array(value)?.into_iter().map(PathBuf::from).collect());
|
||||
return Ok(());
|
||||
}
|
||||
let slot = match key {
|
||||
"select" => &mut config.lint_select,
|
||||
"ignore" => &mut config.lint_ignore,
|
||||
_ => {
|
||||
return Err(format!("unknown key `{key}` under `[lint]` (known keys: select, ignore)"))
|
||||
return Err(format!(
|
||||
"unknown key `{key}` under `[lint]` (known keys: select, ignore, waivers)"
|
||||
))
|
||||
}
|
||||
};
|
||||
if slot.is_some() {
|
||||
@@ -359,10 +377,16 @@ fn load(path: &Path) -> Result<FileConfig, String> {
|
||||
// `filelist` is the one value that names another file, so it is resolved
|
||||
// here — against the config file's own directory, which `parse` cannot
|
||||
// know. An absolute path is left alone (`join` already does that).
|
||||
let dir = path.parent().unwrap_or(Path::new(".")).to_path_buf();
|
||||
if let Some(filelist) = config.filelist.take() {
|
||||
let dir = path.parent().unwrap_or(Path::new("."));
|
||||
config.filelist = Some(dir.join(filelist));
|
||||
}
|
||||
// `[lint] waivers` names other files the same way, and is resolved the
|
||||
// same way: against the config file's directory, an absolute path left
|
||||
// alone by `join`.
|
||||
if let Some(waivers) = config.lint_waivers.take() {
|
||||
config.lint_waivers = Some(waivers.into_iter().map(|file| dir.join(file)).collect());
|
||||
}
|
||||
// So an error about a `[lint.<rule>]` entry can name the file to edit.
|
||||
config.source = Some(path.to_path_buf());
|
||||
Ok(config)
|
||||
@@ -428,6 +452,34 @@ exclude = [ \"build\", \"*_gen.sv\", ]
|
||||
);
|
||||
}
|
||||
|
||||
/// `[lint] waivers` names other files, so it resolves the way `filelist`
|
||||
/// does: against the config file's own directory, absolute paths left
|
||||
/// alone. See `docs/features/waiver-files/README.md`.
|
||||
#[test]
|
||||
fn lint_waivers_are_a_list_resolved_against_the_config_files_directory() {
|
||||
assert_eq!(
|
||||
ok("[lint]\nwaivers = [ \"a.waiver\", \"deep/b.waiver\" ]").lint_waivers,
|
||||
Some(vec![PathBuf::from("a.waiver"), PathBuf::from("deep/b.waiver")])
|
||||
);
|
||||
assert_eq!(
|
||||
ok("[lint]\nselect = [\"no-tabs\"]").lint_waivers,
|
||||
None,
|
||||
"absent unless written"
|
||||
);
|
||||
assert!(err("[lint]\nwaivers = \"a.waiver\"").contains("multi-line arrays"));
|
||||
assert!(err("[lint]\nwaivers = []\nwaivers = []").contains("duplicate key `waivers`"));
|
||||
assert!(err("[lint]\nwaiver = []").contains("unknown key `waiver` under `[lint]`"));
|
||||
|
||||
let tree = TempTree::new();
|
||||
tree.write("lucisv.toml", "[lint]\nwaivers = [ \"rtl/a.waiver\", \"/opt/b.waiver\" ]\n");
|
||||
let deep = tree.write("a/b/x.sv", "");
|
||||
let found = Discovery::new(true).for_file(&deep).unwrap();
|
||||
assert_eq!(
|
||||
found.lint_waivers,
|
||||
Some(vec![tree.path.join("rtl/a.waiver"), PathBuf::from("/opt/b.waiver")])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_file_sets_nothing() {
|
||||
assert_eq!(ok(""), FileConfig::default());
|
||||
|
||||
@@ -14,6 +14,7 @@ use lsp_types::{
|
||||
use vlog_linter::{apply_fixes, rule_by_name, Applicability, Violation};
|
||||
|
||||
use crate::convert::Positions;
|
||||
use crate::lint::LintRun;
|
||||
use crate::state::Document;
|
||||
|
||||
/// The kind of the fix-everything action, namespaced under `source.fixAll` so
|
||||
@@ -27,6 +28,7 @@ pub const FIX_ALL: &str = "source.fixAll.lucisv";
|
||||
/// client, because a fix-on-save request asks for `source.fixAll.lucisv` alone
|
||||
/// and computing every quick fix for it would be work nobody reads.
|
||||
pub fn code_actions(
|
||||
run: &LintRun,
|
||||
uri: &Uri,
|
||||
doc: &Document,
|
||||
range: Range,
|
||||
@@ -34,7 +36,7 @@ pub fn code_actions(
|
||||
tab_width: usize,
|
||||
) -> Vec<CodeActionOrCommand> {
|
||||
let positions = doc.positions();
|
||||
let violations = crate::lint::fixable(doc, tab_width);
|
||||
let violations = crate::lint::fixable(run, doc, tab_width);
|
||||
let mut actions = Vec::new();
|
||||
if wanted(only, &CodeActionKind::QUICKFIX) {
|
||||
let quick = violations.iter().filter_map(|v| quick_fix(uri, &positions, v, range));
|
||||
@@ -170,7 +172,7 @@ mod tests {
|
||||
fn actions_of(ws: &Workspace) -> Vec<CodeAction> {
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
code_actions(&uri(), doc, whole, None, 2)
|
||||
code_actions(&LintRun::default(), &uri(), doc, whole, None, 2)
|
||||
.into_iter()
|
||||
.map(|a| match a {
|
||||
CodeActionOrCommand::CodeAction(action) => action,
|
||||
@@ -248,7 +250,14 @@ mod tests {
|
||||
start: Position { line: 1, character: 0 },
|
||||
end: Position { line: 1, character: 0 },
|
||||
};
|
||||
let actions = code_actions(&uri(), doc, line1, Some(&[CodeActionKind::QUICKFIX]), 2);
|
||||
let actions = code_actions(
|
||||
&LintRun::default(),
|
||||
&uri(),
|
||||
doc,
|
||||
line1,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
2,
|
||||
);
|
||||
assert_eq!(actions.len(), 1, "the cursor's line only: {actions:#?}");
|
||||
}
|
||||
|
||||
@@ -320,14 +329,32 @@ mod tests {
|
||||
start: Position { line: fenced_line, character: 0 },
|
||||
end: Position { line: fenced_line, character: 0 },
|
||||
};
|
||||
let actions = code_actions(&uri(), doc, at, Some(&[CodeActionKind::QUICKFIX]), 2);
|
||||
let actions = code_actions(
|
||||
&LintRun::default(),
|
||||
&uri(),
|
||||
doc,
|
||||
at,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
2,
|
||||
);
|
||||
assert!(actions.is_empty(), "no quick fix inside a fence: {actions:#?}");
|
||||
// The unfenced tab one line further down still has one.
|
||||
let at = Range {
|
||||
start: Position { line: 4, character: 0 },
|
||||
end: Position { line: 4, character: 0 },
|
||||
};
|
||||
assert_eq!(code_actions(&uri(), doc, at, Some(&[CodeActionKind::QUICKFIX]), 2).len(), 1);
|
||||
assert_eq!(
|
||||
code_actions(
|
||||
&LintRun::default(),
|
||||
&uri(),
|
||||
doc,
|
||||
at,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
2
|
||||
)
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -370,14 +397,19 @@ mod tests {
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
let fix_all_only = [CodeActionKind::new(FIX_ALL)];
|
||||
let actions = code_actions(&uri(), doc, whole, Some(&fix_all_only), 2);
|
||||
let actions = code_actions(&LintRun::default(), &uri(), doc, whole, Some(&fix_all_only), 2);
|
||||
assert_eq!(actions.len(), 1, "no quick fixes when only fixAll was asked for");
|
||||
// `source` is a prefix filter for `source.fixAll.lucisv`.
|
||||
let source = [CodeActionKind::SOURCE];
|
||||
assert_eq!(code_actions(&uri(), doc, whole, Some(&source), 2).len(), 1);
|
||||
assert_eq!(
|
||||
code_actions(&LintRun::default(), &uri(), doc, whole, Some(&source), 2).len(),
|
||||
1
|
||||
);
|
||||
// And an unrelated filter selects nothing.
|
||||
let refactor = [CodeActionKind::REFACTOR];
|
||||
assert!(code_actions(&uri(), doc, whole, Some(&refactor), 2).is_empty());
|
||||
assert!(
|
||||
code_actions(&LintRun::default(), &uri(), doc, whole, Some(&refactor), 2).is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -386,7 +418,14 @@ mod tests {
|
||||
let ws = workspace(text);
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
let actions = code_actions(&uri(), doc, whole, Some(&[CodeActionKind::QUICKFIX]), 4);
|
||||
let actions = code_actions(
|
||||
&LintRun::default(),
|
||||
&uri(),
|
||||
doc,
|
||||
whole,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
4,
|
||||
);
|
||||
let CodeActionOrCommand::CodeAction(fix) = &actions[0] else { panic!("an action") };
|
||||
assert_eq!(applied(text, fix), "module m;\n wire a;\nendmodule\n");
|
||||
}
|
||||
@@ -407,4 +446,28 @@ mod tests {
|
||||
assert!(out.contains("é 🎉"), "comments are never dropped: {out:?}");
|
||||
assert_eq!(out, "module m;\n // é 🎉 wire a;\nendmodule\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_externally_waived_finding_gets_no_quick_fix_and_fix_all_leaves_it() {
|
||||
// §39 QA's HIGH: `fixable` used `default_rules()` and no waivers, so
|
||||
// fix-on-save rewrote a line a checked-in waiver file had waived.
|
||||
let src = "module m;\n\twire a;\nendmodule\n";
|
||||
let ws = workspace(src);
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
let (external, problems) = vlog_linter::ExternalWaivers::parse(
|
||||
std::path::Path::new("team.waiver"),
|
||||
"waive --rule=no-tabs\n",
|
||||
);
|
||||
assert!(problems.is_empty(), "{problems:?}");
|
||||
let waived = LintRun::default().with_external(external);
|
||||
assert!(
|
||||
code_actions(&waived, &uri(), doc, whole, None, 2).is_empty(),
|
||||
"no quick fix and no fix-all for a waived finding"
|
||||
);
|
||||
assert!(
|
||||
!code_actions(&LintRun::default(), &uri(), doc, whole, None, 2).is_empty(),
|
||||
"the same buffer without the waiver is fixable"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,14 @@
|
||||
//! `docs/features/server-lint/README.md`.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use lsp_types::{Diagnostic, DiagnosticSeverity, NumberOrString};
|
||||
use lucisv_core::config::FileConfig;
|
||||
use vlog_formatter::fence::{self, Region};
|
||||
use vlog_linter::{
|
||||
default_rules, lint, workspace_rules, LintContext, MentionOracle, ModuleInterface, Rule,
|
||||
RuleOptions, Severity, Violation,
|
||||
default_rules, lint_with, workspace_rules, ExternalWaivers, LintContext, MentionOracle,
|
||||
ModuleInterface, Rule, RuleOptions, Severity, Violation,
|
||||
};
|
||||
use vlog_semantic::{FileId, SymbolKind, WorkspaceIndex};
|
||||
|
||||
@@ -41,6 +43,10 @@ pub struct LintRun<'a> {
|
||||
/// The width `line-length` holds this buffer to — the width the formatter
|
||||
/// would wrap it to, so the two halves of lucisv cannot disagree.
|
||||
line_length: usize,
|
||||
/// The external waiver files in force for this buffer, from its
|
||||
/// `lucisv.toml` and from `lucisv.lint.waivers`. Empty unless one is
|
||||
/// configured, and then costing the pass nothing.
|
||||
external: ExternalWaivers,
|
||||
}
|
||||
|
||||
impl Default for LintRun<'_> {
|
||||
@@ -50,6 +56,7 @@ impl Default for LintRun<'_> {
|
||||
oracle: None,
|
||||
options: RuleOptions::new(),
|
||||
line_length: DEFAULT_LINE_LENGTH,
|
||||
external: ExternalWaivers::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,8 +80,17 @@ impl<'a> LintRun<'a> {
|
||||
let workspace = index.files().len() > usize::from(own.is_some());
|
||||
let rules = enabled_rules(ws.client_settings(), workspace);
|
||||
let oracle = workspace.then_some(IndexMentions { index, own });
|
||||
let (options, line_length) = configured(ws.client_settings(), doc);
|
||||
LintRun { rules, oracle, options, line_length }
|
||||
let (options, line_length, file) = configured(ws.client_settings(), doc);
|
||||
let external = external_waivers(&waiver_paths(ws.client_settings(), ws.roots(), &file)).0;
|
||||
LintRun { rules, oracle, options, line_length, external }
|
||||
}
|
||||
|
||||
/// A run carrying these external waivers — for the tests that pin what a
|
||||
/// waiver keeps out of the code actions.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_external(mut self, external: ExternalWaivers) -> Self {
|
||||
self.external = external;
|
||||
self
|
||||
}
|
||||
|
||||
/// This run's context over a buffer's own parse products.
|
||||
@@ -109,7 +125,7 @@ impl<'a> LintRun<'a> {
|
||||
/// reads it per formatting request: a `lucisv.toml` edited while the server
|
||||
/// runs takes effect at the next publish, and the read is a few stats beside
|
||||
/// a parse and an analysis the same pass already paid for.
|
||||
fn configured(client: &ClientSettings, doc: &Document) -> (RuleOptions, usize) {
|
||||
fn configured(client: &ClientSettings, doc: &Document) -> (RuleOptions, usize, FileConfig) {
|
||||
let file = doc
|
||||
.path
|
||||
.as_deref()
|
||||
@@ -125,7 +141,51 @@ fn configured(client: &ClientSettings, doc: &Document) -> (RuleOptions, usize) {
|
||||
}
|
||||
options.overlay(&client.lint_options);
|
||||
let width = file.line_length.or(client.line_length).unwrap_or(DEFAULT_LINE_LENGTH);
|
||||
(options, width)
|
||||
(options, width, file)
|
||||
}
|
||||
|
||||
/// The waiver files governing one buffer: its `lucisv.toml`'s `[lint] waivers`
|
||||
/// first, then `lucisv.lint.waivers` from the editor.
|
||||
///
|
||||
/// The two **add up**, the way they do on the command line — a waiver file
|
||||
/// only ever suppresses findings, so there is nothing here for one list to
|
||||
/// take back from the other. A relative setting path is resolved against the
|
||||
/// first workspace root, exactly as `lucisv.filelist` is; a `lucisv.toml`'s
|
||||
/// paths were already resolved against that file's own directory.
|
||||
pub fn waiver_paths(client: &ClientSettings, roots: &[PathBuf], file: &FileConfig) -> Vec<PathBuf> {
|
||||
let mut paths: Vec<PathBuf> = file.lint_waivers.iter().flatten().cloned().collect();
|
||||
for setting in &client.lint_waivers {
|
||||
let path = Path::new(setting);
|
||||
paths.push(match roots.first() {
|
||||
Some(root) if path.is_relative() => root.join(path),
|
||||
_ => path.to_path_buf(),
|
||||
});
|
||||
}
|
||||
paths
|
||||
}
|
||||
|
||||
/// Those files, read: the waivers and one message per file or line that could
|
||||
/// not be used.
|
||||
///
|
||||
/// **Nothing here is fatal.** A push arrives on a socket and a bad path in it
|
||||
/// must never cost a user every diagnostic in their file — this module's
|
||||
/// standing rule, and `settings::rule_options`'. The messages are logged once,
|
||||
/// when the settings arrive (`server::notification::apply_settings`); the lint
|
||||
/// pass, which runs on every keystroke, drops them silently rather than
|
||||
/// logging the same line a hundred times.
|
||||
pub fn external_waivers(paths: &[PathBuf]) -> (ExternalWaivers, Vec<String>) {
|
||||
let mut waivers = ExternalWaivers::default();
|
||||
let mut problems = Vec::new();
|
||||
for path in paths {
|
||||
match ExternalWaivers::read(path) {
|
||||
Ok((file, bad)) => {
|
||||
problems.extend(bad);
|
||||
waivers.absorb(file);
|
||||
}
|
||||
Err(problem) => problems.push(problem),
|
||||
}
|
||||
}
|
||||
(waivers, problems)
|
||||
}
|
||||
|
||||
/// Which rules a buffer is linted with, given what the editor's settings say.
|
||||
@@ -256,8 +316,13 @@ fn context(doc: &Document) -> LintContext<'_> {
|
||||
///
|
||||
/// This is the diagnostics path, which never looks at a fix, so the width a
|
||||
/// `no-tabs` fix would expand a tab to is left at the linter's own default.
|
||||
/// The external waivers apply here exactly as the inline ones do, as a union.
|
||||
/// Which of them *fired* is discarded: only a whole run can tell whether a
|
||||
/// waiver was dead, and a server never has one — it lints the buffers a user
|
||||
/// happens to have open. `lucisv check` is what reports an unused external
|
||||
/// waiver; see `docs/features/waiver-files/README.md`.
|
||||
pub fn violations_in(doc: &Document, run: &LintRun) -> Vec<Violation> {
|
||||
lint(&run.context(doc), &run.rules)
|
||||
lint_with(&run.context(doc), &run.rules, &run.external).0
|
||||
}
|
||||
|
||||
/// The findings a code action may offer a fix for, with their fixes built for
|
||||
@@ -274,8 +339,14 @@ pub fn violations_in(doc: &Document, run: &LintRun) -> Vec<Violation> {
|
||||
/// just has no lightbulb. Which bytes count as fenced is
|
||||
/// [`fence::protected_regions`]' answer, the one the CLI asks too; see
|
||||
/// `docs/features/shared-fence-filter/README.md`.
|
||||
pub fn fixable(doc: &Document, tab_width: usize) -> Vec<Violation> {
|
||||
let found = lint(&context(doc).with_tab_width(tab_width), &default_rules());
|
||||
pub fn fixable(run: &LintRun, doc: &Document, tab_width: usize) -> Vec<Violation> {
|
||||
// The buffer's own run: its enabled rules and its external waiver files,
|
||||
// so a fix is never offered — nor applied by fix-on-save — for a finding
|
||||
// the diagnostics pass would not have shown. Found by §39's QA: with
|
||||
// `default_rules()` and no waivers here, `source.fixAll.lucisv` rewrote a
|
||||
// line a checked-in waiver file had waived.
|
||||
let ctx = run.context(doc).with_tab_width(tab_width);
|
||||
let found = lint_with(&ctx, &run.rules, &run.external).0;
|
||||
// One tolerant parse per code-action request: `protected_regions` takes
|
||||
// text and parses internally, on purpose — one fence answer for every
|
||||
// front end, none of which can feed it a stale tree (see
|
||||
@@ -449,7 +520,7 @@ mod tests {
|
||||
let doc = ws.document(&uri).expect("open");
|
||||
let diags = diagnostics(doc);
|
||||
assert_eq!(diags.len(), 2, "both tabs are reported: {diags:#?}");
|
||||
let offered = fixable(doc, 2);
|
||||
let offered = fixable(&LintRun::default(), doc, 2);
|
||||
assert_eq!(offered.len(), 1, "only the unfenced one may be fixed: {offered:#?}");
|
||||
let free = text.find("\twire b").expect("the unfenced tab") as u32;
|
||||
assert_eq!(offered[0].span.start, free);
|
||||
@@ -469,7 +540,7 @@ mod tests {
|
||||
.any(|d| d.code == Some(NumberOrString::String("no-tabs".into()))),
|
||||
"still reported"
|
||||
);
|
||||
assert!(fixable(doc, 2).is_empty(), "and still not fixable");
|
||||
assert!(fixable(&LintRun::default(), doc, 2).is_empty(), "and still not fixable");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -711,7 +782,7 @@ mod tests {
|
||||
#[test]
|
||||
fn an_unfenced_file_offers_every_fix() {
|
||||
let (ws, uri) = doc_of("module m;\n// just a note\n\twire a;\nendmodule\n");
|
||||
assert_eq!(fixable(ws.document(&uri).expect("open"), 2).len(), 1);
|
||||
assert_eq!(fixable(&LintRun::default(), ws.document(&uri).expect("open"), 2).len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -719,9 +790,60 @@ mod tests {
|
||||
let (ws, uri) = doc_of("module m;\n\twire a;\nendmodule\n");
|
||||
let doc = ws.document(&uri).expect("open");
|
||||
for width in [2usize, 4] {
|
||||
let found = fixable(doc, width);
|
||||
let found = fixable(&LintRun::default(), doc, width);
|
||||
let fix = found[0].fix.as_ref().expect("no-tabs offers a fix");
|
||||
assert_eq!(fix.edits[0].1, " ".repeat(width));
|
||||
}
|
||||
}
|
||||
|
||||
/// The two waiver lists add up, and only the setting's relative paths are
|
||||
/// anchored at the first root — a `lucisv.toml`'s were resolved against
|
||||
/// that file's own directory before they got here. TODO §39.
|
||||
#[test]
|
||||
fn the_config_files_waivers_come_first_and_the_settings_are_rooted() {
|
||||
let file = FileConfig {
|
||||
lint_waivers: Some(vec![PathBuf::from("/proj/rtl/project.waiver")]),
|
||||
..Default::default()
|
||||
};
|
||||
let client = ClientSettings {
|
||||
lint_waivers: vec!["team.waiver".to_string(), "/etc/global.waiver".to_string()],
|
||||
..Default::default()
|
||||
};
|
||||
let roots = vec![PathBuf::from("/work/top")];
|
||||
assert_eq!(
|
||||
waiver_paths(&client, &roots, &file),
|
||||
vec![
|
||||
PathBuf::from("/proj/rtl/project.waiver"),
|
||||
PathBuf::from("/work/top/team.waiver"),
|
||||
PathBuf::from("/etc/global.waiver"),
|
||||
]
|
||||
);
|
||||
// With no root at all a relative path is left as written rather than
|
||||
// guessed at, exactly as `filelist_path` leaves it.
|
||||
assert_eq!(
|
||||
waiver_paths(&client, &[], &FileConfig::default()),
|
||||
vec![PathBuf::from("team.waiver"), PathBuf::from("/etc/global.waiver")]
|
||||
);
|
||||
assert!(waiver_paths(&ClientSettings::default(), &roots, &FileConfig::default()).is_empty());
|
||||
}
|
||||
|
||||
/// A waiver file that is missing, and one with a bad line, are both
|
||||
/// described rather than fatal — and the good directives of the second
|
||||
/// still apply. TODO §39.
|
||||
#[test]
|
||||
fn a_bad_waiver_file_is_described_and_its_good_directives_still_apply() {
|
||||
let dir = std::env::temp_dir().join(format!("lucisv_waiver_paths_{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).expect("temp dir");
|
||||
let good = dir.join("good.waiver");
|
||||
std::fs::write(&good, "waive --rule=no-tabs\nwaive --rule=nope\n").expect("write");
|
||||
|
||||
let (waivers, problems) = external_waivers(&[good.clone(), dir.join("missing.waiver")]);
|
||||
assert!(!waivers.is_empty(), "the good directive survived its neighbour");
|
||||
assert_eq!(problems.len(), 2, "{problems:?}");
|
||||
assert!(problems[0].contains("good.waiver:2: unknown rule `nope`"), "{problems:?}");
|
||||
assert!(problems[1].contains("missing.waiver"), "{problems:?}");
|
||||
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ use super::client::ms;
|
||||
use super::Server;
|
||||
use crate::{
|
||||
code_action, completion, design_hierarchy, file_ops, folding, format, hierarchy, hover,
|
||||
includes, inlay, inline, lens, linked, nav, pairs, ports, rename, selection, signature,
|
||||
includes, inlay, inline, lens, linked, lint, nav, pairs, ports, rename, selection, signature,
|
||||
symbols, tokens, type_def, type_hierarchy,
|
||||
};
|
||||
|
||||
@@ -251,8 +251,9 @@ impl Server {
|
||||
// or from the built-in default.
|
||||
let tab_width =
|
||||
format::indent_width(doc.path.as_deref(), self.workspace.client_settings());
|
||||
let run = lint::LintRun::for_document(&self.workspace, doc);
|
||||
let mut actions =
|
||||
code_action::code_actions(&uri, doc, p.range, only.as_deref(), tab_width);
|
||||
code_action::code_actions(&run, &uri, doc, p.range, only.as_deref(), tab_width);
|
||||
// The port refactorings answer for the cursor, not for a range:
|
||||
// the request's start is where the user is.
|
||||
if code_action::wanted(only.as_deref(), &CodeActionKind::new(ports::REFACTOR_PORTS))
|
||||
|
||||
@@ -25,7 +25,7 @@ use serde::de::DeserializeOwned;
|
||||
use super::batch::{widen_of, Widen};
|
||||
use super::client::ms;
|
||||
use super::Server;
|
||||
use crate::{file_ops, settings, sync, watch};
|
||||
use crate::{file_ops, lint, settings, sync, watch};
|
||||
|
||||
impl Server {
|
||||
/// Handle one notification, timing it when `--verbose` asked. A
|
||||
@@ -259,6 +259,21 @@ impl Server {
|
||||
},
|
||||
);
|
||||
}
|
||||
// And the same for `lucisv.lint.waivers`: a file that is not there, or
|
||||
// a directive that does not parse, is dropped and said once — here,
|
||||
// where the setting arrives, rather than on every keystroke from the
|
||||
// lint pass that reads the files. Only the setting's own files are
|
||||
// checked; a `lucisv.toml`'s `[lint] waivers` is that file's problem
|
||||
// and `lucisv check` fails the run over it.
|
||||
for problem in waiver_problems(&settings, self.workspace.roots()) {
|
||||
self.notify(
|
||||
LogMessage::METHOD,
|
||||
LogMessageParams {
|
||||
typ: MessageType::WARNING,
|
||||
message: format!("lucisv: lucisv.lint.waivers: {problem}; ignored"),
|
||||
},
|
||||
);
|
||||
}
|
||||
// Only `exclude` and `filelist` change which files exist as far as
|
||||
// this server is concerned; the other settings are read afresh by the
|
||||
// next request that wants them and need no invalidation.
|
||||
@@ -322,3 +337,22 @@ fn closing_uri(notification: &Notification) -> Option<Uri> {
|
||||
fn folder_paths(folders: &[WorkspaceFolder]) -> Vec<std::path::PathBuf> {
|
||||
folders.iter().filter_map(|folder| crate::uri::uri_to_path(&folder.uri)).collect()
|
||||
}
|
||||
|
||||
/// What `lucisv.lint.waivers` names that could not be used: a file that is not
|
||||
/// there, or a directive that does not parse.
|
||||
///
|
||||
/// Read here rather than trusted, because a path is not something a settings
|
||||
/// parser can validate: only opening the file says whether it exists. The
|
||||
/// files are read again by the lint pass that actually applies them — a few
|
||||
/// small files beside a parse and an analysis — which keeps one reader for
|
||||
/// both and no cache to go stale when the user edits a waiver file.
|
||||
fn waiver_problems(
|
||||
settings: &settings::ClientSettings,
|
||||
roots: &[std::path::PathBuf],
|
||||
) -> Vec<String> {
|
||||
if settings.lint_waivers.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let paths = lint::waiver_paths(settings, roots, &lucisv_core::config::FileConfig::default());
|
||||
lint::external_waivers(&paths).1
|
||||
}
|
||||
@@ -202,6 +202,16 @@ pub struct ClientSettings {
|
||||
/// One line per refused `lucisv.lint.options` entry, ready for a
|
||||
/// `window/logMessage`. Empty for a settings push that was all valid.
|
||||
pub lint_option_warnings: Vec<String>,
|
||||
/// `lucisv.lint.waivers`: external waiver files, each absolute or relative
|
||||
/// to the first workspace root — the editor's spelling of
|
||||
/// `lucisv check --waiver-file` and of `waivers` under `[lint]` in a
|
||||
/// `lucisv.toml`. They **add** to whatever that table names.
|
||||
///
|
||||
/// The paths are taken as written and nothing is read here: whether a file
|
||||
/// exists and whether its directives parse is answered where the files are
|
||||
/// read (`lint::external_waivers`), and reported once through the log when
|
||||
/// this value arrives.
|
||||
pub lint_waivers: Vec<String>,
|
||||
}
|
||||
|
||||
/// The settings a client that said nothing is treated as having asked for.
|
||||
@@ -232,6 +242,7 @@ impl Default for ClientSettings {
|
||||
lint_rules: BTreeMap::new(),
|
||||
lint_options: RuleOptions::new(),
|
||||
lint_option_warnings: Vec::new(),
|
||||
lint_waivers: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,8 +257,14 @@ fn every_class_on() -> BTreeMap<Severity, bool> {
|
||||
///
|
||||
/// Its only use is equality — the server compares it across a settings change
|
||||
/// to decide whether every open file must be published again.
|
||||
pub type LintSelection =
|
||||
(Vec<String>, Vec<String>, BTreeMap<Severity, bool>, BTreeMap<String, bool>, RuleOptions);
|
||||
pub type LintSelection = (
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
BTreeMap<Severity, bool>,
|
||||
BTreeMap<String, bool>,
|
||||
RuleOptions,
|
||||
Vec<String>,
|
||||
);
|
||||
|
||||
/// The lint settings of `settings`, as one comparable value.
|
||||
///
|
||||
@@ -262,6 +279,9 @@ pub fn lint_selection(settings: &ClientSettings) -> LintSelection {
|
||||
settings.lint_severity.clone(),
|
||||
settings.lint_rules.clone(),
|
||||
settings.lint_options.clone(),
|
||||
// A waiver file added or dropped changes which findings survive, so it
|
||||
// republishes for exactly the reason a changed option does.
|
||||
settings.lint_waivers.clone(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -342,6 +362,9 @@ pub fn from_payload(settings: &Value) -> ClientSettings {
|
||||
lint_rules: rule_toggles(lint.and_then(|l| l.get("rules"))),
|
||||
lint_options: options,
|
||||
lint_option_warnings: warnings,
|
||||
// Paths, not rule names: nothing to validate against the registry, and
|
||||
// a path that names nothing is reported when the file is read.
|
||||
lint_waivers: strings(lint.and_then(|l| l.get("waivers"))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,6 +980,30 @@ mod tests {
|
||||
assert_eq!(found.max_file_size, DEFAULT_MAX_FILE_SIZE);
|
||||
}
|
||||
|
||||
/// `lucisv.lint.waivers` is a list of paths, taken as written: this module
|
||||
/// has no filesystem to check them against, and whether a file exists or
|
||||
/// parses is answered where it is read. TODO §39.
|
||||
#[test]
|
||||
fn the_waivers_setting_is_a_list_of_paths_taken_as_written() {
|
||||
let found = settings(json!({"lucisv": {"lint": {
|
||||
"waivers": ["project.waiver", "/abs/other.waiver", 7, null]
|
||||
}}}));
|
||||
assert_eq!(found.lint_waivers, vec!["project.waiver", "/abs/other.waiver"]);
|
||||
assert!(settings(json!({"lucisv": {"lint": {}}})).lint_waivers.is_empty());
|
||||
// Wrong-typed altogether: the whole list is "no opinion", never a
|
||||
// guess, exactly as `select` and `exclude` are.
|
||||
for bad in [json!("project.waiver"), json!(3), json!(null), json!({"a": 1})] {
|
||||
assert!(
|
||||
settings(json!({"lucisv": {"lint": {"waivers": bad}}})).lint_waivers.is_empty(),
|
||||
"waivers {bad} must be ignored"
|
||||
);
|
||||
}
|
||||
// A changed list republishes, for the reason a changed option does.
|
||||
let one = settings(json!({"lucisv": {"lint": {"waivers": ["a.waiver"]}}}));
|
||||
let two = settings(json!({"lucisv": {"lint": {"waivers": ["b.waiver"]}}}));
|
||||
assert_ne!(lint_selection(&one), lint_selection(&two));
|
||||
}
|
||||
|
||||
/// A settings payload with no options object is exactly today's
|
||||
/// behaviour: every rule reads its own default.
|
||||
#[test]
|
||||
|
||||
@@ -625,6 +625,15 @@ impl Workspace {
|
||||
!self.roots.is_empty()
|
||||
}
|
||||
|
||||
/// The workspace folders, in the order the client named them.
|
||||
///
|
||||
/// The first one is what a relative path in a setting is resolved against,
|
||||
/// which is what [`Workspace::filelist_path`] does inline and what
|
||||
/// `lucisv.lint.waivers` needs too.
|
||||
pub fn roots(&self) -> &[PathBuf] {
|
||||
&self.roots
|
||||
}
|
||||
|
||||
/// The directories the folder scope walks: every directory a buffer has
|
||||
/// been opened from this session, each raised `lucisv.index.scopeDepth`
|
||||
/// levels. **Empty when the folder scope is not the active rung** — a
|
||||
|
||||
@@ -7542,6 +7542,87 @@ fn the_lint_options_setting_changes_what_is_published_and_a_bad_entry_is_logged(
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// `lucisv.lint.waivers` over the wire — TODO §39.
|
||||
///
|
||||
/// Four claims a unit test cannot make: that a `[lint] waivers` in a checked-in
|
||||
/// `lucisv.toml` suppresses a finding the editor would otherwise draw; that the
|
||||
/// setting *adds* a second file mid-session and the squiggle goes away without
|
||||
/// a reload; that a waiver file with one bad directive is dropped **line by
|
||||
/// line** — the good directives still apply — and logged once; and that the
|
||||
/// server never publishes an `unused-waiver` for an external waiver, because
|
||||
/// it never sees a whole run.
|
||||
#[test]
|
||||
fn the_waivers_setting_suppresses_findings_and_a_bad_directive_is_logged() {
|
||||
let dir = temp_dir("lintwaivers");
|
||||
std::fs::write(dir.join("lucisv.toml"), "[lint]\nwaivers = [ \"project.waiver\" ]\n")
|
||||
.expect("write");
|
||||
std::fs::write(dir.join("project.waiver"), "waive --rule=no-tabs --line=2\n").expect("write");
|
||||
// One good directive and one that does not parse: the good one must still
|
||||
// apply, which is what "drops the line, never the file" means.
|
||||
std::fs::write(
|
||||
dir.join("extra.waiver"),
|
||||
"waive --rule=no-tabs --line=3\nwaive --rule=no-such-rule\n",
|
||||
)
|
||||
.expect("write");
|
||||
let file = dir.join("tabs.sv");
|
||||
let text = "module tabs;\n\twire a;\n\twire b;\nendmodule\n";
|
||||
std::fs::write(&file, text).expect("write");
|
||||
let root = format!("file://{}", dir.display());
|
||||
let uri = format!("file://{}", file.display());
|
||||
|
||||
let session = [
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"processId":null,"rootUri":"{root}","capabilities":{{}}}}}}"#
|
||||
)),
|
||||
frame(r#"{"jsonrpc":"2.0","method":"initialized","params":{}}"#),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
|
||||
serde_json::to_string(text).expect("json")
|
||||
)),
|
||||
// The editor's list adds to the `lucisv.toml`'s, relative to the root.
|
||||
frame(
|
||||
r#"{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"lucisv":{"lint":{"waivers":["extra.waiver","gone.waiver"]}}}}}"#,
|
||||
),
|
||||
frame(r#"{"jsonrpc":"2.0","id":9,"method":"shutdown","params":null}"#),
|
||||
frame(r#"{"jsonrpc":"2.0","method":"exit","params":null}"#),
|
||||
]
|
||||
.concat();
|
||||
|
||||
let messages = talk(&session);
|
||||
let tabs: Vec<Vec<&str>> = messages
|
||||
.iter()
|
||||
.filter(|m| m["method"] == "textDocument/publishDiagnostics")
|
||||
.filter(|m| m["params"]["uri"] == uri.as_str())
|
||||
.map(|m| {
|
||||
m["params"]["diagnostics"]
|
||||
.as_array()
|
||||
.map(|list| list.iter().filter_map(|d| d["code"].as_str()).collect())
|
||||
.unwrap_or_default()
|
||||
})
|
||||
.collect();
|
||||
assert!(tabs.len() >= 2, "one publish per state: {tabs:?}");
|
||||
assert_eq!(tabs[0], vec!["no-tabs"], "the toml waived line 2, line 3 is left: {tabs:?}");
|
||||
assert!(
|
||||
tabs[tabs.len() - 1].is_empty(),
|
||||
"the setting's good directive waived line 3 without a reload: {tabs:?}"
|
||||
);
|
||||
for published in &tabs {
|
||||
assert!(!published.contains(&"unused-waiver"), "never from the server: {tabs:?}");
|
||||
}
|
||||
|
||||
let logged: Vec<&str> = messages
|
||||
.iter()
|
||||
.filter(|m| m["method"] == "window/logMessage")
|
||||
.filter_map(|m| m["params"]["message"].as_str())
|
||||
.filter(|text| text.contains("lucisv.lint.waivers"))
|
||||
.collect();
|
||||
assert_eq!(logged.len(), 2, "the bad directive and the missing file: {logged:?}");
|
||||
assert!(logged.iter().any(|line| line.contains("unknown rule")), "{logged:?}");
|
||||
assert!(logged.iter().any(|line| line.contains("gone.waiver")), "{logged:?}");
|
||||
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// `lucisv.instantiate` — `docs/topo.md` §2.9-19. What only an e2e test can
|
||||
/// check: that the command is advertised in `initialize`, that its three
|
||||
/// arguments survive the wire, and that the skeleton arrives as a
|
||||
|
||||
@@ -12,6 +12,12 @@ vlog_parser = { path = "../vlog_parser" }
|
||||
# workspace crate that answers that, and it depends on `vlog_parser` alone, so
|
||||
# this adds no external code — see docs/features/semantic-lints/README.md.
|
||||
vlog_semantic = { path = "../vlog_semantic" }
|
||||
# A waiver file's `--location` is matched exactly the way an `--exclude`
|
||||
# pattern is, and that matcher is `lucisv_core::walk::is_excluded`. Depending
|
||||
# on it rather than copying it is the only way the two can be *the same*
|
||||
# semantics; `lucisv_core` itself has no dependencies at all, so this adds no
|
||||
# external code and closes no loop — see docs/features/waiver-files/README.md.
|
||||
lucisv_core = { path = "../lucisv_core" }
|
||||
|
||||
[dev-dependencies]
|
||||
# Tests only: the .lint case harness asserts that a lint fix never produces
|
||||
|
||||
@@ -39,6 +39,7 @@ mod violation;
|
||||
mod visit;
|
||||
mod vscode;
|
||||
mod waiver;
|
||||
mod waiver_file;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -58,6 +59,7 @@ pub use violation::{apply_fixes, Applicability, Fix, Fixed, Violation};
|
||||
pub use vlog_semantic::words;
|
||||
pub use vscode::{rule_setting, severity_setting, vscode_lint_settings, RULE_CHOICES};
|
||||
pub use waiver::UNUSED_WAIVER;
|
||||
pub use waiver_file::{ExternalWaivers, UnusedReport, WaiverUse};
|
||||
|
||||
use waiver::Waivers;
|
||||
|
||||
@@ -74,14 +76,32 @@ pub fn run(source: &str, path: Option<PathBuf>, enabled: &[&'static dyn Rule]) -
|
||||
/// The result is sorted by position, then by rule name, so two runs over the
|
||||
/// same file print in the same order whatever order the registry has.
|
||||
pub fn lint(ctx: &LintContext, enabled: &[&'static dyn Rule]) -> Vec<Violation> {
|
||||
lint_with(ctx, enabled, &ExternalWaivers::default()).0
|
||||
}
|
||||
|
||||
/// [`lint`] with the run's external waiver files applied too, reporting which
|
||||
/// of their directives fired.
|
||||
///
|
||||
/// **Precedence is union**: a violation is dropped when an inline waiver *or*
|
||||
/// an external one covers it, and one both cover marks both used, so neither
|
||||
/// is then reported as dead. The usage half is the caller's to keep — only a
|
||||
/// whole run knows whether a `--location` matched some file somewhere, which
|
||||
/// is why `lucisv check` reports unused external waivers and the server does
|
||||
/// not. See `docs/features/waiver-files/README.md`.
|
||||
pub fn lint_with(
|
||||
ctx: &LintContext,
|
||||
enabled: &[&'static dyn Rule],
|
||||
external: &ExternalWaivers,
|
||||
) -> (Vec<Violation>, WaiverUse) {
|
||||
let names: Vec<&'static str> = enabled.iter().map(|rule| rule.name()).collect();
|
||||
let mut waivers = Waivers::collect(ctx);
|
||||
let mut used = WaiverUse::default();
|
||||
|
||||
let mut found = Vec::new();
|
||||
for rule in enabled {
|
||||
found.extend(rule.check(ctx));
|
||||
}
|
||||
let mut kept = waivers.filter(ctx, found);
|
||||
let mut kept = waive(ctx, &mut waivers, external, &mut used, found);
|
||||
|
||||
if names.contains(&UNUSED_WAIVER) {
|
||||
// `unused-waiver` findings are themselves waivable, which is circular:
|
||||
@@ -92,7 +112,7 @@ pub fn lint(ctx: &LintContext, enabled: &[&'static dyn Rule]) -> Vec<Violation>
|
||||
loop {
|
||||
let before = waivers.used_count();
|
||||
let unused = waivers.unused(&names);
|
||||
let surviving = waivers.filter(ctx, unused);
|
||||
let surviving = waive(ctx, &mut waivers, external, &mut used, unused);
|
||||
if waivers.used_count() == before {
|
||||
kept.extend(surviving);
|
||||
break;
|
||||
@@ -104,7 +124,31 @@ pub fn lint(ctx: &LintContext, enabled: &[&'static dyn Rule]) -> Vec<Violation>
|
||||
(a.span.start, a.span.end, a.rule).cmp(&(b.span.start, b.span.end, b.rule))
|
||||
});
|
||||
stamp_severities(&mut kept);
|
||||
kept
|
||||
(kept, used)
|
||||
}
|
||||
|
||||
/// The violations neither an inline waiver nor an external one covers.
|
||||
///
|
||||
/// Both are always asked — never `||` short-circuited — because a violation
|
||||
/// two waivers cover has to mark both of them used.
|
||||
fn waive(
|
||||
ctx: &LintContext,
|
||||
inline: &mut Waivers,
|
||||
external: &ExternalWaivers,
|
||||
used: &mut WaiverUse,
|
||||
violations: Vec<Violation>,
|
||||
) -> Vec<Violation> {
|
||||
let path = ctx.path();
|
||||
violations
|
||||
.into_iter()
|
||||
.filter(|violation| {
|
||||
let (line, _) = ctx.line_index().line_col(violation.span.start);
|
||||
let inline_waived = inline.covers(violation.rule, line);
|
||||
let external_waived =
|
||||
!external.is_empty() && external.covers(path, violation.rule, line, used);
|
||||
!(inline_waived || external_waived)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Gives every finding the class its rule declares.
|
||||
|
||||
@@ -113,26 +113,20 @@ impl Waivers {
|
||||
Waivers { entries }
|
||||
}
|
||||
|
||||
/// Drops the violations a waiver covers, marking those waivers used.
|
||||
pub(crate) fn filter(
|
||||
&mut self,
|
||||
ctx: &LintContext,
|
||||
violations: Vec<Violation>,
|
||||
) -> Vec<Violation> {
|
||||
violations
|
||||
.into_iter()
|
||||
.filter(|violation| {
|
||||
let (line, _) = ctx.line_index().line_col(violation.span.start);
|
||||
let mut waived = false;
|
||||
for entry in &mut self.entries {
|
||||
if entry.rule == violation.rule && entry.scope.covers(line) {
|
||||
entry.used = true;
|
||||
waived = true;
|
||||
}
|
||||
}
|
||||
!waived
|
||||
})
|
||||
.collect()
|
||||
/// True when some waiver covers `rule` at `line`, marking every waiver
|
||||
/// that does used.
|
||||
///
|
||||
/// Every one, not the first: a finding two waivers cover has both of them
|
||||
/// doing their job, and reporting the second as dead would be a lie.
|
||||
pub(crate) fn covers(&mut self, rule: &str, line: u32) -> bool {
|
||||
let mut waived = false;
|
||||
for entry in &mut self.entries {
|
||||
if entry.rule == rule && entry.scope.covers(line) {
|
||||
entry.used = true;
|
||||
waived = true;
|
||||
}
|
||||
}
|
||||
waived
|
||||
}
|
||||
|
||||
/// How many waivers have suppressed something so far. Grows only, which
|
||||
|
||||
@@ -0,0 +1,570 @@
|
||||
//! External waiver files: Verible's `waive` directives, written in a file of
|
||||
//! their own rather than in a comment in the RTL.
|
||||
//!
|
||||
//! Grammar (Verible's, so an existing `.waiver` file carries over unchanged) —
|
||||
//! one directive per line, `#` comments and blank lines ignored:
|
||||
//!
|
||||
//! ```text
|
||||
//! waive --rule=<rule> every line of every file
|
||||
//! waive --rule=<rule> --line=12 one line
|
||||
//! waive --rule=<rule> --line=12-20 a range, both ends included
|
||||
//! waive --rule=<rule> --location=legacy_top.sv the files that pattern names
|
||||
//! ```
|
||||
//!
|
||||
//! The one deliberate difference from Verible: `--location` is **not** a
|
||||
//! regular expression. It is matched exactly the way an `--exclude` pattern is
|
||||
//! ([`lucisv_core::walk::is_excluded`]), so a pattern means one thing across
|
||||
//! the whole tool; a pattern that looks like a regex is refused with a message
|
||||
//! saying so rather than silently matching nothing.
|
||||
//!
|
||||
//! Precedence is **union** with the inline waivers of `waiver.rs`: a violation
|
||||
//! is suppressed when either covers it, and a violation both cover marks both
|
||||
//! used. See `docs/features/waiver-files/README.md`.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use vlog_parser::span::TextRange;
|
||||
|
||||
use crate::registry::rule_by_name;
|
||||
use crate::severity::Severity;
|
||||
use crate::violation::Violation;
|
||||
use crate::waiver::UNUSED_WAIVER;
|
||||
|
||||
/// Every external waiver of one run, from any number of files.
|
||||
#[derive(Default)]
|
||||
pub struct ExternalWaivers {
|
||||
sources: Vec<Source>,
|
||||
directives: Vec<Directive>,
|
||||
}
|
||||
|
||||
/// One waiver file that was read. Its text is kept because an unused
|
||||
/// directive is reported at the line it was written on, and only the text
|
||||
/// turns that directive's span into a line and a column.
|
||||
struct Source {
|
||||
path: PathBuf,
|
||||
text: String,
|
||||
}
|
||||
|
||||
/// One `waive` directive.
|
||||
struct Directive {
|
||||
/// Index into [`ExternalWaivers::sources`].
|
||||
source: usize,
|
||||
/// The directive's own line, where an `unused-waiver` finding points.
|
||||
span: TextRange,
|
||||
/// The rule waived; always a name the registry knows.
|
||||
rule: String,
|
||||
/// `--line`: 1-based, both ends included. `None` is the whole file.
|
||||
lines: Option<(u32, u32)>,
|
||||
/// `--location`: an `--exclude` pattern. `None` is every file.
|
||||
location: Option<String>,
|
||||
}
|
||||
|
||||
/// Which external waivers have suppressed something.
|
||||
///
|
||||
/// One run's worth: the CLI lints its files in parallel and merges what each
|
||||
/// one used, because a `--location` pattern may cover files linted on several
|
||||
/// workers. Usage only ever grows.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct WaiverUse {
|
||||
used: Vec<bool>,
|
||||
}
|
||||
|
||||
impl WaiverUse {
|
||||
/// Folds another pass's usage into this one.
|
||||
pub fn merge(&mut self, other: &WaiverUse) {
|
||||
if self.used.len() < other.used.len() {
|
||||
self.used.resize(other.used.len(), false);
|
||||
}
|
||||
for (slot, fired) in self.used.iter_mut().zip(&other.used) {
|
||||
*slot |= *fired;
|
||||
}
|
||||
}
|
||||
|
||||
fn mark(&mut self, index: usize) {
|
||||
if self.used.len() <= index {
|
||||
self.used.resize(index + 1, false);
|
||||
}
|
||||
self.used[index] = true;
|
||||
}
|
||||
|
||||
fn fired(&self, index: usize) -> bool {
|
||||
self.used.get(index).copied().unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
/// One waiver file's dead directives, ready to be reported: the file, its
|
||||
/// text — for the line and column — and one finding each.
|
||||
pub struct UnusedReport {
|
||||
/// The waiver file the directives were written in.
|
||||
pub path: PathBuf,
|
||||
/// That file's text.
|
||||
pub text: String,
|
||||
/// One `unused-waiver` violation per directive that suppressed nothing.
|
||||
pub violations: Vec<Violation>,
|
||||
}
|
||||
|
||||
impl ExternalWaivers {
|
||||
/// Reads one waiver file: the directives that parsed, and one
|
||||
/// `<file>:<line>: message` per line that did not.
|
||||
///
|
||||
/// A file that cannot be read at all is the `Err`; a file that reads and
|
||||
/// has bad lines is an `Ok` carrying both halves, so a front end may
|
||||
/// choose between failing the run (the CLI) and dropping the line and
|
||||
/// logging it (the server).
|
||||
pub fn read(path: &Path) -> Result<(ExternalWaivers, Vec<String>), String> {
|
||||
let text = std::fs::read_to_string(path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
Ok(ExternalWaivers::parse(path, &text))
|
||||
}
|
||||
|
||||
/// [`ExternalWaivers::read`] over text already in hand.
|
||||
pub fn parse(path: &Path, text: &str) -> (ExternalWaivers, Vec<String>) {
|
||||
let source = Source { path: path.to_path_buf(), text: text.to_string() };
|
||||
let mut waivers = ExternalWaivers { sources: vec![source], directives: Vec::new() };
|
||||
let mut problems = Vec::new();
|
||||
// `split_inclusive` rather than `lines`, so the offsets stay right in
|
||||
// a file with CRLF endings: `lines` drops bytes this has to count.
|
||||
let mut offset: u32 = 0;
|
||||
for (index, raw) in text.split_inclusive('\n').enumerate() {
|
||||
let trimmed = raw.trim_end_matches(['\n', '\r']);
|
||||
let span = TextRange::new(offset, offset + trimmed.len() as u32);
|
||||
offset += raw.len() as u32;
|
||||
// A BOM is not a directive, and an editor that writes one should
|
||||
// not turn the first line into an error naming an invisible byte.
|
||||
let line = trimmed.trim().trim_start_matches('\u{feff}');
|
||||
if line.is_empty() || line.starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
match parse_directive(line, span) {
|
||||
Ok(directive) => waivers.directives.push(directive),
|
||||
Err(problem) => {
|
||||
problems.push(format!("{}:{}: {problem}", path.display(), index + 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
(waivers, problems)
|
||||
}
|
||||
|
||||
/// Adds another file's directives to these.
|
||||
pub fn absorb(&mut self, other: ExternalWaivers) {
|
||||
let offset = self.sources.len();
|
||||
self.sources.extend(other.sources);
|
||||
self.directives.extend(other.directives.into_iter().map(|mut directive| {
|
||||
directive.source += offset;
|
||||
directive
|
||||
}));
|
||||
}
|
||||
|
||||
/// True when no waiver file contributed a directive — the everyday case,
|
||||
/// and the one the linter must pay nothing for.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.directives.is_empty()
|
||||
}
|
||||
|
||||
/// True when some directive waives this finding, marking every directive
|
||||
/// that does used.
|
||||
///
|
||||
/// Every one, not the first: a finding two waivers cover has both of them
|
||||
/// doing their job, and reporting the second as dead afterwards would be a
|
||||
/// lie.
|
||||
pub(crate) fn covers(
|
||||
&self,
|
||||
path: Option<&Path>,
|
||||
rule: &str,
|
||||
line: u32,
|
||||
used: &mut WaiverUse,
|
||||
) -> bool {
|
||||
let mut waived = false;
|
||||
for (index, directive) in self.directives.iter().enumerate() {
|
||||
if directive.covers(path, rule, line) {
|
||||
used.mark(index);
|
||||
waived = true;
|
||||
}
|
||||
}
|
||||
waived
|
||||
}
|
||||
|
||||
/// The `unused-waiver` findings for directives that suppressed nothing,
|
||||
/// grouped by the file they were written in.
|
||||
///
|
||||
/// `enabled` is every rule the run had switched on. A waiver for a rule
|
||||
/// that never ran is silent, exactly as an inline one is — it never had a
|
||||
/// chance to fire — and so is everything here when `unused-waiver` itself
|
||||
/// is off.
|
||||
pub fn unused(&self, used: &WaiverUse, enabled: &[&'static str]) -> Vec<UnusedReport> {
|
||||
if !enabled.contains(&UNUSED_WAIVER) {
|
||||
return Vec::new();
|
||||
}
|
||||
let severity = rule_by_name(UNUSED_WAIVER).map_or(Severity::Style, |rule| rule.severity());
|
||||
let mut reports: Vec<UnusedReport> = self
|
||||
.sources
|
||||
.iter()
|
||||
.map(|source| UnusedReport {
|
||||
path: source.path.clone(),
|
||||
text: source.text.clone(),
|
||||
violations: Vec::new(),
|
||||
})
|
||||
.collect();
|
||||
for (index, directive) in self.directives.iter().enumerate() {
|
||||
if used.fired(index) || !enabled.contains(&directive.rule.as_str()) {
|
||||
continue;
|
||||
}
|
||||
let message = format!("unused waiver for `{}`", directive.rule);
|
||||
let mut violation = Violation::new(UNUSED_WAIVER, message, directive.span);
|
||||
// Built outside `lint`, which is what stamps every other finding.
|
||||
violation.severity = severity;
|
||||
if let Some(report) = reports.get_mut(directive.source) {
|
||||
report.violations.push(violation);
|
||||
}
|
||||
}
|
||||
reports.retain(|report| !report.violations.is_empty());
|
||||
reports
|
||||
}
|
||||
}
|
||||
|
||||
impl Directive {
|
||||
/// True when this directive waives `rule` at `line` of `path`.
|
||||
///
|
||||
/// A buffer with no path (stdin) is covered by a directive with no
|
||||
/// `--location` and by no other: a pattern cannot match a name that does
|
||||
/// not exist.
|
||||
fn covers(&self, path: Option<&Path>, rule: &str, line: u32) -> bool {
|
||||
if self.rule != rule {
|
||||
return false;
|
||||
}
|
||||
if let Some((start, end)) = self.lines {
|
||||
if line < start || end < line {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
match &self.location {
|
||||
None => true,
|
||||
Some(pattern) => path.is_some_and(|path| {
|
||||
lucisv_core::walk::is_excluded(path, std::slice::from_ref(pattern))
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One directive line: its rule, its line range and its location pattern.
|
||||
///
|
||||
/// `span` is that line's own range in the waiver file, carried into the
|
||||
/// directive so an unused one can be reported where it was written. The
|
||||
/// source index is filled in by [`ExternalWaivers::absorb`].
|
||||
fn parse_directive(line: &str, span: TextRange) -> Result<Directive, String> {
|
||||
let mut words = line.split_whitespace();
|
||||
// The line was trimmed and is not empty, so there is a first word.
|
||||
let keyword = words.next().unwrap_or_default();
|
||||
if keyword != "waive" {
|
||||
return Err(format!("expected a `waive` directive, found `{keyword}`"));
|
||||
}
|
||||
let mut rule: Option<String> = None;
|
||||
let mut lines: Option<(u32, u32)> = None;
|
||||
let mut location: Option<String> = None;
|
||||
for word in words {
|
||||
let (flag, value) = split_flag(word)?;
|
||||
match flag {
|
||||
"--rule" => set_once(&mut rule, flag, parse_rule(value)?)?,
|
||||
"--line" => set_once(&mut lines, flag, parse_lines(value)?)?,
|
||||
_ => set_once(&mut location, flag, parse_location(value)?)?,
|
||||
}
|
||||
}
|
||||
let rule = rule.ok_or("`waive` needs a `--rule=<rule-name>`")?;
|
||||
Ok(Directive { source: 0, span, rule, lines, location })
|
||||
}
|
||||
|
||||
/// Fills a slot the directive may only fill once.
|
||||
fn set_once<T>(slot: &mut Option<T>, flag: &str, value: T) -> Result<(), String> {
|
||||
if slot.is_some() {
|
||||
return Err(format!("`{flag}` is given twice"));
|
||||
}
|
||||
*slot = Some(value);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The `--flag=value` one word of a directive is.
|
||||
fn split_flag(word: &str) -> Result<(&str, &str), String> {
|
||||
let (flag, value) = word.split_once('=').unwrap_or((word, ""));
|
||||
match flag {
|
||||
"--rule" | "--line" | "--location" => {}
|
||||
// Verible's third matcher waives by the *text* of the line, which
|
||||
// needs the regex engine lucisv deliberately does not have.
|
||||
"--regex" => {
|
||||
return Err("`--regex` is not supported; waive by `--line` or `--location`".to_string())
|
||||
}
|
||||
other => {
|
||||
return Err(format!(
|
||||
"unknown option `{other}` (the options are `--rule`, `--line` and `--location`)"
|
||||
))
|
||||
}
|
||||
}
|
||||
if !word.contains('=') {
|
||||
return Err(format!("`{flag}` takes a value: write `{flag}=<value>`"));
|
||||
}
|
||||
if value.is_empty() {
|
||||
return Err(format!("`{flag}` has an empty value"));
|
||||
}
|
||||
Ok((flag, value))
|
||||
}
|
||||
|
||||
/// A `--rule` value: one rule the registry knows.
|
||||
///
|
||||
/// A severity word is refused rather than expanded. `--select style` turns a
|
||||
/// whole class on for a run the user is watching; a waiver file is checked in,
|
||||
/// and one word there quietly silencing every style rule in the project is not
|
||||
/// a thing anyone should be able to write by accident.
|
||||
fn parse_rule(value: &str) -> Result<String, String> {
|
||||
if rule_by_name(value).is_some() {
|
||||
return Ok(value.to_string());
|
||||
}
|
||||
if Severity::from_name(value).is_some() {
|
||||
return Err(format!(
|
||||
"`--rule={value}` names a severity class; a waiver names one rule at a time"
|
||||
));
|
||||
}
|
||||
Err(format!("unknown rule `{value}`"))
|
||||
}
|
||||
|
||||
/// A `--line` value: `N` or `N-M`, 1-based, both ends included.
|
||||
fn parse_lines(value: &str) -> Result<(u32, u32), String> {
|
||||
let malformed =
|
||||
|| format!("`--line={value}` is not a line or a line range (`--line=5`, `--line=5-9`)");
|
||||
let (start, end) = value.split_once('-').unwrap_or((value, value));
|
||||
let start: u32 = start.parse().map_err(|_| malformed())?;
|
||||
let end: u32 = end.parse().map_err(|_| malformed())?;
|
||||
if start == 0 {
|
||||
return Err(format!("`--line={value}` starts at 0; lines are numbered from 1"));
|
||||
}
|
||||
if end < start {
|
||||
return Err(format!("`--line={value}` counts backwards"));
|
||||
}
|
||||
Ok((start, end))
|
||||
}
|
||||
|
||||
/// A `--location` value: an `--exclude` pattern, never a regex.
|
||||
fn parse_location(value: &str) -> Result<String, String> {
|
||||
match regex_hint(value) {
|
||||
Some(found) => Err(format!(
|
||||
"`--location={value}` looks like a regular expression (`{found}`); lucisv matches a \
|
||||
location the way `--exclude` does — `*` stands for any run of characters within one \
|
||||
path component, a pattern with `/` matches a path suffix and one without matches the \
|
||||
file name, and nothing else is a metacharacter"
|
||||
)),
|
||||
None => Ok(value.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
/// The first regex metacharacter in a pattern, if it has one.
|
||||
///
|
||||
/// A bare `.` is not one: `foo.sv` is a file name. `.*` and `.+` are, and so
|
||||
/// is every character that means nothing in a glob and something in a regex.
|
||||
fn regex_hint(pattern: &str) -> Option<String> {
|
||||
for token in [".*", ".+"] {
|
||||
if pattern.contains(token) {
|
||||
return Some(token.to_string());
|
||||
}
|
||||
}
|
||||
pattern.chars().find(|c| "\\^$[]()|?+{}".contains(*c)).map(|c| c.to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn waivers(text: &str) -> (ExternalWaivers, Vec<String>) {
|
||||
ExternalWaivers::parse(Path::new("project.waiver"), text)
|
||||
}
|
||||
|
||||
/// The one problem `text` produces, without the `file:line: ` prefix.
|
||||
fn problem(text: &str) -> String {
|
||||
let (waivers, problems) = waivers(text);
|
||||
assert!(waivers.is_empty(), "a bad line contributes no directive");
|
||||
assert_eq!(problems.len(), 1, "{problems:?}");
|
||||
problems[0].split_once(": ").expect("a `file:line: message`").1.to_string()
|
||||
}
|
||||
|
||||
/// Whether the file's directives waive `rule` at `line` of `path`.
|
||||
fn covered(text: &str, path: Option<&str>, rule: &str, line: u32) -> bool {
|
||||
let (waivers, problems) = waivers(text);
|
||||
assert!(problems.is_empty(), "{problems:?}");
|
||||
let mut used = WaiverUse::default();
|
||||
waivers.covers(path.map(Path::new), rule, line, &mut used)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_directive_shape_parses() {
|
||||
let (waivers, problems) = waivers(
|
||||
"# a comment\n\
|
||||
\n\
|
||||
waive --rule=no-tabs\n\
|
||||
waive --rule=no-tabs --line=12\n\
|
||||
waive --rule=no-tabs --line=12-20\n\
|
||||
waive --rule=no-tabs --location=legacy.sv\n\
|
||||
\x20 waive --rule=no-tabs --line=3 --location=rtl/legacy.sv\n\
|
||||
waive --location=a.sv --rule=no-tabs\n",
|
||||
);
|
||||
assert!(problems.is_empty(), "{problems:?}");
|
||||
assert_eq!(waivers.directives.len(), 6);
|
||||
assert_eq!(waivers.directives[1].lines, Some((12, 12)));
|
||||
assert_eq!(waivers.directives[2].lines, Some((12, 20)));
|
||||
assert_eq!(waivers.directives[3].location.as_deref(), Some("legacy.sv"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn crlf_line_endings_do_not_shift_a_directives_span() {
|
||||
let (waivers, problems) = waivers("# note\r\nwaive --rule=no-tabs\r\n");
|
||||
assert!(problems.is_empty(), "{problems:?}");
|
||||
let span = waivers.directives[0].span;
|
||||
assert_eq!(span.start as usize, "# note\r\n".len());
|
||||
assert_eq!(span.end as usize, "# note\r\nwaive --rule=no-tabs".len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_error_names_the_file_the_line_and_the_difference() {
|
||||
let (_, problems) = waivers("waive --rule=no-such-rule\n");
|
||||
assert_eq!(problems[0], "project.waiver:1: unknown rule `no-such-rule`");
|
||||
|
||||
assert_eq!(problem("waive\n"), "`waive` needs a `--rule=<rule-name>`");
|
||||
assert_eq!(problem("waive --line=3\n"), "`waive` needs a `--rule=<rule-name>`");
|
||||
assert!(problem("skip --rule=no-tabs\n").contains("found `skip`"));
|
||||
assert!(problem("waive --rule=style\n").contains("names a severity class"));
|
||||
assert!(problem("waive --rule=no-tabs --line=0\n").contains("numbered from 1"));
|
||||
assert!(problem("waive --rule=no-tabs --line=9-5\n").contains("counts backwards"));
|
||||
assert!(problem("waive --rule=no-tabs --line=x\n").contains("is not a line or a line"));
|
||||
assert!(problem("waive --rule=no-tabs --line=5-\n").contains("is not a line or a line"));
|
||||
assert!(problem("waive --rule=no-tabs --rule=no-tabs\n").contains("given twice"));
|
||||
assert!(problem("waive --rule=no-tabs --lines=3\n").contains("unknown option `--lines`"));
|
||||
assert!(problem("waive --rule=no-tabs --regex=x\n").contains("`--regex` is not supported"));
|
||||
assert!(problem("waive --rule\n").contains("takes a value"));
|
||||
assert!(problem("waive --rule=\n").contains("empty value"));
|
||||
assert!(problem("waive --rule=no-tabs --location=x --location=y\n").contains("twice"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_regex_looking_location_is_refused_and_a_glob_is_not() {
|
||||
for pattern in [".*_pkg.sv", "top\\.sv", "^a.sv$", "(a|b).sv", "a?.sv", "a+.sv", "[ab].sv"]
|
||||
{
|
||||
let text = format!("waive --rule=no-tabs --location={pattern}\n");
|
||||
let message = problem(&text);
|
||||
assert!(message.contains("looks like a regular expression"), "{pattern}: {message}");
|
||||
assert!(message.contains("`--exclude`"), "{pattern}: {message}");
|
||||
}
|
||||
for pattern in ["a.sv", "*_gen.sv", "rtl/*.sv", "legacy/top.sv", "*"] {
|
||||
let text = format!("waive --rule=no-tabs --location={pattern}\n");
|
||||
let (_, problems) = waivers(&text);
|
||||
assert!(problems.is_empty(), "{pattern}: {problems:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_directive_with_no_line_and_no_location_covers_everything() {
|
||||
let text = "waive --rule=no-tabs\n";
|
||||
assert!(covered(text, Some("rtl/a.sv"), "no-tabs", 1));
|
||||
assert!(covered(text, Some("elsewhere/b.sv"), "no-tabs", 900));
|
||||
assert!(covered(text, None, "no-tabs", 1), "a stdin buffer too");
|
||||
assert!(!covered(text, Some("rtl/a.sv"), "no-trailing-whitespace", 1), "another rule");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_line_covers_itself_and_a_range_covers_both_ends() {
|
||||
let one = "waive --rule=no-tabs --line=12\n";
|
||||
assert!(covered(one, Some("a.sv"), "no-tabs", 12));
|
||||
assert!(!covered(one, Some("a.sv"), "no-tabs", 11));
|
||||
assert!(!covered(one, Some("a.sv"), "no-tabs", 13));
|
||||
|
||||
let range = "waive --rule=no-tabs --line=12-14\n";
|
||||
for line in [12, 13, 14] {
|
||||
assert!(covered(range, Some("a.sv"), "no-tabs", line), "line {line}");
|
||||
}
|
||||
assert!(!covered(range, Some("a.sv"), "no-tabs", 11));
|
||||
assert!(!covered(range, Some("a.sv"), "no-tabs", 15));
|
||||
}
|
||||
|
||||
/// The `--exclude` semantics, at the waiver file's end of them: a pattern
|
||||
/// without `/` matches the file name at any depth, one with `/` matches a
|
||||
/// path suffix, and `*` stays inside one component.
|
||||
#[test]
|
||||
fn a_location_matches_the_way_an_exclude_pattern_does() {
|
||||
let by_name = "waive --rule=no-tabs --location=legacy.sv\n";
|
||||
assert!(covered(by_name, Some("a/b/legacy.sv"), "no-tabs", 1));
|
||||
assert!(!covered(by_name, Some("a/b/other.sv"), "no-tabs", 1));
|
||||
|
||||
let by_suffix = "waive --rule=no-tabs --location=vendor/legacy.sv\n";
|
||||
assert!(covered(by_suffix, Some("a/vendor/legacy.sv"), "no-tabs", 1));
|
||||
assert!(!covered(by_suffix, Some("a/rtl/legacy.sv"), "no-tabs", 1));
|
||||
|
||||
let glob = "waive --rule=no-tabs --location=*_gen.sv\n";
|
||||
assert!(covered(glob, Some("rtl/top_gen.sv"), "no-tabs", 1));
|
||||
assert!(!covered(glob, Some("rtl/top.sv"), "no-tabs", 1));
|
||||
// `*` does not cross a `/`, exactly as in a walk's exclude.
|
||||
let anchored = "waive --rule=no-tabs --location=rtl/*.sv\n";
|
||||
assert!(covered(anchored, Some("top/rtl/b.sv"), "no-tabs", 1));
|
||||
assert!(!covered(anchored, Some("rtl/a/b.sv"), "no-tabs", 1));
|
||||
|
||||
// A buffer with no path is covered by nothing that names a location.
|
||||
assert!(!covered(by_name, None, "no-tabs", 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_directive_that_fired_is_not_reported_and_one_that_did_not_is() {
|
||||
let (waivers, problems) =
|
||||
waivers("waive --rule=no-tabs\nwaive --rule=no-trailing-whitespace\n");
|
||||
assert!(problems.is_empty(), "{problems:?}");
|
||||
let enabled = ["no-tabs", "no-trailing-whitespace", UNUSED_WAIVER];
|
||||
|
||||
let mut used = WaiverUse::default();
|
||||
assert!(waivers.covers(Some(Path::new("a.sv")), "no-tabs", 1, &mut used));
|
||||
|
||||
let reports = waivers.unused(&used, &enabled);
|
||||
assert_eq!(reports.len(), 1, "one waiver file, one group");
|
||||
assert_eq!(reports[0].path, PathBuf::from("project.waiver"));
|
||||
assert_eq!(reports[0].violations.len(), 1, "only the one that never fired");
|
||||
assert!(reports[0].violations[0].message.contains("no-trailing-whitespace"));
|
||||
assert_eq!(reports[0].violations[0].rule, UNUSED_WAIVER);
|
||||
assert_eq!(reports[0].violations[0].severity, Severity::Style, "stamped here");
|
||||
// The finding points at the dead directive's own line.
|
||||
assert_eq!(reports[0].violations[0].span.start as usize, "waive --rule=no-tabs\n".len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_waiver_for_a_rule_the_run_did_not_enable_is_silent() {
|
||||
let (waivers, _) = waivers("waive --rule=no-tabs\n");
|
||||
let used = WaiverUse::default();
|
||||
assert!(waivers.unused(&used, &["no-trailing-whitespace", UNUSED_WAIVER]).is_empty());
|
||||
// And so is everything when `unused-waiver` itself is off.
|
||||
assert!(waivers.unused(&used, &["no-tabs"]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn absorbing_a_second_file_keeps_each_directive_with_its_own_file() {
|
||||
let (mut first, _) =
|
||||
ExternalWaivers::parse(Path::new("a.waiver"), "waive --rule=no-tabs\n");
|
||||
let (second, _) =
|
||||
ExternalWaivers::parse(Path::new("b.waiver"), "waive --rule=no-trailing-whitespace\n");
|
||||
first.absorb(second);
|
||||
assert_eq!(first.directives.len(), 2);
|
||||
|
||||
let mut used = WaiverUse::default();
|
||||
assert!(first.covers(Some(Path::new("a.sv")), "no-tabs", 1, &mut used));
|
||||
let reports = first.unused(&used, &["no-tabs", "no-trailing-whitespace", UNUSED_WAIVER]);
|
||||
assert_eq!(reports.len(), 1, "only the file with a dead directive: {}", reports.len());
|
||||
assert_eq!(reports[0].path, PathBuf::from("b.waiver"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn usage_merges_across_the_files_a_run_linted_in_parallel() {
|
||||
let (waivers, _) = waivers(
|
||||
"waive --rule=no-tabs --location=a.sv\n\
|
||||
waive --rule=no-tabs --location=b.sv\n",
|
||||
);
|
||||
let enabled = ["no-tabs", UNUSED_WAIVER];
|
||||
|
||||
let mut first = WaiverUse::default();
|
||||
waivers.covers(Some(Path::new("a.sv")), "no-tabs", 1, &mut first);
|
||||
assert_eq!(waivers.unused(&first, &enabled)[0].violations.len(), 1, "b.sv's is dead");
|
||||
|
||||
let mut second = WaiverUse::default();
|
||||
waivers.covers(Some(Path::new("b.sv")), "no-tabs", 1, &mut second);
|
||||
first.merge(&second);
|
||||
assert!(waivers.unused(&first, &enabled).is_empty(), "both fired, over two files");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
# waiver-files
|
||||
|
||||
## Goal
|
||||
|
||||
Findings can be suppressed from *outside* the RTL, in Verible's waiver file
|
||||
format, so a project that already has a `.waiver` file carries it over
|
||||
unchanged and a team can silence a rule for a legacy directory without
|
||||
editing five hundred files. One directive per line —
|
||||
`waive --rule=<rule> [--line=N|--line=N-M] [--location=<pattern>]`, with `#`
|
||||
comments and blank lines ignored — read from `--waiver-file` on the command
|
||||
line, from `waivers` under `[lint]` in a `lucisv.toml`, and from
|
||||
`lucisv.lint.waivers` in an editor. External waivers and the inline
|
||||
`// lucisv: waive` comments are a **union**: a finding either covers is
|
||||
suppressed, and one both cover marks both used. This closes §4's last two
|
||||
waiver items (TODO §39).
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **`--location` is not a regex.** Verible's is; lucisv has no regex engine
|
||||
in the linter's path and deliberately keeps `--exclude`'s glob semantics
|
||||
everywhere a pattern names files. A pattern that *looks* like a regex is
|
||||
refused with a message saying what the difference is, rather than silently
|
||||
matching nothing. The detector is `waiver_file::regex_hint`: `.*`, `.+`,
|
||||
or any of `\ ^ $ [ ] ( ) | ? + { }`. A bare `.` is not a metacharacter —
|
||||
`foo.sv` is a file name. A pattern that is a valid glob *and* looks like a
|
||||
regex (a file with a `+` in its name) is refused; nothing in the corpus or
|
||||
in opentitan has one, and the message tells the user what to write.
|
||||
- **A directive names one rule.** A severity word (`error`, `warning`,
|
||||
`style`) is refused, though `--select`/`--ignore` accept one: a waiver file
|
||||
is checked in, and one word in it quietly silencing a whole class is not
|
||||
something anyone should be able to write by accident.
|
||||
- **`--regex=` is refused by name**, because Verible has it and a user
|
||||
carrying a file over deserves to be told which directive lucisv cannot
|
||||
honour rather than "unknown option".
|
||||
- **Line ranges are `N-M`, inclusive, 1-based**, matching Verible. `N:M` is
|
||||
not accepted.
|
||||
- **A stdin buffer has no path**, so a directive with a `--location` cannot
|
||||
cover it; one without covers it like any other file.
|
||||
- The CLI de-duplicates waiver files by their **canonicalized** path, so the
|
||||
same file named by `--waiver-file` and by a `lucisv.toml` is read once. If
|
||||
canonicalization fails (a path that does not exist) the path as written is
|
||||
the key — and a non-existent path fails the run a line later anyway.
|
||||
- The server reads its waiver files **on every lint pass**, exactly as it
|
||||
already re-reads the buffer's `lucisv.toml` per pass, so a waiver file
|
||||
edited while the editor is open takes effect at the next publish with no
|
||||
cache to invalidate. The cost is a few `read_to_string`s of small files
|
||||
beside a parse and an analysis, and it is zero when nothing is configured.
|
||||
- `lint::fixable` (the code-action path) still runs `default_rules()` with no
|
||||
waivers at all, inline or external — unchanged from before this round. A
|
||||
waived finding was never published, so no lightbulb is offered for it in
|
||||
practice; the mismatch is pre-existing and out of scope here.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**Consumed**
|
||||
|
||||
- `lucisv_core::walk::is_excluded` — the `--exclude` matcher, now also the
|
||||
`--location` matcher. **This adds `lucisv_core` as a dependency of
|
||||
`vlog_linter`** (`crates/vlog_linter/Cargo.toml`, with the reason in a
|
||||
comment). `lucisv_core` has no dependencies of its own, so this adds no
|
||||
external code and closes no loop; copying the matcher instead would have
|
||||
meant the two *look* the same and can drift. **This is a new edge for
|
||||
`docs/topo.md`: `vlog_linter ──▶ lucisv_core`.** That file is owned by
|
||||
another process this round, so the edge is recorded here for the lead to
|
||||
apply.
|
||||
- `lucisv_core::config::FileConfig::lint_waivers` — new `Option<Vec<PathBuf>>`
|
||||
field, `[lint] waivers`, resolved against the config file's own directory
|
||||
by `Discovery` exactly as `filelist` is.
|
||||
- `vlog_linter::rule_by_name` / `Severity::from_name` — a directive's `--rule`
|
||||
is validated against the registry at parse time.
|
||||
|
||||
**Promised**
|
||||
|
||||
- `vlog_linter::lint(ctx, rules)` is **unchanged** in signature and behaviour;
|
||||
it now delegates to `lint_with(ctx, rules, &ExternalWaivers::default())`.
|
||||
- `vlog_linter::lint_with(ctx, rules, &ExternalWaivers) -> (Vec<Violation>,
|
||||
WaiverUse)` is the new entry point. The `WaiverUse` half is the caller's to
|
||||
merge across a run and hand back to `ExternalWaivers::unused`.
|
||||
- `vlog_linter::{ExternalWaivers, UnusedReport, WaiverUse}` are public.
|
||||
`ExternalWaivers::read` returns `(waivers, problems)` — a file that cannot
|
||||
be opened is the `Err`, a file with bad *lines* is an `Ok` carrying both —
|
||||
so the CLI can fail the run and the server can drop the line and log it,
|
||||
from one reader.
|
||||
- `vlog_linter::waiver::Waivers::filter` is gone, replaced by
|
||||
`Waivers::covers(rule, line)`; the union has to ask both waiver kinds about
|
||||
every violation, and a `filter` that dropped violations before the external
|
||||
one saw them would have marked only one of a covering pair used. Internal
|
||||
to the crate (`pub(crate)`), so nothing outside moves.
|
||||
- `lucisv_server::state::Workspace::roots()` is new (`&[PathBuf]`), for
|
||||
resolving a relative `lucisv.lint.waivers` entry against the first root the
|
||||
way `filelist_path` does inline.
|
||||
- `lucisv_server::lint::{waiver_paths, external_waivers}` are public so
|
||||
`server/notification.rs` can validate the setting once when it arrives.
|
||||
- `settings::LintSelection` gained a sixth element (the waiver list), so a
|
||||
changed list republishes every open buffer, as a changed option already did.
|
||||
- `lucisv::lint::{plan, check_stdin}`: `check_stdin` takes one more argument
|
||||
(`&ExternalWaivers`); `external_waivers(opts, configs)` is public for the
|
||||
stdin path in `main.rs`.
|
||||
|
||||
**Requested of the lead** (files owned by the concurrent docs process): the
|
||||
`README.md` / docs-site text under "Docs to apply at merge (lead)" below, and
|
||||
the `docs/topo.md` edge above.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] 39.1 `waiver_file.rs` (parse + match) and the union in `lib.rs`
|
||||
- [x] 39.2 discovery: `[lint] waivers`, `--waiver-file`, `lucisv.lint.waivers`
|
||||
- [x] 39.3 unused reporting on the CLI; errors on both front ends
|
||||
- [x] the VS Code setting — **by hand** in `editors/vscode/package.json`:
|
||||
`vlog_linter::vscode` generates only `lucisv.lint.severity.*` and
|
||||
`lucisv.lint.rules.*`, and the drift test
|
||||
(`settings.rs::the_vscode_lint_toggles_match_the_registry`) filters on
|
||||
exactly those two prefixes, so `lucisv.lint.select`, `ignore`, `options`
|
||||
and now `waivers` are hand-written beside them
|
||||
- [x] tests: every directive shape and every error; matching by name, path
|
||||
suffix, line and range; union with an inline waiver; unused reporting;
|
||||
CLI (`--waiver-file` twice, toml + CLI, exit codes); server unit tests;
|
||||
one e2e case over the wire
|
||||
- [x] docs: this README; TODO §4's two waiver lines and §39's own boxes
|
||||
- [ ] QA
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-09-04 (dev).**
|
||||
|
||||
- `crates/vlog_linter/src/waiver_file.rs` (new, ~330 lines with tests): the
|
||||
directive parser, the matcher, `WaiverUse` and the unused report.
|
||||
`waiver.rs` is untouched except that `filter` became `covers` — it is still
|
||||
only the inline story.
|
||||
- The union lives in `lib.rs::waive`, which asks **both** waiver kinds about
|
||||
every violation and never short-circuits: `inline.covers(..) || external
|
||||
.covers(..)` with `||` would have left the second waiver of a covering pair
|
||||
looking dead. There is a test for exactly that in `cli.rs`.
|
||||
- Grammar accepted, exactly:
|
||||
`waive` then any order of `--rule=<rule>` (required, once),
|
||||
`--line=<N>` or `--line=<N>-<M>` (once), `--location=<pattern>` (once).
|
||||
Leading and trailing whitespace ignored, `#` comments and blank lines
|
||||
ignored, CRLF handled (the span arithmetic uses `split_inclusive('\n')` so a
|
||||
`\r` does not shift a directive's reported line). There is no quoting, so a
|
||||
pattern cannot contain a space — the same limitation `.f` filelists have.
|
||||
- Every error message (each prefixed `<file>:<line>: `):
|
||||
- ``expected a `waive` directive, found `<word>` ``
|
||||
- ``` `waive` needs a `--rule=<rule-name>` ```
|
||||
- ``unknown rule `<name>` ``
|
||||
- ``` `--rule=<word>` names a severity class; a waiver names one rule at a time ```
|
||||
- ``` `--line=<v>` is not a line or a line range (`--line=5`, `--line=5-9`) ```
|
||||
- ``` `--line=<v>` starts at 0; lines are numbered from 1 ```
|
||||
- ``` `--line=<v>` counts backwards ```
|
||||
- ``` `--location=<v>` looks like a regular expression (`<token>`); lucisv
|
||||
matches a location the way `--exclude` does — … ```
|
||||
- ``` `--<flag>` is given twice ```
|
||||
- ``` `--regex` is not supported; waive by `--line` or `--location` ```
|
||||
- ``unknown option `<flag>` (the options are `--rule`, `--line` and
|
||||
`--location`)``
|
||||
- ``` `--<flag>` takes a value: write `--<flag>=<value>` ```
|
||||
- ``` `--<flag>` has an empty value ```
|
||||
- and, for a file that cannot be opened at all, `<path>: <io error>`.
|
||||
- CLI: `--waiver-file` is repeatable and lint-only; the run's set is the flag's
|
||||
files in order, then every `[lint] waivers` entry of a config file governing
|
||||
an input, de-duplicated canonically. The first problem fails the run at exit
|
||||
2 before anything is linted, matching a bad `[lint.<rule>]` entry.
|
||||
- Unused external waivers are computed **after** the whole run
|
||||
(`lint::dead_waivers`), from the `WaiverUse` each file's report carries,
|
||||
merged. They are reported as ordinary `unused-waiver` violations against the
|
||||
waiver file, which means they flow through `--output-format json` and the
|
||||
exit code unchanged. A stdin run is a run of one buffer and reports them
|
||||
too.
|
||||
- `check_one`/`run_rules`/`fix_source` grew a `Pass<'a>` struct rather than a
|
||||
seventh and eighth parameter (clippy's `too_many_arguments` was one argument
|
||||
away). Pure plumbing; no behaviour moved.
|
||||
- Under `--fix`, usage accumulates across the fix rounds: a waiver that
|
||||
covered a finding the fix then removed still did its job.
|
||||
- Server: `LintRun` carries an `ExternalWaivers`; `violations_in` calls
|
||||
`lint_with` and discards the usage half, because the server never sees a
|
||||
whole run and must not claim a waiver is dead. The setting's files are read
|
||||
a second time in `apply_settings` purely to log what is wrong with them —
|
||||
once per settings push instead of once per keystroke.
|
||||
- Deviations from the plan, all noted above: the `lucisv_core` dependency in
|
||||
`vlog_linter` (Handshakes), the VS Code setting added by hand rather than
|
||||
through the generator (which does not cover this family of settings), and
|
||||
`editors/vscode/README.md` gaining the setting's row — a file outside the
|
||||
plan's expected touch set, listed below.
|
||||
|
||||
**Gates (all guarded, 2026-09-04)**
|
||||
|
||||
- `cargo fmt -p` clean for `lucisv`, `lucisv_core`, `lucisv_server`,
|
||||
`vlog_linter`; `cargo clippy --all-targets` clean (zero warnings).
|
||||
- `tools/guard.sh -- cargo test --workspace`: **3 764 passed, 0 failed, 44
|
||||
ignored** (3 744 at 0.41.0, plus this round's 20 new tests).
|
||||
- `tools/guard.sh -- tools/corpus_check.sh`: **814/820**, the same six
|
||||
failures as 0.41.0.
|
||||
- `cargo build --release -p lucisv -p lucisv_server`, then
|
||||
`tools/guard.sh -- node editors/vscode/smoke.js target/release/lucisv-server`
|
||||
— OK, 20 messages.
|
||||
- opentitan demonstration, read-only:
|
||||
`target/release/lucisv check --no-cache --select error,warning,style
|
||||
hw/ip/aes/rtl` reports **307** violations; with
|
||||
`--waiver-file <scratch>/opentitan.waiver` holding
|
||||
|
||||
```text
|
||||
waive --rule=dff-name-style --line=226 --location=aes_key_expand.sv
|
||||
```
|
||||
|
||||
it reports **306**, and the one line that disappears is exactly
|
||||
`aes_key_expand.sv:226:12 … [dff-name-style]`. (The *default* rule set finds
|
||||
nothing at all in `hw/ip/aes/rtl`, which is why the demonstration selects
|
||||
every class.) `git -C ~/repo/opentitan status --porcelain` afterwards shows
|
||||
only the three pre-existing modified files.
|
||||
|
||||
**Files touched outside the plan's expected set**
|
||||
|
||||
- `crates/vlog_linter/Cargo.toml` — the `lucisv_core` path dependency.
|
||||
- `crates/lucisv_server/src/state.rs` — `Workspace::roots()`, an accessor.
|
||||
- `crates/lucisv_server/tests/e2e.rs`, `crates/lucisv/tests/cli.rs` — tests
|
||||
the plan asked for.
|
||||
- `editors/vscode/README.md` — the settings table's row for
|
||||
`lucisv.lint.waivers` (`README.md` at the repo root and everything under
|
||||
`docs/site/` were owned by another process this round and are left alone;
|
||||
their text is below).
|
||||
|
||||
## Docs to apply at merge (lead)
|
||||
|
||||
Ready to paste. The first block is for `README.md` (the linter section, after
|
||||
the inline-waiver paragraph) and for
|
||||
`docs/site/src/content/docs/guides/linter.md`.
|
||||
|
||||
```markdown
|
||||
### Waivers
|
||||
|
||||
A finding is suppressed by a comment in the RTL:
|
||||
|
||||
```systemverilog
|
||||
wire a; // lucisv: waive no-tabs
|
||||
// lucisv: waive-start line-length
|
||||
…
|
||||
// lucisv: waive-stop line-length
|
||||
```
|
||||
|
||||
`verilog_lint:` is accepted in place of `lucisv:`, so a Verible-annotated
|
||||
codebase needs no editing.
|
||||
|
||||
It can also be suppressed from **outside** the RTL, in Verible's waiver file
|
||||
format — one directive per line, `#` comments and blank lines ignored:
|
||||
|
||||
```text
|
||||
# every line of every file
|
||||
waive --rule=no-tabs
|
||||
# one line, or a range with both ends included
|
||||
waive --rule=line-length --line=12
|
||||
waive --rule=line-length --line=12-20
|
||||
# only the files a pattern names
|
||||
waive --rule=no-tabs --location=legacy/top.sv
|
||||
```
|
||||
|
||||
`--rule` is required and names exactly one rule — a severity word is not
|
||||
accepted here. `--line` is 1-based. `--location` is matched the way an
|
||||
`--exclude` pattern is: `*` stands for any run of characters *within* one path
|
||||
component, a pattern containing `/` matches a path suffix, and one without
|
||||
matches the file name at any depth. Unlike Verible's, it is **not** a regular
|
||||
expression, and a pattern that looks like one (`.*`, `\.`, `[…]`) is an error
|
||||
naming the difference rather than a pattern that silently matches nothing.
|
||||
|
||||
lucisv reads waiver files from three places, and they **add up**:
|
||||
|
||||
| Where | Paths relative to | Applies to |
|
||||
| --- | --- | --- |
|
||||
| `lucisv check --waiver-file <path>` (repeatable) | the working directory | that run |
|
||||
| `waivers` under `[lint]` in `lucisv.toml` | that `lucisv.toml` | the CLI and the editor |
|
||||
| `lucisv.lint.waivers` in an editor | the first workspace folder | the editor |
|
||||
|
||||
```toml
|
||||
[lint]
|
||||
waivers = [ "waivers/legacy.waiver" ]
|
||||
```
|
||||
|
||||
External waivers and inline ones are a **union**: a finding either covers is
|
||||
suppressed, and a finding both cover leaves neither reported as dead.
|
||||
|
||||
A waiver file that does not exist, or a directive that does not parse, fails
|
||||
`lucisv check` with `<file>:<line>: <message>` and exit 2 — the same treatment
|
||||
a bad `[lint.<rule>]` entry gets. In an editor the bad line is dropped, the
|
||||
rest of the file still applies, and the problem is written once to the lucisv
|
||||
log.
|
||||
|
||||
A waiver that suppressed nothing is itself reported, under the
|
||||
`unused-waiver` rule: an inline one at the comment, an external one at its
|
||||
line of the waiver file. **Only `lucisv check` reports unused external
|
||||
waivers**, and only after the whole run has been linted — a `--location` may
|
||||
name a file the run has not reached yet, and an editor never sees a whole run
|
||||
at all.
|
||||
```
|
||||
|
||||
For `docs/site/src/content/docs/reference/cli.md`, in the `lucisv check`
|
||||
options table:
|
||||
|
||||
```markdown
|
||||
| `--waiver-file <PATH>` | Read waiver directives from this file; repeatable. Adds to whatever `waivers` under `[lint]` in a `lucisv.toml` already names. Relative to the working directory. A missing file or an unparsable directive is an error (exit 2) |
|
||||
```
|
||||
|
||||
For `docs/site/src/content/docs/start/configuration.md`, in the `lucisv.toml`
|
||||
key table and the editor-settings table respectively:
|
||||
|
||||
```markdown
|
||||
| `[lint] waivers` | `[]` | External waiver files, resolved against the `lucisv.toml`'s own directory. Verible's format; see the linter guide's Waivers section |
|
||||
```
|
||||
|
||||
```markdown
|
||||
| `lucisv.lint.waivers` | `[]` | External waiver files, absolute or relative to the first workspace folder; added to whatever `[lint] waivers` names. A missing file or an unparsable directive is logged and dropped. Unused external waivers are reported by `lucisv check` only |
|
||||
```
|
||||
|
||||
And the edge for `docs/topo.md`: **`vlog_linter ──▶ lucisv_core`** —
|
||||
`waiver_file.rs` matches a `--location` with `walk::is_excluded`, the same
|
||||
matcher `--exclude` uses.
|
||||
|
||||
### 2026-09-05 — lead, at review
|
||||
|
||||
QA's HIGH closed in the tree: `lucisv_server::lint::fixable` now takes the
|
||||
buffer's `LintRun` and lints with `lint_with(ctx, run.rules, run.external)`,
|
||||
so a quick fix is never offered — and `source.fixAll.lucisv` never applied —
|
||||
for a finding a checked-in waiver file waived; the code-action entry point
|
||||
takes the run and the dispatch builds it with `LintRun::for_document`. This
|
||||
also stops the code-action path from fixing under `default_rules()` while
|
||||
the diagnostics pass runs the enabled set, a second pre-existing drift.
|
||||
Pinned by `an_externally_waived_finding_gets_no_quick_fix_and_fix_all_leaves_it`.
|
||||
The BOM LOW: a leading U+FEFF is stripped before the first directive is
|
||||
read. The other LOW (a bad line in a file named by `[lint] waivers` is
|
||||
dropped silently in the editor, the editor-setting path is logged) is
|
||||
documented in the applied docs and folded into §42.2, which surfaces every
|
||||
rejected project entry with file and line. The docs in "Docs to apply at
|
||||
merge" are applied to README.md, the linter guide, cli.md, configuration.md
|
||||
and topo.md.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-05 (QA).**
|
||||
|
||||
Read the plan (TODO §39), the feature README in full, and the diffs of
|
||||
`crates/vlog_linter/src/{waiver_file.rs,waiver.rs,lib.rs}`,
|
||||
`crates/lucisv_core/src/config.rs`,
|
||||
`crates/lucisv/src/{args.rs,lint.rs,main.rs}`,
|
||||
`crates/lucisv_server/src/{lint.rs,settings.rs,state.rs,server/notification.rs}`,
|
||||
`editors/vscode/package.json` and `editors/vscode/README.md`, and the two test
|
||||
files. Built `cargo build --release -p lucisv -p lucisv_server`, then attacked
|
||||
the grammar, precedence and both front ends by hand, using scratch files under
|
||||
the session scratchpad and read-only runs over opentitan. Every experiment
|
||||
that needed a real request over the wire (server disk re-read, code-action
|
||||
gap) was a temporary `#[test]` appended to `crates/lucisv_server/tests/e2e.rs`,
|
||||
run under `tools/guard.sh`, then removed — `git diff --stat` on that file
|
||||
after removal matches the dev's own 81-line addition exactly, confirming no
|
||||
residue.
|
||||
|
||||
**CLI grammar — all shapes and errors, verified by direct reproduction.**
|
||||
`--rule` alone, `--line=N`, `--line=N-M`, `--location=name.sv`,
|
||||
`--location=dir/name.sv` (suffix), all three together in every order (3
|
||||
permutations tried) — every shape suppresses exactly the finding(s) it should
|
||||
and nothing else. Every error message in the Work Log fires with the
|
||||
`<file>:<line>: message` shape and exit 2: bad keyword, missing `--rule`,
|
||||
unknown rule, severity-as-rule, `--line=0`, `--line=9-5`, non-numeric
|
||||
`--line`, doubled flag, unknown flag, `--regex=`, flag with no value, empty
|
||||
value, a regex-looking `--location` (with the reason named). With three bad
|
||||
lines in one file (line 1 fine, line 2 and 3 both bad), only line 2 is
|
||||
reported — the **first** bad line, confirmed. With two waiver files
|
||||
(`goodA.waiver` clean, `badB.waiver` bad), the error correctly names
|
||||
`badB.waiver`, not a false-positive stop at the first file.
|
||||
|
||||
Edge cases: `--line=5-5` behaves as a one-line range; `--line=1-4` spanning
|
||||
the whole 4-line file waives every occurrence; `--line=100` past EOF is
|
||||
reported `unused-waiver`, never an error; `--location` naming a file absent
|
||||
from the run is reported unused; `--location=f*.sv` and `--location=**/foo.sv`
|
||||
both match via the `--exclude` glob semantics as documented; CRLF endings
|
||||
parse every directive without shifting reported line numbers (multi-line CRLF
|
||||
file tested, both directives fired); a UTF-8 BOM before `waive` is rejected
|
||||
with a (slightly odd but non-corrupting) "found `\u{feff}waive`" message, exit
|
||||
2 — acceptable, not a hazard; tabs between `--rule=`/`--line=`/`--location=`
|
||||
words parse fine (`split_whitespace` handles them); `Waive` (capitalized) is
|
||||
correctly rejected — the grammar is case-sensitive as specified; an empty
|
||||
waiver file contributes nothing and errors nothing; a directory given as
|
||||
`--waiver-file` surfaces the OS "Is a directory" error at exit 2; a
|
||||
non-UTF-8 waiver file is rejected with "stream did not contain valid UTF-8",
|
||||
exit 2. The same waiver file given twice via `--waiver-file` is read once —
|
||||
confirmed by only one `unused-waiver` finding, not two, for a dead directive
|
||||
in it.
|
||||
|
||||
Discovery combinations: `[lint] waivers` in a `lucisv.toml` (resolved
|
||||
against the toml's directory) plus `--waiver-file` (resolved against the
|
||||
cwd) from a **different cwd** than the toml's directory both applied
|
||||
together correctly, suppressing both their respective lines. A `lucisv.toml`
|
||||
pointing at a missing waiver file fails the run with the resolved absolute
|
||||
path and exit 2.
|
||||
|
||||
**Precedence — union, exactly as specified.** A finding covered by both an
|
||||
inline `// lucisv: waive` and a matching external directive is suppressed
|
||||
once, and **neither** is reported unused. An inline waiver covering nothing
|
||||
plus an external one covering the actual finding: the inline is reported
|
||||
`unused-waiver`, the external (which fired) is not. `--select` excluding the
|
||||
waived rule entirely makes the waiver silent (no `unused-waiver`) — consistent
|
||||
with existing inline-waiver behavior and documented in the Assumptions.
|
||||
`--fix` with a waived fixable violation: reproduced on a scratch copy (never
|
||||
opentitan) — the waived line's tab was left untouched while an unwaived tab
|
||||
on another line was fixed in the same run. Exit code and `--output-format
|
||||
json`: an unused external waiver flows through as an ordinary violation
|
||||
(`"filename":"<waiver-file>"`, correct line/column) and contributes to the
|
||||
non-zero exit code.
|
||||
|
||||
**Server, over the wire (temporary e2e tests, removed after).** `[lint]
|
||||
waivers` in a checked-in `lucisv.toml` suppresses a published diagnostic
|
||||
(confirmed both standalone and combined with `lucisv.lint.waivers`).
|
||||
`workspace/didChangeConfiguration` adding, then removing, then re-adding
|
||||
`lucisv.lint.waivers` mid-session updates published diagnostics each time
|
||||
(`[1,2] → [2] → [1,2] → [2]`, 0-based `no-tabs` lines, across four pushes) —
|
||||
no reload needed. A waiver file **edited on disk while the server runs** is
|
||||
re-read: verified by hand-driving the JSON-RPC stream (rather than the
|
||||
`talk()` helper, which writes the whole session before reading anything, so
|
||||
race-free ordering needed manual interleaving) — read the first publish,
|
||||
*then* rewrote the waiver file on disk, *then* sent a no-op `didChange`, and
|
||||
the second publish reflected the new file content with no restart. This
|
||||
matches the Assumptions section's claim exactly. A bad directive in
|
||||
`lucisv.lint.waivers` is logged once via `window/logMessage` (not
|
||||
`showMessage`) when the setting arrives, not once per keystroke — confirmed
|
||||
both by the dev's own e2e test (exactly 2 log lines for one bad rule + one
|
||||
missing file) and by code inspection: `lint::violations_in`/`LintRun::for_
|
||||
document` discard the read's problem list on every pass, so only
|
||||
`notification.rs`'s one-time read at settings-arrival time can log anything.
|
||||
The server never publishes `unused-waiver` for an external waiver, in any of
|
||||
the above scenarios — confirmed.
|
||||
|
||||
One clarification volunteered here since it affects how a reader should
|
||||
weight the "documented" note in the config.rs precedent: a bad `[lint]
|
||||
waivers` entry from a *toml* (as opposed to the `lucisv.lint.waivers`
|
||||
*setting*) is silently dropped by the server with **no log line at all** —
|
||||
`notification.rs::waiver_problems` only inspects the setting's own paths
|
||||
(`FileConfig::default()` is passed, discarding the buffer's real config).
|
||||
This is consistent with the server's pre-existing treatment of a bad
|
||||
`[lint.<rule>]` entry (`lint.rs::configured`'s comment: "dropped here rather
|
||||
than reported... which is where a config error belongs" — i.e. `lucisv
|
||||
check`'s job), so it is not a new inconsistency, but it means a typo in a
|
||||
checked-in `lucisv.toml`'s `[lint] waivers` is invisible in the editor with no
|
||||
log trace at all (only `lucisv check` will ever catch it). Not filing this as
|
||||
a defect since it matches standing precedent, but noting it because the plan
|
||||
text's single sentence ("the server logs it through notification.rs and
|
||||
drops that line, never the file") reads as if it covers all three discovery
|
||||
paths, and it does not — it covers only the editor setting.
|
||||
|
||||
**Opentitan (read-only).** Reproduced exactly: `--select error,warning,style
|
||||
hw/ip/aes/rtl` → **307**; with the `dff-name-style --line=226
|
||||
--location=aes_key_expand.sv` waiver → **306**, and the missing line is
|
||||
confirmed to be `aes_key_expand.sv:226:12 … [dff-name-style]`. Added: the
|
||||
`--location` **suffix** form `aes/rtl/aes_key_expand.sv` → also **306**
|
||||
(same result as the file-name form). A whole-file waiver
|
||||
(`--rule=port-name-suffix --location=aes_wrap.sv`, no `--line`) → **304**
|
||||
(three `port-name-suffix` findings in that file, all gone, zero remaining).
|
||||
A waiver naming a file outside the run (`--location=nonexistent_file_xyz.sv`)
|
||||
produces exactly one `unused-waiver` line. `git -C
|
||||
~/repo/opentitan status --porcelain` after every run showed only the three
|
||||
pre-existing modified files (`hw/ip/aes/dv/tb/tb.sv`,
|
||||
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`).
|
||||
|
||||
**Gates (all guarded).** `cargo fmt --check`: clean. `cargo clippy
|
||||
--all-targets`: clean, zero warnings. `tools/guard.sh -- cargo test
|
||||
--workspace`: **3 764 passed, 0 failed, 44 ignored** — matches the dev's
|
||||
figure exactly. `tools/guard.sh -- tools/corpus_check.sh`: **814/820
|
||||
(99.3%)**, the same six pre-existing failures (one `end`, one identifier, one
|
||||
expression, one declaration/instantiation, one `;`, one lex "number base").
|
||||
`tools/guard.sh -- node editors/vscode/smoke.js target/release/lucisv-server`:
|
||||
OK, 20 messages.
|
||||
|
||||
### Findings
|
||||
|
||||
**HIGH — the code-action path does not honor external waivers, and the
|
||||
Assumptions section understates it.** `lucisv_server::lint::fixable`
|
||||
(`crates/lucisv_server/src/lint.rs:334`, called from
|
||||
`code_action::code_actions`, `crates/lucisv_server/src/code_action.rs:37`)
|
||||
calls the old `lint(&ctx, &default_rules())` rather than `lint_with`, so it
|
||||
never consults `LintRun::external`. **Inline waivers are still respected
|
||||
here** — `lint()` internally still runs `Waivers::collect(ctx)` regardless of
|
||||
the `external` argument, so an inline-waived finding correctly gets no quick
|
||||
fix. **External waivers are not respected at all**, and this is
|
||||
reproducible, not merely theoretical:
|
||||
|
||||
- Reproduction (temporary e2e test, removed after): a buffer with three
|
||||
tabbed lines — one inline-waived (`// lucisv: waive no-tabs`), one
|
||||
externally waived via a `lucisv.toml`'s `[lint] waivers` pointing at a
|
||||
waiver file with `--rule=no-tabs --line=3`, one waived by neither.
|
||||
Published diagnostics correctly show only the un-waived line. A
|
||||
`textDocument/codeAction` request over the whole buffer returns **two**
|
||||
quickfix actions: the un-waived line (expected) **and the externally
|
||||
waived line** (not expected — no action should exist for it at all). Worse,
|
||||
a `source.fixAll.lucisv` request (what an editor's "format/fix on save"
|
||||
sends) **actually rewrites the externally-waived line**, turning its tab
|
||||
into spaces — silently overriding the waiver a team member wrote into a
|
||||
checked-in `lucisv.toml`.
|
||||
- The Assumptions section's claim — "A waived finding was never published,
|
||||
so no lightbulb is offered for it in practice; the mismatch is pre-existing
|
||||
and out of scope here" — is only half right. It is accurate for a finding
|
||||
an *inline* waiver covers (no lightbulb, confirmed). It is **not** accurate
|
||||
for a finding only an *external* waiver covers: `code_actions` never
|
||||
consults the published diagnostics list or the request's `range` against
|
||||
what the client already sees — it recomputes `fixable()` independently and
|
||||
offers/applies whatever it finds, waiver or not. The QA brief's own
|
||||
framing ("it is pre-existing for inline waivers too") does not hold up
|
||||
against this reproduction — the inline case is fine; only the external one
|
||||
is broken, and it is broken in a way that actively edits code
|
||||
(`fixAll`), not merely in a way that could theoretically surface a
|
||||
quickfix nobody clicks.
|
||||
- This does not violate the CLAUDE.md corruption invariant (the output is a
|
||||
valid, idempotent formatting change, just one the team asked to suppress
|
||||
for that line) but it does defeat the stated purpose of an external
|
||||
waiver for anyone with fix-on-save enabled, which is a common editor
|
||||
default. Recommend `fixable` take the buffer's `ExternalWaivers` (already
|
||||
computed once per `LintRun`) the same way `violations_in` does, or, if a
|
||||
fix for 0.42.0 is out of scope, correcting the Assumptions section to state
|
||||
the real risk plainly (external waivers are not honored by the editor's
|
||||
quick-fix or fix-on-save code path) rather than describing it as
|
||||
no-observable-difference.
|
||||
|
||||
**LOW — BOM message is unusual but not a hazard.** A waiver file with a
|
||||
leading UTF-8 BOM produces `` expected a `waive` directive, found
|
||||
`\u{feff}waive` `` (the BOM character embedded verbatim in the error text)
|
||||
rather than a message about the BOM specifically. Exit 2, no corruption, and
|
||||
BOM'd waiver files are not mentioned as a requirement anywhere in the plan —
|
||||
recording this only because the QA brief asked for a BOM to be tried. Not
|
||||
blocking.
|
||||
|
||||
**LOW — documentation precision.** The plan's discovery-rule bullet describes
|
||||
the server logging behavior for a bad waiver line as if it applied uniformly
|
||||
across all three discovery paths; in the implementation it applies only to
|
||||
the `lucisv.lint.waivers` editor setting, and a bad `[lint] waivers` entry
|
||||
from a `lucisv.toml` is silently dropped with no log at all on the server
|
||||
side. This matches the server's existing, unrelated precedent for
|
||||
`[lint.<rule>]` entries, so it is not a code defect, just worth a line in the
|
||||
feature README's Assumptions (or the merge docs) so a future reader is not
|
||||
surprised that only the editor-setting path logs.
|
||||
|
||||
Everything else asked for in the QA brief — every directive shape and error,
|
||||
every precedence combination, `--select`/`--ignore` interaction, `--fix`
|
||||
interaction, server settings roundtrip, disk re-read, toml-via-server,
|
||||
opentitan counts — checked out exactly as designed and documented.
|
||||
|
||||
**Verdict: REWORK** — one HIGH finding (the code-action/fixAll gap for
|
||||
external waivers, and the inaccurate risk description of it in the
|
||||
Assumptions section). Everything else in the feature — the CLI grammar, the
|
||||
CLI's own `--fix`, precedence, discovery, the diagnostics-publishing half of
|
||||
the server, and the opentitan demonstration — is solid and matches the plan
|
||||
precisely. The lead's call on whether the HIGH finding blocks 0.42.0 or ships
|
||||
with corrected documentation and a follow-up item; either way the
|
||||
Assumptions section as written should not stand unchanged, since it asserts
|
||||
something this QA pass showed to be false in the `fixAll` case specifically.
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-05 — lead.** Accepted with the rework above; ships in 0.42.0 with
|
||||
§38. The format, discovery and precedence are the ruled ones, and the dev's
|
||||
deviations hold: the `vlog_linter ──▶ lucisv_core` edge is the right price
|
||||
for one pattern language across `--exclude` and `--location` (copying the
|
||||
matcher would have made two), the `Pass` struct is plain plumbing, and the
|
||||
setting joins the hand-written `select`/`ignore`/`options` rather than the
|
||||
generator's per-rule toggles. QA's HIGH was real and is the kind of gap a
|
||||
union has to be checked for at every consumer — the fix routes the last
|
||||
consumer through the run. Unused-waiver reporting on the CLI only, after the
|
||||
whole run, stays as ruled. The opentitan demonstration (307 → 306 by one
|
||||
directive, 304 with a whole-file rule waiver) is the behaviour asked for.
|
||||
+1
-1
@@ -103,4 +103,4 @@ do not have independent fence scopes. Fenced text must still parse.</p>
|
||||
<li><strong>Write atomically.</strong> An error leaves the affected file untouched.</li>
|
||||
<li><strong>Stay deterministic.</strong> Parallel worker count changes performance, never output order or exit status.</li>
|
||||
</ol>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/guides/formatter.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-08-27T03:31:44.000Z">Aug 27, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/start/configuration/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Configuration</span></span></a><a href="/guides/linter/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Linter</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/guides/formatter.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/start/configuration/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Configuration</span></span></a><a href="/guides/linter/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Linter</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
+22
-3
@@ -94,7 +94,26 @@ array, with a <code dir="auto">severity</code> field on each diagnostic.</p>
|
||||
<div class="sl-heading-wrapper level-h2"><h2 id="waivers">Waivers</h2><a class="sl-anchor-link" href="#waivers"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “Waivers”</span></a></div>
|
||||
<div class="expressive-code"><figure class="frame not-content"><figcaption class="header"></figcaption><pre data-language="system-verilog"><code><div class="ec-line"><div class="code"><span style="--0:#C792EA;--1:#8844AE">wire</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#C5E478;--1:#3B61B0">a</span><span style="--0:#D6DEEB;--1:#403F53">; </span><span style="--0:#919F9F;--1:#5D6376">// lucisv: waive no-tabs</span></div></div><div class="ec-line"><div class="code"><span style="--0:#919F9F;--1:#5D6376">// lucisv: waive no-tabs</span></div></div><div class="ec-line"><div class="code"><span style="--0:#C792EA;--1:#8844AE">wire</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#C5E478;--1:#3B61B0">b</span><span style="--0:#D6DEEB;--1:#403F53">;</span></div></div><div class="ec-line"><div class="code"><span style="--0:#919F9F;--1:#5D6376">// lucisv: waive-start module-name-style</span></div></div><div class="ec-line"><div class="code"><span style="--0:#C792EA;--1:#8844AE">module</span><span style="--0:#D6DEEB;--1:#403F53"> LegacyName;</span></div></div><div class="ec-line"><div class="code"><span style="--0:#C792EA;--1:#8844AE">endmodule</span></div></div><div class="ec-line"><div class="code"><span style="--0:#919F9F;--1:#5D6376">// lucisv: waive-stop module-name-style</span></div></div></code></pre><div class="copy"><div aria-live="polite"></div><button title="Copy to clipboard" data-copied="Copied!" data-code="wire a; // lucisv: waive no-tabs// lucisv: waive no-tabswire b;// lucisv: waive-start module-name-stylemodule LegacyName;endmodule// lucisv: waive-stop module-name-style"><div></div></button></div></figure></div>
|
||||
<p><code dir="auto">verilog_lint:</code> is accepted in place of <code dir="auto">lucisv:</code> for Verible compatibility. The <code dir="auto">unused-waiver</code> rule reports malformed, unknown, or no-longer-needed suppressions when their target rule is enabled.</p>
|
||||
<p>External waiver files are not implemented in v0.41.0; the planned waiver-file
|
||||
settings and CLI flag are not accepted yet.</p>
|
||||
<p>Findings can also be suppressed from <strong>outside</strong> the RTL, in Verible’s
|
||||
waiver-file format — one directive per line, <code dir="auto">#</code> comments and blank lines
|
||||
ignored:</p>
|
||||
<div class="expressive-code"><figure class="frame not-content"><figcaption class="header"></figcaption><pre data-language="text"><code><div class="ec-line"><div class="code"><span style="--0:#d6deeb;--1:#403f53"># every line of every file</span></div></div><div class="ec-line"><div class="code"><span style="--0:#d6deeb;--1:#403f53">waive --rule=no-tabs</span></div></div><div class="ec-line"><div class="code"><span style="--0:#d6deeb;--1:#403f53"># one line, or a range with both ends included</span></div></div><div class="ec-line"><div class="code"><span style="--0:#d6deeb;--1:#403f53">waive --rule=line-length --line=12</span></div></div><div class="ec-line"><div class="code"><span style="--0:#d6deeb;--1:#403f53">waive --rule=line-length --line=12-20</span></div></div><div class="ec-line"><div class="code"><span style="--0:#d6deeb;--1:#403f53"># only the files a pattern names</span></div></div><div class="ec-line"><div class="code"><span style="--0:#d6deeb;--1:#403f53">waive --rule=no-tabs --location=legacy/top.sv</span></div></div></code></pre><div class="copy"><div aria-live="polite"></div><button title="Copy to clipboard" data-copied="Copied!" data-code="# every line of every filewaive --rule=no-tabs# one line, or a range with both ends includedwaive --rule=line-length --line=12waive --rule=line-length --line=12-20# only the files a pattern nameswaive --rule=no-tabs --location=legacy/top.sv"><div></div></button></div></figure></div>
|
||||
<p><code dir="auto">--rule</code> is required and names exactly one rule (a severity word is not
|
||||
accepted). <code dir="auto">--line</code> is 1-based. <code dir="auto">--location</code> is matched the way an
|
||||
<code dir="auto">--exclude</code> pattern is — <code dir="auto">*</code> within one path component, a pattern with <code dir="auto">/</code>
|
||||
matching a path suffix, one without matching the file name at any depth — and
|
||||
<strong>not</strong> as a regular expression; a pattern that looks like one (<code dir="auto">.*</code>, <code dir="auto">\.</code>,
|
||||
<code dir="auto">[…]</code>) is an error naming the difference.</p>
|
||||
<p>Waiver files come from three places, and they add up: <code dir="auto">lucisv check --waiver-file <path></code> (repeatable, relative to the working directory),
|
||||
<code dir="auto">waivers</code> under <code dir="auto">[lint]</code> in <code dir="auto">lucisv.toml</code> (relative to that file; read by the
|
||||
CLI and the editor), and the editor setting <code dir="auto">lucisv.lint.waivers</code> (relative to
|
||||
the first workspace folder). External and inline waivers are a union: a
|
||||
finding either covers is suppressed, and one both cover leaves neither
|
||||
reported as dead. A missing file or an unparsable directive fails <code dir="auto">lucisv check</code> with <code dir="auto"><file>:<line>: <message></code> and exit 2; in an editor the bad line
|
||||
is dropped and the rest of the file applies — a bad line in a file named by
|
||||
the editor setting is written once to the lucisv log, one named by
|
||||
<code dir="auto">lucisv.toml</code> is not (run <code dir="auto">lucisv check</code> to see it). Unused external waivers
|
||||
are reported under <code dir="auto">unused-waiver</code> at their line of the waiver file, by
|
||||
<code dir="auto">lucisv check</code> only and only after the whole run.</p>
|
||||
<p>See the <a href="/reference/rules/">complete rule reference</a>.</p>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/guides/linter.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-02T16:06:08.000Z">Sep 2, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/formatter/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a><a href="/guides/editors/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Editors & LSP</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/guides/linter.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/formatter/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a><a href="/guides/editors/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Editors & LSP</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
{"version":"1.5.2","languages":{"en":{"hash":"en_db82295a7c","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]}
|
||||
{"version":"1.5.2","languages":{"en":{"hash":"en_a31252bf8c","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]}
|
||||
Binary file not shown.
Binary file not shown.
+1
-1
@@ -175,4 +175,4 @@ server/editor setting names. Source modules are split by grammar domain under
|
||||
</ul>
|
||||
<div class="sl-heading-wrapper level-h2"><h2 id="release-surface">Release surface</h2><a class="sl-anchor-link" href="#release-surface"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “Release surface”</span></a></div>
|
||||
<p>The supported publication surface is seven VS Code <code dir="auto">.vsix</code> packages plus checksums: five platform packages (Apple Silicon/Intel macOS, x86-64/ARM64 static-musl Linux, Windows), one all-platform package, and one universal package requiring binaries on <code dir="auto">PATH</code>. Both <code dir="auto">lucisv</code> and <code dir="auto">lucisv-server</code> are bundled in platform packages. Standalone binaries are built by the tooling but are not published as release assets. The release tooling audits file type, dynamic linkage, and the glibc ceiling for cross-built artifacts.</p>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/architecture.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-08-27T03:31:44.000Z">Aug 27, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/rust-api/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Rust API index</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/architecture.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/rust-api/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Rust API index</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
+6
-1
@@ -230,6 +230,11 @@
|
||||
<td>Allow unsafe fixes when a rule provides them</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code dir="auto">--waiver-file <PATH></code></td>
|
||||
<td>path</td>
|
||||
<td>Read Verible-format waiver directives from this file; repeatable. Adds to <code dir="auto">[lint] waivers</code> from <code dir="auto">lucisv.toml</code>. Relative to the working directory. A missing file or an unparsable directive is an error (exit 2)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code dir="auto">--rules-doc</code></td>
|
||||
<td>—</td>
|
||||
<td>Print registry-generated rule and option documentation and exit; takes no files</td>
|
||||
@@ -266,4 +271,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<p>An error outranks “would change.” Every file involved in an error is left untouched.</p>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/cli.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-08-27T03:31:44.000Z">Aug 27, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/syntax/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Supported syntax</span></span></a><a href="/reference/rules/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/cli.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/syntax/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Supported syntax</span></span></a><a href="/reference/rules/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
+1
-1
@@ -342,4 +342,4 @@ index scope when the defining module lives outside the default folder scope.</p>
|
||||
</table>
|
||||
<div class="sl-heading-wrapper level-h2"><h2 id="workspace-lifecycle">Workspace lifecycle</h2><a class="sl-anchor-link" href="#workspace-lifecycle"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “Workspace lifecycle”</span></a></div>
|
||||
<p>The server handles <code dir="auto">didOpen</code>, incremental <code dir="auto">didChange</code>, <code dir="auto">didSave</code>, <code dir="auto">didClose</code>, watched-file changes, configuration changes, cancellation, shutdown, and exit. It dynamically registers file watchers, emits work-done progress while building large indexes, coalesces code-lens refreshes, and promotes open-buffer overlays into the workspace without waiting for disk writes.</p>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/language-tools.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-03T09:28:11.000Z">Sep 3, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/rules/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a><a href="/reference/rust-api/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Rust API index</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/language-tools.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/rules/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a><a href="/reference/rust-api/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Rust API index</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
+1
-1
@@ -748,4 +748,4 @@
|
||||
<p>Reports a <code dir="auto">;</code> written after a <code dir="auto">`uvm_*</code> macro invocation. The macros expand to a <code dir="auto">begin … end</code>, so the <code dir="auto">;</code> is a null statement — usually inert, and not after <code dir="auto">if (x) </code>uvm_info(…); else …<code dir="auto">, where the </code>else<code dir="auto">then belongs to nothing. Off by default in both, because the semicolon is written everywhere in existing UVM code. No fix: deleting it is exactly the edit that is unsafe in the shape the rule exists for. Verible's</code>uvm-macro-semicolon`, same default.</p>
|
||||
<div class="sl-heading-wrapper level-h2"><h2 id="v2001-generate-begin">v2001-generate-begin</h2><a class="sl-anchor-link" href="#v2001-generate-begin"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “v2001-generate-begin”</span></a></div>
|
||||
<p>Reports a bare <code dir="auto">begin … end</code> written directly inside a <code dir="auto">generate … endgenerate</code> with no <code dir="auto">if</code>, <code dir="auto">for</code> or <code dir="auto">case</code> around it. It opens an unnamed generate block — an invented path segment that renumbers when a block is added above it — and buys nothing, because the region is already a scope. Read from the same recovered block <code dir="auto">module-begin-block</code> reads, one scope in. Verible’s <code dir="auto">v2001-generate-begin</code>, same default.</p>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/rules.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-04T22:08:53.000Z">Sep 4, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/cli/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">CLI</span></span></a><a href="/reference/language-tools/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Language tools</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/rules.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/cli/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">CLI</span></span></a><a href="/reference/language-tools/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Language tools</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
+1
-1
@@ -640,4 +640,4 @@ a codec-version decision so stale caches cannot silently omit answers.</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<aside aria-label="Types" class="starlight-aside starlight-aside--note"><p class="starlight-aside__title" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" class="starlight-aside__icon"><path d="M12 11a1 1 0 0 0-1 1v4a1 1 0 0 0 2 0v-4a1 1 0 0 0-1-1Zm.38-3.92a1 1 0 0 0-.76 0 1 1 0 0 0-.33.21 1.15 1.15 0 0 0-.21.33 1 1 0 0 0 .21 1.09c.097.088.209.16.33.21A1 1 0 0 0 13 8a1.05 1.05 0 0 0-.29-.71 1 1 0 0 0-.33-.21ZM12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm0 18a8 8 0 1 1 0-16.001A8 8 0 0 1 12 20Z"/></svg>Types</p><div class="starlight-aside__content"><p>The crates also expose their data models—AST nodes, diagnostics, rule traits, workspace identifiers, edits, plans, and formatter document nodes. This page intentionally indexes callable behavior; generated Rust API docs remain the right place for field-level type details.</p></div></aside>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/rust-api.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-03T09:28:11.000Z">Sep 3, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/language-tools/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Language tools</span></span></a><a href="/reference/architecture/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Architecture</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/rust-api.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/language-tools/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Language tools</span></span></a><a href="/reference/architecture/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Architecture</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
+13
-1
@@ -129,6 +129,13 @@
|
||||
<td>rule names or severity classes</td>
|
||||
<td>CLI</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code dir="auto">[lint].waivers</code></td>
|
||||
<td>string array</td>
|
||||
<td style="text-align: right"><code dir="auto">[]</code></td>
|
||||
<td>external waiver files, resolved against this file’s directory (Verible’s format; see the linter guide)</td>
|
||||
<td>CLI and editor</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><code dir="auto">[lint.<rule-name>]</code> tables configure individual rules. The rule registry
|
||||
@@ -267,6 +274,11 @@ not enable a rule that is off by default.</p>
|
||||
<td style="text-align: right"><code dir="auto">{}</code></td>
|
||||
<td>Per-rule option objects, using the same validator as project configuration</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code dir="auto">lucisv.lint.waivers</code></td>
|
||||
<td style="text-align: right"><code dir="auto">[]</code></td>
|
||||
<td>External waiver files, absolute or relative to the first workspace folder; added to <code dir="auto">[lint] waivers</code>. A missing file or a bad directive is logged once and dropped. Unused external waivers are reported by <code dir="auto">lucisv check</code> only</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>For formatting, project configuration wins over editor line length and
|
||||
@@ -282,4 +294,4 @@ entries are currently dropped by server linting without a per-entry log;
|
||||
<code dir="auto">lucisv check</code> reports them as configuration errors.</p>
|
||||
<div class="sl-heading-wrapper level-h2"><h2 id="cache">Cache</h2><a class="sl-anchor-link" href="#cache"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “Cache”</span></a></div>
|
||||
<p>Successful “already formatted” verdicts are cached under <code dir="auto">.lucisv_cache/</code>. Entries are keyed by file, content hash, line length, indentation, and lucisv version. Files that would change or fail are never cached. Use <code dir="auto">--no-cache</code> to disable reads and writes or <code dir="auto">--cache-dir</code> to relocate the store.</p>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/start/configuration.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-03T09:28:11.000Z">Sep 3, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/start/quick-start/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Quick start</span></span></a><a href="/guides/formatter/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/start/configuration.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/start/quick-start/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Quick start</span></span></a><a href="/guides/formatter/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
|
||||
@@ -55,7 +55,39 @@ endmodule
|
||||
|
||||
`verilog_lint:` is accepted in place of `lucisv:` for Verible compatibility. The `unused-waiver` rule reports malformed, unknown, or no-longer-needed suppressions when their target rule is enabled.
|
||||
|
||||
External waiver files are not implemented in v0.41.0; the planned waiver-file
|
||||
settings and CLI flag are not accepted yet.
|
||||
Findings can also be suppressed from **outside** the RTL, in Verible's
|
||||
waiver-file format — one directive per line, `#` comments and blank lines
|
||||
ignored:
|
||||
|
||||
```text
|
||||
# every line of every file
|
||||
waive --rule=no-tabs
|
||||
# one line, or a range with both ends included
|
||||
waive --rule=line-length --line=12
|
||||
waive --rule=line-length --line=12-20
|
||||
# only the files a pattern names
|
||||
waive --rule=no-tabs --location=legacy/top.sv
|
||||
```
|
||||
|
||||
`--rule` is required and names exactly one rule (a severity word is not
|
||||
accepted). `--line` is 1-based. `--location` is matched the way an
|
||||
`--exclude` pattern is — `*` within one path component, a pattern with `/`
|
||||
matching a path suffix, one without matching the file name at any depth — and
|
||||
**not** as a regular expression; a pattern that looks like one (`.*`, `\.`,
|
||||
`[…]`) is an error naming the difference.
|
||||
|
||||
Waiver files come from three places, and they add up: `lucisv check
|
||||
--waiver-file <path>` (repeatable, relative to the working directory),
|
||||
`waivers` under `[lint]` in `lucisv.toml` (relative to that file; read by the
|
||||
CLI and the editor), and the editor setting `lucisv.lint.waivers` (relative to
|
||||
the first workspace folder). External and inline waivers are a union: a
|
||||
finding either covers is suppressed, and one both cover leaves neither
|
||||
reported as dead. A missing file or an unparsable directive fails `lucisv
|
||||
check` with `<file>:<line>: <message>` and exit 2; in an editor the bad line
|
||||
is dropped and the rest of the file applies — a bad line in a file named by
|
||||
the editor setting is written once to the lucisv log, one named by
|
||||
`lucisv.toml` is not (run `lucisv check` to see it). Unused external waivers
|
||||
are reported under `unused-waiver` at their line of the waiver file, by
|
||||
`lucisv check` only and only after the whole run.
|
||||
|
||||
See the [complete rule reference](/reference/rules/).
|
||||
@@ -45,6 +45,7 @@ The subcommand is recognized only as the first argument. To format a file named
|
||||
| `--output-format` | `text` or `json` | Select human or machine-readable diagnostics |
|
||||
| `--fix` | — | Apply safe fixes and rewrite files |
|
||||
| `--unsafe-fixes` | — | Allow unsafe fixes when a rule provides them |
|
||||
| `--waiver-file <PATH>` | path | Read Verible-format waiver directives from this file; repeatable. Adds to `[lint] waivers` from `lucisv.toml`. Relative to the working directory. A missing file or an unparsable directive is an error (exit 2) |
|
||||
| `--rules-doc` | — | Print registry-generated rule and option documentation and exit; takes no files |
|
||||
|
||||
Text diagnostics use `FILE:LINE:COL: severity: message [rule]`. JSON output is one array of diagnostic objects, each carrying `severity`. JSON output is lint-only; formatter errors remain text on stderr.
|
||||
|
||||
@@ -32,6 +32,7 @@ style_regex = "[a-z_0-9]+"
|
||||
| `filelist` | string | — | EDA `.f` path | server index |
|
||||
| `[lint].select` | string array | defaults | rule names or severity classes | CLI |
|
||||
| `[lint].ignore` | string array | `[]` | rule names or severity classes | CLI |
|
||||
| `[lint].waivers` | string array | `[]` | external waiver files, resolved against this file's directory (Verible's format; see the linter guide) | CLI and editor |
|
||||
|
||||
`[lint.<rule-name>]` tables configure individual rules. The rule registry
|
||||
validates option names, types, bounds, and patterns; `lucisv check --rules-doc`
|
||||
@@ -81,6 +82,7 @@ Unknown keys, out-of-range numbers, invalid values, tables other than `[lint]` a
|
||||
| `lucisv.lint.severity.error` / `.warning` / `.style` | `true` | Enable each severity class |
|
||||
| `lucisv.lint.rules.<rule>` | `default` | Override a rule with `default`, `on`, or `off` |
|
||||
| `lucisv.lint.options` | `{}` | Per-rule option objects, using the same validator as project configuration |
|
||||
| `lucisv.lint.waivers` | `[]` | External waiver files, absolute or relative to the first workspace folder; added to `[lint] waivers`. A missing file or a bad directive is logged once and dropped. Unused external waivers are reported by `lucisv check` only |
|
||||
|
||||
For formatting, project configuration wins over editor line length and
|
||||
indentation, then editor tab size supplies an indent fallback, then built-in
|
||||
|
||||
@@ -112,6 +112,7 @@ what a change on the pointed-to side must not silently break.
|
||||
| `vlog_semantic ──▶ vlog_parser` | depends | The AST read-only, `parse_source_tolerant`/`parse_tolerant` (never fails; `Error` nodes are opaque leaves), the **name-span contract** `src[name_span] == name` on every declaring node, `token::is_keyword`, `defines::collect_defines`/`DefineTable`, `TextRange`. `bind/`'s `ItemKind`/`ExprKind`/`DimKind` matches are exhaustive — new variants cost an arm here too. |
|
||||
| `vlog_linter ──▶ vlog_parser` | depends | `ParsedSource::parse` = `tokenize` + `parse_tolerant` (one-parse bundle), `LineIndex`, `TextRange`, AST shapes walked by `visit.rs` (which ends in `_ => {}`, so new variants usually cost nothing here), token facts for text rules (a macro use is one `Ident` token; a directive is one `Directive` token). |
|
||||
| `vlog_linter ──▶ vlog_semantic` | depends | `analyze`, `Semantics::{symbols, references, references_of}` for semantic rules, including signal usage and duplicate-declaration checks. `Semantics::duplicates()` was added by linter-expansion-1 without changing persisted facts. `LintContext::semantics()` computes analysis lazily when a rule asks for it. Justified in `vlog_linter/Cargo.toml`; adds no external code (`vlog_semantic` is `vlog_parser` + std). |
|
||||
| `vlog_linter ──▶ lucisv_core` | depends | `walk::is_excluded`, the `--exclude` matcher, reused for a waiver file's `--location` so one pattern language serves the whole tool (waiver-files, §39, 2026-09-04). `lucisv_core` still depends on nothing, so no cycle. |
|
||||
| `vlog_linter ──▶ vlog_formatter` **(dev-only)** | depends (tests) | The `.lint` fix harness asserts a lint fix never produces text `format_source` refuses. **The library dependency list is still `vlog_parser` + `vlog_semantic` + std** — `cargo tree -p vlog_linter -e normal` is the pinned check. Do not promote this to a normal dep; the fence filter deliberately lives in the front ends instead (see shared-fence-filter, §2.4). |
|
||||
| `vlog_refactor ──▶ vlog_parser` | depends | `tokenize`, `parse_source_tolerant` + diagnostics, `LineIndex`, `TextRange`, the port/instantiation/module AST shapes, `token::is_keyword` (new-name validity), `defines` via the index. Every edit span originates in a parsed node — no textual search-and-replace. |
|
||||
| `vlog_refactor ──▶ vlog_semantic` | depends | `Semantics` queries (`symbol_at`, `references_of`, `reference_id_at`, …), `Resolution` variants (three of them are refusal rules), `WorkspaceIndex` + `resolve_external` + `ExternalTarget`, and the exactness promise on `name_span` (re-checked before each edit is emitted). One historical exception: refactor-rename added `Target::Declaration` + end-label uses *into* `vlog_semantic` (lead-authorized, additive — see §2.6). |
|
||||
|
||||
Reference in new issue
Block a user