From 27d760fd613ff5ea38e2e559820b1e359dd0fa35 Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Sat, 20 Apr 2019 12:46:06 -0400 Subject: [PATCH 1/4] Fix a renamed clippy lint --- src/tests/category.rs | 2 +- src/tests/krate.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/category.rs b/src/tests/category.rs index 99f4ad0f57c..ad8067f7e58 100644 --- a/src/tests/category.rs +++ b/src/tests/category.rs @@ -74,7 +74,7 @@ fn show() { } #[test] -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] fn update_crate() { let (_b, app, middle) = app(); let mut req = req(Method::Get, "/api/v1/categories/foo"); diff --git a/src/tests/krate.rs b/src/tests/krate.rs index a14621fe554..554e2410a3c 100644 --- a/src/tests/krate.rs +++ b/src/tests/krate.rs @@ -95,7 +95,7 @@ fn index() { } #[test] -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] fn index_queries() { let (app, anon, user) = TestApp::init().with_user(); let user = user.as_model(); @@ -316,7 +316,7 @@ fn index_sorting() { } #[test] -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] fn exact_match_on_queries_with_sort() { let (app, anon, user) = TestApp::init().with_user(); let user = user.as_model(); @@ -1459,7 +1459,7 @@ fn yank_not_owner() { } #[test] -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] fn yank_max_version() { let (_, anon, _, token) = TestApp::with_proxy().with_token(); From a57a6ffa33e967ab17024edfa4afe4ef03763726 Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Sat, 20 Apr 2019 13:12:34 -0400 Subject: [PATCH 2/4] Deny `clippy::all` This will explicitly opt-in to clippy lints when using RLS. --- src/bin/background-worker.rs | 2 +- src/bin/delete-crate.rs | 2 +- src/bin/delete-version.rs | 2 +- src/bin/monitor.rs | 2 +- src/bin/populate.rs | 2 +- src/bin/render-readmes.rs | 2 +- src/bin/server.rs | 2 +- src/bin/test-pagerduty.rs | 2 +- src/bin/transfer-crates.rs | 2 +- src/bin/update-downloads.rs | 2 +- src/lib.rs | 2 +- src/s3/lib.rs | 2 +- src/tests/all.rs | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/bin/background-worker.rs b/src/bin/background-worker.rs index 99b93481a19..0715eff2e90 100644 --- a/src/bin/background-worker.rs +++ b/src/bin/background-worker.rs @@ -7,7 +7,7 @@ // Usage: // cargo run --bin background-worker -#![deny(warnings)] +#![deny(warnings, clippy::all)] use cargo_registry::git::Repository; use cargo_registry::{background_jobs::*, db}; diff --git a/src/bin/delete-crate.rs b/src/bin/delete-crate.rs index 952c429bebc..36a4e6cbf8d 100644 --- a/src/bin/delete-crate.rs +++ b/src/bin/delete-crate.rs @@ -5,7 +5,7 @@ // Usage: // cargo run --bin delete-crate crate-name -#![deny(warnings)] +#![deny(warnings, clippy::all)] use cargo_registry::{db, models::Crate, schema::crates}; use std::{ diff --git a/src/bin/delete-version.rs b/src/bin/delete-version.rs index 07f0ee4cde4..05df21302e7 100644 --- a/src/bin/delete-version.rs +++ b/src/bin/delete-version.rs @@ -5,7 +5,7 @@ // Usage: // cargo run --bin delete-version crate-name version-number -#![deny(warnings)] +#![deny(warnings, clippy::all)] use cargo_registry::{ db, diff --git a/src/bin/monitor.rs b/src/bin/monitor.rs index fc2025ea9ee..eeee65fc7d5 100644 --- a/src/bin/monitor.rs +++ b/src/bin/monitor.rs @@ -4,7 +4,7 @@ //! Usage: //! cargo run --bin monitor -#![deny(warnings)] +#![deny(warnings, clippy::all)] mod on_call; diff --git a/src/bin/populate.rs b/src/bin/populate.rs index 0240d4a9c97..f158c7e88bd 100644 --- a/src/bin/populate.rs +++ b/src/bin/populate.rs @@ -4,7 +4,7 @@ // Usage: // cargo run --bin populate version_id1 version_id2 ... -#![deny(warnings)] +#![deny(warnings, clippy::all)] use cargo_registry::{db, schema::version_downloads}; use std::env; diff --git a/src/bin/render-readmes.rs b/src/bin/render-readmes.rs index 10387512ea7..8b9bcbe71c3 100644 --- a/src/bin/render-readmes.rs +++ b/src/bin/render-readmes.rs @@ -3,7 +3,7 @@ // // Warning: this can take a lot of time. -#![deny(warnings)] +#![deny(warnings, clippy::all)] #[macro_use] extern crate serde; diff --git a/src/bin/server.rs b/src/bin/server.rs index 954625be6dc..ab14e4eaaed 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,4 +1,4 @@ -#![deny(warnings)] +#![deny(warnings, clippy::all)] use cargo_registry::{boot, App, Env}; use jemalloc_ctl; diff --git a/src/bin/test-pagerduty.rs b/src/bin/test-pagerduty.rs index a2baffc342c..7084b87b451 100644 --- a/src/bin/test-pagerduty.rs +++ b/src/bin/test-pagerduty.rs @@ -5,7 +5,7 @@ //! //! Event type can be trigger, acknowledge, or resolve -#![deny(warnings)] +#![deny(warnings, clippy::all)] mod on_call; diff --git a/src/bin/transfer-crates.rs b/src/bin/transfer-crates.rs index 369317c0ddf..27be12e4c65 100644 --- a/src/bin/transfer-crates.rs +++ b/src/bin/transfer-crates.rs @@ -3,7 +3,7 @@ // Usage: // cargo run --bin transfer-crates from-user to-user -#![deny(warnings)] +#![deny(warnings, clippy::all)] use cargo_registry::{ db, diff --git a/src/bin/update-downloads.rs b/src/bin/update-downloads.rs index e450bfdcc9a..8fe22f820d9 100644 --- a/src/bin/update-downloads.rs +++ b/src/bin/update-downloads.rs @@ -1,4 +1,4 @@ -#![deny(warnings)] +#![deny(warnings, clippy::all)] #[macro_use] extern crate diesel; diff --git a/src/lib.rs b/src/lib.rs index a720e9c18a6..b0b75a63d03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! All implemented routes are defined in the [middleware](fn.middleware.html) function and //! implemented in the [category](category/index.html), [keyword](keyword/index.html), //! [krate](krate/index.html), [user](user/index.html) and [version](version/index.html) modules. -#![deny(warnings)] +#![deny(warnings, clippy::all)] #![deny(missing_debug_implementations, missing_copy_implementations)] #![deny(bare_trait_objects)] #![recursion_limit = "256"] diff --git a/src/s3/lib.rs b/src/s3/lib.rs index cc913f56bbc..70052cffe58 100644 --- a/src/s3/lib.rs +++ b/src/s3/lib.rs @@ -1,4 +1,4 @@ -#![deny(warnings)] +#![deny(warnings, clippy::all)] extern crate base64; extern crate chrono; diff --git a/src/tests/all.rs b/src/tests/all.rs index 24e5344f151..1c79a03e0be 100644 --- a/src/tests/all.rs +++ b/src/tests/all.rs @@ -1,4 +1,4 @@ -#![deny(warnings)] +#![deny(warnings, clippy::all)] #[macro_use] extern crate diesel; From a4a717d83ff9007acdacbfa2c52f1a51f59ddaa8 Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Sat, 20 Apr 2019 13:26:15 -0400 Subject: [PATCH 3/4] Deny `rust_2018_idioms` --- src/background_jobs.rs | 2 +- src/bin/background-worker.rs | 2 +- src/bin/delete-crate.rs | 2 +- src/bin/delete-version.rs | 2 +- src/bin/monitor.rs | 2 +- src/bin/populate.rs | 2 +- src/bin/render-readmes.rs | 2 +- src/bin/server.rs | 2 +- src/bin/test-pagerduty.rs | 2 +- src/bin/transfer-crates.rs | 2 +- src/bin/update-downloads.rs | 2 +- src/db.rs | 6 +++--- src/lib.rs | 2 +- src/s3/lib.rs | 2 +- src/tests/all.rs | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/background_jobs.rs b/src/background_jobs.rs index 25af3c661b2..732e914a826 100644 --- a/src/background_jobs.rs +++ b/src/background_jobs.rs @@ -44,7 +44,7 @@ impl Environment { .map(|(u, p)| (u.as_str(), p.as_str())) } - pub fn connection(&self) -> CargoResult { + pub fn connection(&self) -> CargoResult> { self.connection_pool.0.get().map_err(Into::into) } diff --git a/src/bin/background-worker.rs b/src/bin/background-worker.rs index 0715eff2e90..fd22def7f42 100644 --- a/src/bin/background-worker.rs +++ b/src/bin/background-worker.rs @@ -7,7 +7,7 @@ // Usage: // cargo run --bin background-worker -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] use cargo_registry::git::Repository; use cargo_registry::{background_jobs::*, db}; diff --git a/src/bin/delete-crate.rs b/src/bin/delete-crate.rs index 36a4e6cbf8d..07a6b29f6bd 100644 --- a/src/bin/delete-crate.rs +++ b/src/bin/delete-crate.rs @@ -5,7 +5,7 @@ // Usage: // cargo run --bin delete-crate crate-name -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] use cargo_registry::{db, models::Crate, schema::crates}; use std::{ diff --git a/src/bin/delete-version.rs b/src/bin/delete-version.rs index 05df21302e7..d612b3129fb 100644 --- a/src/bin/delete-version.rs +++ b/src/bin/delete-version.rs @@ -5,7 +5,7 @@ // Usage: // cargo run --bin delete-version crate-name version-number -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] use cargo_registry::{ db, diff --git a/src/bin/monitor.rs b/src/bin/monitor.rs index eeee65fc7d5..bd97e7c20f5 100644 --- a/src/bin/monitor.rs +++ b/src/bin/monitor.rs @@ -4,7 +4,7 @@ //! Usage: //! cargo run --bin monitor -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] mod on_call; diff --git a/src/bin/populate.rs b/src/bin/populate.rs index f158c7e88bd..f45776cc575 100644 --- a/src/bin/populate.rs +++ b/src/bin/populate.rs @@ -4,7 +4,7 @@ // Usage: // cargo run --bin populate version_id1 version_id2 ... -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] use cargo_registry::{db, schema::version_downloads}; use std::env; diff --git a/src/bin/render-readmes.rs b/src/bin/render-readmes.rs index 8b9bcbe71c3..0388b8c4050 100644 --- a/src/bin/render-readmes.rs +++ b/src/bin/render-readmes.rs @@ -3,7 +3,7 @@ // // Warning: this can take a lot of time. -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] #[macro_use] extern crate serde; diff --git a/src/bin/server.rs b/src/bin/server.rs index ab14e4eaaed..f74adb5b615 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,4 +1,4 @@ -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] use cargo_registry::{boot, App, Env}; use jemalloc_ctl; diff --git a/src/bin/test-pagerduty.rs b/src/bin/test-pagerduty.rs index 7084b87b451..12055fbe126 100644 --- a/src/bin/test-pagerduty.rs +++ b/src/bin/test-pagerduty.rs @@ -5,7 +5,7 @@ //! //! Event type can be trigger, acknowledge, or resolve -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] mod on_call; diff --git a/src/bin/transfer-crates.rs b/src/bin/transfer-crates.rs index 27be12e4c65..76fd187c03c 100644 --- a/src/bin/transfer-crates.rs +++ b/src/bin/transfer-crates.rs @@ -3,7 +3,7 @@ // Usage: // cargo run --bin transfer-crates from-user to-user -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] use cargo_registry::{ db, diff --git a/src/bin/update-downloads.rs b/src/bin/update-downloads.rs index 8fe22f820d9..0f16cb60855 100644 --- a/src/bin/update-downloads.rs +++ b/src/bin/update-downloads.rs @@ -1,4 +1,4 @@ -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] #[macro_use] extern crate diesel; diff --git a/src/db.rs b/src/db.rs index a7ec931ed58..d0548ff6f5a 100644 --- a/src/db.rs +++ b/src/db.rs @@ -18,7 +18,7 @@ pub enum DieselPool { } impl DieselPool { - pub fn get(&self) -> CargoResult { + pub fn get(&self) -> CargoResult> { match self { DieselPool::Pool(pool) => Ok(DieselPooledConn::Pool(pool.get()?)), DieselPool::Test(conn) => Ok(DieselPooledConn::Test(conn.lock())), @@ -89,11 +89,11 @@ pub trait RequestTransaction { /// /// The connection will live for the lifetime of the request. // FIXME: This description does not match the implementation below. - fn db_conn(&self) -> CargoResult; + fn db_conn(&self) -> CargoResult>; } impl RequestTransaction for T { - fn db_conn(&self) -> CargoResult { + fn db_conn(&self) -> CargoResult> { self.app().diesel_database.get().map_err(Into::into) } } diff --git a/src/lib.rs b/src/lib.rs index b0b75a63d03..fca561e4cb0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! All implemented routes are defined in the [middleware](fn.middleware.html) function and //! implemented in the [category](category/index.html), [keyword](keyword/index.html), //! [krate](krate/index.html), [user](user/index.html) and [version](version/index.html) modules. -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] #![deny(missing_debug_implementations, missing_copy_implementations)] #![deny(bare_trait_objects)] #![recursion_limit = "256"] diff --git a/src/s3/lib.rs b/src/s3/lib.rs index 70052cffe58..4992d0266e8 100644 --- a/src/s3/lib.rs +++ b/src/s3/lib.rs @@ -1,4 +1,4 @@ -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] extern crate base64; extern crate chrono; diff --git a/src/tests/all.rs b/src/tests/all.rs index 1c79a03e0be..f44c4a49df1 100644 --- a/src/tests/all.rs +++ b/src/tests/all.rs @@ -1,4 +1,4 @@ -#![deny(warnings, clippy::all)] +#![deny(warnings, clippy::all, rust_2018_idioms)] #[macro_use] extern crate diesel; From ffe2ff6f0d637eda01c077de55472017ecf1a5de Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Thu, 25 Apr 2019 21:42:13 -0400 Subject: [PATCH 4/4] Support old lint name until the next stable release --- src/tests/all.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tests/all.rs b/src/tests/all.rs index f44c4a49df1..5d92560f24c 100644 --- a/src/tests/all.rs +++ b/src/tests/all.rs @@ -1,4 +1,10 @@ #![deny(warnings, clippy::all, rust_2018_idioms)] +// TODO: Remove after we can bump to Rust 1.35 stable in `RustConfig` +#![allow( + renamed_and_removed_lints, + clippy::cyclomatic_complexity, + clippy::unknown_clippy_lints +)] #[macro_use] extern crate diesel;