You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-clippy-uno.md
+50Lines changed: 50 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,56 @@ I don't think the compler will want _all_ correctness lints here, however if the
118
118
where it being _not_ a bug is an exceedingly rare case (i.e. very low false positive frequency) it should probably belong in the
119
119
compiler.
120
120
121
+
## What lints belong in clippy?
122
+
123
+
Essentially, we consider the categorization itself to be a definition of boundaries -- if it doesn't fit in the categories,
124
+
it doesn't fit in clippy (or needs an RFC for, specifically).
125
+
126
+
In itself this isn't complete, we explicitly have a "pedantic" group that's kinda ill defined.
127
+
128
+
The rules for the main categories (style/complexity/correctness/perf -- things which are warn or deny by default) are:
129
+
130
+
- Main category lints need to be something the community has general agreement on. This does _not_ mean each lint
131
+
addition must go through an RFC-like process. Instead, this is to be judged by the maintainers during the review of the lint pull request
132
+
(taking into account objections raised if any). If the lint turns out to be controversial in the future we can flip it off or recategorize it.
133
+
- Generally, _if_ a lint is triggered, this should be _useful_ to _most_ Rust programmers seeing it _most_ of the time.
134
+
- It is okay for a lint to deal with niche code that usually won't even be triggered. Lints can target subsets of the community provided they don't randomly trigger for others.
135
+
- It is okay if the lint has some false positives (cases where it lints for things which are actually okay), as long as they don't dominate.
136
+
- It is also okay if the lint warns about things which people do not feel are worth fixing -- i.e. the programmer agrees that it is a problem
137
+
but does not wish to fix this. Using clippy is itself an opt-in to more finicky linting. However, this is sometimes an indicator of such a lint potentially belonging in the pedantic group.
138
+
- Clippy is meant to be used with a liberal sprinkling of `allow`. If there's a specific use case where a lint doesn't apply, and the solution
139
+
is to slap `allow` on it, that's okay. A minor level of false positives like this is to be tolerated. Similarly, style lints are allowed to be
140
+
about things a lot of people don't care about (i.e. they don't prefer the _opposite_ style, they just don't care).
141
+
- Clippy lints _do_ deal with the visual presentation of your code, but only for things which `rustfmt` doesn't or can't handle. So, for example,
142
+
rustfmt will not ask you to replace `if {} else { if {} }` with `if {} else if {}`, but clippy might. There is some overlap in this area and we expect
143
+
to work with rustfmt on precisely figuring out what goes where. Such lints are usually `style` lints or `complexity` lints.
144
+
- Clippy lints are allowed to make some kind of semantic changes, but not all:
145
+
- The general rule is that clippy will not attempt to change what it perceives to be the intent of the code, but will rather change
146
+
the code to make it closer to the intent or make it achieve that intent better
147
+
- Clippy lints _do_ deal with potential typos and mistakes. For example, clippy will detect `for x in y.next()` which is
148
+
very likely a bug (you either mean `if let` or mean to unwrap). Such lints are usually `correctness` lints.
149
+
- Clippy lints also _do_ deal with misunderstandings of Rust, for example code doing `foo == NaN` is a misunderstanding
150
+
of how Rust floats work. These are also usually `correctness` lints.
151
+
- Clippy lints _do not_ comment on the business logic of your program. This comes from the "perceived intent" rule
152
+
above, changes to business logic are a change to perceived intent.
153
+
- Clippy lints _do_ ask you to make semantic changes that achieve the same _effect_ with
154
+
perhaps better performance. Such lints are usually `perf` lints.
155
+
156
+
157
+
For the other categories (these are allow by default):
158
+
159
+
- Lints which are "pedantic" should still roughly fall into one of the main categories, just that they are too annoying
160
+
(or possibly controversial) to be warn by default. So a lint must follow all the above rules if pedantic, but is allowed to be
161
+
"too finicky to fix", and may have looser consensus (i.e. some controversy).
162
+
- Similar rules for "nursery" except their reason for being allow by default is lack of maturity (i.e. the lint is buggy or still needs some thought)
163
+
- "restriction" lints follow all the rules for semantic changes, but do not bother with the rules
164
+
for the lint being useful to most rust programmers. A restriction lint must still be such that you have a
165
+
good reason to enable it — "I dislike such code" is insufficient &mdash but will likely be a lint most programmers
166
+
wish to keep off by default for most of their code. The goal of restriction lints is to provide tools with which you can supplement
167
+
the language checks in very specific cases where you need it, e.g. forbidding panics from a certain area of code.
168
+
- "cargo" lints follow the same rules as pedantic lints (we only have one of them right now, so we may be experimenting with this in the future)
0 commit comments