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

Enable lints for discussion #356

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fwdctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ futures-util = "0.3.29"
assert_cmd = "2.0.7"
predicates = "3.0.1"
serial_test = "2.0.0"

[lints.rust]
unsafe_code = "deny"

[lints.clippy]
unwrap_used = "warn"
indexing_slicing = "warn"
explicit_deref_methods = "warn"
missing_const_for_fn = "warn"
4 changes: 2 additions & 2 deletions fwdctl/src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub struct Options {
max_revisions: u32,
}

pub fn initialize_db_config(opts: &Options) -> DbConfig {
pub(super) const fn initialize_db_config(opts: &Options) -> DbConfig {
DbConfig {
meta_ncached_pages: opts.meta_ncached_pages,
meta_ncached_files: opts.meta_ncached_files,
Expand Down Expand Up @@ -279,7 +279,7 @@ pub fn initialize_db_config(opts: &Options) -> DbConfig {
}
}

pub async fn run(opts: &Options) -> Result<(), api::Error> {
pub(super) async fn run(opts: &Options) -> Result<(), api::Error> {
let db_config = initialize_db_config(opts);
log::debug!("database configuration parameters: \n{:?}\n", db_config);

Expand Down
2 changes: 1 addition & 1 deletion fwdctl/src/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Options {
pub db: String,
}

pub async fn run(opts: &Options) -> Result<(), api::Error> {
pub(super) async fn run(opts: &Options) -> Result<(), api::Error> {
log::debug!("deleting key {:?}", opts);
let cfg = DbConfig::builder()
.truncate(false)
Expand Down
4 changes: 2 additions & 2 deletions fwdctl/src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Options {
pub db: String,
}

pub async fn run(opts: &Options) -> Result<(), api::Error> {
pub(super) async fn run(opts: &Options) -> Result<(), api::Error> {
log::debug!("dump database {:?}", opts);
let cfg = DbConfig::builder()
.truncate(false)
Expand All @@ -37,7 +37,7 @@ pub async fn run(opts: &Options) -> Result<(), api::Error> {
match stream.next().await {
None => break,
Some(Ok((key, value))) => {
println!("'{}': '{}'", u8_to_string(&key), u8_to_string(&value))
println!("'{}': '{}'", u8_to_string(&key), u8_to_string(&value));
}
Some(Err(e)) => return Err(e),
}
Expand Down
4 changes: 2 additions & 2 deletions fwdctl/src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Options {
pub db: String,
}

pub async fn run(opts: &Options) -> Result<(), api::Error> {
pub(super) async fn run(opts: &Options) -> Result<(), api::Error> {
log::debug!("get key value pair {:?}", opts);
let cfg = DbConfig::builder()
.truncate(false)
Expand All @@ -39,7 +39,7 @@ pub async fn run(opts: &Options) -> Result<(), api::Error> {
match rev.val(opts.key.as_bytes()).await {
Ok(Some(val)) => {
let s = String::from_utf8_lossy(val.as_ref());
println!("{:?}", s);
println!("{s:?}");
Ok(())
}
Ok(None) => {
Expand Down
2 changes: 1 addition & 1 deletion fwdctl/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Options {
pub db: String,
}

pub async fn run(opts: &Options) -> Result<(), api::Error> {
pub(super) async fn run(opts: &Options) -> Result<(), api::Error> {
log::debug!("inserting key value pair {:?}", opts);
let cfg = DbConfig::builder()
.truncate(false)
Expand Down
4 changes: 2 additions & 2 deletions fwdctl/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Options {
pub db: String,
}

pub async fn run(opts: &Options) -> Result<(), api::Error> {
pub(super) async fn run(opts: &Options) -> Result<(), api::Error> {
log::debug!("root hash {:?}", opts);
let cfg = DbConfig::builder()
.truncate(false)
Expand All @@ -32,6 +32,6 @@ pub async fn run(opts: &Options) -> Result<(), api::Error> {
let db = Db::new(opts.db.clone(), &cfg.build()).await?;

let root = db.root_hash().await?;
println!("{:X?}", root);
println!("{root:X?}");
Ok(())
}