Skip to content

chore(lib): start a strict clippy config#4075

Merged
seanmonstar merged 1 commit into
masterfrom
sean/xsppuxutzuqs
May 22, 2026
Merged

chore(lib): start a strict clippy config#4075
seanmonstar merged 1 commit into
masterfrom
sean/xsppuxutzuqs

Conversation

@seanmonstar
Copy link
Copy Markdown
Member

This starts a change to embrace a strict allowlist with Clippy.

Why?

Clippy can detect a lot of mistakes. The defaults are very good. But it has the power to detect many more probable mistakes, and enforce coding patterns beyond formatting. With the increase in LLM generated code, a stricter Clippy can protect us from the LLM generating poorer code.

The pedantic and restriction groups are not enabled by default. There is even a warning to not enable the restriction group blindly. But, even they have good lints. The usual recommendation is to just turn on the lints you care about.

Instead, this embraces restricting everything by default, and keep an explicit allowlist. The benefits for this are that we explicitly consider every possible "bad code" lint. We decide if it's something to ignore. And we also don't accidentally not notice a new lint. Every time Clippy upgrades, we may see some new lints that could improve our code. That is excellent! When that happens, we can decide whether to adjust the code, or allow the lint.

More reading

How?

Restricting all these lints in one go would be a large amount of changes. Some of them can be done automatically (cargo clippy --fix), some of them an LLM can very easily do, and some require manual inspection in each place.

This starts by enabling all the groups, listing out every lint that was triggered, and then allows them explicitly for now. I've split that list into two separate smaller lists (described here in reverse order):

  • Lints that are expliticly allowed.

  • Lints that should be decided on, either by fixing the code, or removing the TODO and putting them in the explicitly allowed list (ideally explaining why).

Follow up commits can address those lints, and when doing so, update the list. This will prevent rot from occurring by keeping the PR open for a long time, or conflicts.

cc #4071

@seanmonstar seanmonstar force-pushed the sean/xsppuxutzuqs branch 3 times, most recently from b3b718e to c9719f9 Compare May 22, 2026 15:51
This starts a change to embrace a strict allowlist with Clippy.

## Why?

Clippy can detect a lot of mistakes. The defaults are very good. But it has the
power to detect many more _probable_ mistakes, and enforce coding patterns
beyond formatting. With the increase in LLM generated code, a stricter Clippy
can protect us from the LLM generating poorer code.

The pedantic and restriction groups are not enabled by default. There is even a
warning to not enable the restriction group blindly. But, even they have good
lints. The usual recommendation is to just turn on the lints you care about.

Instead, this embraces restricting everything by default, and keep an explicit
allowlist. The benefits for this are that we explicitly consider every possible
"bad code" lint. We decide if it's something to ignore. And we also don't
accidentally not notice a new lint. Every time Clippy upgrades, we may see some
new lints that could improve our code. That is excellent! When that happens, we
can decide whether to adjust the code, or allow the lint.

[More reading](https://billylevin.dev/posts/clippy-config/)

## How?

Restricting all these lints in one go would be a large amount of changes. Some
of them can be done automatically (`cargo clippy --fix`), some of them an LLM
can very easily do, and some require manual inspection in each place.

This starts by enabling all the groups, listing out every lint that was
triggered, and then allows them explicitly for now. I've split that list into
two separate smaller lists (described here in reverse order):

- Lints that are expliticly allowed.

- Lints that should be decided on, either by fixing the code, or removing the
  TODO and putting them in the explicitly allowed list (ideally explaining why).

Follow up commits can address those lints, and when doing so, update the list.
This will prevent rot from occurring by keeping the PR open for a long time, or
conflicts.
@seanmonstar seanmonstar merged commit cad38b7 into master May 22, 2026
24 checks passed
@seanmonstar seanmonstar deleted the sean/xsppuxutzuqs branch May 22, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants