Skip to content

Commit f7af8bf

Browse files
committed
Handle --no-deps flag same as --fix flag.
As proposed in the pull request thread, there is some inconsistency in handling the `--no-deps` flag which requires `--` before it, and `--fix` flag which does not. In this commit the `--no-deps` flag does not need the `--` anymore. However, it can still be used that way: `cargo clipyy -- --no-deps`.
1 parent 0e5802e commit f7af8bf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Common options:
1919
-h, --help Print this message
2020
-V, --version Print version info and exit
2121
22-
Note: --no-deps flag is used with `cargo clippy --`. Example: `cargo clippy -- --no-deps`
23-
2422
Other options are the same as `cargo check`.
2523
2624
To allow or deny a lint from the command line you can use `cargo clippy --`
@@ -75,21 +73,26 @@ impl ClippyCmd {
7573
{
7674
let mut cargo_subcommand = "check";
7775
let mut args = vec![];
76+
let mut clippy_args: Vec<String> = vec![];
7877

7978
for arg in old_args.by_ref() {
8079
match arg.as_str() {
8180
"--fix" => {
8281
cargo_subcommand = "fix";
8382
continue;
8483
},
84+
"--no-deps" => {
85+
clippy_args.push("--no-deps".into());
86+
continue;
87+
},
8588
"--" => break,
8689
_ => {},
8790
}
8891

8992
args.push(arg);
9093
}
9194

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

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)