Getting started with Rust clippy

The process at Adding Lints - Clippy Documentation is a bit surprising to me.

I would have expected the standard process for writing a new linter to be:

  1. create new empty cargo project
  2. add some dependency to Cargo.toml
  3. write code
  4. run new linter

However, instead, is the process:

  1. clone the clipppy repo
  2. create a local fork, add a new linter
  3. rebuild entire repo to get a new clippy binary

?

Just want to double check, as this is not what I expected.

Seems expected to me. AFAIK clippy is just one linter (binary) containing many lints. Not a collection of linters. Just imagine the overhead of having to run hundreds of independend binaries, presumably independently parsing and pre-analyzing your Rust code, every time you run cargo clippy.

2 Likes

We could imagine Clippy lints being built like proc-macros, where they are built as separate dylibs and are loaded and run by Clippy, giving them access to a shared pre-analyzed input. (And I read that the dylint tool works just like that.) But Clippy doesn't in fact work that way.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.