Skip to content

Commit 0794a41

Browse files
committed
Fix all clippy warnings and migrate deprecated set_zoom() calls
- Remove unused lifetime on find_links_connected_to_node - Suppress too_many_arguments on find_link_at - Rename CompositeValidator::add() to with() to avoid Add trait confusion - Migrate set_zoom() to set_viewport() in tests - Replace unnecessary vec![] with plain arrays in tests - Fix always-true assertion in scalability test - Add type_complexity allows on complex tuple fields
1 parent ce4315d commit 0794a41

10 files changed

Lines changed: 30 additions & 27 deletions

File tree

examples/advanced/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ fn main() {
452452

453453
// Validate link using the new validator framework
454454
let validator: CompositeValidator<_, LinkData> = CompositeValidator::new()
455-
.add(BasicLinkValidator::new(output_type))
456-
.add(NoDuplicatesValidator);
455+
.with(BasicLinkValidator::new(output_type))
456+
.with(NoDuplicatesValidator);
457457

458458
let links_vec: Vec<LinkData> = links.iter().collect();
459459
match validator.validate(start_pin, end_pin, &cache, &links_vec) {

examples/pin-compatibility/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ fn main() {
227227
// Create composite validator with basic checks + type compatibility
228228
let validator: CompositeValidator<SimpleNodeGeometry, LinkData> =
229229
CompositeValidator::new()
230-
.add(BasicLinkValidator::new(2)) // 2 = output pin type
231-
.add(TypeCompatibilityValidator);
230+
.with(BasicLinkValidator::new(2)) // 2 = output pin type
231+
.with(TypeCompatibilityValidator);
232232

233233
let links_vec: Vec<LinkData> = links.iter().collect();
234234
matches!(
@@ -286,8 +286,8 @@ fn main() {
286286
// Create composite validator with basic checks + type compatibility
287287
let validator: CompositeValidator<SimpleNodeGeometry, LinkData> =
288288
CompositeValidator::new()
289-
.add(BasicLinkValidator::new(2)) // 2 = output pin type
290-
.add(TypeCompatibilityValidator);
289+
.with(BasicLinkValidator::new(2)) // 2 = output pin type
290+
.with(TypeCompatibilityValidator);
291291

292292
let links_vec: Vec<LinkData> = links.iter().collect();
293293
match validator.validate(start_pin, end_pin, &cache, &links_vec) {

src/graph.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl GraphLogic {
100100
/// * `node_id` - The ID of the node being deleted/queried
101101
/// * `links` - Iterator over the links
102102
/// * `cache` - Geometry cache to look up pin ownership
103-
pub fn find_links_connected_to_node<'a, I, L, N>(
103+
pub fn find_links_connected_to_node<I, L, N>(
104104
node_id: i32,
105105
links: I,
106106
cache: &GeometryCache<N>,
@@ -459,8 +459,8 @@ where
459459
///
460460
/// ```ignore
461461
/// let validator = CompositeValidator::new()
462-
/// .add(BasicLinkValidator::new(2))
463-
/// .add(NoDuplicatesValidator);
462+
/// .with(BasicLinkValidator::new(2))
463+
/// .with(NoDuplicatesValidator);
464464
///
465465
/// let result = validator.validate(start_pin, end_pin, &cache, &links);
466466
/// ```
@@ -486,7 +486,7 @@ impl<N, L> CompositeValidator<N, L> {
486486
///
487487
/// Validators are checked in the order they were added.
488488
/// The first validator to return Invalid will short-circuit.
489-
pub fn add<V: LinkValidator<N, L> + 'static>(mut self, validator: V) -> Self {
489+
pub fn with<V: LinkValidator<N, L> + 'static>(mut self, validator: V) -> Self {
490490
self.validators.push(Box::new(validator));
491491
self
492492
}
@@ -719,8 +719,8 @@ mod tests {
719719
fn test_composite_validator_passes_all() {
720720
let cache = setup_cache();
721721
let validator: CompositeValidator<_, TestLink> = CompositeValidator::new()
722-
.add(BasicLinkValidator::new(2))
723-
.add(NoDuplicatesValidator);
722+
.with(BasicLinkValidator::new(2))
723+
.with(NoDuplicatesValidator);
724724

725725
let links = vec![];
726726

@@ -732,8 +732,8 @@ mod tests {
732732
fn test_composite_validator_short_circuits_on_basic() {
733733
let cache = setup_cache();
734734
let validator: CompositeValidator<_, TestLink> = CompositeValidator::new()
735-
.add(BasicLinkValidator::new(2))
736-
.add(NoDuplicatesValidator);
735+
.with(BasicLinkValidator::new(2))
736+
.with(NoDuplicatesValidator);
737737

738738
let links = vec![];
739739

@@ -746,8 +746,8 @@ mod tests {
746746
fn test_composite_validator_short_circuits_on_duplicates() {
747747
let cache = setup_cache();
748748
let validator: CompositeValidator<_, TestLink> = CompositeValidator::new()
749-
.add(BasicLinkValidator::new(2))
750-
.add(NoDuplicatesValidator);
749+
.with(BasicLinkValidator::new(2))
750+
.with(NoDuplicatesValidator);
751751

752752
let links = vec![TestLink {
753753
id: 1,

src/state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ where
8585
}
8686

8787
/// Find link at position
88+
#[allow(clippy::too_many_arguments)]
8889
pub fn find_link_at<'a, I>(
8990
&'a self,
9091
x: f32,

tests/common/harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl MinimalTestHarness {
138138
let w = w.clone();
139139
move |z, pan_x, pan_y| {
140140
if let Some(w) = w.upgrade() {
141-
ctrl.set_zoom(z);
141+
ctrl.set_viewport(z, pan_x, pan_y);
142142
w.set_grid_commands(ctrl.generate_grid(w.get_width_(), w.get_height_(), pan_x, pan_y));
143143
tracker.update_viewport.borrow_mut().push((z, pan_x, pan_y));
144144
}

tests/common/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ pub struct CallbackTracker {
2525
/// Count of delete_selected calls
2626
pub delete_selected: Rc<RefCell<usize>>,
2727
/// (node_id, x, y, width, height)
28+
#[allow(clippy::type_complexity)]
2829
pub node_rect_changed: Rc<RefCell<Vec<(i32, f32, f32, f32, f32)>>>,
2930
/// (pin_id, node_id, pin_type, x, y)
31+
#[allow(clippy::type_complexity)]
3032
pub pin_position_changed: Rc<RefCell<Vec<(i32, i32, i32, f32, f32)>>>,
3133
/// (zoom, pan_x, pan_y)
3234
pub update_viewport: Rc<RefCell<Vec<(f32, f32, f32)>>>,

tests/level3_links.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fn test_zoom_affects_link_path() {
273273
let path_zoom_1 = harness.ctrl.compute_link_path(3, 4);
274274

275275
// Change zoom
276-
harness.ctrl.set_zoom(2.0);
276+
harness.ctrl.set_viewport(2.0, 0.0, 0.0);
277277
let path_zoom_2 = harness.ctrl.compute_link_path(3, 4);
278278

279279
// Paths should be different due to bezier offset scaling

tests/level5_keyboard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn test_deleting_node_should_also_remove_connected_links() {
218218

219219
// Find links connected to node 1
220220
// Pin IDs for node 1 are: 2 (input) and 3 (output)
221-
let node_pins = vec![2, 3]; // node_id * 2 and node_id * 2 + 1
221+
let node_pins = [2, 3]; // node_id * 2 and node_id * 2 + 1
222222

223223
// Remove connected links
224224
let mut links_to_remove = Vec::new();

tests/level6_advanced.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ fn test_default_zoom_is_one() {
3737
fn test_set_zoom() {
3838
let harness = MinimalTestHarness::new();
3939

40-
harness.ctrl.set_zoom(1.5);
40+
harness.ctrl.set_viewport(1.5, 0.0, 0.0);
4141
assert_eq!(harness.ctrl.zoom(), 1.5);
4242

43-
harness.ctrl.set_zoom(0.5);
43+
harness.ctrl.set_viewport(0.5, 0.0, 0.0);
4444
assert_eq!(harness.ctrl.zoom(), 0.5);
4545
}
4646

@@ -51,7 +51,7 @@ fn test_zoom_affects_link_path_calculation() {
5151

5252
let path_at_1x = harness.ctrl.compute_link_path(3, 4);
5353

54-
harness.ctrl.set_zoom(2.0);
54+
harness.ctrl.set_viewport(2.0, 0.0, 0.0);
5555
let path_at_2x = harness.ctrl.compute_link_path(3, 4);
5656

5757
// Paths should differ due to zoom affecting bezier control points
@@ -68,7 +68,7 @@ fn test_zoom_affects_grid_generation() {
6868

6969
let grid_1x = harness.ctrl.generate_grid(800.0, 600.0, 0.0, 0.0);
7070

71-
harness.ctrl.set_zoom(2.0);
71+
harness.ctrl.set_viewport(2.0, 0.0, 0.0);
7272
let grid_2x = harness.ctrl.generate_grid(800.0, 600.0, 0.0, 0.0);
7373

7474
assert_ne!(
@@ -302,8 +302,8 @@ fn test_composite_validator() {
302302
setup_test_geometry(&harness);
303303

304304
let validator = CompositeValidator::new()
305-
.add(BasicLinkValidator::new(2))
306-
.add(NoDuplicatesValidator);
305+
.with(BasicLinkValidator::new(2))
306+
.with(NoDuplicatesValidator);
307307

308308
let cache = harness.ctrl.cache();
309309
let cache = cache.borrow();
@@ -461,7 +461,7 @@ fn test_find_links_connected_to_node() {
461461
harness.ctrl.cache().borrow_mut().handle_pin_report(7, 3, 2, 150.0, 50.0);
462462

463463
// Find links connected to node 2 (pins 4 and 5)
464-
let node2_pins = vec![4, 5];
464+
let node2_pins = [4, 5];
465465
let mut connected = Vec::new();
466466

467467
for i in 0..harness.links.row_count() {

tests/level7_scalability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ fn test_compute_link_path_1k_links() {
687687

688688
for (_, start_pin, end_pin) in &links {
689689
let path = cache.compute_link_path(*start_pin, *end_pin, 1.0, 50.0);
690-
assert!(path.is_some() || true); // Some might be None if pins don't exist
690+
let _ = path; // Some might be None if pins don't exist
691691
}
692692

693693
let elapsed = start.elapsed();

0 commit comments

Comments
 (0)