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

Add clippy to Travis integration #739

Merged

Conversation

rloomba
Copy link
Contributor

@rloomba rloomba commented Oct 7, 2020

Inspired by #724. This PR fixes 37 warnings caused by using redundant fields and adds clippy integration to Travis to error out if a redundant field is detected. Hopefully we can slowly fix warnings/errors and add those fixed lints to the list of denies or as @casey mentioned, disable specific lints using #![allow(clippy::LINT)] in modules/crates/functions.

Does it make sense to specify clippy to run on 1.30.0 for lightning and 1.39.0 for lightning-net-tokio?

@codecov
Copy link

codecov bot commented Oct 7, 2020

Codecov Report

Merging #739 into main will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #739      +/-   ##
==========================================
+ Coverage   91.94%   91.98%   +0.04%     
==========================================
  Files          37       37              
  Lines       20108    20108              
==========================================
+ Hits        18488    18497       +9     
+ Misses       1620     1611       -9     
Impacted Files Coverage Δ
lightning/src/lib.rs 100.00% <ø> (ø)
lightning/src/ln/channelmanager.rs 85.64% <ø> (ø)
lightning/src/ln/peer_handler.rs 58.43% <ø> (ø)
lightning/src/chain/channelmonitor.rs 95.07% <100.00%> (ø)
lightning/src/ln/channel.rs 86.34% <100.00%> (ø)
lightning/src/ln/onion_utils.rs 95.13% <100.00%> (ø)
lightning/src/ln/peer_channel_encryptor.rs 93.35% <100.00%> (ø)
lightning/src/util/chacha20poly1305rfc.rs 100.00% <100.00%> (ø)
lightning/src/ln/functional_tests.rs 97.06% <0.00%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f35a5ce...262172c. Read the comment docs.

@TheBlueMatt
Copy link
Collaborator

Cool. Probably worth at least turning on whatever subset already passes instead of just one lint, and definitely add let_underscore_lock, given that was the actual bug for us.

@rloomba rloomba force-pushed the rloomba/add-clippy-to-travis branch from 858ab6f to 0c950e4 Compare October 7, 2020 22:14
Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

Otherwise ACK 0c950e4

.travis.yml Outdated Show resolved Hide resolved
@rloomba rloomba force-pushed the rloomba/add-clippy-to-travis branch from 0c950e4 to 67a7f20 Compare October 8, 2020 00:44
@rloomba
Copy link
Contributor Author

rloomba commented Oct 8, 2020

It looks like unfortunately 1.30.0 doesn't support scoped lints, more at rust-lang/rust#44690:

error[E0658]: scoped lint `clippy::erasing_op` is experimental (see issue #44690)

So if we ever move the MSRV to 1.31.0 or higher, we'll be able to specify lints within individual libs.

But for now, we'll only run the lint on 1.39.0 with the default linter + add allows for erasing_op, never_loop, and if_same_then_else. I think we'll be able to easily refactor so we can remove never_loop and if_same_then_else.

clippy docs

@TheBlueMatt
Copy link
Collaborator

I dont think our MSRV needs to extend to clippy - in general test and other infrastructure which isn't required for users I don't think needs to observe MSRV at all.

CONTRIBUTING.md Outdated
@@ -77,6 +77,17 @@ Coding Conventions
Use tabs. If you want to align lines, use spaces. Any desired alignment should
display fine at any tab-length display setting.

Please lint your code using [clippy](https://github.com/rust-lang/rust-clippy).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe "Note that our CI enforces a few basic clippy lints - you can test locally if you use rustup, or just push to CI to test." or something like that, given that clippy is only available via rustup and we dont want to encourge people to use rustup when they otherwise wouldn't (as a few other things we use break, eg the bindings generation link-time-LTO, which is way more important than clippy)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

awesome, thanks for the context!

@rloomba
Copy link
Contributor Author

rloomba commented Oct 8, 2020

I dont think our MSRV needs to extend to clippy - in general test and other infrastructure which isn't required for users I don't think needs to observe MSRV at all.

Totally agree. I think if we ever want to support the broader Rust feature of scoped attributes for white-listed tools, e.g., #![allow(clippy::erasing_op)], as seen in 0c950e4, we'll need to increase our MSRV to 1.31.0. Because in currently in 1.30.0, if we include a scoped attribute, there's a compiler error show in #739 (comment) that stops the build.

@rloomba rloomba force-pushed the rloomba/add-clippy-to-travis branch from 67a7f20 to 426c5b2 Compare October 8, 2020 17:00
@TheBlueMatt
Copy link
Collaborator

there's a compiler error show in #739 (comment) that stops the build.

Ah, OK, I misunderstood the conversation sorry.

@TheBlueMatt
Copy link
Collaborator

TheBlueMatt commented Oct 8, 2020

Can you add the lint run to github CI as well? We'll probably remove travis soon, I think. Otherwise, ACK!

@TheBlueMatt TheBlueMatt merged commit 52121ea into lightningdevkit:main Oct 8, 2020
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.

None yet

3 participants