lintcheck: fix --fix and document it in the readme.

also hook lintcheck into clippy-dev so that `clippy dev fmt` formats it.
This commit is contained in:
Matthias Krüger 2021-03-11 15:18:56 +01:00
parent b29ef183fb
commit b068b742ee
3 changed files with 12 additions and 1 deletions

View File

@ -54,6 +54,7 @@ pub fn run(check: bool, verbose: bool) {
success &= cargo_fmt(context, project_root.as_path())?;
success &= cargo_fmt(context, &project_root.join("clippy_dev"))?;
success &= cargo_fmt(context, &project_root.join("rustc_tools_util"))?;
success &= cargo_fmt(context, &project_root.join("lintcheck"))?;
for entry in WalkDir::new(project_root.join("tests")) {
let entry = entry?;

View File

@ -67,3 +67,9 @@ is checked.
**Note:** `-Wclippy::all` is always enabled by default, unless `-Aclippy::all`
is explicitly specified in the options.
### Fix mode
You can run `./lintcheck/target/debug/lintcheck --fix` which will run Clippy with `-Zunstable-options --fix` and print a warning if Clippys suggestions fail to apply (if the resulting code does not build).
This lets us spot bad suggestions or false positives automatically in some cases.
Please note that the target dir should be cleaned afterwards since clippy will modify the downloaded sources which can lead to unexpected results when running lintcheck again afterwards.

View File

@ -862,7 +862,11 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
.long("jobs")
.help("number of threads to use, 0 automatic choice"),
)
.arg(Arg::with_name("fix").help("runs cargo clippy --fix and checks if all suggestions apply"))
.arg(
Arg::with_name("fix")
.long("--fix")
.help("runs cargo clippy --fix and checks if all suggestions apply"),
)
.get_matches()
}