Skip to content

Added clippy ignore rules for all errors and warnings #3238

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 2 commits into from
Aug 29, 2024

Conversation

Mirebella
Copy link
Contributor

As mentioned #3223 (comment) and #3223 (comment), this PR adds a list of ignored(allowed) clippy errors and warnings to the CI checks.

@Mirebella Mirebella changed the title Add clippy checks Added clippy ignore rules for all errors and warnings Aug 13, 2024
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 82.50000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 89.80%. Comparing base (5e62df7) to head (0d71a5f).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/util/indexed_map.rs 0.00% 1 Missing and 1 partial ⚠️
lightning-rapid-gossip-sync/src/processing.rs 0.00% 1 Missing ⚠️
lightning/src/events/mod.rs 0.00% 1 Missing ⚠️
lightning/src/ln/channelmanager.rs 50.00% 1 Missing ⚠️
lightning/src/routing/scoring.rs 0.00% 1 Missing ⚠️
lightning/src/util/logger.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3238      +/-   ##
==========================================
- Coverage   89.82%   89.80%   -0.02%     
==========================================
  Files         126      126              
  Lines      103024   103020       -4     
  Branches   103024   103020       -4     
==========================================
- Hits        92543    92519      -24     
- Misses       7769     7776       +7     
- Partials     2712     2725      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Thanks, are there any of these that we're only hitting one or five times that we should just go ahead and fix immediately rather than allowing first?

@dunxen
Copy link
Contributor

dunxen commented Aug 15, 2024

Here is a small sample of lints that seems to be low hanging fruit and can possibly be fixed in this PR:

  • clippy::assign_op_pattern
  • clippy::assigning_clones
  • clippy::bind_instead_of_map
  • clippy::bool_comparison
  • clippy::wrong_self_convention
  • clippy::while_let_on_iterator
  • clippy::vec_init_then_push
  • clippy::useless_format
  • clippy::unwrap_or_default

A commit per lint fix would be a nice separation of concerns but combining a few small ones in a single commit should also be ok :)

@Mirebella Mirebella force-pushed the clippy-checks branch 3 times, most recently from 6d07e0a to 4dad726 Compare August 27, 2024 16:39
@Mirebella
Copy link
Contributor Author

I addressed all comments above. Ready for another review.

Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

LGTM overall, just a though is if we need to have some sort of githook now to run what the CI is running.

I think it is a waste of CI cycles just pushing the code and find out that there is some warning to be fixed

@dunxen
Copy link
Contributor

dunxen commented Aug 28, 2024

LGTM overall, just a though is if we need to have some sort of githook now to run what the CI is running.

I think it is a waste of CI cycles just pushing the code and find out that there is some warning to be fixed

There are no custom githooks at the moment, so that would be a whole other discussion on what would/wouldn't belong there. I'd recommend opening a separate issue.

Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

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

Thanks! I think it's okay to tackle the rest in some follow-up PRs. I'm sure there are many easy wins still remaining out of these allowed warnings but I haven't checked.

@@ -2049,7 +2050,7 @@ impl MaybeReadable for Event {
payment_hash,
purpose: _init_tlv_based_struct_field!(purpose, upgradable_required),
amount_msat,
htlcs: htlcs.unwrap_or(vec![]),
htlcs: htlcs.unwrap_or_default(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I generally find the use of default strictly less readable than explicit Vec::new (which is ~free, though we can always do unwrap_or_else(Vec::new) to avoid the call), but for now its fine.

@TheBlueMatt TheBlueMatt merged commit 1122e82 into lightningdevkit:main Aug 29, 2024
17 of 19 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.

4 participants