Skip to content

Commit

Permalink
add clippy rule to disable multihash_codetable::Code
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Nov 28, 2024
1 parent b38c583 commit e5bc4db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ path = "std::sync::Mutex"
reason = """the standard library synchronization primitives are poisoned when aquiring threads panic.
use parking_lot::Mutex instead to silently ignore panics."""

[[disallowed-types]]
path = "multihash_codetable::Code"
reason = """use `crate::utils::multihash::MultihashCode` instead which has `Identity` code back-filled."""

[[disallowed-methods]]
path = "tempfile::NamedTempFile::new"
reason = """The temporary files created by this method are not persistable if the temporary directory lives on a different filesystem than the target directory. While it is valid in other contexts (if not persisting files), it was misused many times and so we are banning it. Consider using `tempfile::NamedTempFile::new_in` or `tempfile::NamedTempFile::Builder"""
3 changes: 3 additions & 0 deletions src/utils/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ use cid::Cid;
use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::CborStore;
use fvm_ipld_encoding::{to_vec, DAG_CBOR};
#[allow(clippy::disallowed_types)]
use multihash_codetable::Code;

use serde::ser::Serialize;

/// Extension methods for inserting and retrieving IPLD data with CIDs
pub trait BlockstoreExt: Blockstore {
/// Batch put CBOR objects into block store and returns vector of CIDs
#[allow(clippy::disallowed_types)]
fn bulk_put<'a, S, V>(&self, values: V, code: Code) -> anyhow::Result<Vec<Cid>>
where
Self: Sized,
Expand Down Expand Up @@ -59,6 +61,7 @@ pub trait CborStoreExt: CborStore {
/// mhType := uint64(mh.BLAKE2B_MIN + 31)
/// // 45569 + 31 = 45600 = 0xb220
/// ```
#[allow(clippy::disallowed_types)]
fn default_code() -> Code {
Code::Blake2b256
}
Expand Down

0 comments on commit e5bc4db

Please sign in to comment.