Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clippy warning #266

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

fix clippy

e04fafd
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Open

fix: clippy warning #266

fix clippy
e04fafd
Select commit
Loading
Failed to load commit list.
This check has been archived and is scheduled for deletion. Learn more about checks retention
GitHub Actions / clippy succeeded Jul 21, 2023 in 0s

clippy

25 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 25
Note 0
Help 0

Versions

  • rustc 1.71.0 (8ede3aae2 2023-07-12)
  • cargo 1.71.0 (cfd3bbd8f 2023-06-08)
  • clippy 0.1.71 (8ede3aa 2023-07-12)

Annotations

Check warning on line 497 in grovedb/src/operations/proof/generate.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (9/7)

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

Check warning on line 190 in grovedb/src/operations/proof/generate.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (8/7)

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

Check warning on line 524 in grovedb/src/operations/delete/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

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

Check warning on line 272 in grovedb/src/operations/delete/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

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

Check warning on line 71 in grovedb/src/operations/delete/worst_case.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

casting to the same type is unnecessary (`u16` -> `u16`)

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

Check warning on line 76 in grovedb/src/operations/delete/average_case.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

casting to the same type is unnecessary (`u16` -> `u16`)

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

Check warning on line 548 in grovedb/src/element/query.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (12/7)

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

Check warning on line 147 in grovedb/src/element/query.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (8/7)

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

Check warning on line 1572 in grovedb/src/batch/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

implicitly performing saturating subtraction

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

Check warning on line 238 in grovedb/src/batch/estimated_costs/average_case_costs.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

iterating on a map's keys

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("/"))
    |

Check warning on line 216 in grovedb/src/batch/estimated_costs/average_case_costs.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

iterating on a map's keys

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("/"))
    |

Check warning on line 12 in grovedb/src/versioning.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

function `read_proof_version` is never used

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

Check warning on line 263 in grovedb/src/operations/proof/verify.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused variable: `proof_version`

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

Check warning on line 5 in grovedb/src/versioning.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused import: `Error::InternalError`

warning: unused import: `Error::InternalError`
 --> grovedb/src/versioning.rs:5:20
  |
5 | use crate::{Error, Error::InternalError};
  |                    ^^^^^^^^^^^^^^^^^^^^

Check warning on line 3 in grovedb/src/versioning.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused import: `VarIntWriter`

warning: unused import: `VarIntWriter`
 --> grovedb/src/versioning.rs:3:46
  |
3 | use integer_encoding::{VarInt, VarIntReader, VarIntWriter};
  |                                              ^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Check warning on line 1803 in grovedb/src/batch/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `else { if .. }` block can be collapsed

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 +         }
     |

Check warning on line 79 in merk/src/estimated_costs/average_case_costs.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `impl` can be derived

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,
   |

Check warning on line 172 in storage/src/rocksdb_storage/storage_context/raw_iterator.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

the borrowed expression implements the required traits

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

Check warning on line 51 in storage/src/rocksdb_storage/storage_context/raw_iterator.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

the borrowed expression implements the required traits

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

Check warning on line 314 in storage/src/rocksdb_storage/storage_context/context_tx.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `[u8; 32]` which implements the `Copy` trait

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

Check warning on line 299 in storage/src/rocksdb_storage/storage_context/context_tx.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `[u8; 32]` which implements the `Copy` trait

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

Check warning on line 282 in storage/src/rocksdb_storage/storage_context/context_no_tx.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `[u8; 32]` which implements the `Copy` trait

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

Check warning on line 268 in storage/src/rocksdb_storage/storage_context/context_no_tx.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `[u8; 32]` which implements the `Copy` trait

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

Check warning on line 43 in storage/src/rocksdb_storage/storage.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused imports: `DB`, `Options`

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

Check warning on line 66 in costs/src/storage_cost/removal.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `impl` can be derived

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,
   |