diff --git a/Cargo.toml b/Cargo.toml index 0a4edd0eb..f1fdc317a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,5 +24,8 @@ homepage = "https://sentry.io/welcome/" edition = "2021" rust-version = "1.88" +[workspace.lints.clippy] +arithmetic-side-effects.level = "warn" + [workspace.lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] } diff --git a/sentry-contexts/src/utils.rs b/sentry-contexts/src/utils.rs index 8acd9c83b..6c311a36e 100644 --- a/sentry-contexts/src/utils.rs +++ b/sentry-contexts/src/utils.rs @@ -54,7 +54,7 @@ mod model_support { pub fn get_macos_version() -> Option { let version = sysctlbyname_call("kern.osproductversion")?; - let dot_count = version.split('.').count() - 1; + let dot_count = version.split('.').count().saturating_sub(1); if dot_count < 2 { return Some(version + ".0"); } diff --git a/sentry-core/src/logger.rs b/sentry-core/src/logger.rs index 293bf3740..0a0e4db66 100644 --- a/sentry-core/src/logger.rs +++ b/sentry-core/src/logger.rs @@ -25,13 +25,13 @@ macro_rules! logger_log { "sentry.message.template".to_owned(), $crate::protocol::LogAttribute($crate::protocol::Value::from($fmt)) ); - let mut i = 0; + let mut i = 0usize; $( attributes.insert( format!("sentry.message.parameter.{}", i), $crate::protocol::LogAttribute($crate::protocol::Value::from($arg)) ); - i += 1; + i = i.checked_add(1).expect("number of parametrs should not overflow usize"); )* let _ = i; // avoid triggering the `unused_assignments` lint diff --git a/sentry-core/src/session.rs b/sentry-core/src/session.rs index e9fd2f298..baa8a22d5 100644 --- a/sentry-core/src/session.rs +++ b/sentry-core/src/session.rs @@ -2,6 +2,8 @@ //! //! +#![expect(clippy::arithmetic_side_effects)] // https://github.com/getsentry/sentry-rust/issues/1117 + #[cfg(feature = "release-health")] pub use session_impl::*; diff --git a/sentry-types/src/protocol/envelope.rs b/sentry-types/src/protocol/envelope.rs index 9ce4c5610..0d2c28823 100644 --- a/sentry-types/src/protocol/envelope.rs +++ b/sentry-types/src/protocol/envelope.rs @@ -1,3 +1,5 @@ +#![expect(clippy::arithmetic_side_effects)] // https://github.com/getsentry/sentry-rust/issues/1118 + use std::{borrow::Cow, io::Write, path::Path, time::SystemTime}; use serde::{Deserialize, Serialize}; diff --git a/sentry/src/transports/ratelimit.rs b/sentry/src/transports/ratelimit.rs index b47f9e533..2a9803197 100644 --- a/sentry/src/transports/ratelimit.rs +++ b/sentry/src/transports/ratelimit.rs @@ -1,3 +1,5 @@ +#![expect(clippy::arithmetic_side_effects)] // https://github.com/getsentry/sentry-rust/issues/1115 + use httpdate::parse_http_date; use std::time::{Duration, SystemTime};