Skip to content

fix clippy issues #1905

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

Merged
merged 1 commit into from
Jul 14, 2025
Merged

fix clippy issues #1905

merged 1 commit into from
Jul 14, 2025

Conversation

marcoieni
Copy link
Member

@marcoieni marcoieni commented Jul 10, 2025

Let's run clippy in CI to improve the quality of the codebase

@@ -19,7 +19,11 @@ fn team_create() {
let user = model.create_user("mark");
let user2 = model.create_user("jan");
let gh = model.gh_model();
model.create_team(TeamData::new("admins").gh_team(DEFAULT_ORG, "admins-gh", &[user, user2]));
model.create_team(TeamData::new_builder("admins").gh_team(
Copy link
Member Author

@marcoieni marcoieni Jul 10, 2025

Choose a reason for hiding this comment

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

I had to rename new because that method wasn't returning Self. So I called the method new_builder.

An alternative is calling it just builder

Copy link
Member

Choose a reason for hiding this comment

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

build? It's annoying though, I would just silence the lint on this method.

Copy link
Member

Choose a reason for hiding this comment

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

I also agree to silence that lint.

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I'd stick with the convention here and rename the method to something like builder. We're probably all using code completion, so there's imo no cost in adding a few characters to the method name. 😅

But not a blocking concern, happy to go with whatever the majority thinks...

Copy link
Member Author

Choose a reason for hiding this comment

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

I went for #[allow(clippy::new_ret_no_self)] since it's the less destructive option. We can always remove it in another PR

@marcoieni marcoieni force-pushed the fix-clippy-issues branch 3 times, most recently from bae4776 to 32be30c Compare July 10, 2025 09:06
@marcoieni marcoieni marked this pull request as ready for review July 10, 2025 09:07
Copy link

Dry-run check results

[WARN  sync_team] sync-team is running in dry mode, no changes will be applied.
[INFO  sync_team] synchronizing github

Comment on lines +54 to +55
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
Copy link
Contributor

Choose a reason for hiding this comment

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

this will imply that contributions to the codebase must now pass clippy, and no warnings allowed.
I see that a clippy lint is enforcing two rules:

  • #![allow(clippy::enum_variant_names)]
  • #[allow(clippy::type_complexity)]

Copy link
Contributor

Choose a reason for hiding this comment

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

Also one question (for my curiosity): I think I don't see a specific clippy lint config file. What happens if clippy "stabilizes" and adds a new default?

Copy link
Member Author

Choose a reason for hiding this comment

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

this will imply that contributions to the codebase must now pass clippy

yes. I find clippy is a good teacher for new contributors. They learn about idiomatic rust 👍

and no warnings allowed

I think that all clippy lints are treated as warnings, so if you don't add -D warnings then this step will pass 😅

What happens if clippy "stabilizes" and adds a new default?

clippy adds new defaults on every rust release more or less. We pin the rust version in CI, so whenever we bump the rust version we need to fix new clippy lints, too (if any)

@apiraino
Copy link
Contributor

Is the diff mostly stylistic changes? How do they improve the quality of the code?

@marcoieni
Copy link
Member Author

How do they improve the quality of the code?

the code is more readable imo

e.g.
image
image

jdno
jdno previously approved these changes Jul 14, 2025
Copy link
Member

@jdno jdno left a comment

Choose a reason for hiding this comment

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

Great find! Will help a lot with long-term maintenance of the code base. 🙂

@marcoieni marcoieni added this pull request to the merge queue Jul 14, 2025
Merged via the queue into master with commit 7d74d9d Jul 14, 2025
3 checks passed
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.

5 participants