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 warning #2010

Merged
merged 9 commits into from
Nov 14, 2022
Merged

Clippy warning #2010

merged 9 commits into from
Nov 14, 2022

Conversation

sgued
Copy link
Contributor

@sgued sgued commented Oct 30, 2022

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you doing the PR on the next branch?

This PR fixes clippy warnings and adds cargo clippy --workspace -- -Dwarnings to the CI to avoid merging future PRs with warnings.

It's based on top of #2009 which should probably be merged before it.

- script: cargo fmt --check
displayName: Cargo fmt
- script: cargo clippy --workspace -- -Dwarnings
displayName: Cargo clippy
Copy link
Collaborator

Choose a reason for hiding this comment

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

The reason why those were not enforced in the CI is that some people don't use those tools and I didn't really want to force them too when I can just run it myself eventually. I could be convinced of adding them to CI but leaning towards no for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO enforcing the use of these tools is beneficial because:

  • Most rust projects use them
  • They play a huge role in making rust style consistent across the ecosystem
  • They are overall of great quality, and the defaults are pretty good

If someone doesn't use them, it's more likely to be because they either don't know about them, or because they forgot to run them. In both cases teaching or reminding them about those tools would probably be for the best and IHMO reduces maintainer burden. Someone who forgot to run clippy would probably be fine with fixing their non-idiomatic code, and a new rust developer would probably be delighted to discover these tools. I would understand the reluctance if they were of bad quality or niche, but rustfmt and clippy are IMHO very good tools, and they are considered standard across the Rust ecosystem. We could also mention them in the PR template, it might help.

Not enforcing them poses a couple issues on the contrary. Many developers rely on their editor to automatically format code on save. Non formatted code means that theses developers must turn that setting off which makes it harder to format the new code of the PR.
Clippy warnings are also a great tool for development, and many people rely on them to improve their code. Having noise coming from code unrelated to the one from the ongoing PR is a pain.

Cargo fmt and clippy fixes PRs like this one can also be the source of merge conflicts, which are can be painful to resolve for devs inexperienced with git.

The decision is yours, if you don't want them in CI I'll remove them from this PR, but I think that would be a mistake.

@Keats
Copy link
Collaborator

Keats commented Nov 14, 2022

Looks like there are some conflicts after merging the cargo fmt PR. Can you rebase?

@sgued
Copy link
Contributor Author

sgued commented Nov 14, 2022

Done. I have also fixed the new warnings that appeared after rebasing.

@Keats Keats merged commit ee4f53e into getzola:next Nov 14, 2022
@Keats
Copy link
Collaborator

Keats commented Nov 14, 2022

Thanks!

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.

2 participants