]> git.lizzy.rs Git - rust.git/blob - clippy_dev/README.md
Auto merge of #6834 - hyd-dev:clippy-args, r=phansch,flip1995,oli-obk
[rust.git] / clippy_dev / README.md
1 # Clippy Dev Tool
2
3 The Clippy Dev Tool is a tool to ease Clippy development, similar to `rustc`s
4 `x.py`.
5
6 Functionalities (incomplete):
7
8 ## `lintcheck`
9
10 Runs clippy on a fixed set of crates read from
11 `clippy_dev/lintcheck_crates.toml` and saves logs of the lint warnings into the
12 repo.  We can then check the diff and spot new or disappearing warnings.
13
14 From the repo root, run:
15
16 ```
17 cargo run --target-dir clippy_dev/target --package clippy_dev \
18 --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --features lintcheck -- lintcheck
19 ```
20
21 or
22
23 ```
24 cargo dev-lintcheck
25 ```
26
27 By default the logs will be saved into
28 `lintcheck-logs/lintcheck_crates_logs.txt`.
29
30 You can set a custom sources.toml by adding `--crates-toml custom.toml` or using
31 `LINTCHECK_TOML="custom.toml"` where `custom.toml` must be a relative path from
32 the repo root.
33
34 The results will then be saved to `lintcheck-logs/custom_logs.toml`.
35
36 ### Configuring the Crate Sources
37
38 The sources to check are saved in a `toml` file. There are three types of
39 sources.
40
41 1. Crates-io Source
42
43    ```toml
44    bitflags = {name = "bitflags", versions = ['1.2.1']}
45    ```
46    Requires a "name" and one or multiple "versions" to be checked.
47
48 2. `git` Source
49    ````toml
50    puffin = {name = "puffin", git_url = "https://github.com/EmbarkStudios/puffin", git_hash = "02dd4a3"}
51    ````
52    Requires a name, the url to the repo and unique identifier of a commit,
53    branch or tag which is checked out before linting.  There is no way to always
54    check `HEAD` because that would lead to changing lint-results as the repo
55    would get updated.  If `git_url` or `git_hash` is missing, an error will be
56    thrown.
57
58 3. Local Dependency
59    ```toml
60    clippy = {name = "clippy", path = "/home/user/clippy"}
61    ```
62    For when you want to add a repository that is not published yet.
63
64 #### Command Line Options (optional)
65
66 ```toml
67 bitflags = {name = "bitflags", versions = ['1.2.1'], options = ['-Wclippy::pedantic', '-Wclippy::cargo']}
68 ```
69
70 It is possible to specify command line options for each crate. This makes it
71 possible to only check a crate for certain lint groups. If no options are
72 specified, the lint groups `clippy::all`, `clippy::pedantic`, and
73 `clippy::cargo` are checked. If an empty array is specified only `clippy::all`
74 is checked.
75
76 **Note:** `-Wclippy::all` is always enabled by default, unless `-Aclippy::all`
77 is explicitly specified in the options.