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

refactor: fix clippy issues for near-o11y #8291

Merged
merged 5 commits into from
Jan 6, 2023

Conversation

pugachAG
Copy link
Contributor

@pugachAG pugachAG commented Jan 5, 2023

Fix the issues reported by cargo clippy -p near-o11y as part of #8145

@pugachAG pugachAG marked this pull request as ready for review January 5, 2023 16:30
@pugachAG pugachAG requested a review from a team as a code owner January 5, 2023 16:30
@nagisa
Copy link
Collaborator

nagisa commented Jan 5, 2023

IMO we should decide which clippy lints we're enabling first, set them to warn and only then start fixing the issues, possibly removing the lints as we go.

In particular I would probably advocate for disabling the lint that necessitated the n /= 10 change. While neat that it is possible to write this in a terser way, I think the original was tad a bit more readable there.

Another approach that I have been using in the past is set up clippy without lints at all, and then enable them one-by-one, fixing the specific lints for the entire codebase at once. It then makes discussions about whether the lint is valuable for us or not much more… substantiated.

@nagisa
Copy link
Collaborator

nagisa commented Jan 5, 2023

I would advocate allowing all style category lints for the initial pass, actually. No reason to hinder the adoption with what are somewhat opinionated calls. Lets give time for people to get used to having clippy tell them about important stuff first. I think they’ll be much more open to majority of the style & pedantic lints once they know clippy is a highly valuable tool :)

@jakmeier
Copy link
Contributor

jakmeier commented Jan 5, 2023

Very good points, I like the idea of @nagisa to allow all style category lints to start with. Adding them one-by-one and discussing whether a particular lint is useful seems like a good approach. How about we allow all and warn/deny on clippy::correctness + clippy::suspicious at first?

Copy link
Contributor

@jakmeier jakmeier left a comment

Choose a reason for hiding this comment

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

I think I like all changes except for the /=, and even that doesn't personally bother me if we change it. 😄 So I'll approve the PR, independent of how how we move forward with enabling clippy

@@ -63,7 +63,7 @@ fn inc_counter_vec_with_label_values_stack_no_format(bench: &mut Bencher) {
loop {
idx -= 1;
buf[idx] = b'0' + (n % 10) as u8;
n = n / 10;
n /= 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

this also feels a bit odd to me, eitherway it's fine but personally I don't think n /= 10 is better than n = n / 10

@pugachAG
Copy link
Contributor Author

pugachAG commented Jan 6, 2023

@nagisa @jakmeier thanks for sharing your feedback on the overall approach. I agree that it makes sense to first enable clippy with the most useful lints (clippy::correctness + clippy::suspicious as was suggested by Jakob). Further I will work on gradually enabling parts of clippy rather than fixing all issues for every package.

I will merge with this PR while reverting the n /= 10 change.

@near-bulldozer near-bulldozer bot merged commit 28b2191 into near:master Jan 6, 2023
near-bulldozer bot pushed a commit that referenced this pull request Jan 11, 2023
This enables clippy `clippy::correctness` checks as part of CI as discussed [here](#8291 (comment)).

It is added as part of `sanity check` step for consistency, since that is where `cargo check` is executed.

This fixes the following issues in order to pass the added checks:
* noop `.clone()`
* this loop never actually loops 
* `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `self.burst == 0` instead

This PR is a part of #8145
@pugachAG pugachAG mentioned this pull request Jan 11, 2023
nikurt pushed a commit to nikurt/nearcore that referenced this pull request Jan 15, 2023
This enables clippy `clippy::correctness` checks as part of CI as discussed [here](near#8291 (comment)).

It is added as part of `sanity check` step for consistency, since that is where `cargo check` is executed.

This fixes the following issues in order to pass the added checks:
* noop `.clone()`
* this loop never actually loops 
* `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `self.burst == 0` instead

This PR is a part of near#8145
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.

3 participants