Skip to content

Commit 685fc62

Browse files
dev: Use expect rather than allow (#184)
To prevent stale `#[allow(...)]`s, this PR configures `clippy` to reject them in favour of the `#[expect(..., reason="...")]` attribute. In the process, it performs a few clean-ups: - All `allow`s for panic/expect/unwrap in tests are removed. They are unnecessary, given our clippy.toml file: ```toml allow-unwrap-in-tests = true allow-expect-in-tests = true allow-panic-in-tests = true ``` - (Plausible) reasons are added where they were missing - All lints are set to `warn`. No need to use `deny`, since we fail on warnings in CI.
1 parent fae0ddb commit 685fc62

118 files changed

Lines changed: 216 additions & 226 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ license = "Apache-2.0"
2020
repository = "https://github.com/Firma-AI/openfirma"
2121

2222
[workspace.lints.clippy]
23-
pedantic = { level = "deny", priority = -1 }
23+
pedantic = { level = "warn", priority = -1 }
2424
nursery = { level = "warn", priority = -1 }
25-
unwrap_used = "deny"
26-
expect_used = "deny"
27-
panic = "deny"
25+
unwrap_used = "warn"
26+
expect_used = "warn"
27+
panic = "warn"
2828
missing_const_for_fn = "allow"
29+
allow_attributes = "warn"
2930

3031
[workspace.lints.rust]
31-
unsafe_code = "deny"
32+
unsafe_code = "warn"
3233

3334
[workspace.dependencies]
3435
anyhow = "1"

crates/firma-authority/src/authorized_clients.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ struct AuthorizedClientsFile {
9494
}
9595

9696
#[derive(Deserialize)]
97-
#[allow(dead_code)]
97+
#[expect(
98+
dead_code,
99+
reason = "backward-compatible TOML schema accepts metadata fields that serde deserializes even when the loader ignores them"
100+
)]
98101
struct AuthorizedEntry {
99102
#[serde(default)]
100103
cn: Option<String>,
@@ -112,7 +115,6 @@ struct ClientEntry {
112115
}
113116

114117
#[cfg(test)]
115-
#[allow(clippy::unwrap_used, clippy::panic)]
116118
mod tests {
117119
use super::*;
118120
use std::io::Write as _;

crates/firma-authority/src/cedar_loader.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ fn compute_version_hash(policies: &str, schema: &str) -> String {
326326
}
327327

328328
#[cfg(test)]
329-
#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
330329
mod tests {
331330
use super::*;
332331
use std::fs;

crates/firma-authority/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ pub enum ConfigError {
283283
}
284284

285285
#[cfg(test)]
286-
#[allow(clippy::unwrap_used, clippy::panic)]
287286
mod tests {
288287
use super::*;
289288

crates/firma-authority/src/issuance.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ pub async fn issue_capability(
109109
}
110110

111111
#[cfg(test)]
112-
#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
113112
mod tests {
114113
use super::*;
115114
use pasetors::keys::{AsymmetricKeyPair, Generate};

crates/firma-authority/src/revocation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ impl RevocationStoreWatcher {
424424
}
425425

426426
#[cfg(test)]
427-
#[allow(clippy::unwrap_used, clippy::panic)]
428427
mod tests {
429428
use super::*;
430429

crates/firma-authority/src/server.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ where
239239
// Per-mode server future builders
240240
// ---------------------------------------------------------------------------
241241

242-
#[allow(clippy::too_many_arguments)]
242+
#[expect(
243+
clippy::too_many_arguments,
244+
reason = "mTLS server construction needs explicit TLS paths, services, listener, and shutdown signal"
245+
)]
243246
async fn build_mtls_future<F, H>(
244247
cert_path: &Path,
245248
key_path: &Path,

crates/firma-authority/src/service.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ pub(crate) fn clamp_ttl(requested: i32, max: i32) -> i32 {
528528
}
529529

530530
#[cfg(test)]
531-
#[allow(clippy::unwrap_used, clippy::panic)]
532531
mod tests {
533532
use super::*;
534533

crates/firma-authority/src/startup/log_contract.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub fn log_ready_sequence(report: &StartupReport<'_>) {
3939
}
4040

4141
#[cfg(test)]
42-
#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
4342
mod tests {
4443
use super::*;
4544
use std::path::PathBuf;

crates/firma-authority/src/tls_verifier.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ fn extract_identity(cert_der: &CertificateDer<'_>) -> Option<String> {
158158
}
159159

160160
#[cfg(test)]
161-
#[allow(clippy::unwrap_used, clippy::panic, clippy::expect_used)]
162161
mod tests {
163162
use super::*;
164163
fn make_allow_list(ids: &[&str]) -> Arc<AuthorizedClientSet> {

0 commit comments

Comments
 (0)