8000 fix(lint): restore clean cargo clippy --all-targets --all-features by adityamukho · Pull Request #112 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions benches/minigraf_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,18 @@ fn bench_recursion(c: &mut Criterion) {
let mut group = c.benchmark_group("recursion/fanout");
group.sample_size(10);
// (width, depth): (10,3) ~1110 nodes — manageable transitive closure
for &(label, width, depth) in &[("w10_d3", 10usize, 3usize)] {
let db = helpers::fanout_graph(width, depth);
group.bench_with_input(
BenchmarkId::from_parameter(label),
&(width, depth),
|b, _| {
b.iter(|| {
db.execute("(query [:find ?to :where (reach :n0 ?to)])")
.unwrap()
});
},
);
}
let (label, width, depth) = ("w10_d3", 10usize, 3usize);
let db = helpers::fanout_graph(width, depth);
group.bench_with_input(
BenchmarkId::from_parameter(label),
&(width, depth),
|b, _| {
b.iter(|| {
db.execute("(query [:find ?to :where (reach :n0 ?to)])")
.unwrap()
});
},
);
group.finish();
}
}
Expand Down
20 changes: 8 additions & 12 deletions src/query/datalog/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,11 +1715,7 @@ mod tests {

// Retract it using UUID-based entity reference
let cmd = parse_datalog_command(
format!(
r#"(retract [[#uuid "{}" :person/age 30]])"#,
alice_id.to_string()
)
.as_str(),
format!(r#"(retract [[#uuid "{}" :person/age 30]])"#, alice_id).as_str(),
)
.unwrap();

Expand Down Expand Up @@ -1866,7 +1862,7 @@ mod tests {
// Query using rule invocation: find all nodes reachable from A
let query_str = format!(
r#"(query [:find ?to :where (reachable #uuid "{}" ?to)])"#,
a.to_string()
a
);
let query_cmd = parse_datalog_command(&query_str).unwrap();

Expand Down Expand Up @@ -1928,7 +1924,7 @@ mod tests {
// Query: find names of nodes reachable from A
let query_str = format!(
r#"(query [:find ?name :where (reachable #uuid "{}" ?to) [?to :person/name ?name]])"#,
a.to_string()
a
);
let query_cmd = parse_datalog_command(&query_str).unwrap();

Expand Down Expand Up @@ -1982,7 +1978,7 @@ mod tests {
// Query: find all nodes reachable from A
let query_str = format!(
r#"(query [:find ?to :where (reachable #uuid "{}" ?to)])"#,
a.to_string()
a
);
let query_cmd = parse_datalog_command(&query_str).unwrap();

Expand Down Expand Up @@ -2217,7 +2213,7 @@ mod tests {
// Query: find names of nodes transitively reachable from A
let query_str = format!(
r#"(query [:find ?name :where (reachable #uuid "{}" ?to) [?to :person/name ?name]])"#,
a.to_string()
a
);
let query_cmd = parse_datalog_command(&query_str).unwrap();

Expand Down Expand Up @@ -3779,12 +3775,12 @@ mod expr_eval_tests {
(
e1,
":item/score".to_string(),
crate::graph::types::Value::Float(3.14),
crate::graph::types::Value::Float(3.5),
),
(
e2,
":item/score".to_string(),
crate::graph::types::Value::Float(2.71),
crate::graph::types::Value::Float(2.5),
),
],
None,
Expand All @@ -3799,7 +3795,7 @@ mod expr_eval_tests {
assert_eq!(results.len(), 1, "expected one result");
assert_eq!(
results[0][0],
crate::graph::types::Value::Float(3.14),
crate::graph::types::Value::Float(3.5),
"max of floats should return largest"
);
}
Expand Down
14 changes: 7 additions & 7 deletions src/query/datalog/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,55 +549,55 @@ mod tests {

#[test]
fn apply_builtin_count() {
let vals = vec![Value::Integer(1), Value::Integer(2), Value::Integer(3)];
let vals = [Value::Integer(1), Value::Integer(2), Value::Integer(3)];
let refs: Vec<&Value> = vals.iter().collect();
let result = apply_builtin_aggregate("count", &refs).unwrap();
assert_eq!(result, Value::Integer(3));
}

#[test]
fn apply_builtin_sum_integers() {
let vals = vec![Value::Integer(10), Value::Integer(20), Value::Integer(30)];
let vals = [Value::Integer(10), Value::Integer(20), Value::Integer(30)];
let refs: Vec<&Value> = vals.iter().collect();
let result = apply_builtin_aggregate("sum", &refs).unwrap();
assert_eq!(result, Value::Integer(60));
}

#[test]
fn apply_builtin_sum_floats() {
let vals = vec![Value::Float(1.5), Value::Float(2.5)];
let vals = [Value::Float(1.5), Value::Float(2.5)];
let refs: Vec<&Value> = vals.iter().collect();
let result = apply_builtin_aggregate("sum", &refs).unwrap();
assert_eq!(result, Value::Float(4.0));
}

#[test]
fn apply_builtin_min() {
let vals = vec![Value::Integer(30), Value::Integer(10), Value::Integer(20)];
let vals = [Value::Integer(30), Value::Integer(10), Value::Integer(20)];
let refs: Vec<&Value> = vals.iter().collect();
let result = apply_builtin_aggregate("min", &refs).unwrap();
assert_eq!(result, Value::Integer(10));
}

#[test]
fn apply_builtin_max() {
let vals = vec![Value::Integer(30), Value::Integer(10), Value::Integer(20)];
let vals = [Value::Integer(30), Value::Integer(10), Value::Integer(20)];
let refs: Vec<&Value> = vals.iter().collect();
let result = apply_builtin_aggregate("max", &refs).unwrap();
assert_eq!(result, Value::Integer(30));
}

#[test]
fn apply_builtin_avg() {
let vals = vec![Value::Integer(10), Value::Integer(20), Value::Integer(30)];
let vals = [Value::Integer(10), Value::Integer(20), Value::Integer(30)];
let refs: Vec<&Value> = vals.iter().collect();
let result = apply_builtin_aggregate("avg", &refs).unwrap();
assert_eq!(result, Value::Float(20.0));
}

#[test]
fn apply_builtin_count_distinct() {
let vals = vec![Value::Integer(1), Value::Integer(2), Value::Integer(1)];
let vals = [Value::Integer(1), Value::Integer(2), Value::Integer(1)];
let refs: Vec<&Value> = vals.iter().collect();
let result = apply_builtin_aggregate("count-distinct", &refs).unwrap();
assert_eq!(result, Value::Integer(2));
Expand Down
1 change: 1 addition & 0 deletions src/query/datalog/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub fn plan(
mod tests {
use super::*;
use crate::query::datalog::types::{EdnValue, Pattern};
#[cfg(not(feature = "wasm"))]
use crate::storage::index::Indexes;
use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion src/storage/packed_pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ mod tests {
Uuid::from_u128(n as u128),
":attr".to_string(),
Value::Integer(n as i64),
n as u64,
n,
n,
0,
VALID_TIME_FOREVER,
Expand Down
7 changes: 2 additions & 5 deletions src/storage/persistent_facts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1495,11 +1495,7 @@ mod tests {
crate::storage::FACT_PAGE_FORMAT_PACKED
);
// 51 facts @ ~25/page = ~3 pages (far fewer than 51)
let fact_page_count = if header.eavt_root_page > 1 {
header.eavt_root_page - 1
} else {
0
};
let fact_page_count = header.eavt_root_page.saturating_sub(1);
assert!(
fact_page_count <= 5,
"got {} fact pages (expected <=5)",
Expand Down Expand Up @@ -1882,6 +1878,7 @@ mod tests {
let mut file = std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&path)
.unwrap();
file.write_all(&vec![0u8; PAGE_SIZE]).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ mod tests {
let fact = make_fact(alice, ":name", Value::String("Alice".to_string()), 1);

let mut writer = WalWriter::open_or_create(&path).unwrap();
writer.append_entry(1, &[fact.clone()]).unwrap();
writer.append_entry(1, std::slice::from_ref(&fact)).unwrap();

let mut reader = WalReader::open(&path).unwrap();
let entries = reader.read_entries().unwrap();
Expand Down
8 changes: 8 additions & 0 deletions tests/not_join_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn result_count(r: &QueryResult) -> usize {
}

/// 1. Basic not-join: single join var, inner var existentially quantified.
///
/// alice has a blocked dep → excluded; bob has no deps → included.
#[test]
fn test_not_join_basic_inner_var_excluded() {
Expand Down Expand Up @@ -46,6 +47,7 @@ fn test_not_join_basic_inner_var_excluded() {
}

/// 2. Multiple join vars.
///
/// u1 has restricted role r1; u2 has unrestricted role r2 → only u2 returned.
#[test]
fn test_not_join_multiple_join_vars() {
Expand Down Expand Up @@ -75,6 +77,7 @@ fn test_not_join_multiple_join_vars() {
}

/// 3. Multi-clause not-join body (conjunction of patterns).
///
/// Only e3 has :data true and no :tag :sensitive.
#[test]
fn test_not_join_multi_clause_body() {
Expand Down Expand Up @@ -105,6 +108,7 @@ fn test_not_join_multi_clause_body() {
}

/// 4. not-join in a rule body.
///
/// alice has a rejected dep → ineligible; bob has no deps → eligible.
#[test]
fn test_not_join_in_rule_body() {
Expand Down Expand Up @@ -210,6 +214,7 @@ fn test_not_join_multi_stratum_chain() {
}

/// 6. not-join allows inner vars not bound by outer clauses (unlike plain `not`).
///
/// alice's dep is blocked → excluded; bob's dep is not blocked → included.
#[test]
fn test_not_join_allows_inner_var_not_would_reject() {
Expand Down Expand Up @@ -242,6 +247,7 @@ fn test_not_join_allows_inner_var_not_would_reject() {
}

/// 7. not-join combined with :as-of time travel.
///
/// At tx 1 alice has no dep yet → passes not-join.
/// At tx 2 alice's dep is present and blocked → excluded.
#[test]
Expand Down Expand Up @@ -289,6 +295,7 @@ fn test_not_join_with_as_of() {
}

/// 8. Unbound join variable rejected at parse time.
///
/// ?unbound appears in the join-vars list but is never bound by any outer clause.
#[test]
fn test_not_join_unbound_join_var_parse_error() {
Expand Down Expand Up @@ -326,6 +333,7 @@ fn test_not_join_nested_inside_not_rejected() {
}

/// 10. not-join body contains a RuleInvocation — derived rule facts correctly negated end-to-end.
///
/// Rule: (banned ?x) :- [?x :status :banned]
/// Rule: (eligible ?x) :- [?x :applied true], (not-join [?x] (banned ?x))
/// alice: applied + banned → NOT eligible; bob: applied only → eligible.
Expand Down
4 changes: 2 additions & 2 deletions tests/recursive_rules_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ fn test_long_chain_transitive_closure() {
})
.collect();

for i in 1..10 {
assert!(targets.contains(&nodes[i]));
for node in &nodes[1..10] {
assert!(targets.contains(node));
}
}
_ => panic!("Expected QueryResults"),
Expand Down
20 changes: 10 additions & 10 deletions tests/udf_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ fn custom_aggregate_geometric_mean() {
acc.0 += f.ln();
acc.1 += 1;
}
} else if let Value::Integer(i) = v {
if *i > 0 {
acc.0 += (*i as f64).ln();
acc.1 += 1;
}
} else if let Value::Integer(i) = v
&& *i > 0
{
acc.0 += (*i as f64).ln();
acc.1 += 1;
}
},
|acc: &(f64, usize), _n: usize| {
Expand Down Expand Up @@ -80,11 +80,11 @@ fn custom_aggregate_empty_result() {
"geomean2",
|| (0.0_f64, 0usize),
|acc: &mut (f64, usize), v: &Value| {
if let Value::Float(f) = v {
if *f > 0.0 {
acc.0 += f.ln();
acc.1 += 1;
}
if let Value::Float(f) = v
&& *f > 0.0
{
acc.0 += f.ln();
acc.1 += 1;
}
},
|acc: &(f64, usize), _n: usize| {
Expand Down
Loading
0