commit 77f35d8fc62fb899aa7faf9e0f884d695365631f
parent 4c920562a6ab6246ea6d2d96dd1720d33e37afdf
Author: Antoine A <>
Date: Wed, 18 Mar 2026 12:00:07 +0100
common: clean code
Diffstat:
12 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/Makefile b/Makefile
@@ -37,6 +37,7 @@ install: build install-nobuild-files
.PHONY: check
check: install-nobuild-files
+ cargo clippy --all-targets
cargo test
.PHONY: doc
diff --git a/common/taler-api/src/json.rs b/common/taler-api/src/json.rs
@@ -118,7 +118,7 @@ where
let mut buf = [0; MAX_BODY_LENGTH];
let (decompressed, code) =
zlib_rs::decompress_slice(&mut buf, &bytes, InflateConfig::default());
- dbg!(code);
+ dbg!(code);
match code {
ReturnCode::Ok => Bytes::copy_from_slice(decompressed),
ReturnCode::BufError => {
diff --git a/common/taler-api/src/subject.rs b/common/taler-api/src/subject.rs
@@ -126,7 +126,7 @@ pub enum OutgoingSubjectErr {
Url(#[from] url::ParseError),
}
-/// Parse a talerable outgoing tranfer subject
+/// Parse a talerable outgoing transfer subject
pub fn parse_outgoing(subject: &str) -> Result<OutgoingSubject, OutgoingSubjectErr> {
let mut parts = subject.split(' ');
let first = parts.next().ok_or(OutgoingSubjectErr::MissingParts)?;
@@ -372,7 +372,7 @@ fn parse() {
&standard[1..], // Check fail if missing char
//"2MZT6RS3RVB3B0E2RDMYW0YRA3Y0VPHYV0CYDE6XBB0YMPFXCEG0", // Check fail if not a valid key
] {
- assert_eq!(parse_incoming_unstructured(&case), Ok(None));
+ assert_eq!(parse_incoming_unstructured(case), Ok(None));
}
if ty == IncomingType::kyc {
diff --git a/common/taler-api/tests/api.rs b/common/taler-api/tests/api.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2024-2025 Taler Systems SA
+ Copyright (C) 2024, 2025, 2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -80,7 +80,7 @@ async fn outgoing_history() {
.post("/taler-wire-gateway/transfer")
.json(&json!({
"request_uid": HashCode::rand(),
- "amount": amount(&format!("EUR:0.0{i}")),
+ "amount": amount(format!("EUR:0.0{i}")),
"exchange_base_url": url("http://exchange.taler"),
"wtid": ShortHashCode::rand(),
"credit_account": url("payto://test"),
diff --git a/common/taler-api/tests/common/db.rs b/common/taler-api/tests/common/db.rs
@@ -229,7 +229,7 @@ pub async fn add_incoming(
} else {
AddIncomingResult::Success {
id: r.try_get_safeu64("out_tx_row_id")?,
- created_at: r.try_get_timestamp("out_created_at")?.into(),
+ created_at: r.try_get_timestamp("out_created_at")?,
}
})
})
diff --git a/common/taler-common/src/config.rs b/common/taler-common/src/config.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2025 Taler Systems SA
+ Copyright (C) 2025, 2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -996,7 +996,7 @@ mod test {
let second_file = std::fs::File::create_new(&second_path).unwrap();
second_file
- .set_permissions(Permissions::from_mode(0222))
+ .set_permissions(Permissions::from_mode(0o222))
.unwrap();
check_err(format!(
"Could not read config at '{second_path_fmt}': permission denied"
@@ -1027,7 +1027,7 @@ mod test {
#[test]
fn parsing() {
- let check = |err: &str, content: &str| check_err(err, Config::from_mem(&content));
+ let check = |err: &str, content: &str| check_err(err, Config::from_mem(content));
check(
"Expected section header, option assignment or directive at 'mem:1'",
@@ -1107,7 +1107,7 @@ mod test {
check_err(
format!(
"Invalid {ty} option 'value' in section 'section': {}",
- error_fmt(&raw)
+ error_fmt(raw)
),
lambda(&cfg.section("section"), "value").require(),
)
diff --git a/common/taler-common/src/types/iban.rs b/common/taler-common/src/types/iban.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2025 Taler Systems SA
+ Copyright (C) 2025, 2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -305,7 +305,7 @@ fn parse_iban() {
// Random
let rand = IBAN::random(iban.country());
- let parsed = IBAN::from_str(&rand.to_string()).unwrap();
+ let parsed = IBAN::from_str(rand.as_ref()).unwrap();
assert_eq!(rand, parsed);
}
@@ -317,7 +317,7 @@ fn parse_iban() {
("FRANCE123456", IbanErrorKind::Malformed),
("DE44500105175407324932", IbanErrorKind::Checksum(28)),
] {
- let iban = IBAN::from_str(&invalid).unwrap_err();
+ let iban = IBAN::from_str(invalid).unwrap_err();
assert_eq!(iban.kind, err);
}
}
@@ -332,7 +332,7 @@ fn parse_bic() {
("BNPAFRPP", ("BNPA", "FR", "PP", None)), // BNP Paribas, France
("INGBNL2A", ("INGB", "NL", "2A", None)), // ING Bank, Netherlands
] {
- let bic = BIC::from_str(&valid).unwrap();
+ let bic = BIC::from_str(valid).unwrap();
assert_eq!(
(
bic.bank_code(),
@@ -352,7 +352,7 @@ fn parse_bic() {
("DEUTD3FF", BicErrorKind::CountryCode),
("DEUTDEFF@@1", BicErrorKind::Invalid),
] {
- let bic = BIC::from_str(&invalid).unwrap_err();
+ let bic = BIC::from_str(invalid).unwrap_err();
assert_eq!(bic.kind, err, "{invalid}");
}
}
diff --git a/taler-cyclos/src/db.rs b/taler-cyclos/src/db.rs
@@ -926,7 +926,7 @@ mod test {
};
// Insert
assert_eq!(
- db::register_tx_in(db, &tx, &first, &now)
+ db::register_tx_in(db, &tx, first, &now)
.await
.expect("register tx in"),
AddIncomingResult::Success {
@@ -943,7 +943,7 @@ mod test {
valued_at: later,
..tx.clone()
},
- &first,
+ first,
&now
)
.await
@@ -963,7 +963,7 @@ mod test {
valued_at: later,
..tx
},
- &second,
+ second,
&now
)
.await
@@ -1316,7 +1316,7 @@ mod test {
.expect("transfer"),
TransferResult::Success {
id: 2,
- initiated_at: later.into()
+ initiated_at: later
}
);
@@ -1386,7 +1386,7 @@ mod test {
&TxIn {
transfer_id: 12,
tx_id: None,
- amount: amount.clone(),
+ amount,
subject: "subject".to_owned(),
debtor_id: 31000163100000000,
debtor_name: "Name".to_string(),
@@ -1411,7 +1411,7 @@ mod test {
&TxIn {
transfer_id: 13,
tx_id: None,
- amount: amount.clone(),
+ amount,
subject: "subject".to_owned(),
debtor_id: 31000163100000000,
debtor_name: "Name".to_string(),
diff --git a/taler-cyclos/tests/api.rs b/taler-cyclos/tests/api.rs
@@ -100,7 +100,7 @@ async fn outgoing_history() {
async move {
let mut conn = acquire.await.unwrap();
db::register_tx_out(
- &mut *conn,
+ &mut conn,
&db::TxOut {
transfer_id: i as i64,
tx_id: if i % 2 == 0 {
diff --git a/taler-magnet-bank/src/db.rs b/taler-magnet-bank/src/db.rs
@@ -882,7 +882,7 @@ mod test {
let date = Zoned::now().date();
let later = date.tomorrow().unwrap();
let tx = TxIn {
- code: code,
+ code,
amount: amount("EUR:10"),
subject: "subject".to_owned(),
debtor: magnet_payto(
@@ -893,7 +893,7 @@ mod test {
};
// Insert
assert_eq!(
- register_tx_in(db, &tx, &first, &now)
+ register_tx_in(db, &tx, first, &now)
.await
.expect("register tx in"),
AddIncomingResult::Success {
@@ -910,7 +910,7 @@ mod test {
value_date: later,
..tx.clone()
},
- &first,
+ first,
&now
)
.await
@@ -930,7 +930,7 @@ mod test {
value_date: later,
..tx
},
- &second,
+ second,
&now
)
.await
@@ -1322,7 +1322,7 @@ mod test {
make_transfer(&mut db, &req, &now).await.expect("transfer"),
TransferResult::Success {
id: 1,
- initiated_at: now.into()
+ initiated_at: now
}
);
// Idempotent
@@ -1332,7 +1332,7 @@ mod test {
.expect("transfer"),
TransferResult::Success {
id: 1,
- initiated_at: now.into()
+ initiated_at: now
}
);
// Request UID reuse
@@ -1378,7 +1378,7 @@ mod test {
.expect("transfer"),
TransferResult::Success {
id: 2,
- initiated_at: later.into()
+ initiated_at: later
}
);
diff --git a/taler-magnet-bank/src/lib.rs b/taler-magnet-bank/src/lib.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2025 Taler Systems SA
+ Copyright (C) 2025, 2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -221,7 +221,7 @@ mod test {
let hu_payto: HuIban = iban_payto.into_inner().try_into().unwrap();
assert_eq!(hu_payto.bban(), account);
// Roundtrip
- let iban = HuIban::from_bban(&account).unwrap();
+ let iban = HuIban::from_bban(account).unwrap();
let payto = iban.as_payto();
assert_eq!(payto, valid);
}
diff --git a/taler-magnet-bank/tests/api.rs b/taler-magnet-bank/tests/api.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2025 Taler Systems SA
+ Copyright (C) 2025, 2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -97,7 +97,7 @@ async fn outgoing_history() {
let mut conn = acquire.await.unwrap();
let now = Zoned::now().date();
db::register_tx_out(
- &mut *conn,
+ &mut conn,
&db::TxOut {
code: i as u64,
amount: amount("EUR:10"),