diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c784734d..cdcc3f4a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --all + args: --workspace --tests --examples build_and_test: diff --git a/src/blob.rs b/src/blob.rs index 3fc3028c0..4abb13fa7 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -685,7 +685,7 @@ mod tests { let (stem, ext) = BlobObject::sanitise_name("foo?.bar"); assert!(stem.contains("foo")); - assert!(!stem.contains("?")); + assert!(!stem.contains('?')); assert_eq!(ext, ".bar"); let (stem, ext) = BlobObject::sanitise_name("no-extension"); @@ -698,10 +698,10 @@ mod tests { assert!(!stem.contains("ignored")); assert!(stem.contains("this")); assert!(stem.contains("forbidden")); - assert!(!stem.contains("/")); - assert!(!stem.contains("\\")); - assert!(!stem.contains(":")); - assert!(!stem.contains("*")); - assert!(!stem.contains("?")); + assert!(!stem.contains('/')); + assert!(!stem.contains('\\')); + assert!(!stem.contains(':')); + assert!(!stem.contains('*')); + assert!(!stem.contains('?')); } } diff --git a/src/configure/auto_mozilla.rs b/src/configure/auto_mozilla.rs index d0c18b4b7..f434cc1a1 100644 --- a/src/configure/auto_mozilla.rs +++ b/src/configure/auto_mozilla.rs @@ -268,6 +268,8 @@ pub(crate) async fn moz_autoconfigure( #[cfg(test)] mod tests { + #![allow(clippy::indexing_slicing)] + use super::*; #[test] diff --git a/src/configure/auto_outlook.rs b/src/configure/auto_outlook.rs index c4a8c6a43..091901e63 100644 --- a/src/configure/auto_outlook.rs +++ b/src/configure/auto_outlook.rs @@ -209,6 +209,8 @@ pub(crate) async fn outlk_autodiscover( #[cfg(test)] mod tests { + #![allow(clippy::indexing_slicing)] + use super::*; #[test] diff --git a/src/configure/mod.rs b/src/configure/mod.rs index 098e2bfe0..8e303c1fc 100644 --- a/src/configure/mod.rs +++ b/src/configure/mod.rs @@ -498,6 +498,7 @@ pub enum Error { #[cfg(test)] mod tests { + #![allow(clippy::indexing_slicing)] use super::*; use crate::config::*; diff --git a/src/context.rs b/src/context.rs index d7d065bd1..d281a936f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -573,7 +573,7 @@ mod tests { let tmp = tempfile::tempdir().unwrap(); let dbfile = tmp.path().join("db.sqlite"); let blobdir = PathBuf::new(); - let res = Context::with_blobdir("FakeOS".into(), dbfile.into(), blobdir.into(), 1).await; + let res = Context::with_blobdir("FakeOS".into(), dbfile.into(), blobdir, 1).await; assert!(res.is_err()); } diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index bd4d28530..7bf950f17 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -2213,7 +2213,7 @@ mod tests { } else { panic!("Wrong item type"); }; - let msg = message::Message::load_from_db(&t.ctx, msg_id.clone()) + let msg = message::Message::load_from_db(&t.ctx, *msg_id) .await .unwrap(); assert_eq!(msg.is_dc_message, MessengerMessage::Yes); @@ -2264,7 +2264,7 @@ mod tests { chat::get_chat_msgs(&t.ctx, group_id, 0, None).await.len(), 1 ); - let msg = message::Message::load_from_db(&t.ctx, msg_id.clone()) + let msg = message::Message::load_from_db(&t.ctx, *msg_id) .await .unwrap(); assert_eq!(msg.state, MessageState::OutMdnRcvd); @@ -2352,7 +2352,7 @@ mod tests { } else { panic!("Wrong item type"); }; - let msg = message::Message::load_from_db(&t.ctx, msg_id.clone()) + let msg = message::Message::load_from_db(&t.ctx, *msg_id) .await .unwrap(); assert_eq!(msg.is_dc_message, MessengerMessage::Yes); diff --git a/src/dc_tools.rs b/src/dc_tools.rs index a6954c6b6..ad22ac6f8 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -639,6 +639,8 @@ pub(crate) fn improve_single_line_input(input: impl AsRef) -> String { #[cfg(test)] mod tests { + #![allow(clippy::indexing_slicing)] + use super::*; use std::convert::TryInto; diff --git a/src/key.rs b/src/key.rs index 35a588339..b9e88f8be 100644 --- a/src/key.rs +++ b/src/key.rs @@ -529,11 +529,11 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD #[test] fn test_from_slice_bad_data() { let mut bad_data: [u8; 4096] = [0; 4096]; - for i in 0..4096 { - bad_data[i] = (i & 0xff) as u8; + for (i, v) in bad_data.iter_mut().enumerate() { + *v = (i & 0xff) as u8; } for j in 0..(4096 / 40) { - let slice = &bad_data[j..j + 4096 / 2 + j]; + let slice = &bad_data.get(j..j + 4096 / 2 + j).unwrap(); assert!(SignedPublicKey::from_slice(slice).is_err()); assert!(SignedSecretKey::from_slice(slice).is_err()); } @@ -593,7 +593,7 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD let ctx0 = ctx.clone(); let thr0 = thread::spawn(move || async_std::task::block_on(SignedPublicKey::load_self(&ctx0))); - let ctx1 = ctx.clone(); + let ctx1 = ctx; let thr1 = thread::spawn(move || async_std::task::block_on(SignedPublicKey::load_self(&ctx1))); let res0 = thr0.join().unwrap(); diff --git a/src/location.rs b/src/location.rs index aba674b30..7bafb2bf2 100644 --- a/src/location.rs +++ b/src/location.rs @@ -723,6 +723,8 @@ pub(crate) async fn job_maybe_send_locations_ended( #[cfg(test)] mod tests { + #![allow(clippy::indexing_slicing)] + use super::*; use crate::test_utils::TestContext; @@ -772,7 +774,7 @@ mod tests { assert!(locations_ref[0].latitude < 51.423724f64); assert!(locations_ref[0].longitude >= 8.552556f64); assert!(locations_ref[0].longitude < 8.552557f64); - assert_eq!(locations_ref[0].accuracy, 0.0f64); + assert!(locations_ref[0].accuracy.abs() < f64::EPSILON); assert_eq!(locations_ref[0].timestamp, timestamp); } } diff --git a/src/message.rs b/src/message.rs index 861140850..b87aee441 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1893,8 +1893,7 @@ mod tests { ); assert_eq!( - get_summarytext_by_raw(Viewtype::Voice, no_text.as_ref(), &mut some_file, 50, &ctx) - .await, + get_summarytext_by_raw(Viewtype::Voice, no_text.as_ref(), &some_file, 50, &ctx).await, "Voice message" // file names are not added for voice messages ); @@ -1904,8 +1903,7 @@ mod tests { ); assert_eq!( - get_summarytext_by_raw(Viewtype::Audio, no_text.as_ref(), &mut some_file, 50, &ctx) - .await, + get_summarytext_by_raw(Viewtype::Audio, no_text.as_ref(), &some_file, 50, &ctx).await, "Audio \u{2013} foo.bar" // file name is added for audio ); @@ -1921,8 +1919,7 @@ mod tests { ); assert_eq!( - get_summarytext_by_raw(Viewtype::File, some_text.as_ref(), &mut some_file, 50, &ctx) - .await, + get_summarytext_by_raw(Viewtype::File, some_text.as_ref(), &some_file, 50, &ctx).await, "File \u{2013} foo.bar \u{2013} bla bla" // file name is added for files ); @@ -1930,7 +1927,7 @@ mod tests { asm_file.set(Param::File, "foo.bar"); asm_file.set_cmd(SystemMessage::AutocryptSetupMessage); assert_eq!( - get_summarytext_by_raw(Viewtype::File, no_text.as_ref(), &mut asm_file, 50, &ctx).await, + get_summarytext_by_raw(Viewtype::File, no_text.as_ref(), &asm_file, 50, &ctx).await, "Autocrypt Setup Message" // file name is not added for autocrypt setup messages ); } @@ -2007,7 +2004,7 @@ mod tests { let chatitems = chat::get_chat_msgs(&t.ctx, device_chat_id, 0, None).await; for chatitem in chatitems { if let ChatItem::Message { msg_id } = chatitem { - if let Ok(msg) = Message::load_from_db(&t.ctx, msg_id.clone()).await { + if let Ok(msg) = Message::load_from_db(&t.ctx, msg_id).await { if msg.get_viewtype() == Viewtype::Image { has_image = true; // just check that width/height are inside some reasonable ranges diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 89ead0a80..40a2b5cc0 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1318,6 +1318,8 @@ where #[cfg(test)] mod tests { + #![allow(clippy::indexing_slicing)] + use super::*; use crate::test_utils::*; diff --git a/src/param.rs b/src/param.rs index ae551cd6a..bb32af3de 100644 --- a/src/param.rs +++ b/src/param.rs @@ -475,8 +475,8 @@ mod tests { ); // Blob in blobdir, expect blob. - let bar = t.ctx.get_blobdir().join("bar"); - p.set(Param::File, bar.to_str().unwrap()); + let bar_path = t.ctx.get_blobdir().join("bar"); + p.set(Param::File, bar_path.to_str().unwrap()); let blob = p .get_blob(Param::File, &t.ctx, false) .await diff --git a/src/pgp.rs b/src/pgp.rs index ecfc5190e..73c6c3896 100644 --- a/src/pgp.rs +++ b/src/pgp.rs @@ -439,9 +439,9 @@ mod tests { let bob = bob_keypair(); TestKeys { alice_secret: alice.secret.clone(), - alice_public: alice.public.clone(), + alice_public: alice.public, bob_secret: bob.secret.clone(), - bob_public: bob.public.clone(), + bob_public: bob.public, } } } diff --git a/src/provider/mod.rs b/src/provider/mod.rs index 51055cd21..c217813bb 100644 --- a/src/provider/mod.rs +++ b/src/provider/mod.rs @@ -93,6 +93,8 @@ pub fn get_provider_info(addr: &str) -> Option<&Provider> { #[cfg(test)] mod tests { + #![allow(clippy::indexing_slicing)] + use super::*; #[test]