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

Remove clippy allow directives/or provide reasons #1388

Closed
7 tasks
blacktemplar opened this issue Jul 23, 2020 · 1 comment
Closed
7 tasks

Remove clippy allow directives/or provide reasons #1388

blacktemplar opened this issue Jul 23, 2020 · 1 comment

Comments

@blacktemplar
Copy link
Contributor

blacktemplar commented Jul 23, 2020

Description

In the last clippy cleanup (pull request #1385) some unresolved warnings got ignored via #[allow...] directives. For each of them and all the other allow directives currently in the code base we should either remove them or comment on why the warnings should get ignored.

A list of ignored warnings grouped by modules from pull request #1385 is (this list does not consider allow directives added before #1385):

  • this function has too many arguments:
    • beacon_node/store
    • beacon_node/network
  • very complex type used
    • beacon_node/eth2_libp2p
    • beacon_node/beacon_chain
    • beacon_node/network
    • beacon_node/client
  • unneeded return statement
    • beacon_node/network: I could simply remove those returns, but I don't like it since if this function gets extended at some point the returns would be important. So I am not sure how to handle this (ignore the warning for the whole function?)

Steps to resolve

Either remove or comment on all uncommented #[allow...] directives in the code base.

bors bot pushed a commit that referenced this issue Jul 23, 2020
## Issue Addressed

NA

## Proposed Changes

Fixes most clippy warnings and ignores the rest of them, see issue #1388.
bors bot pushed a commit that referenced this issue Jul 23, 2020
## Issue Addressed

NA

## Proposed Changes

Fixes most clippy warnings and ignores the rest of them, see issue #1388.
bors bot pushed a commit that referenced this issue Jul 28, 2020
## Issue Addressed
#1388 partially (eth2_libp2p & network)

## Proposed Changes 
TLDR at the end
- *Complex types* are 3 on the handlers/Behaviours but the types are `Poll<ComplexType>` where `ComplexType` comes from the traits of libp2p. Those, I don't thing are worth an alias. A couple more were from using tokio combinators and were removed writing things the async way and using [`BoxFuture`](https://docs.rs/futures/0.3.5/futures/future/type.BoxFuture.html)
- The *cognitive complexity*.. I tried to address those before (they come from the poll functions too) and tbh they are cognitively simpler to understand the way they are now. Moving separate parts to functions doesn't add much since that code is not repeated and they all do early returns. If moved those returns would now need to be wrapped in an Option, probably, and checked to be returned again. I would leave them like that but that's just preference.
- *Too many arguments*: They are not easily put together in a wrapping struct since the parameters don't relate semantically (Ex: fn new with a log, a reference to the chain, a peer, etc) but some may differ.
- *Needless returns* were indeed needless

## Additional Info
TLDR: removed needless return, used BoxFuture and async, left the rest untouched since those lgtm
@ghost ghost added A0 infra-ci labels Sep 9, 2020
@paulhauner paulhauner changed the title Remove allow directives/or provide reasons Remove clippy allow directives/or provide reasons Sep 20, 2020
@paulhauner paulhauner added A1 and removed A0 labels Oct 5, 2020
@paulhauner paulhauner removed the A1 label Nov 8, 2020
@paulhauner
Copy link
Member

Closing due to inactivity and lots of changes to the code since it was created.

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

No branches or pull requests

2 participants