1
0
Fork
You've already forked lintspec
0
Mirror for repository on github https://github.com/beeb/lintspec
  • Rust 93.9%
  • Solidity 5.5%
  • Nix 0.6%
beeb-release-plz[bot] 0abbbe73cd
chore: release ( #252 )
Co-authored-by: beeb-release-plz[bot] <146623270+beeb-release-plz[bot]@users.noreply.github.com>
2026年07月10日 20:59:52 +02:00
.config fix: various validation logic fixes and add a bunch of tests ( #33 ) 2025年02月21日 15:52:13 +01:00
.github chore(deps)!: update dependencies ( #251 ) 2026年07月10日 20:51:00 +02:00
crates chore: release ( #252 ) 2026年07月10日 20:59:52 +02:00
.envrc chore(direnv): use nix-direnv and reload on config change ( #233 ) 2026年02月20日 08:16:20 +01:00
.gitignore feat!: solar parsing backend ( #69 ) 2025年05月14日 22:53:45 +02:00
.lintspec.toml feat!: add -n to specify parallelism ( #240 ) 2026年03月11日 15:59:49 +01:00
.nsignore docs: add comment 2025年02月19日 11:34:41 +01:00
action.yml refactor!: granular configuration ( #56 ) 2025年03月13日 10:18:55 +01:00
Cargo.lock chore: release ( #252 ) 2026年07月10日 20:59:52 +02:00
Cargo.toml chore(deps)!: update dependencies ( #251 ) 2026年07月10日 20:51:00 +02:00
cliff.toml chore(changelog): automatically assign features to the "Added" group ( #94 ) 2025年06月04日 13:23:35 +02:00
clippy.toml chore: clippy config ( #206 ) 2025年11月20日 09:50:20 +01:00
CONTRIBUTING.md chore: update contributing guide ( #232 ) 2026年02月17日 09:50:40 +01:00
deny.toml feat!: make solar the default parser ( #168 ) 2025年10月15日 15:08:00 +02:00
dist-workspace.toml chore(deps)!: update dependencies ( #251 ) 2026年07月10日 20:51:00 +02:00
flake.lock chore(deps)!: update dependencies ( #251 ) 2026年07月10日 20:51:00 +02:00
flake.nix chore(deps): update deps ( #245 ) 2026年04月29日 21:22:17 +02:00
LICENSE-APACHE ci: add cargo-dist ( #7 ) 2025年02月20日 07:04:21 +01:00
LICENSE-MIT ci: add cargo-dist ( #7 ) 2025年02月20日 07:04:21 +01:00
README.md chore(deps)!: update dependencies ( #251 ) 2026年07月10日 20:51:00 +02:00
release-plz.toml refactor!: split logic into core crate ( #216 ) 2026年02月10日 10:19:58 +01:00
rust-toolchain.toml chore: rustfmt and clippy are included by default ( #207 ) 2025年11月20日 15:46:27 +01:00
screenshot.png chore: add readme 2025年02月19日 14:53:06 +01:00

🔎 lintspec

lintspec screenshot

Lintspec is a command-line utility (linter) that checks the completeness and validity of NatSpec doc-comments in Solidity code. It is focused on speed and ergonomics. By default, lintspec will respect gitignore rules when looking for Solidity source files.

Dual-licensed under MIT or Apache 2.0.

Note: the main branch can contain unreleased changes. To view the README information for the latest stable release, visit crates.io or select the latest git tag from the branch/tag dropdown.

Installation

Via cargo

cargo install lintspec

Via cargo-binstall

cargo binstall lintspec

Via nix

nix-env -iA nixpkgs.lintspec
# or
nix-shell -p lintspec
# or
nix run nixpkgs#lintspec

Pre-built binaries and install script

Head over to the releases page!

Legacy slang Backend

Although the default parser backend is now the very fast solar, the legacy slang parser is still available when installing with cargo install.

cargo install lintspec --no-default-features -F slang

This feature exposes an additional CLI flag --skip-version-detection which can help if slang doesn't support the version of Solidity you target. Note that enabling slang makes the program ~7x slower compared to the default.

Usage

Usage: lintspec [OPTIONS] [PATH]... [COMMAND]
Commands:
 init Create a `.lintspec.toml` config file with default values
 completions Generate shell completion scripts
 help Print this message or the help of the given subcommand(s)
Arguments:
 [PATH]... One or more paths to files and folders to analyze
Options:
 -e, --exclude <EXCLUDE> Path to a file or folder to exclude (can be used more than once)
 --config <CONFIG> Optional path to a TOML config file
 -o, --out <OUT> Write output to a file instead of stderr
 --inheritdoc Enforce that all public and external items have `@inheritdoc`
 --inheritdoc-override Enforce that `override` internal functions and modifiers have `@inheritdoc`
 --notice-or-dev Do not distinguish between `@notice` and `@dev` when considering "required" validation rules
 -n, --parallel <THREADS> Number of parallel workers/threads, or 0 to use the number of logical cores
 --title-ignored <TYPE> Ignore `@title` for these items (can be used more than once)
 --title-required <TYPE> Enforce `@title` for these items (can be used more than once)
 --title-forbidden <TYPE> Forbid `@title` for these items (can be used more than once)
 --author-ignored <TYPE> Ignore `@author` for these items (can be used more than once)
 --author-required <TYPE> Enforce `@author` for these items (can be used more than once)
 --author-forbidden <TYPE> Forbid `@author` for these items (can be used more than once)
 --notice-ignored <TYPE> Ignore `@notice` for these items (can be used more than once)
 --notice-required <TYPE> Enforce `@notice` for these items (can be used more than once)
 --notice-forbidden <TYPE> Forbid `@notice` for these items (can be used more than once)
 --dev-ignored <TYPE> Ignore `@dev` for these items (can be used more than once)
 --dev-required <TYPE> Enforce `@dev` for these items (can be used more than once)
 --dev-forbidden <TYPE> Forbid `@dev` for these items (can be used more than once)
 --param-ignored <TYPE> Ignore `@param` for these items (can be used more than once)
 --param-required <TYPE> Enforce `@param` for these items (can be used more than once)
 --param-forbidden <TYPE> Forbid `@param` for these items (can be used more than once)
 --return-ignored <TYPE> Ignore `@return` for these items (can be used more than once)
 --return-required <TYPE> Enforce `@return` for these items (can be used more than once)
 --return-forbidden <TYPE> Forbid `@return` for these items (can be used more than once)
 --json Output diagnostics in JSON format
 --compact Compact output
 --sort Sort the results by file path
 -s, --stdout Write diagnostics to stdout instead of stderr
 -0, --exit-zero Exit with code 0 even when there are diagnostics
 -h, --help Print help (see more with '--help')
 -V, --version Print version

Configuration

Config File

Create a default configuration with the following command:

lintspec init

This will create a .lintspec.toml file with the default configuration in the current directory. Check out the example file for more information.

All items for which the default configuration suits you can be removed from the file if desired. Note that some settings could change their default value in the future (in a new major release) which could alter behavior if they are not specified.

Environment Variables

Environment variables (in capitals, with the LS_ prefix) can also be used and take precedence over the configuration file. They use the same names as in the TOML config file and use the _ character as delimiter for nested items. An additional LS_CONFIG_PATH variable is available to set an optional path to the TOML file (the default is ./.lintspec.toml).

Examples:

  • LS_CONFIG_PATH=.config/lintspec.toml
  • LS_LINTSPEC_PATHS=[src,test]
  • LS_LINTSPEC_INHERITDOC=false
  • LS_LINTSPEC_NOTICE_OR_DEV=true: if the setting name contains _, it is not considered a delimiter
  • LS_OUTPUT_JSON=true
  • LS_CONSTRUCTOR_NOTICE=required

CLI Arguments

Finally, the tool can be customized with command-line arguments, which take precedence over the other two methods. To see the CLI usage information, run:

lintspec help

For arguments (--[TYPE]--required, --[TYPE]--ignored, --[TYPE]--forbidden) which expect an "item", the following values are available:

# for @title and @author
contract, interface, library
# for others
contract, interface, library, constructor, enum,
error, event,private-function, internal-function,
public-function, external-function, modifier, struct,
private-variable, internal-variable, public-variable

Usage in GitHub Actions

You can check your code in CI with the lintspec GitHub Action. Any .lintspec.toml or .nsignore file in the repository's root will be used to configure the execution.

The action generates annotations that are displayed in the source files when viewed (e.g. in a PR's "Files" tab).

Options

The following options are available for the action (all are optional if a config file is present):

Input Default Value Description Example
working-directory "./" Working directory path "./src"
paths "[]" Paths to scan, relative to the working directory, in square brackets and separated by commas. Required unless a .lintspec.toml file is present in the working directory. "[path/to/file.sol,test/test.sol]"
exclude "[]" Paths to exclude, relative to the working directory, in square brackets and separated by commas "[path/to/exclude,other/path.sol]"
extra-args Extra arguments passed to the lintspec command "--inheritdoc=false"
version "latest" Version of lintspec to use. For enhanced security, you can pin this to a fixed version "0.9.0"
fail-on-problem "true" Whether the action should fail when NatSpec problems have been found. Disabling this only creates annotations for found problems, but succeeds "false"

Example Workflow

name:Lintspecon:pull_request:jobs:lintspec:runs-on:ubuntu-lateststeps:- uses:actions/checkout@v2- uses:beeb/lintspec@v0.12.2# all the lines below are optionalwith:working-directory:"./"paths:"[]"exclude:"[]"extra-args:""version:"latest"fail-on-problem:"true"

Usage as a Library

The core functionality is available as a separate crate lintspec-core, which contains the parsing and validation logic without CLI dependencies.

cargo add lintspec-core

Alternatively, in Cargo.toml:

[dependencies]
lintspec-core = "0.12.2"

Feature flags

  • solar: enables the solar_parse parser backend (default)
  • slang: enables the slang_solidity parser backend

Credits

This tool walks in the footsteps of natspec-smells, thanks to them for inspiring this project!

Comparison with natspec-smells

Benchmark

On a regular laptop with 16 cores, linting the Uniswap/v4-core src folder on linux, lintspec v0.11.3 is about 1700x faster, or 0.06% of the execution time:

Benchmark 1: npx @defi-wonderland/natspec-smells --include 'src/**/*.sol' --enforceInheritdoc --constructorNatspec
 Time (mean ± σ): 12.445 s ± 0.204 s [User: 14.510 s, System: 0.461 s]
 Range (min ... max): 12.238 s ... 12.824 s 10 runs
Benchmark 2: lintspec src --compact --param-required struct
 Time (mean ± σ): 7.3 ms ± 0.9 ms [User: 16.6 ms, System: 7.7 ms]
 Range (min ... max): 5.5 ms ... 10.3 ms 292 runs
Summary
 lintspec src --compact --param-required struct ran
 1708.61 ± 218.10 times faster than npx @defi-wonderland/natspec-smells --include 'src/**/*.sol' --enforceInheritdoc --constructorNatspec

Features

Feature lintspec natspec-smells
Identify missing NatSpec
Identify duplicate NatSpec
Include files/folders
Exclude files/folders
Enforce usage of @inheritdoc
Enforce NatSpec on constructors
Configure via config file
Configure via env variables
Respects gitignore files
Granular validation rules
Pretty output with code excerpt
JSON output
Output to file
Multithreaded
Built-in CI action
No pre-requisites (node/npm)