diff --git a/Dockerfile b/Dockerfile index 587110fc..a2004385 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG APPNAME=contile # make sure that the build and run environments are the same version -FROM rust:1.53-slim-buster as builder +FROM rust:1.54-slim-buster as builder ARG APPNAME ADD . /app WORKDIR /app diff --git a/src/adm/filter.rs b/src/adm/filter.rs index 716fe206..e7f7dd42 100644 --- a/src/adm/filter.rs +++ b/src/adm/filter.rs @@ -94,7 +94,7 @@ impl AdmFilter { Err(e) => { tags.add_tag("type", species); tags.add_extra("tile", &tile.name); - tags.add_extra("url", &url); + tags.add_extra("url", url); tags.add_extra("parse_error", &e.to_string()); return Err(HandlerErrorKind::InvalidHost(species, url.to_string()).into()); } @@ -126,7 +126,7 @@ impl AdmFilter { Err(e) => { tags.add_tag("type", species); tags.add_extra("tile", &tile.name); - tags.add_extra("url", &url); + tags.add_extra("url", url); tags.add_extra("parse_error", &e.to_string()); return Err(HandlerErrorKind::InvalidHost(species, url.to_string()).into()); @@ -142,7 +142,7 @@ impl AdmFilter { trace!("bad url: url={:?}", url.to_string()); tags.add_tag("type", species); tags.add_extra("tile", &tile.name); - tags.add_extra("url", &url); + tags.add_extra("url", url); tags.add_extra("reason", "bad host"); return Err(HandlerErrorKind::InvalidHost(species, url.to_string()).into()); @@ -152,10 +152,10 @@ impl AdmFilter { trace!("missing param: key={:?} url={:?}", &key, url.to_string()); tags.add_tag("type", species); tags.add_extra("tile", &tile.name); - tags.add_extra("url", &url); + tags.add_extra("url", url); tags.add_extra("reason", "missing required query param"); - tags.add_extra("param", &key); + tags.add_extra("param", key); return Err(HandlerErrorKind::InvalidHost(species, url.to_string()).into()); } } @@ -164,7 +164,7 @@ impl AdmFilter { trace!("invalid param key={:?} url={:?}", &key, url.to_string()); tags.add_tag("type", species); tags.add_extra("tile", &tile.name); - tags.add_extra("url", &url); + tags.add_extra("url", url); tags.add_extra("reason", "invalid query param"); tags.add_extra("param", &key); @@ -190,7 +190,7 @@ impl AdmFilter { Err(e) => { tags.add_tag("type", species); tags.add_extra("tile", &tile.name); - tags.add_extra("url", &url); + tags.add_extra("url", url); tags.add_extra("parse_error", &e.to_string()); return Err(HandlerErrorKind::InvalidHost(species, url.to_string()).into()); } @@ -204,7 +204,7 @@ impl AdmFilter { trace!("missing param key=id url={:?}", url.to_string()); tags.add_tag("type", species); tags.add_extra("tile", &tile.name); - tags.add_extra("url", &url); + tags.add_extra("url", url); tags.add_extra("reason", "invalid query param"); tags.add_extra("param", "id"); return Err(HandlerErrorKind::InvalidHost(species, url.to_string()).into()); diff --git a/src/metrics.rs b/src/metrics.rs index 76fa73e9..89258c33 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -44,7 +44,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) => { @@ -146,7 +146,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. @@ -176,7 +176,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/img_storage.rs b/src/server/img_storage.rs index 24ba2981..f1c36099 100644 --- a/src/server/img_storage.rs +++ b/src/server/img_storage.rs @@ -355,7 +355,7 @@ impl StoreImage { return Err(err); } }; - self.meta(&image, fmt)? + self.meta(image, fmt)? }; if self.settings.metrics.symmetric && image_metrics.width != image_metrics.height { let mut tags = Tags::default(); diff --git a/src/server/location.rs b/src/server/location.rs index a8f0e764..4996a64a 100644 --- a/src/server/location.rs +++ b/src/server/location.rs @@ -334,7 +334,7 @@ impl Location { match self.iploc.clone().unwrap().lookup::>(ip_addr) { Ok(location) => { if let Some(names) = location.city.and_then(|c| c.names) { - result.city = get_preferred_language_element(&preferred_languages, &names) + result.city = get_preferred_language_element(preferred_languages, &names) } else { metrics.incr_with_tags("location.unknown.city", Some(&tags)); }; @@ -472,7 +472,7 @@ pub mod test { let hv = "US, USCA"; test_head.headers_mut().append( HeaderName::from_static(test_header), - HeaderValue::from_static(&hv), + HeaderValue::from_static(hv), ); let loc = LocationResult::from_header(&test_head, &settings, &metrics); @@ -502,7 +502,7 @@ pub mod test { let hv = ", "; test_head.headers_mut().append( HeaderName::from_static(GOOG_LOC_HEADER), - HeaderValue::from_static(&hv), + HeaderValue::from_static(hv), ); let loc = LocationResult::from_header(&test_head, &settings, &metrics); assert!(loc.region() == ""); diff --git a/src/tags.rs b/src/tags.rs index 5c734f97..79dbf0d2 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -43,7 +43,7 @@ const VALID_UA_OS: &[&str] = &["Firefox OS", "Linux", "Mac OSX"]; /// metrics and logging). pub fn parse_user_agent(agent: &str) -> (WootheeResult<'_>, &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: "", @@ -294,7 +294,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(()) } diff --git a/src/web/extractors.rs b/src/web/extractors.rs index d20a1356..192d07f3 100644 --- a/src/web/extractors.rs +++ b/src/web/extractors.rs @@ -38,7 +38,7 @@ impl FromRequest for DeviceInfo { .unwrap_or(&EMPTY_HEADER) .to_str() .unwrap_or_default(); - Ok(get_device_info(&ua)?) + Ok(get_device_info(ua)?) } .boxed_local() } diff --git a/src/web/handlers.rs b/src/web/handlers.rs index 1acc514c..b4e86e62 100644 --- a/src/web/handlers.rs +++ b/src/web/handlers.rs @@ -97,8 +97,8 @@ pub async fn get_tiles( metrics.incr_with_tags("tiles.invalid", Some(&tags)); // Report directly to sentry // (This is starting to become a pattern. 🤔) - let mut tags = Tags::from_head(request.head(), &settings); - tags.add_extra("err", &es); + let mut tags = Tags::from_head(request.head(), settings); + tags.add_extra("err", es); tags.add_tag("level", "warning"); l_sentry::report(&tags, sentry::event_from_error(&e)); warn!("ADM Server error: {:?}", e); diff --git a/src/web/test.rs b/src/web/test.rs index 22a2fd20..fd80a125 100644 --- a/src/web/test.rs +++ b/src/web/test.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use actix_cors::Cors; use actix_web::{ - dev, http::header, http::StatusCode, middleware::errhandlers::ErrorHandlers, test, web, App, + http::header, http::StatusCode, middleware::errhandlers::ErrorHandlers, test, web, App, HttpRequest, HttpResponse, HttpServer, }; use futures::{channel::mpsc, StreamExt}; @@ -66,7 +66,6 @@ macro_rules! init_app { } struct MockAdm { - pub server: dev::Server, pub endpoint_url: String, pub request_rx: mpsc::UnboundedReceiver, } @@ -111,8 +110,8 @@ fn init_mock_adm(response: String) -> MockAdm { .bind(("127.0.0.1", 0)) .expect("Couldn't bind mock_adm"); let addr = server.addrs().pop().expect("No mock_adm addr"); + server.run(); MockAdm { - server: server.run(), endpoint_url: format!("http://{}:{}/?partner=foo&sub1=bar", addr.ip(), addr.port()), request_rx, } @@ -372,11 +371,9 @@ async fn basic_default() { let tiles = result["tiles"].as_array().expect("!tiles.is_array()"); // remember, we cap at `settings.adm_max_tiles` (currently 2) assert_eq!(tiles.len(), 2); - let names: Vec<&str> = tiles + assert!(!tiles .iter() - .map(|tile| tile["name"].as_str().unwrap()) - .collect(); - assert!(!names.contains(&"Los Pollos Hermanos")); + .any(|tile| tile["name"].as_str().unwrap() == "Los Pollos Hermanos")); } #[actix_rt::test] diff --git a/src/web/user_agent.rs b/src/web/user_agent.rs index abaddb7c..fd47d967 100644 --- a/src/web/user_agent.rs +++ b/src/web/user_agent.rs @@ -60,7 +60,7 @@ pub fn get_device_info(ua: &str) -> HandlerResult { // XXX: Tags::from_head already adds this err.tags.add_extra("ua", ua); err.tags - .add_extra("name", &wresult.name.to_lowercase().as_str()); + .add_extra("name", wresult.name.to_lowercase().as_str()); return Err(err); }