Linting Errors and Warnings

1
closed
Riceman2000
Riceman2000
Posted 4 months ago

Linting Errors and Warnings #375

There are a few linting errors and warnings currently, especially in ./src/data_structures and ./src/graph

Examples:

parameter is only used in recursion --at--> src\data_structures\b_tree.rs:104:39
error: parameter is only used in recursion
   --> src\data_structures\b_tree.rs:104:39
    |
104 |     fn traverse_node<T: Ord + Debug>(&self, node: &Node<T>, depth: usize) {
    |                                       ^^^^
    |
    = note: `-D clippy::only-used-in-recursion` implied by `-D warnings`
note: parameter used here
   --> src\data_structures\b_tree.rs:110:17
    |
110 |                 self.traverse_node(&node.children[index], _depth);
    |                 ^^^^
...
115 |             self.traverse_node(node.children.last().unwrap(), _depth);
    |             ^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#only_used_in_recursion
parameter is only used in recursion --at--> src\data_structures\linked_list.rs:185:26
error: parameter is only used in recursion
   --> src\data_structures\linked_list.rs:185:26
    |
185 |     fn get_ith_node(&mut self, node: Option<NonNull<Node<T>>>, index: i32) -> Option<&T> {
    |                          ^^^^
    |
note: parameter used here
   --> src\data_structures\linked_list.rs:190:22
    |
190 |                 _ => self.get_ith_node(unsafe { (*next_ptr.as_ptr()).next }, index - 1),
    |                      ^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#only_used_in_recursion
parameter is only used in recursion --at--> src\general\huffman_encoding.rs:63:17
error: parameter is only used in recursion
  --> src\general\huffman_encoding.rs:46:10
   |
46 |         &self,
   |          ^^^^
   |
note: parameter used here
  --> src\general\huffman_encoding.rs:63:17
   |
63 |                 self.get_alphabet(height + 1, path, node.left.as_ref().unwrap(), map);
   |                 ^^^^
64 |                 self.get_alphabet(
   |                 ^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#only_used_in_recursion
use of `or_insert` followed by a call to `new` --at--> src\graph\floyd_warshall.rs:53:34
error: use of `or_insert` followed by a call to `new`
  --> src\graph\floyd_warshall.rs:53:34
   |
53 | ...                   .or_insert(BTreeMap::new())
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_default()`
   |
   = note: `-D clippy::or-fun-call` implied by `-D warnings`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call
use of `or_insert` followed by a call to `new` --at--> src\graph\prufer_code.rs:36:19
error: use of `or_insert` followed by a call to `new`
  --> src\graph\prufer_code.rs:36:19
   |
36 |     tree.entry(a).or_insert(vec![]).push(b);
   |                   ^^^^^^^^^^^^^^^^^ help: try this: `or_default()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

While these issues are mainly stylistic it could be a good first PR opportunity for some quick fixes that stop warnings. Warnings about recursion may be unavoidable for some algorithms without making them completely cumbersome and hard to understand, in those cases #[allow(clippy::~specific_error~)] ... (if everyone is ok with ignoring the warnings).

Hope to start some discussion on how to proceed as new warnings come about.

Thanks!

Arjun31415
Arjun31415
Created 4 months ago

Can be closed. Fixed in #396