web search done right
fix clippy warnings in tests
Mikkel Denker6c365f369a31
diff --git a/crates/core/src/ampc/dht/mod.rs b/crates/core/src/ampc/dht/mod.rsindex 1b9178f2..483f16dc 100644--- a/crates/core/src/ampc/dht/mod.rs+++ b/crates/core/src/ampc/dht/mod.rs@@ -390,7 +390,6 @@ pub mod tests {.batch_set(table.clone(),(0..N)- .into_iter().map(|i| {(i.to_be_bytes().as_ref().into(),@@ -413,9 +412,9 @@ pub mod tests {res.sort_by_key(|(k, _)| k.clone());assert_eq!(res.len(), N as usize);- for i in 0..N as usize {+ for (i, r) in res.into_iter().enumerate() {assert_eq!(- res[i],+ r,(i.to_be_bytes().as_ref().into(),i.to_be_bytes().as_ref().into(),diff --git a/crates/core/src/ampc/dht_conn.rs b/crates/core/src/ampc/dht_conn.rsindex 63637334..c29f9df9 100644--- a/crates/core/src/ampc/dht_conn.rs+++ b/crates/core/src/ampc/dht_conn.rs@@ -497,7 +497,7 @@ mod tests {.batch_set(vec![(Id(1), Counter(0)), (Id(2), Counter(0))]);let mut res = tables.id.batch_get(vec![Id(1), Id(2)]);- res.sort_by(|(a, _), (b, _)| a.cmp(&b));+ res.sort_by(|(a, _), (b, _)| a.cmp(b));assert_eq!(res, vec![(Id(1), Counter(0)), (Id(2), Counter(0))]);@@ -510,7 +510,7 @@ mod tests {);let mut res = tables.id.batch_get(vec![Id(0), Id(1), Id(2)]);- res.sort_by(|(a, _), (b, _)| a.cmp(&b));+ res.sort_by(|(a, _), (b, _)| a.cmp(b));assert_eq!(res,diff --git a/crates/core/src/distributed/sonic/mod.rs b/crates/core/src/distributed/sonic/mod.rsindex 3be9e8a0..08fb1e96 100644--- a/crates/core/src/distributed/sonic/mod.rs+++ b/crates/core/src/distributed/sonic/mod.rs@@ -293,7 +293,7 @@ mod tests {.unwrap().block_on(async move {let addr = free_socket_addr();- let server = Server::bind(addr.clone()).await.unwrap();+ let server = Server::bind(addr).await.unwrap();let connection = Connection::create(addr).await.unwrap();let svr_task = tokio::spawn(async move { svr_fn(server).await });diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rsindex e7c95500..f0d73d91 100644--- a/crates/core/src/lib.rs+++ b/crates/core/src/lib.rs@@ -237,9 +237,9 @@ fn free_socket_addr() -> std::net::SocketAddr {use std::net::{Ipv4Addr, TcpListener};let listener = TcpListener::bind((Ipv4Addr::LOCALHOST, 0)).unwrap();- let addr = listener.local_addr().unwrap();+- addr+ listener.local_addr().unwrap()}fn ceil_char_boundary(str: &str, index: usize) -> usize {diff --git a/crates/core/src/query/optic.rs b/crates/core/src/query/optic.rsindex 2c7923ce..6c98a103 100644--- a/crates/core/src/query/optic.rs+++ b/crates/core/src/query/optic.rs@@ -283,6 +283,7 @@ mod tests {const CONTENT: &str = "this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever";#[test]+ #[allow(clippy::too_many_lines)]fn discard_and_boost_hosts() {let mut index = Index::temporary().expect("Unable to open index");@@ -505,6 +506,7 @@ mod tests {}#[test]+ #[allow(clippy::too_many_lines)]fn empty_discard() {let mut index = Index::temporary().expect("Unable to open index");@@ -617,6 +619,7 @@ mod tests {}#[tokio::test]+ #[allow(clippy::too_many_lines)]async fn liked_hosts() {let mut index = Index::temporary().expect("Unable to open index");@@ -770,6 +773,7 @@ mod tests {}#[test]+ #[allow(clippy::too_many_lines)]fn schema_org_search() {let mut index = Index::temporary().expect("Unable to open index");@@ -1101,6 +1105,7 @@ mod tests {}#[test]+ #[allow(clippy::too_many_lines)]fn special_pattern_syntax() {let mut index = Index::temporary().expect("Unable to open index");@@ -1380,6 +1385,7 @@ mod tests {}#[test]+ #[allow(clippy::too_many_lines)]fn wildcard_edge_cases() {let mut index = Index::temporary().expect("Unable to open index");diff --git a/crates/core/src/ranking/optics.rs b/crates/core/src/ranking/optics.rsindex 33bffbed..ea56c4a5 100644--- a/crates/core/src/ranking/optics.rs+++ b/crates/core/src/ranking/optics.rs@@ -34,6 +34,7 @@ mod tests {const CONTENT: &str = "this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever";#[tokio::test]+ #[allow(clippy::too_many_lines)]async fn host_rankings() {let mut index = Index::temporary().expect("Unable to open index");diff --git a/crates/core/src/webgraph/centrality/mod.rs b/crates/core/src/webgraph/centrality/mod.rsindex bb8e088e..ff012f3e 100644--- a/crates/core/src/webgraph/centrality/mod.rs+++ b/crates/core/src/webgraph/centrality/mod.rs@@ -120,28 +120,26 @@ mod tests {#[test]fn test_top_k() {- let hits = vec![- (SortableFloat(0.0), NodeID::from(0 as u64)),- (SortableFloat(1.0), NodeID::from(1 as u64)),- (SortableFloat(2.0), NodeID::from(2 as u64)),- (SortableFloat(3.0), NodeID::from(3 as u64)),- (SortableFloat(4.0), NodeID::from(4 as u64)),- (SortableFloat(5.0), NodeID::from(5 as u64)),- (SortableFloat(6.0), NodeID::from(6 as u64)),- (SortableFloat(7.0), NodeID::from(7 as u64)),- (SortableFloat(8.0), NodeID::from(8 as u64)),- (SortableFloat(9.0), NodeID::from(9 as u64)),- ];+ let hits = [(SortableFloat(0.0), NodeID::from(0_u64)),+ (SortableFloat(1.0), NodeID::from(1_u64)),+ (SortableFloat(2.0), NodeID::from(2_u64)),+ (SortableFloat(3.0), NodeID::from(3_u64)),+ (SortableFloat(4.0), NodeID::from(4_u64)),+ (SortableFloat(5.0), NodeID::from(5_u64)),+ (SortableFloat(6.0), NodeID::from(6_u64)),+ (SortableFloat(7.0), NodeID::from(7_u64)),+ (SortableFloat(8.0), NodeID::from(8_u64)),+ (SortableFloat(9.0), NodeID::from(9_u64))];let top_5 = crate::sorted_k(hits.iter().copied(), 5);assert_eq!(top_5,vec![- (SortableFloat(0.0), NodeID::from(0 as u64)),- (SortableFloat(1.0), NodeID::from(1 as u64)),- (SortableFloat(2.0), NodeID::from(2 as u64)),- (SortableFloat(3.0), NodeID::from(3 as u64)),- (SortableFloat(4.0), NodeID::from(4 as u64))+ (SortableFloat(0.0), NodeID::from(0_u64)),+ (SortableFloat(1.0), NodeID::from(1_u64)),+ (SortableFloat(2.0), NodeID::from(2_u64)),+ (SortableFloat(3.0), NodeID::from(3_u64)),+ (SortableFloat(4.0), NodeID::from(4_u64))]);@@ -149,9 +147,9 @@ mod tests {assert_eq!(top_3,vec![- (SortableFloat(0.0), NodeID::from(0 as u64)),- (SortableFloat(1.0), NodeID::from(1 as u64)),- (SortableFloat(2.0), NodeID::from(2 as u64))+ (SortableFloat(0.0), NodeID::from(0_u64)),+ (SortableFloat(1.0), NodeID::from(1_u64)),+ (SortableFloat(2.0), NodeID::from(2_u64))]);@@ -161,18 +159,16 @@ mod tests {#[test]fn test_top_k_reversed() {- let hits = vec![- (SortableFloat(9.0), NodeID::from(9 as u64)),- (SortableFloat(8.0), NodeID::from(8 as u64)),- (SortableFloat(7.0), NodeID::from(7 as u64)),- (SortableFloat(6.0), NodeID::from(6 as u64)),- (SortableFloat(5.0), NodeID::from(5 as u64)),- (SortableFloat(4.0), NodeID::from(4 as u64)),- (SortableFloat(3.0), NodeID::from(3 as u64)),- (SortableFloat(2.0), NodeID::from(2 as u64)),- (SortableFloat(1.0), NodeID::from(1 as u64)),- (SortableFloat(0.0), NodeID::from(0 as u64)),- ];+ let hits = [(SortableFloat(9.0), NodeID::from(9_u64)),+ (SortableFloat(8.0), NodeID::from(8_u64)),+ (SortableFloat(7.0), NodeID::from(7_u64)),+ (SortableFloat(6.0), NodeID::from(6_u64)),+ (SortableFloat(5.0), NodeID::from(5_u64)),+ (SortableFloat(4.0), NodeID::from(4_u64)),+ (SortableFloat(3.0), NodeID::from(3_u64)),+ (SortableFloat(2.0), NodeID::from(2_u64)),+ (SortableFloat(1.0), NodeID::from(1_u64)),+ (SortableFloat(0.0), NodeID::from(0_u64))];let top_5 = crate::sorted_k(hits.iter().copied().map(Reverse), 5).into_iter()@@ -182,11 +178,11 @@ mod tests {assert_eq!(top_5,vec![- (SortableFloat(9.0), NodeID::from(9 as u64)),- (SortableFloat(8.0), NodeID::from(8 as u64)),- (SortableFloat(7.0), NodeID::from(7 as u64)),- (SortableFloat(6.0), NodeID::from(6 as u64)),- (SortableFloat(5.0), NodeID::from(5 as u64))+ (SortableFloat(9.0), NodeID::from(9_u64)),+ (SortableFloat(8.0), NodeID::from(8_u64)),+ (SortableFloat(7.0), NodeID::from(7_u64)),+ (SortableFloat(6.0), NodeID::from(6_u64)),+ (SortableFloat(5.0), NodeID::from(5_u64))]);@@ -198,9 +194,9 @@ mod tests {assert_eq!(top_3,vec![- (SortableFloat(9.0), NodeID::from(9 as u64)),- (SortableFloat(8.0), NodeID::from(8 as u64)),- (SortableFloat(7.0), NodeID::from(7 as u64))+ (SortableFloat(9.0), NodeID::from(9_u64)),+ (SortableFloat(8.0), NodeID::from(8_u64)),+ (SortableFloat(7.0), NodeID::from(7_u64))]);}diff --git a/crates/core/src/webgraph/id_node_db.rs b/crates/core/src/webgraph/id_node_db.rsindex 693b240f..97ff9335 100644--- a/crates/core/src/webgraph/id_node_db.rs+++ b/crates/core/src/webgraph/id_node_db.rs@@ -72,7 +72,7 @@ mod tests {let mut db = Id2NodeDb::open(gen_temp_path());let a_node = Node::from("a".to_string());- let a_id = NodeID::from(0 as u64);+ let a_id = NodeID::from(0_u64);db.put(&a_id, &a_node);db.flush();@@ -80,7 +80,7 @@ mod tests {assert_eq!(db.get(&a_id), Some(a_node.clone()));let b_node = Node::from("b".to_string());- let b_id = NodeID::from(1 as u64);+ let b_id = NodeID::from(1_u64);assert_eq!(db.get(&b_id), None);diff --git a/crates/core/src/webgraph/segment.rs b/crates/core/src/webgraph/segment.rsindex ee611ea5..0291a391 100644--- a/crates/core/src/webgraph/segment.rs+++ b/crates/core/src/webgraph/segment.rs@@ -155,6 +155,7 @@ mod test {use super::*;#[test]+ #[allow(clippy::too_many_lines)]fn simple_triangle_graph() {// ┌────┐// │ │@@ -173,16 +174,16 @@ mod test {let mut edges = Vec::new();let a = FullNodeID {- id: NodeID::from(0 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(0_u64),+ host: NodeID::from(0_u64),};let b = FullNodeID {- id: NodeID::from(1 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(1_u64),+ host: NodeID::from(0_u64),};let c = FullNodeID {- id: NodeID::from(2 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(2_u64),+ host: NodeID::from(0_u64),};edges.push(InnerEdge {diff --git a/crates/core/src/webgraph/store.rs b/crates/core/src/webgraph/store.rsindex a2fe9938..937cfb5e 100644--- a/crates/core/src/webgraph/store.rs+++ b/crates/core/src/webgraph/store.rs@@ -374,12 +374,12 @@ mod tests {let e = InnerEdge {from: FullNodeID {- id: NodeID::from(0 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(0_u64),+ host: NodeID::from(0_u64),},to: FullNodeID {- id: NodeID::from(1 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(1_u64),+ host: NodeID::from(0_u64),},label: "test".to_string(),};@@ -388,12 +388,12 @@ mod tests {let store = kv.finalize();- let edges: Vec<_> = store.get_with_label(&NodeID::from(0 as u64), &EdgeLimit::Unlimited);+ let edges: Vec<_> = store.get_with_label(&NodeID::from(0_u64), &EdgeLimit::Unlimited);assert_eq!(edges.len(), 1);assert_eq!(&edges[0], &Edge::from(e.clone()));- let edges: Vec<_> = store.get_with_label(&NodeID::from(1 as u64), &EdgeLimit::Unlimited);+ let edges: Vec<_> = store.get_with_label(&NodeID::from(1_u64), &EdgeLimit::Unlimited);assert_eq!(edges.len(), 0);}@@ -409,12 +409,12 @@ mod tests {let e = InnerEdge {from: FullNodeID {- id: NodeID::from(0 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(0_u64),+ host: NodeID::from(0_u64),},to: FullNodeID {- id: NodeID::from(1 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(1_u64),+ host: NodeID::from(0_u64),},label: "test".to_string(),};@@ -423,10 +423,10 @@ mod tests {let store = kv.finalize();- let edges: Vec<_> = store.get_with_label(&NodeID::from(0 as u64), &EdgeLimit::Unlimited);+ let edges: Vec<_> = store.get_with_label(&NodeID::from(0_u64), &EdgeLimit::Unlimited);assert_eq!(edges.len(), 0);- let edges: Vec<_> = store.get_with_label(&NodeID::from(1 as u64), &EdgeLimit::Unlimited);+ let edges: Vec<_> = store.get_with_label(&NodeID::from(1_u64), &EdgeLimit::Unlimited);assert_eq!(edges.len(), 1);assert_eq!(&edges[0], &Edge::from(e.clone()));}@@ -444,11 +444,11 @@ mod tests {let e = InnerEdge {from: FullNodeID {id: NodeID::from(i as u64),- host: NodeID::from(0 as u64),+ host: NodeID::from(0_u64),},to: FullNodeID {- id: NodeID::from(1 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(1_u64),+ host: NodeID::from(0_u64),},label: "test".to_string(),};@@ -458,7 +458,7 @@ mod tests {let store = kv.finalize();- let edges: Vec<_> = store.get_with_label(&NodeID::from(1 as u64), &EdgeLimit::Limit(5));+ let edges: Vec<_> = store.get_with_label(&NodeID::from(1_u64), &EdgeLimit::Limit(5));assert_eq!(edges.len(), 5);}@@ -467,9 +467,9 @@ mod tests {let mut rank_store =speedy_kv::Db::open_or_create(crate::gen_temp_path().join("test-rank-store")).unwrap();- rank_store.insert(NodeID::from(2 as u64), 1).unwrap();- rank_store.insert(NodeID::from(3 as u64), 2).unwrap();- rank_store.insert(NodeID::from(1 as u64), 3).unwrap();+ rank_store.insert(NodeID::from(2_u64), 1).unwrap();+ rank_store.insert(NodeID::from(3_u64), 2).unwrap();+ rank_store.insert(NodeID::from(1_u64), 3).unwrap();rank_store.commit().unwrap();@@ -482,36 +482,36 @@ mod tests {let e1 = InnerEdge {from: FullNodeID {- id: NodeID::from(1 as u64),- host: NodeID::from(1 as u64),+ id: NodeID::from(1_u64),+ host: NodeID::from(1_u64),},to: FullNodeID {- id: NodeID::from(0 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(0_u64),+ host: NodeID::from(0_u64),},label: "1".to_string(),};let e2 = InnerEdge {from: FullNodeID {- id: NodeID::from(2 as u64),- host: NodeID::from(2 as u64),+ id: NodeID::from(2_u64),+ host: NodeID::from(2_u64),},to: FullNodeID {- id: NodeID::from(0 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(0_u64),+ host: NodeID::from(0_u64),},label: "2".to_string(),};let e3 = InnerEdge {from: FullNodeID {- id: NodeID::from(3 as u64),- host: NodeID::from(3 as u64),+ id: NodeID::from(3_u64),+ host: NodeID::from(3_u64),},to: FullNodeID {- id: NodeID::from(0 as u64),- host: NodeID::from(0 as u64),+ id: NodeID::from(0_u64),+ host: NodeID::from(0_u64),},label: "3".to_string(),};@@ -522,7 +522,7 @@ mod tests {let store = kv.finalize();- let edges: Vec<_> = store.get_with_label(&NodeID::from(0 as u64), &EdgeLimit::Unlimited);+ let edges: Vec<_> = store.get_with_label(&NodeID::from(0_u64), &EdgeLimit::Unlimited);assert_eq!(edges.len(), 3);diff --git a/crates/core/src/webpage/schema_org/microdata.rs b/crates/core/src/webpage/schema_org/microdata.rsindex 1f54f4af..89addfa6 100644--- a/crates/core/src/webpage/schema_org/microdata.rs+++ b/crates/core/src/webpage/schema_org/microdata.rs@@ -438,6 +438,7 @@ mod tests {}#[test]+ #[allow(clippy::too_many_lines)]fn entire_website() {let root = kuchiki::parse_html().one(