run clippy for no, default, and all features

This should be good enough for now.
This commit is contained in:
Charles Hall 2024-04-27 20:23:59 -07:00
parent d21221d54e
commit 806fabc4c7
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
3 changed files with 40 additions and 13 deletions

View file

@ -47,10 +47,36 @@ RUSTDOCFLAGS="-D warnings" cargo doc \
"""
[[task]]
name = "cargo-clippy"
name = "cargo-clippy/none"
group = "lints"
script = """
cargo clippy \
--workspace \
--all-targets \
--no-default-features \
--color=always \
-- \
-D warnings
"""
[[task]]
name = "cargo-clippy/default"
group = "lints"
script = "cargo clippy --workspace --all-targets --color=always -- -D warnings"
[[task]]
name = "cargo-clippy/all"
group = "lints"
script = """
cargo clippy \
--workspace \
--all-targets \
--all-features \
--color=always \
-- \
-D warnings
"""
[[task]]
name = "cargo"
group = "tests"

View file

@ -210,6 +210,10 @@ impl KeyValueDatabase {
}
/// Load an existing database or create a new one.
#[cfg_attr(
not(any(feature = "rocksdb", feature = "sqlite")),
allow(unreachable_code)
)]
pub async fn load_or_create(config: Config) -> Result<()> {
Self::check_db_setup(&config)?;
@ -218,19 +222,15 @@ impl KeyValueDatabase {
.map_err(|_| Error::BadConfig("Database folder doesn't exists and couldn't be created (e.g. due to missing permissions). Please create the database folder yourself."))?;
}
#[cfg_attr(
not(any(feature = "rocksdb", feature = "sqlite")),
allow(unused_variables)
)]
let builder: Arc<dyn KeyValueDatabaseEngine> = match &*config.database_backend {
"sqlite" => {
#[cfg(not(feature = "sqlite"))]
return Err(Error::BadConfig("Database backend not found."));
#[cfg(feature = "sqlite")]
Arc::new(Arc::<abstraction::sqlite::Engine>::open(&config)?)
}
"rocksdb" => {
#[cfg(not(feature = "rocksdb"))]
return Err(Error::BadConfig("Database backend not found."));
#[cfg(feature = "rocksdb")]
Arc::new(Arc::<abstraction::rocksdb::Engine>::open(&config)?)
}
#[cfg(feature = "sqlite")]
"sqlite" => Arc::new(Arc::<abstraction::sqlite::Engine>::open(&config)?),
#[cfg(feature = "rocksdb")]
"rocksdb" => Arc::new(Arc::<abstraction::rocksdb::Engine>::open(&config)?),
_ => {
return Err(Error::BadConfig("Database backend not found."));
}

View file

@ -18,6 +18,7 @@ pub fn millis_since_unix_epoch() -> u64 {
.as_millis() as u64
}
#[cfg(any(feature = "rocksdb", feature = "sqlite"))]
pub fn increment(old: Option<&[u8]>) -> Option<Vec<u8>> {
let number = match old.map(|bytes| bytes.try_into()) {
Some(Ok(bytes)) => {