Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy should probably say something if it sees both a clippy.toml and a .clippy.toml #8323

Closed
hawkw opened this issue Jan 20, 2022 · 0 comments · Fixed by #8326
Closed

Clippy should probably say something if it sees both a clippy.toml and a .clippy.toml #8323

hawkw opened this issue Jan 20, 2022 · 0 comments · Fixed by #8326
Labels
A-ui Area: Clippy interface, usage and configuration C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@hawkw
Copy link

hawkw commented Jan 20, 2022

Description

I recently wasted a bit of time trying to figure out why my lint configurations in a clippy.toml file were not being honored by Clippy. It turned out that the problem was that the workspace already had a .clippy.toml file, which I hadn't noticed existed.

It appears that when clippy searches for config files, it just picks the first one it finds, and stops looking:

for config_file_name in &CONFIG_FILE_NAMES {
if let Ok(config_file) = current.join(config_file_name).canonicalize() {
match fs::metadata(&config_file) {
Err(e) if e.kind() == io::ErrorKind::NotFound => {},
Err(e) => return Err(e),
Ok(md) if md.is_dir() => {},
Ok(_) => return Ok(Some(config_file)),
}
}
}
. So, it was picking the .clippy.toml file and ignoring the clippy.toml I had created.

Admittedly, this was a pretty silly mistake on my part! But, it would be nice if Clippy could notice when there are multiple config files in a workspace, and say "hey, looks like you have multiple config files in the same workspace, I'm only honoring this one". That would have saved me some confusion.

Version

rustc 1.56.1 (59eed8a2a 2021-11-01)
binary: rustc
commit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35
commit-date: 2021-11-01
host: x86_64-unknown-linux-gnu
release: 1.56.1
LLVM version: 13.0.0

Additional Labels

@rustbot label +C-enhancement

@rustbot rustbot added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Jan 20, 2022
@xFrednet xFrednet added the A-ui Area: Clippy interface, usage and configuration label Jan 20, 2022
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Jan 20, 2022
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Jan 30, 2022
bors added a commit that referenced this issue Jan 30, 2022
warn if we find multiple clippy configs

Fixes #8323

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: warn if we find multiple clippy configs
bors added a commit that referenced this issue Jan 31, 2022
warn if we find multiple clippy configs

Fixes #8323

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: warn if we find multiple clippy configs
bors added a commit that referenced this issue Feb 6, 2022
warn if we find multiple clippy configs

Fixes #8323

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: warn if we find multiple clippy configs
@bors bors closed this as completed in 97e5a70 Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ui Area: Clippy interface, usage and configuration C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants