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

Introduce a cargo clippy run #2025

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Introduce a cargo clippy run #2025

wants to merge 1 commit into from

Conversation

mgeisler
Copy link
Collaborator

This might help catch stylistic problems in our Rust code.

@mgeisler mgeisler force-pushed the clippy-lint branch 2 times, most recently from 0590609 to 3917067 Compare April 24, 2024 11:40
Personally, I don’t always agree with Clippy, but it a very widely
recommended tool for writing idiomatic Rust. So on balance, I think
it’s overall a good idea to enable it for both our exercises and our
tooling.
Copy link
Collaborator

@antoniolinhart antoniolinhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This will help make style more consistent

Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried that this might "correct" some things that had been written as-is for didactic reasons, but it looks like those are handled well. It also seems that this isn't scanning code in rust blocks in the .md files, which probably helps.

Comment on lines -40 to -45
blood_pressure_change: match self.last_blood_pressure {
Some(lbp) => {
Some((bp.0 as i32 - lbp.0 as i32, bp.1 as i32 - lbp.1 as i32))
}
None => None,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably exclude third_party/ somehow..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good idea! Let me figure out how to do that before merging!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the settings are done in the workspace Cargo.toml and every Cargo.toml has a workspace = true in the [lints] section as described in https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table we could tell cargo clippy what to do in the third_party Cargo.toml.

This would enable a central configuration for clippy and gives the option to override specific settings for individual components

@mgeisler
Copy link
Collaborator Author

Another thought, as discussed on #2410. We should try and enable Clippy as part of dprint. A short look in the README lead me to the clippy-driver, which accepts input on stdin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants