diff --git a/src/bin/purge_ttl.rs b/src/bin/purge_ttl.rs index ee563ef961..8d67b7ba5a 100644 --- a/src/bin/purge_ttl.rs +++ b/src/bin/purge_ttl.rs @@ -167,7 +167,7 @@ fn delete_incremental( max_to_delete: u64, ) -> Result<(), Box> { let mut total: u64 = 0; - let (mut req, mut txn) = begin_transaction(&client, &session, RequestType::ReadWrite)?; + let (mut req, mut txn) = begin_transaction(client, session, RequestType::ReadWrite)?; loop { let select_sql = format!("SELECT fxa_uid, fxa_kid, collection_id, {} FROM {} WHERE expiry < CURRENT_TIMESTAMP() LIMIT {}", column, table, chunk_size); trace!( @@ -214,12 +214,12 @@ fn delete_incremental( delete_sql.trim_end_matches(&", ".to_string()).to_string() ); trace!("Deleting chunk with: {}", delete_sql); - let mut delete_req = continue_transaction(&session, txn.clone()); + let mut delete_req = continue_transaction(session, txn.clone()); delete_req.set_sql(delete_sql); client.execute_sql(&delete_req)?; info!("{}: removed {} rows", table, total); - commit_transaction(&client, &session, txn.clone())?; - let (newreq, newtxn) = begin_transaction(&client, &session, RequestType::ReadWrite)?; + commit_transaction(client, session, txn.clone())?; + let (newreq, newtxn) = begin_transaction(client, session, RequestType::ReadWrite)?; req = newreq; txn = newtxn; } diff --git a/src/db/mod.rs b/src/db/mod.rs index 9970edf345..7ace6df282 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -273,8 +273,8 @@ pub async fn pool_from_settings( let url = Url::parse(&settings.database_url).map_err(|e| DbErrorKind::InvalidUrl(e.to_string()))?; Ok(match url.scheme() { - "mysql" => Box::new(mysql::pool::MysqlDbPool::new(&settings, &metrics)?), - "spanner" => Box::new(spanner::pool::SpannerDbPool::new(&settings, &metrics).await?), + "mysql" => Box::new(mysql::pool::MysqlDbPool::new(settings, metrics)?), + "spanner" => Box::new(spanner::pool::SpannerDbPool::new(settings, metrics).await?), _ => Err(DbErrorKind::InvalidUrl(settings.database_url.to_owned()))?, }) } diff --git a/src/db/mysql/models.rs b/src/db/mysql/models.rs index 335beb1a8d..4fdec0c350 100644 --- a/src/db/mysql/models.rs +++ b/src/db/mysql/models.rs @@ -986,7 +986,7 @@ impl MysqlDb { batch_db_method!(delete_batch_sync, delete, DeleteBatch); pub fn get_batch_sync(&self, params: params::GetBatch) -> Result> { - batch::get(&self, params) + batch::get(self, params) } pub fn timestamp(&self) -> SyncTimestamp { diff --git a/src/db/mysql/test.rs b/src/db/mysql/test.rs index df6459d090..a26ba6f2c2 100644 --- a/src/db/mysql/test.rs +++ b/src/db/mysql/test.rs @@ -32,7 +32,7 @@ pub fn db(settings: &Settings) -> Result { let _ = env_logger::try_init(); // inherit SYNC_DATABASE_URL from the env - let pool = MysqlDbPool::new(&settings, &metrics::Metrics::noop())?; + let pool = MysqlDbPool::new(settings, &metrics::Metrics::noop())?; pool.get_sync() } diff --git a/src/db/spanner/models.rs b/src/db/spanner/models.rs index f69e8ae8aa..26b7eac195 100644 --- a/src/db/spanner/models.rs +++ b/src/db/spanner/models.rs @@ -575,7 +575,7 @@ impl SpannerDb { .one_or_none() .await? .ok_or(DbErrorKind::CollectionNotFound)?; - let modified = SyncTimestamp::from_rfc3339(&result[0].get_string_value())?; + let modified = SyncTimestamp::from_rfc3339(result[0].get_string_value())?; Ok(modified) } @@ -609,7 +609,7 @@ impl SpannerDb { .get_string_value() .parse::() .map_err(|e| DbErrorKind::Integrity(e.to_string()))?; - let modified = SyncTimestamp::from_rfc3339(&row[1].get_string_value())?; + let modified = SyncTimestamp::from_rfc3339(row[1].get_string_value())?; results.insert(collection_id, modified); } self.map_collection_names(results).await @@ -1509,7 +1509,7 @@ impl SpannerDb { .one_or_none() .await?; if let Some(result) = result { - SyncTimestamp::from_rfc3339(&result[0].get_string_value()) + SyncTimestamp::from_rfc3339(result[0].get_string_value()) } else { SyncTimestamp::from_i64(0) } diff --git a/src/db/spanner/support.rs b/src/db/spanner/support.rs index 78a36b2ee5..648bfb3716 100644 --- a/src/db/spanner/support.rs +++ b/src/db/spanner/support.rs @@ -378,7 +378,7 @@ pub fn bso_from_row(mut row: Vec) -> Result { }, payload: row[2].take_string_value(), modified, - expiry: SyncTimestamp::from_rfc3339(&row[4].get_string_value())?.as_i64(), + expiry: SyncTimestamp::from_rfc3339(row[4].get_string_value())?.as_i64(), }) } diff --git a/src/db/transaction.rs b/src/db/transaction.rs index 72ea9269cc..7975e532b4 100644 --- a/src/db/transaction.rs +++ b/src/db/transaction.rs @@ -222,7 +222,7 @@ impl FromRequest for DbTransactionPool { .to_str() .unwrap_or("NONE"); - let col_result = CollectionParam::extrude(&req.uri(), &mut req.extensions_mut()); + let col_result = CollectionParam::extrude(req.uri(), &mut req.extensions_mut()); let state = match req.app_data::>() { Some(v) => v, None => { @@ -251,7 +251,7 @@ impl FromRequest for DbTransactionPool { let bso_opt = bso.map(|b| b.bso); let is_read = matches!(method, Method::GET | Method::HEAD); - let precondition = PreConditionHeaderOpt::extrude(&req.headers())?; + let precondition = PreConditionHeaderOpt::extrude(req.headers())?; let pool = Self { pool: state.db_pool.clone(), is_read, diff --git a/src/main.rs b/src/main.rs index ad4347eea6..3b848aa5cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ async fn main() -> Result<(), Box> { // Avoid its default reqwest transport for now due to issues w/ // likely grpcio's boringssl let curl_transport_factory = |options: &sentry::ClientOptions| { - Arc::new(sentry::transports::CurlHttpTransport::new(&options)) + Arc::new(sentry::transports::CurlHttpTransport::new(options)) as Arc }; let _sentry = sentry::init(sentry::ClientOptions { diff --git a/src/server/metrics.rs b/src/server/metrics.rs index ce472cec1d..742dbd2cb4 100644 --- a/src/server/metrics.rs +++ b/src/server/metrics.rs @@ -38,7 +38,7 @@ impl Drop for Metrics { let tags = timer.tags.tags.clone(); let keys = tags.keys(); for tag in keys { - tagged = tagged.with_tag(tag, &tags.get(tag).unwrap()) + tagged = tagged.with_tag(tag, tags.get(tag).unwrap()) } match tagged.try_send() { Err(e) => { @@ -142,7 +142,7 @@ impl Metrics { } for key in mtags.tags.keys().clone() { if let Some(val) = mtags.tags.get(key) { - tagged = tagged.with_tag(&key, val.as_ref()); + tagged = tagged.with_tag(key, val.as_ref()); } } // Include any "hard coded" tags. diff --git a/src/server/test.rs b/src/server/test.rs index a418b1708e..d75fa57e2c 100644 --- a/src/server/test.rs +++ b/src/server/test.rs @@ -64,7 +64,7 @@ fn get_test_settings() -> Settings { async fn get_test_state(settings: &Settings) -> ServerState { let metrics = Metrics::sink(); ServerState { - db_pool: pool_from_settings(&settings, &Metrics::from(&metrics)) + db_pool: pool_from_settings(settings, &Metrics::from(&metrics)) .await .expect("Could not get db_pool in get_test_state"), limits: Arc::clone(&SERVER_LIMITS), diff --git a/src/server/user_agent.rs b/src/server/user_agent.rs index 3fcb92ada5..244e341a37 100644 --- a/src/server/user_agent.rs +++ b/src/server/user_agent.rs @@ -13,7 +13,7 @@ const VALID_UA_OS: &[&str] = &["Firefox OS", "Linux", "Mac OSX"]; pub fn parse_user_agent(agent: &str) -> (WootheeResult<'_>, &str, &str) { let parser = Parser::new(); - let wresult = parser.parse(&agent).unwrap_or_else(|| WootheeResult { + let wresult = parser.parse(agent).unwrap_or_else(|| WootheeResult { name: "", category: "", os: "", @@ -46,7 +46,7 @@ mod tests { #[test] fn test_linux() { let agent = r#"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090807 Mandriva Linux/1.9.1.2-1.1mud2009.1 (2009.1) Firefox/3.5.2 FirePHP/0.3,gzip(gfe),gzip(gfe)"#; - let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent); + let (ua_result, metrics_os, metrics_browser) = parse_user_agent(agent); assert_eq!(metrics_os, "Linux"); assert_eq!(ua_result.os, "Linux"); assert_eq!(metrics_browser, "Firefox"); @@ -55,7 +55,7 @@ mod tests { #[test] fn test_windows() { let agent = r#"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)"#; - let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent); + let (ua_result, metrics_os, metrics_browser) = parse_user_agent(agent); assert_eq!(metrics_os, "Windows"); assert_eq!(ua_result.os, "Windows 7"); assert_eq!(metrics_browser, "Firefox"); @@ -65,7 +65,7 @@ mod tests { fn test_osx() { let agent = r#"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.1.1) Gecko/ Firefox/5.0.1"#; - let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent); + let (ua_result, metrics_os, metrics_browser) = parse_user_agent(agent); assert_eq!(metrics_os, "Mac OSX"); assert_eq!(ua_result.os, "Mac OSX"); assert_eq!(metrics_browser, "Firefox"); @@ -75,7 +75,7 @@ mod tests { fn test_other() { let agent = r#"BlackBerry9000/4.6.0.167 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/102"#; - let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent); + let (ua_result, metrics_os, metrics_browser) = parse_user_agent(agent); assert_eq!(metrics_os, "Other"); assert_eq!(ua_result.os, "BlackBerry"); assert_eq!(metrics_browser, "Other"); diff --git a/src/tokenserver/support.rs b/src/tokenserver/support.rs index bd6277e4c4..7ff9a0c5a7 100644 --- a/src/tokenserver/support.rs +++ b/src/tokenserver/support.rs @@ -55,14 +55,14 @@ impl Tokenlib { })?; let kwargs = [("secret", shared_secret)].into_py_dict(py); let token = module - .call("make_token", (plaintext,), Some(&kwargs)) + .call("make_token", (plaintext,), Some(kwargs)) .map_err(|e| { e.print_and_set_sys_last_vars(py); e }) .and_then(|x| x.extract())?; let derived_secret = module - .call("get_derived_secret", (&token,), Some(&kwargs)) + .call("get_derived_secret", (&token,), Some(kwargs)) .map_err(|e| { e.print_and_set_sys_last_vars(py); e diff --git a/src/web/auth.rs b/src/web/auth.rs index 0b0ea1ea05..2b7a8371d7 100644 --- a/src/web/auth.rs +++ b/src/web/auth.rs @@ -187,7 +187,7 @@ impl HawkPayload { Utc::now().timestamp() as u64 }; - HawkPayload::new(header, method, path.as_str(), host, port, &secrets, expiry) + HawkPayload::new(header, method, path.as_str(), host, port, secrets, expiry) } } diff --git a/src/web/extractors.rs b/src/web/extractors.rs index b2554ec886..e45b6dad4d 100644 --- a/src/web/extractors.rs +++ b/src/web/extractors.rs @@ -240,7 +240,7 @@ impl FromRequest for BsoBodies { let mut bsos = Vec::new(); for item in body.lines() { // Check that its a valid JSON map like we expect - if let Ok(raw_json) = serde_json::from_str::(&item) { + if let Ok(raw_json) = serde_json::from_str::(item) { bsos.push(raw_json); } else { // Per Python version, BSO's must json deserialize @@ -398,7 +398,7 @@ impl FromRequest for BsoBody { let max_payload_size = state.limits.max_record_payload_bytes as usize; - let fut = >::from_request(&req, payload) + let fut = >::from_request(req, payload) .map_err(|e| { warn!("⚠️ Could not parse BSO Body: {:?}", e); let err: ApiError = ValidationErrorKind::FromDetails( @@ -569,7 +569,7 @@ impl CollectionParam { return Ok(collection.clone()); } - let collection = Self::col_from_path(&uri)?; + let collection = Self::col_from_path(uri)?; let result = if let Some(collection) = collection { collection.validate().map_err(|e| { ValidationErrorKind::FromValidationErrors(e, RequestErrorLocation::Path, None) @@ -592,7 +592,7 @@ impl FromRequest for CollectionParam { fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future { let req = req.clone(); Box::pin(async move { - if let Some(collection) = Self::extrude(&req.uri(), &mut req.extensions_mut())? { + if let Some(collection) = Self::extrude(req.uri(), &mut req.extensions_mut())? { Ok(collection) } else { Err(ValidationErrorKind::FromDetails( @@ -1067,7 +1067,7 @@ impl HawkIdentifier { uri: &Uri, ) -> Result { let payload = HawkPayload::extrude(header, method, secrets, connection_info, uri)?; - let puid = Self::uid_from_path(&uri)?; + let puid = Self::uid_from_path(uri)?; if payload.user_id != puid { warn!("⚠️ Hawk UID not in URI: {:?} {:?}", payload.user_id, uri); Err(ValidationErrorKind::FromDetails( @@ -1114,7 +1114,7 @@ impl FromRequest for HawkIdentifier { let connection_info = req.connection_info().clone(); let method = req.method().as_str(); let uri = req.uri(); - Self::extrude(&req, method, uri, &connection_info, &state) + Self::extrude(&req, method, uri, &connection_info, state) }) } } @@ -1400,7 +1400,7 @@ impl FromRequest for BatchRequestOpt { let id = match params.batch { None => None, - Some(ref batch) if batch.is_empty() || TRUE_REGEX.is_match(&batch) => None, + Some(ref batch) if batch.is_empty() || TRUE_REGEX.is_match(batch) => None, Some(batch) => { let transaction_pool = DbTransactionPool::extract(&req).await?; let pool = transaction_pool.get_pool()?; @@ -1558,7 +1558,7 @@ fn validate_qs_ids(ids: &[String]) -> Result<(), ValidationError> { )); } for id in ids { - if !VALID_ID_REGEX.is_match(&id) { + if !VALID_ID_REGEX.is_match(id) { return Err(request_error( "Invalid id in ids", RequestErrorLocation::QueryString, @@ -2175,7 +2175,7 @@ mod tests { #[test] fn test_invalid_precondition_headers() { fn assert_invalid_header(req: HttpRequest, _error_header: &str, _error_message: &str) { - let result = PreConditionHeaderOpt::extrude(&req.headers()); + let result = PreConditionHeaderOpt::extrude(req.headers()); assert!(result.is_err()); let response: HttpResponse = result.err().unwrap().into(); assert_eq!(response.status(), 400); @@ -2215,7 +2215,7 @@ mod tests { .data(make_state()) .header("X-If-Modified-Since", "32.1") .to_http_request(); - let result = PreConditionHeaderOpt::extrude(&req.headers()) + let result = PreConditionHeaderOpt::extrude(req.headers()) .unwrap() .opt .unwrap(); @@ -2227,7 +2227,7 @@ mod tests { .data(make_state()) .header("X-If-Unmodified-Since", "32.14") .to_http_request(); - let result = PreConditionHeaderOpt::extrude(&req.headers()) + let result = PreConditionHeaderOpt::extrude(req.headers()) .unwrap() .opt .unwrap(); diff --git a/src/web/middleware/mod.rs b/src/web/middleware/mod.rs index db92c32b25..ba33071031 100644 --- a/src/web/middleware/mod.rs +++ b/src/web/middleware/mod.rs @@ -33,7 +33,7 @@ impl SyncServerRequest for ServiceRequest { let state = &self.app_data::().ok_or_else(|| -> ApiError { ApiErrorKind::Internal("No app_data ServerState".to_owned()).into() })?; - HawkIdentifier::extrude(self, &method.as_str(), &self.uri(), &ci, &state) + HawkIdentifier::extrude(self, method.as_str(), self.uri(), ci, state) } } @@ -51,6 +51,6 @@ impl SyncServerRequest for HttpRequest { .ok_or_else(|| -> ApiError { ApiErrorKind::Internal("No app_data ServerState".to_owned()).into() })?; - HawkIdentifier::extrude(self, &method.as_str(), &self.uri(), &ci, &state) + HawkIdentifier::extrude(self, method.as_str(), self.uri(), ci, state) } } diff --git a/src/web/tags.rs b/src/web/tags.rs index df35266486..e1345c51fd 100644 --- a/src/web/tags.rs +++ b/src/web/tags.rs @@ -179,7 +179,7 @@ impl From for BTreeMap { impl KV for Tags { fn serialize(&self, _rec: &Record<'_>, serializer: &mut dyn slog::Serializer) -> slog::Result { for (key, val) in &self.tags { - serializer.emit_str(Key::from(key.clone()), &val)?; + serializer.emit_str(Key::from(key.clone()), val)?; } Ok(()) }