Skip to content

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.

bash
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 -.

FlagDescription
-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-onlyLint rules only; skip compilation
--compile-onlyCompilation 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, --helpPrint usage and the list of diagnostic codes
--versionPrint 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.

bash
./build/lazyverilog-lint rtl/top.sv
./build/lazyverilog-lint --lint-only rtl/top.sv
./build/lazyverilog-lint -f rtl/vcode.f

Output ​

One line per diagnostic, with 1-based line and column:

text
<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:

bash
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: lint is every rule, lint-naming every naming rule. A value that matches nothing is rejected. lazyverilog-lint --help lists 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:

OptionWhat it does
--fixApply the safe fixes to the files in place
--fix-unsafeApply the safe and the unsafe fixes
--fix-interactiveShow 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 again

Fixes 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.

bash
lazyverilog-lint --fix rtl/alu.sv
lazyverilog-lint --fix-unsafe -f project.f
lazyverilog-lint --fix-interactive rtl/alu.sv

Exit codes ​

CodeMeaning
0No error-severity diagnostics
1Usage error, or file could not be opened
2At least one error-severity diagnostic

Released under the MIT License. Themed with Catppuccin.