bacon icon indicating copy to clipboard operation
bacon copied to clipboard

Spot session configuration of clippy lints does not work

Open sammyhori opened this issue 6 months ago • 2 comments

The documentation states that I can configure (cargo) clippy lints with the example being bacon clippy -- -W clippy::pedantic.

When running that, I instead get:

 error: unexpected argument '-W' found

 Usage: cargo check [OPTIONS]

 For more information, try '--help'.

bacon clippy works as expected and definitely runs clippy rather than check.

Bacon Version

% bacon --version
bacon 3.16.0

System information

OS: macOS Sequoia 15.4.1 Shell: zsh 5.9 (arm64-apple-darwin24.0)

sammyhori avatar Jun 26 '25 09:06 sammyhori

Hum, right, it depends of the precise definition of the "clippy" job and the one currently in the default bacon.toml doesn't have the necessary double dash.

You may use

bacon clippy -- -- -W clippy::pedantic

(notice the double double dash)

or you may change the clippy job definition in your bacon.toml file. For example most of my ones are similar to this:

[jobs.clippy]
command = [
	"cargo", "clippy",
	"--",
	"-A", "clippy::bool_to_int_with_if",
	"-A", "clippy::collapsible_else_if",
	"-A", "clippy::collapsible_if",
	"-A", "clippy::derive_partial_eq_without_eq",
	"-A", "clippy::if_same_then_else",
	"-A", "clippy::len_without_is_empty",
	"-A", "clippy::manual_clamp",
	"-A", "clippy::manual_range_contains",
	"-A", "clippy::manual_unwrap_or",
	"-A", "clippy::match_like_matches_macro",
	"-A", "clippy::module_inception",
	"-A", "clippy::needless_bool",
	"-A", "clippy::needless_range_loop",
	"-A", "clippy::neg_multiply",
	"-A", "clippy::vec_init_then_push",
	"-W", "clippy::explicit_iter_loop",
]
need_stdout = false

so they don't need an additional double dash.

I'll have a look at the documentation and maybe the default job.

Canop avatar Jun 26 '25 10:06 Canop

That works, I see the issue now, in that the example already has the first required double dash in the bacon.toml.

Personally I'd generally expect the required behaviour to configure a clippy lint to be the same regardless of what's given in the bacon.toml, but I understand at this point that that would probably require a breaking change in the cli to properly implement.

Alternatively, a -- -W (or -- -[a-zA-Z]) could automatically attempt to add a second -- if not adding it returns an error.

I guess I could probably write a shell script to do this, although I'm not sure how to run bacon in a way that'll return a non-0 error code when the arguments after a -- are incorrect.

Thanks for the help though, ultimately a clarification in the documentation is probably the way to go 👍.

sammyhori avatar Jun 26 '25 16:06 sammyhori