Skip to content

fix: clippy warning #156

fix: clippy warning

fix: clippy warning #156

Triggered via pull request July 21, 2023 10:26
Status Success
Total duration 12m 1s
Artifacts

coverage.yml

on: pull_request
Fit to window
Zoom out
Zoom in

Annotations

26 warnings
this function has too many arguments (9/7): grovedb/src/operations/proof/generate.rs#L487
warning: this function has too many arguments (9/7) --> grovedb/src/operations/proof/generate.rs:487:5 | 487 | / fn generate_and_store_merk_proof<'a, S, B>( 488 | | &self, 489 | | path: &SubtreePath<B>, 490 | | subtree: &'a Merk<S>, ... | 496 | | key: &[u8], 497 | | ) -> CostResult<(Option<u16>, Option<u16>), Error> | |______________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
this function has too many arguments (8/7): grovedb/src/operations/proof/generate.rs#L181
warning: this function has too many arguments (8/7) --> grovedb/src/operations/proof/generate.rs:181:5 | 181 | / fn prove_subqueries( 182 | | &self, 183 | | proofs: &mut Vec<u8>, 184 | | path: Vec<&[u8]>, ... | 189 | | is_verbose: bool, 190 | | ) -> CostResult<(), Error> { | |______________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
this expression creates a reference which is immediately dereferenced by the compiler: grovedb/src/operations/delete/mod.rs#L524
warning: this expression creates a reference which is immediately dereferenced by the compiler --> grovedb/src/operations/delete/mod.rs:524:25 | 524 | &batch, | ^^^^^^ help: change this to: `batch` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: grovedb/src/operations/delete/mod.rs#L272
warning: this expression creates a reference which is immediately dereferenced by the compiler --> grovedb/src/operations/delete/mod.rs:272:13 | 272 | &batch, | ^^^^^^ help: change this to: `batch` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
casting to the same type is unnecessary (`u16` -> `u16`): grovedb/src/operations/delete/worst_case.rs#L71
warning: casting to the same type is unnecessary (`u16` -> `u16`) --> grovedb/src/operations/delete/worst_case.rs:71:46 | 71 | for height in (stop_path_height..(path_len as u16)).rev() { | ^^^^^^^^^^^^^^^^^ help: try: `path_len` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
casting to the same type is unnecessary (`u16` -> `u16`): grovedb/src/operations/delete/average_case.rs#L76
warning: casting to the same type is unnecessary (`u16` -> `u16`) --> grovedb/src/operations/delete/average_case.rs:76:46 | 76 | for height in (stop_path_height..(path_len as u16)).rev() { | ^^^^^^^^^^^^^^^^^ help: try: `path_len` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default
this function has too many arguments (12/7): grovedb/src/element/query.rs#L535
warning: this function has too many arguments (12/7) --> grovedb/src/element/query.rs:535:5 | 535 | / fn query_item( 536 | | storage: &RocksDbStorage, 537 | | item: &QueryItem, 538 | | results: &mut Vec<QueryResultElement>, ... | 547 | | add_element_function: fn(PathQueryPushArgs) -> CostResult<(), Error>, 548 | | ) -> CostResult<(), Error> { | |______________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
this function has too many arguments (8/7): grovedb/src/element/query.rs#L138
warning: this function has too many arguments (8/7) --> grovedb/src/element/query.rs:138:5 | 138 | / pub fn get_query_apply_function( 139 | | storage: &RocksDbStorage, 140 | | path: &[&[u8]], 141 | | sized_query: &SizedQuery, ... | 146 | | add_element_function: fn(PathQueryPushArgs) -> CostResult<(), Error>, 147 | | ) -> CostResult<(QueryResultElements, u16), Error> { | |______________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments = note: `#[warn(clippy::too_many_arguments)]` on by default
implicitly performing saturating subtraction: grovedb/src/batch/mod.rs#L1570
warning: implicitly performing saturating subtraction --> grovedb/src/batch/mod.rs:1570:13 | 1570 | / if current_level > 0 { 1571 | | current_level -= 1; 1572 | | } | |_____________^ help: try: `current_level = current_level.saturating_sub(1);` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub = note: `#[warn(clippy::implicit_saturating_sub)]` on by default
iterating on a map's keys: grovedb/src/batch/estimated_costs/average_case_costs.rs#L235
warning: iterating on a map's keys --> grovedb/src/batch/estimated_costs/average_case_costs.rs:235:33 | 235 | let paths = self | _________________________________^ 236 | | .paths 237 | | .iter() 238 | | .map(|(k, _v)| k.0.iter().map(|k| hex::encode(k.as_slice())).join("/")) | |_______________________________________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map help: try | 235 ~ let paths = self 236 + .paths.keys().map(|k| k.0.iter().map(|k| hex::encode(k.as_slice())).join("/")) |
iterating on a map's keys: grovedb/src/batch/estimated_costs/average_case_costs.rs#L213
warning: iterating on a map's keys --> grovedb/src/batch/estimated_costs/average_case_costs.rs:213:29 | 213 | let paths = self | _____________________________^ 214 | | .paths 215 | | .iter() 216 | | .map(|(k, _v)| k.0.iter().map(|k| hex::encode(k.as_slice())).join("/")) | |___________________________________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map = note: `#[warn(clippy::iter_kv_map)]` on by default help: try | 213 ~ let paths = self 214 + .paths.keys().map(|k| k.0.iter().map(|k| hex::encode(k.as_slice())).join("/")) |
function `read_proof_version` is never used: grovedb/src/versioning.rs#L12
warning: function `read_proof_version` is never used --> grovedb/src/versioning.rs:12:8 | 12 | pub fn read_proof_version(mut bytes: &[u8]) -> Result<u32, Error> { | ^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
unused variable: `proof_version`: grovedb/src/operations/proof/verify.rs#L263
warning: unused variable: `proof_version` --> grovedb/src/operations/proof/verify.rs:263:14 | 263 | let (proof_version, proof) = read_and_consume_proof_version(proof)?; | ^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_proof_version` | = note: `#[warn(unused_variables)]` on by default
unused import: `Error::InternalError`: grovedb/src/versioning.rs#L5
warning: unused import: `Error::InternalError` --> grovedb/src/versioning.rs:5:20 | 5 | use crate::{Error, Error::InternalError}; | ^^^^^^^^^^^^^^^^^^^^
unused import: `VarIntWriter`: grovedb/src/versioning.rs#L3
warning: unused import: `VarIntWriter` --> grovedb/src/versioning.rs:3:46 | 3 | use integer_encoding::{VarInt, VarIntReader, VarIntWriter}; | ^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
this `else { if .. }` block can be collapsed: grovedb/src/batch/mod.rs#L1795
warning: this `else { if .. }` block can be collapsed --> grovedb/src/batch/mod.rs:1795:16 | 1795 | } else { | ________________^ 1796 | | if new_merk { 1797 | | Ok(Merk::open_empty(storage, MerkType::BaseMerk, false)).wrap_with_cost(cost) 1798 | | } else { ... | 1802 | | } 1803 | | } | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if = note: `#[warn(clippy::collapsible_else_if)]` on by default help: collapse nested if block | 1795 ~ } else if new_merk { 1796 + Ok(Merk::open_empty(storage, MerkType::BaseMerk, false)).wrap_with_cost(cost) 1797 + } else { 1798 + Merk::open_base(storage, false) 1799 + .map_err(|_| Error::CorruptedData("cannot open a the root subtree".to_owned())) 1800 + .add_cost(cost) 1801 + } |
this `impl` can be derived: merk/src/estimated_costs/average_case_costs.rs#L75
warning: this `impl` can be derived --> merk/src/estimated_costs/average_case_costs.rs:75:1 | 75 | / impl Default for EstimatedSumTrees { 76 | | fn default() -> Self { 77 | | EstimatedSumTrees::NoSumTrees 78 | | } 79 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls = note: `#[warn(clippy::derivable_impls)]` on by default = help: remove the manual implementation... help: ...and instead derive it... | 60 + #[derive(Default)] 61 | pub enum EstimatedSumTrees { | help: ...and mark the default variant | 62 ~ #[default] 63 ~ NoSumTrees, |
the borrowed expression implements the required traits: storage/src/rocksdb_storage/storage_context/raw_iterator.rs#L172
warning: the borrowed expression implements the required traits --> storage/src/rocksdb_storage/storage_context/raw_iterator.rs:172:32 | 172 | self.raw_iterator.seek(&self.prefix); | ^^^^^^^^^^^^ help: change this to: `self.prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
the borrowed expression implements the required traits: storage/src/rocksdb_storage/storage_context/raw_iterator.rs#L51
warning: the borrowed expression implements the required traits --> storage/src/rocksdb_storage/storage_context/raw_iterator.rs:51:32 | 51 | self.raw_iterator.seek(&self.prefix); | ^^^^^^^^^^^^ help: change this to: `self.prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
using `clone` on type `[u8; 32]` which implements the `Copy` trait: storage/src/rocksdb_storage/storage_context/context_tx.rs#L314
warning: using `clone` on type `[u8; 32]` which implements the `Copy` trait --> storage/src/rocksdb_storage/storage_context/context_tx.rs:314:21 | 314 | prefix: self.prefix.clone(), | ^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `self.prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
using `clone` on type `[u8; 32]` which implements the `Copy` trait: storage/src/rocksdb_storage/storage_context/context_tx.rs#L299
warning: using `clone` on type `[u8; 32]` which implements the `Copy` trait --> storage/src/rocksdb_storage/storage_context/context_tx.rs:299:21 | 299 | prefix: self.prefix.clone(), | ^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `self.prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
using `clone` on type `[u8; 32]` which implements the `Copy` trait: storage/src/rocksdb_storage/storage_context/context_no_tx.rs#L282
warning: using `clone` on type `[u8; 32]` which implements the `Copy` trait --> storage/src/rocksdb_storage/storage_context/context_no_tx.rs:282:21 | 282 | prefix: self.prefix.clone(), | ^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `self.prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
using `clone` on type `[u8; 32]` which implements the `Copy` trait: storage/src/rocksdb_storage/storage_context/context_no_tx.rs#L268
warning: using `clone` on type `[u8; 32]` which implements the `Copy` trait --> storage/src/rocksdb_storage/storage_context/context_no_tx.rs:268:21 | 268 | prefix: self.prefix.clone(), | ^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `self.prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy = note: `#[warn(clippy::clone_on_copy)]` on by default
unused imports: `DB`, `Options`: storage/src/rocksdb_storage/storage.rs#L43
warning: unused imports: `DB`, `Options` --> storage/src/rocksdb_storage/storage.rs:43:92 | 43 | checkpoint::Checkpoint, ColumnFamily, ColumnFamilyDescriptor, OptimisticTransactionDB, Options, | ^^^^^^^ 44 | Transaction, WriteBatchWithTransaction, DB, DEFAULT_COLUMN_FAMILY_NAME, | ^^ | = note: `#[warn(unused_imports)]` on by default
this `impl` can be derived: costs/src/storage_cost/removal.rs#L62
warning: this `impl` can be derived --> costs/src/storage_cost/removal.rs:62:1 | 62 | / impl Default for StorageRemovedBytes { 63 | | fn default() -> Self { 64 | | NoStorageRemoval 65 | | } 66 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls = note: `#[warn(clippy::derivable_impls)]` on by default = help: remove the manual implementation... help: ...and instead derive it... | 53 + #[derive(Default)] 54 | pub enum StorageRemovedBytes { | help: ...and mark the default variant | 55 ~ #[default] 56 ~ NoStorageRemoval, |
Code Coverage
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/