Commit 8024fac
committed
chore(lib): start a strict clippy config
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.1 parent 5dbcae7 commit 8024fac
2 files changed
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
54 | 71 | | |
55 | 72 | | |
56 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
108 | 179 | | |
109 | 180 | | |
110 | 181 | | |
| |||
0 commit comments