From 426c5b227de2c88909c9385f40106f94e745eef4 Mon Sep 17 00:00:00 2001 From: Ryan Loomba Date: Tue, 6 Oct 2020 16:49:06 -0700 Subject: [PATCH] add clippy to travis integration --- .travis.yml | 4 ++++ CONTRIBUTING.md | 12 ++++++++++++ lightning/src/lib.rs | 1 - lightning/src/ln/channelmanager.rs | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1e136798..8c1f2fd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,10 @@ script: - if [ "$BUILD_NET_TOKIO" == "1" ]; then RUSTFLAGS="-C link-dead-code" cargo build --verbose; fi - if [ "$BUILD_NET_TOKIO" != "1" ]; then RUSTFLAGS="-C link-dead-code" cargo build --verbose -p lightning; fi - rm -f target/debug/lightning-* # Make sure we drop old test binaries + # Run clippy on Rust 1.39.0 + - if [ "$(rustup show | grep default | grep 1.39.0)" != "" ]; then + rustup component add clippy && + cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else; fi # Test the appropriate workspace(s) - if [ "$BUILD_NET_TOKIO" == "1" ]; then RUSTFLAGS="-C link-dead-code" cargo test --verbose; fi - if [ "$BUILD_NET_TOKIO" != "1" ]; then RUSTFLAGS="-C link-dead-code" cargo test --verbose -p lightning; fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b270492b..241c6420 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,6 +77,18 @@ Coding Conventions Use tabs. If you want to align lines, use spaces. Any desired alignment should display fine at any tab-length display setting. +Our CI enforces [clippy's](https://github.com/rust-lang/rust-clippy) default linting +[settings](https://rust-lang.github.io/rust-clippy/rust-1.39.0/index.html). +This includes all lint groups except for nursery, pedantic, and cargo in addition to allowing the following lints: +`erasing_op`, `never_loop`, `if_same_then_else`. + +If you use rustup, feel free to lint locally, otherwise you can just push to CI for automated linting. + +```bash +rustup component add clippy +cargo clippy +``` + Security -------- diff --git a/lightning/src/lib.rs b/lightning/src/lib.rs index 22483339..dbd89a2c 100644 --- a/lightning/src/lib.rs +++ b/lightning/src/lib.rs @@ -36,4 +36,3 @@ pub mod util; pub mod chain; pub mod ln; pub mod routing; - diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index a1951d6b..379fe193 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -16,6 +16,7 @@ //! It does not manage routing logic (see routing::router::get_route for that) nor does it manage constructing //! on-chain transactions (it only monitors the chain to watch for any force-closes that might //! imply it needs to fail HTLCs/payments/channels it manages). +//! use bitcoin::blockdata::block::BlockHeader; use bitcoin::blockdata::constants::genesis_block; -- 2.30.2