Linter CLI
lazyverilog-lint lints one file, or every file in a filelist, and prints lint and compilation diagnostics. See CLI tools to build it.
lazyverilog-lint [-f <filelist>] [--lint-only | --compile-only] [--maxerror <n>] [--nowarn <code>]... [--] [<file>]Give at least -f <filelist> or <file>, and at most one <file> (use -f for more). -- ends the options, for a file whose name starts with -.
| Flag | Description |
|---|---|
-f <filelist> | With no <file>, lint every listed file. With <file>, use the filelist for context and report only that file. Overrides [design].vcode |
--lint-only | Lint rules only; skip compilation |
--compile-only | Compilation diagnostics only; skip lint rules. Cannot be combined with --lint-only |
--maxerror <n> | Stop elaborating after <n> errors. Default 64, 0 for no limit |
--nowarn <code> | Hide diagnostics with this code. Repeatable |
-h, --help | Print usage and the list of diagnostic codes |
--version | Print the version |
Options come from the nearest lazyverilog.toml: [design] and [lint] (see Linter options). [compilation] has no effect: the CLI always compiles unless --lint-only is given.
./build/lazyverilog-lint rtl/top.sv
./build/lazyverilog-lint --lint-only rtl/top.sv
./build/lazyverilog-lint -f rtl/vcode.fOutput
One line per diagnostic, with 1-based line and column:
<file>:<line>:<col>: <severity>: <message> [<code>]Severity is error, warning, info, or hint.
Error limit
Once a compilation passes --maxerror errors, slang stops and the rest of the design is never checked, with no notice. A run that prints only MissingTimeScale errors (common when one file has a `timescale and others do not) may hide real problems behind them. Rerun with --maxerror 0. The lasting fix is a consistent timescale.
Diagnostic codes
Every diagnostic prints its code in brackets, and --nowarn takes that code:
lazyverilog-lint --nowarn lint-naming-input-port --nowarn width-trunc rtl/alu.sv- Lint rules are named
lint-<section>-<rule>. A prefix silences its children:lintis every rule,lint-namingevery naming rule. A value that matches nothing is rejected.lazyverilog-lint --helplists them all. - Compilation warnings use slang's names (
width-trunc,unused-net) and groups (conversion,unused,pedantic). - Compilation errors use slang's CamelCase names (
MissingTimeScale,UnknownModule). These are taken as written, so a misspelling silences nothing.
A hidden error no longer sets exit code 2. Hiding does not free the --maxerror budget: hidden errors still count toward it.
Fixing
Many diagnostics carry a fix. Each fix is either safe, meaning it keeps the design's behavior, or unsafe, meaning it may change it. The list is in Quick fixes. Choose one mode:
| Option | What it does |
|---|---|
--fix | Apply the safe fixes to the files in place |
--fix-unsafe | Apply the safe and the unsafe fixes |
--fix-interactive | Show each fix and ask before applying it |
The three options cannot be combined. The files are rewritten byte for byte, so CRLF line endings stay. A file that changed on disk since it was read is left alone, with a warning on stderr.
Interactive mode prints the diagnostic, the fix title (marked [unsafe] when it is), the affected lines as - (before) and + (after), and then asks Apply this fix [y,n,a,q]?. Answer y to apply, n to skip, a to apply this and every remaining fix without asking again (unsafe ones included), or q to stop. End of input counts as q. The accepted fixes of a file are applied together at the end.
Fixed diagnostics are not printed. A summary goes to stderr whenever a fix option is given, even when nothing was fixed. The count is of fixes applied, so identical fixes from duplicated diagnostics count once:
fixed 2 issue(s) in 1 file(s)
skipped 1 overlapping fix(es); run againFixes that overlap another fix are skipped; run the command again to pick them up. The exit status reflects only the diagnostics that are still printed.
lazyverilog-lint --fix rtl/alu.sv
lazyverilog-lint --fix-unsafe -f project.f
lazyverilog-lint --fix-interactive rtl/alu.svExit codes
| Code | Meaning |
|---|---|
0 | No error-severity diagnostics |
1 | Usage error, or file could not be opened |
2 | At least one error-severity diagnostic |