]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/lintcheck/README.md
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / lintcheck / README.md
CommitLineData
f20569fa
XL
1## `cargo lintcheck`
2
3Runs clippy on a fixed set of crates read from
4`lintcheck/lintcheck_crates.toml` and saves logs of the lint warnings into the
5repo. We can then check the diff and spot new or disappearing warnings.
6
7From the repo root, run:
8
9```
10cargo run --target-dir lintcheck/target --manifest-path lintcheck/Cargo.toml
11```
12
13or
14
15```
16cargo lintcheck
17```
18
19By default the logs will be saved into
20`lintcheck-logs/lintcheck_crates_logs.txt`.
21
22You can set a custom sources.toml by adding `--crates-toml custom.toml` or using
23`LINTCHECK_TOML="custom.toml"` where `custom.toml` must be a relative path from
24the repo root.
25
26The results will then be saved to `lintcheck-logs/custom_logs.toml`.
27
28### Configuring the Crate Sources
29
30The sources to check are saved in a `toml` file. There are three types of
31sources.
32
331. Crates-io Source
34
35 ```toml
36 bitflags = {name = "bitflags", versions = ['1.2.1']}
37 ```
38 Requires a "name" and one or multiple "versions" to be checked.
39
402. `git` Source
41 ````toml
42 puffin = {name = "puffin", git_url = "https://github.com/EmbarkStudios/puffin", git_hash = "02dd4a3"}
43 ````
44 Requires a name, the url to the repo and unique identifier of a commit,
45 branch or tag which is checked out before linting. There is no way to always
46 check `HEAD` because that would lead to changing lint-results as the repo
47 would get updated. If `git_url` or `git_hash` is missing, an error will be
48 thrown.
49
503. Local Dependency
51 ```toml
52 clippy = {name = "clippy", path = "/home/user/clippy"}
53 ```
54 For when you want to add a repository that is not published yet.
55
56#### Command Line Options (optional)
57
58```toml
59bitflags = {name = "bitflags", versions = ['1.2.1'], options = ['-Wclippy::pedantic', '-Wclippy::cargo']}
60```
61
62It is possible to specify command line options for each crate. This makes it
63possible to only check a crate for certain lint groups. If no options are
64specified, the lint groups `clippy::all`, `clippy::pedantic`, and
65`clippy::cargo` are checked. If an empty array is specified only `clippy::all`
66is checked.
67
68**Note:** `-Wclippy::all` is always enabled by default, unless `-Aclippy::all`
69is explicitly specified in the options.
70
71### Fix mode
72You can run `./lintcheck/target/debug/lintcheck --fix` which will run Clippy with `-Zunstable-options --fix` and
73print a warning if Clippys suggestions fail to apply (if the resulting code does not build).
74This lets us spot bad suggestions or false positives automatically in some cases.
75
76Please note that the target dir should be cleaned afterwards since clippy will modify
77the downloaded sources which can lead to unexpected results when running lintcheck again afterwards.