From f6e34a1c675689294f5d2af72f1457c99e64f843 Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Wed, 19 Sep 2018 20:13:08 -0400 Subject: [PATCH] Ensure clippy is run for all targets and switch to clippy-preview on stable `--all-targets` is now passed to clippy on CI. Temporarily, `-- -A renamed_and_removed_lints` is passed as well. This can be removed once the clippy::* attribute syntax is available in stable. Additionally, clippy-preview is now installed and run on stable. We were previously running clippy on an old nightly from late June and no new warnings (except the one noted above) are raised on nightly so switching to the -preview component on stable shouldn't introduce churn. Also, unlike with rustfmt, we can fix and merge any clippy recommendations before they hit the stable channel, so we don't have to sync with new releases. --- .travis.yml | 7 +++---- src/lib.rs | 2 +- src/tests/all.rs | 17 ++++++++++------- src/tests/badge.rs | 16 ++++++++-------- src/tests/record.rs | 8 +------- 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6175fa06386..6039e553c84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,16 +47,15 @@ matrix: allow_failures: - rust: nightly include: - - rust: nightly-2018-06-26 - script: - - cargo install --force clippy --vers 0.0.210 - - cargo clippy - rust: stable before_install: - nvm install 10 - rustup component add rustfmt-preview + - rustup component add clippy-preview script: - cargo fmt -- --check + # TODO: Once clippy:: lint syntax is stable, remove everything after the -- below + - cargo clippy --all-targets -- -A renamed_and_removed_lints - cargo build - cargo test - npm install diff --git a/src/lib.rs b/src/lib.rs index 3f9b9a0331a..df2532c3205 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ #![deny(missing_debug_implementations, missing_copy_implementations)] #![deny(bare_trait_objects)] #![recursion_limit = "256"] -#![allow(unknown_lints, proc_macro_derive_resolution_fallback)] // This can be removed after diesel-1.4 +#![allow(unknown_lints, proc_macro_derive_resolution_fallback)] // TODO: This can be removed after diesel-1.4 extern crate ammonia; extern crate chrono; diff --git a/src/tests/all.rs b/src/tests/all.rs index d3f157e78ad..4965713dc08 100644 --- a/src/tests/all.rs +++ b/src/tests/all.rs @@ -1,5 +1,8 @@ #![deny(warnings)] -#![allow(unknown_lints, proc_macro_derive_resolution_fallback)] // This can be removed after diesel-1.4 +#![allow(unknown_lints, proc_macro_derive_resolution_fallback)] // TODO: This can be removed after diesel-1.4 + +// Several test methods trip this clippy lint +#![cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] extern crate cargo_registry; extern crate chrono; @@ -162,7 +165,7 @@ fn app() -> ( }; let config = cargo_registry::Config { - uploader: uploader, + uploader, session_key: "test this has to be over 32 bytes long".to_string(), git_repo_checkout: git::checkout(), gh_client_id: env::var("GH_CLIENT_ID").unwrap_or_default(), @@ -172,7 +175,7 @@ fn app() -> ( max_upload_size: 3000, max_unpack_size: 2000, mirror: Replica::Primary, - api_protocol: api_protocol, + api_protocol, }; let app = App::new(&config); t!(t!(app.diesel_database.get()).begin_test_transaction()); @@ -251,7 +254,7 @@ fn user(login: &str) -> User { fn new_team(login: &str) -> NewTeam<'_> { NewTeam { github_id: NEXT_ID.fetch_add(1, Ordering::SeqCst) as i32, - login: login, + login, name: None, avatar: None, } @@ -379,9 +382,9 @@ struct CrateBuilder<'a> { impl<'a> CrateBuilder<'a> { fn new(name: &str, owner_id: i32) -> CrateBuilder<'_> { CrateBuilder { - owner_id: owner_id, + owner_id, krate: NewCrate { - name: name, + name, ..NewCrate::default() }, downloads: None, @@ -702,7 +705,7 @@ fn new_req_body( name: u::CrateName(krate.name), vers: u::CrateVersion(semver::Version::parse(version).unwrap()), features: HashMap::new(), - deps: deps, + deps, authors: vec!["foo".to_string()], description: Some("description".to_string()), homepage: krate.homepage, diff --git a/src/tests/badge.rs b/src/tests/badge.rs index da5c5b0353f..cacad5f3e21 100644 --- a/src/tests/badge.rs +++ b/src/tests/badge.rs @@ -113,22 +113,22 @@ fn set_up() -> (Arc, Crate, BadgeRef) { ); let badges = BadgeRef { - appveyor: appveyor, + appveyor, appveyor_attributes: badge_attributes_appveyor, - travis_ci: travis_ci, + travis_ci, travis_ci_attributes: badge_attributes_travis_ci, - gitlab: gitlab, + gitlab, gitlab_attributes: badge_attributes_gitlab, - isitmaintained_issue_resolution: isitmaintained_issue_resolution, + isitmaintained_issue_resolution, isitmaintained_issue_resolution_attributes: badge_attributes_isitmaintained_issue_resolution, - isitmaintained_open_issues: isitmaintained_open_issues, + isitmaintained_open_issues, isitmaintained_open_issues_attributes: badge_attributes_isitmaintained_open_issues, - codecov: codecov, + codecov, codecov_attributes: badge_attributes_codecov, - coveralls: coveralls, + coveralls, coveralls_attributes: badge_attributes_coveralls, - circle_ci: circle_ci, + circle_ci, circle_ci_attributes: badge_attributes_circle_ci, maintenance, maintenance_attributes, diff --git a/src/tests/record.rs b/src/tests/record.rs index d2769269794..cb347e483c3 100644 --- a/src/tests/record.rs +++ b/src/tests/record.rs @@ -265,13 +265,7 @@ fn record_http( hyper_response.status(status); let mut hyper_response = hyper_response.body(body.into()).unwrap(); *hyper_response.headers_mut() = headers; - ( - hyper_response, - Exchange { - response: response, - request: request, - }, - ) + (hyper_response, Exchange { response, request }) }) })) }