Skip to content

Commit

Permalink
Handle --no-deps flag same as --fix flag.
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
nfejzic committed Jul 27, 2021
1 parent 0e5802e commit f7af8bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Common options:
-h, --help Print this message
-V, --version Print version info and exit
Note: --no-deps flag is used with `cargo clippy --`. Example: `cargo clippy -- --no-deps`
Other options are the same as `cargo check`.
To allow or deny a lint from the command line you can use `cargo clippy --`
Expand Down Expand Up @@ -75,21 +73,26 @@ impl ClippyCmd {
{
let mut cargo_subcommand = "check";
let mut args = vec![];
let mut clippy_args: Vec<String> = vec![];

for arg in old_args.by_ref() {
match arg.as_str() {
"--fix" => {
cargo_subcommand = "fix";
continue;
},
"--no-deps" => {
clippy_args.push("--no-deps".into());
continue;
},
"--" => break,
_ => {},
}

args.push(arg);
}

let mut clippy_args: Vec<String> = old_args.collect();
clippy_args.append(&mut (old_args.collect()));
if cargo_subcommand == "fix" && !clippy_args.iter().any(|arg| arg == "--no-deps") {
clippy_args.push("--no-deps".into());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/dogfood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
.env("CARGO_INCREMENTAL", "0")
.arg("clippy")
.args(&["-p", "subcrate"])
.arg("--")
.arg("--no-deps")
.arg("--")
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
.args(&["--cfg", r#"feature="primary_package_test""#])
.output()
Expand Down

0 comments on commit f7af8bf

Please sign in to comment.