Skip to content

Commit ac0fd99

Browse files
committed
Auto merge of #7492 - nfejzic:improve_help, r=Manishearth
Explain flags missing in cargo check in --help This commit closes #7389. As stated in the issue, `cargo clippy --help` provides explanation for some flags and states that the rest are same as in `cargo check --help`, even though some clippy specific flags exist. This commit extends the `cargo clippy --help` with two additional flags, - `cargo clippy --fix` - `cargo clippy --no-deps` If there are more flags which are not present in `cargo check --help` please bring these to my attention, I will include these aswell. For now, I noticed only the two flags mentioned above. changelog: `cargo clippy --help` now explains additional flags missing in `cargo check --help`.
2 parents 43905d9 + f7af8bf commit ac0fd99

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Usage:
1414
cargo clippy [options] [--] [<opts>...]
1515
1616
Common options:
17+
--no-deps Run Clippy only on the given crate, without linting the dependencies
18+
--fix Automatically apply lint suggestions. This flag implies `--no-deps`
1719
-h, --help Print this message
1820
-V, --version Print version info and exit
1921
@@ -71,21 +73,26 @@ impl ClippyCmd {
7173
{
7274
let mut cargo_subcommand = "check";
7375
let mut args = vec![];
76+
let mut clippy_args: Vec<String> = vec![];
7477

7578
for arg in old_args.by_ref() {
7679
match arg.as_str() {
7780
"--fix" => {
7881
cargo_subcommand = "fix";
7982
continue;
8083
},
84+
"--no-deps" => {
85+
clippy_args.push("--no-deps".into());
86+
continue;
87+
},
8188
"--" => break,
8289
_ => {},
8390
}
8491

8592
args.push(arg);
8693
}
8794

88-
let mut clippy_args: Vec<String> = old_args.collect();
95+
clippy_args.append(&mut (old_args.collect()));
8996
if cargo_subcommand == "fix" && !clippy_args.iter().any(|arg| arg == "--no-deps") {
9097
clippy_args.push("--no-deps".into());
9198
}

tests/dogfood.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
7676
.env("CARGO_INCREMENTAL", "0")
7777
.arg("clippy")
7878
.args(&["-p", "subcrate"])
79-
.arg("--")
8079
.arg("--no-deps")
80+
.arg("--")
8181
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
8282
.args(&["--cfg", r#"feature="primary_package_test""#])
8383
.output()

0 commit comments

Comments
 (0)