Skip to content

Commit

Permalink
some clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkeldenker committed Mar 6, 2024
1 parent 0f91ac8 commit 5372416
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 129 deletions.
8 changes: 4 additions & 4 deletions crates/core/benches/bitvec_similarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn random_bitvec(max_len: usize, max_id: usize) -> BitVec {
ranks.push(rng.gen_range(0..max_id) as u64);
}

ranks.sort();
ranks.sort_unstable();
ranks.dedup();

BitVec::new(ranks)
Expand All @@ -26,7 +26,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
for _ in 0..10_000 {
a.sim(&b);
}
})
});
}
});

Expand All @@ -38,7 +38,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
for _ in 0..10_000 {
a.sim(&b);
}
})
});
}
});

Expand All @@ -50,7 +50,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
for _ in 0..10_000 {
a.sim(&b);
}
})
});
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/benches/build_similarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("Inbound similarity creation", |b| {
b.iter(|| {
InboundSimilarity::build(&graph);
})
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion crates/core/benches/harmonic_centrality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
for _ in 0..10 {
HarmonicCentrality::calculate(&webgraph);
}
})
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion crates/core/benches/hyperloglog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
for _ in 0..1_000_000_000 {
log.size();
}
})
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion crates/core/benches/naive_bayes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
"{:.2} ms/pred",
start.elapsed().as_millis() as f32 / num_samples as f32
);
})
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion crates/core/benches/similar_hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {

for _ in 0..10 {
c.bench_function("similar_hosts", |b| {
b.iter(|| finder.find_similar_hosts(&["google.com".to_string()], 100))
b.iter(|| finder.find_similar_hosts(&["google.com".to_string()], 100));
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/examples/bitvec_similarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn random_bitvec(max_len: usize, max_id: usize) -> BitVec {
ranks.push(rng.gen_range(0..max_id) as u64);
}

ranks.sort();
ranks.sort_unstable();
ranks.dedup();

BitVec::new(ranks)
Expand Down
2 changes: 1 addition & 1 deletion crates/core/examples/search_preindexed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub async fn main() {
desc.push_str(query);
desc.push('\'');

println!("{}", desc);
println!("{desc}");

searcher
.search(&SearchQuery {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod tests {
}

#[test]
#[should_panic] //< unfortunately the panic message is not propagated
#[should_panic(expected = "panic should propagate")]
fn test_panic_propagates_multi_thread() {
let _result: Vec<usize> = Executor::with_threads(1, "search-test")
.unwrap()
Expand Down
12 changes: 6 additions & 6 deletions crates/core/src/hyperloglog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,12 @@ pub(crate) const RAW_ESTIMATE_DATA_VEC: &[&[f64]] = &[
97665.679,
98442.68,
99229.3002,
100011.0994,
100790.6386,
101580.1564,
102377.7484,
103152.1392,
103944.2712,
100_011.099_4,
100_790.638_6,
101_580.156_4,
102_377.748_4,
103_152.139_2,
103_944.271_2,
104730.216,
105528.6336,
106324.9398,
Expand Down
4 changes: 0 additions & 4 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
#![doc(html_logo_url = "https://stract.com/images/biglogo.svg")]
// #![warn(clippy::pedantic)]
// #![warn(missing_docs)]
// #![warn(clippy::missing_docs_in_private_items)]
#![allow(clippy::cast_precision_loss)]
#![allow(clippy::missing_errors_doc)]

use serde::{Deserialize, Serialize};
use std::path::PathBuf;
Expand Down
18 changes: 9 additions & 9 deletions crates/core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn main() -> Result<()> {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(webgraph_server::run(config))?
.block_on(webgraph_server::run(config))?;
}
},
Commands::Api { config_path } => {
Expand All @@ -308,23 +308,23 @@ fn main() -> Result<()> {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(api::run(config))?
.block_on(api::run(config))?;
}
Commands::SearchServer { config_path } => {
let config: config::SearchServerConfig = load_toml_config(config_path);

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(search_server::run(config))?
.block_on(search_server::run(config))?;
}
Commands::EntitySearchServer { config_path } => {
let config: config::EntitySearchServerConfig = load_toml_config(config_path);

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(entity_search_server::run(config))?
.block_on(entity_search_server::run(config))?;
}
Commands::AutosuggestScrape {
num_queries: queries_to_scrape,
Expand All @@ -349,23 +349,23 @@ fn main() -> Result<()> {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(entrypoint::crawler::worker(config))?
.block_on(entrypoint::crawler::worker(config))?;
}
Crawler::Coordinator { config_path } => {
let config: config::CrawlCoordinatorConfig = load_toml_config(config_path);

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(entrypoint::crawler::coordinator(config))?
.block_on(entrypoint::crawler::coordinator(config))?;
}
Crawler::Router { config_path } => {
let config: config::CrawlRouterConfig = load_toml_config(config_path);

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(entrypoint::crawler::router(config))?
.block_on(entrypoint::crawler::router(config))?;
}
Crawler::Plan { config_path } => {
let config: config::CrawlPlannerConfig = load_toml_config(config_path);
Expand All @@ -379,7 +379,7 @@ fn main() -> Result<()> {
output_path,
} => safety_classifier::train(dataset_path, output_path)?,
SafetyClassifierOptions::Predict { model_path, text } => {
safety_classifier::predict(model_path, &text)?
safety_classifier::predict(model_path, &text)?;
}
},
Commands::LiveIndex { options } => match options {
Expand All @@ -393,7 +393,7 @@ fn main() -> Result<()> {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(entrypoint::live_index::serve(config))?
.block_on(entrypoint::live_index::serve(config))?;
}
},
Commands::WebSpell { config_path } => {
Expand Down
4 changes: 2 additions & 2 deletions crates/kuchiki/examples/find_matches.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate kuchiki;

use kuchiki::traits::*;
use kuchiki::traits::TendrilSink;

fn main() {
let html = r"
Expand Down Expand Up @@ -43,6 +43,6 @@ fn main() {
//
// "Hello, world!"
// "I love HTML"
println!("{:?}", text);
println!("{text:?}");
}
}
2 changes: 1 addition & 1 deletion crates/kuchiki/examples/stack-overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
node = parent;
}

println!("Trying to drop {} nodes...", depth);
println!("Trying to drop {depth} nodes...");
// Without an explicit `impl Drop for Node`,
// depth = 20_000 causes "thread '<main>' has overflowed its stack"
// on my machine (Linux x86_64).
Expand Down
12 changes: 6 additions & 6 deletions crates/kuchiki/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ pub struct Attribute {
}

impl Attributes {
/// Like IndexMap::contains
/// Like `IndexMap::contains`
pub fn contains<A: Into<LocalName>>(&self, local_name: A) -> bool {
self.map.contains_key(&ExpandedName::new(ns!(), local_name))
}

/// Like IndexMap::get
/// Like `IndexMap::get`
pub fn get<A: Into<LocalName>>(&self, local_name: A) -> Option<&str> {
self.map
.get(&ExpandedName::new(ns!(), local_name))
.map(|attr| &*attr.value)
}

/// Like IndexMap::get_mut
/// Like `IndexMap::get_mut`
pub fn get_mut<A: Into<LocalName>>(&mut self, local_name: A) -> Option<&mut String> {
self.map
.get_mut(&ExpandedName::new(ns!(), local_name))
.map(|attr| &mut attr.value)
}

/// Like IndexMap::entry
/// Like `IndexMap::entry`
pub fn entry<A: Into<LocalName>>(&mut self, local_name: A) -> Entry<ExpandedName, Attribute> {
self.map.entry(ExpandedName::new(ns!(), local_name))
}

/// Like IndexMap::insert
/// Like `IndexMap::insert`
pub fn insert<A: Into<LocalName>>(
&mut self,
local_name: A,
Expand All @@ -76,7 +76,7 @@ impl Attributes {
)
}

/// Like IndexMap::remove
/// Like `IndexMap::remove`
pub fn remove<A: Into<LocalName>>(&mut self, local_name: A) -> Option<Attribute> {
self.map.remove(&ExpandedName::new(ns!(), local_name))
}
Expand Down
20 changes: 10 additions & 10 deletions crates/kuchiki/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use crate::Result;
impl NodeRef {
/// Return an iterator of references to this node and its ancestors.
#[inline]
pub fn inclusive_ancestors(&self) -> Ancestors {
#[must_use] pub fn inclusive_ancestors(&self) -> Ancestors {
Ancestors(Some(self.clone()))
}

/// Return an iterator of references to this node’s ancestors.
#[inline]
pub fn ancestors(&self) -> Ancestors {
#[must_use] pub fn ancestors(&self) -> Ancestors {
Ancestors(self.parent())
}

Expand Down Expand Up @@ -63,7 +63,7 @@ impl NodeRef {

/// Return an iterator of references to this node and the siblings after it.
#[inline]
pub fn inclusive_following_siblings(&self) -> Siblings {
#[must_use] pub fn inclusive_following_siblings(&self) -> Siblings {
match self.parent() {
Some(parent) => {
let last_sibling = parent.last_child().unwrap();
Expand All @@ -85,7 +85,7 @@ impl NodeRef {

/// Return an iterator of references to this node’s siblings after it.
#[inline]
pub fn following_siblings(&self) -> Siblings {
#[must_use] pub fn following_siblings(&self) -> Siblings {
match (self.parent(), self.next_sibling()) {
(Some(parent), Some(next_sibling)) => {
let last_sibling = parent.last_child().unwrap();
Expand All @@ -100,7 +100,7 @@ impl NodeRef {

/// Return an iterator of references to this node’s children.
#[inline]
pub fn children(&self) -> Siblings {
#[must_use] pub fn children(&self) -> Siblings {
match (self.first_child(), self.last_child()) {
(Some(first_child), Some(last_child)) => Siblings(Some(State {
next: first_child,
Expand All @@ -117,7 +117,7 @@ impl NodeRef {
///
/// Note: this is the `NodeEdge::Start` items from `traverse()`.
#[inline]
pub fn inclusive_descendants(&self) -> Descendants {
#[must_use] pub fn inclusive_descendants(&self) -> Descendants {
Descendants(self.traverse_inclusive())
}

Expand All @@ -127,14 +127,14 @@ impl NodeRef {
///
/// Note: this is the `NodeEdge::Start` items from `traverse()`.
#[inline]
pub fn descendants(&self) -> Descendants {
#[must_use] pub fn descendants(&self) -> Descendants {
Descendants(self.traverse())
}

/// Return an iterator of the start and end edges of this node and its descendants,
/// in tree order.
#[inline]
pub fn traverse_inclusive(&self) -> Traverse {
#[must_use] pub fn traverse_inclusive(&self) -> Traverse {
Traverse(Some(State {
next: NodeEdge::Start(self.clone()),
next_back: NodeEdge::End(self.clone()),
Expand All @@ -144,7 +144,7 @@ impl NodeRef {
/// Return an iterator of the start and end edges of this node’s descendants,
/// in tree order.
#[inline]
pub fn traverse(&self) -> Traverse {
#[must_use] pub fn traverse(&self) -> Traverse {
match (self.first_child(), self.last_child()) {
(Some(first_child), Some(last_child)) => Traverse(Some(State {
next: NodeEdge::Start(first_child),
Expand All @@ -163,7 +163,7 @@ impl NodeRef {

/// Return the first inclusive descendants element that match the given selector list.
#[inline]
pub fn select_first(&self, selectors: &str) -> Option<NodeDataRef<ElementData>> {
#[must_use] pub fn select_first(&self, selectors: &str) -> Option<NodeDataRef<ElementData>> {
let mut elements = self.select(selectors).ok()?;
elements.next()
}
Expand Down
Loading

0 comments on commit 5372416

Please sign in to comment.