refactor: enable clippy::arithmetic_side_effects lint

This commit is contained in:
link2xt
2026-02-14 10:12:15 +00:00
committed by l
parent 5a06d08613
commit 10b93b3943
42 changed files with 104 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ use crate::stock_str;
/// Shortens a string to a specified length and adds "[...]" to the
/// end of the shortened string.
#[expect(clippy::arithmetic_side_effects)]
pub(crate) fn truncate(buf: &str, approx_chars: usize) -> Cow<'_, str> {
let count = buf.chars().count();
if count <= approx_chars + DC_ELLIPSIS.len() {
@@ -77,6 +78,7 @@ pub(crate) fn truncate(buf: &str, approx_chars: usize) -> Cow<'_, str> {
/// end of the shortened string.
///
/// returns tuple with the String and a boolean whether is was truncated
#[expect(clippy::arithmetic_side_effects)]
pub(crate) fn truncate_by_lines(
buf: String,
max_lines: usize,
@@ -256,6 +258,7 @@ async fn maybe_warn_on_bad_time(context: &Context, now: i64, known_past_timestam
false
}
#[expect(clippy::arithmetic_side_effects)]
async fn maybe_warn_on_outdated(context: &Context, now: i64, approx_compile_time: i64) {
if now > approx_compile_time + DC_OUTDATED_WARNING_DAYS * 24 * 60 * 60 {
let mut msg = Message::new_text(stock_str::update_reminder_msg_body(context).await);
@@ -649,6 +652,7 @@ impl ToOption<String> for Option<i32> {
}
}
#[expect(clippy::arithmetic_side_effects)]
pub fn remove_subject_prefix(last_subject: &str) -> String {
let subject_start = if last_subject.starts_with("Chat:") {
0
@@ -671,6 +675,7 @@ pub fn remove_subject_prefix(last_subject: &str) -> String {
// Types and methods to create hop-info for message-info
#[expect(clippy::arithmetic_side_effects)]
fn extract_address_from_receive_header<'a>(header: &'a str, start: &str) -> Option<&'a str> {
let header_len = header.len();
header.find(start).and_then(|mut begin| {
@@ -683,6 +688,7 @@ fn extract_address_from_receive_header<'a>(header: &'a str, start: &str) -> Opti
})
}
#[expect(clippy::arithmetic_side_effects)]
pub(crate) fn parse_receive_header(header: &str) -> String {
let header = header.replace(&['\r', '\n'][..], "");
let mut hop_info = String::from("Hop: ");
@@ -789,6 +795,7 @@ pub(crate) fn normalize_text(text: &str) -> Option<String> {
}
/// Increments `*t` and checks that it equals to `expected` after that.
#[expect(clippy::arithmetic_side_effects)]
pub(crate) fn inc_and_check<T: PrimInt + AddAssign + std::fmt::Debug>(
t: &mut T,
expected: T,