From 0b603df13921f905f6078b3a233277f2578df67e Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 24 Nov 2022 13:27:38 +0100 Subject: [PATCH] Add some clippy lints --- .drone.yml | 11 ++++++++--- Cargo.lock | 2 +- examples/federation/lib.rs | 13 ------------- examples/federation/main.rs | 4 ++-- examples/federation/objects/person.rs | 2 +- src/core/activity_queue.rs | 2 +- 6 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 examples/federation/lib.rs diff --git a/.drone.yml b/.drone.yml index e1e28d4..0dffff4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,11 +19,16 @@ steps: - cargo check --all --all-targets - name: cargo clippy - image: rust:1.61-bullseye + image: rust:1.65-bullseye commands: - rustup component add clippy - - cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity -D clippy::dbg_macro - - cargo clippy --workspace -- -D clippy::unwrap_used + - cargo clippy --workspace --tests --all-targets --all-features -- + -D warnings -D deprecated -D clippy::perf -D clippy::complexity + -D clippy::dbg_macro -D clippy::inefficient_to_string + -D clippy::items-after-statements -D clippy::implicit_clone + -D clippy::wildcard_imports -D clippy::cast_lossless + -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls + - cargo clippy --workspace --all-features -- -D clippy::unwrap_used - name: cargo test image: rust:1.61-bullseye diff --git a/Cargo.lock b/Cargo.lock index 5343ae8..668616f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "activitypub_federation" -version = "0.3.3" +version = "0.3.4" dependencies = [ "activitystreams-kinds", "actix-rt", diff --git a/examples/federation/lib.rs b/examples/federation/lib.rs deleted file mode 100644 index 87c421e..0000000 --- a/examples/federation/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -use rand::{distributions::Alphanumeric, thread_rng, Rng}; -use url::{ParseError, Url}; - -/// Just generate random url as object id. In a real project, you probably want to use -/// an url which contains the database id for easy retrieval (or store the random id in db). -pub fn generate_object_id(hostname: &str) -> Result { - let id: String = thread_rng() - .sample_iter(&Alphanumeric) - .take(7) - .map(char::from) - .collect(); - Url::parse(&format!("http://{}/objects/{}", hostname, id)) -} diff --git a/examples/federation/main.rs b/examples/federation/main.rs index 4e5f0f0..2c4964c 100644 --- a/examples/federation/main.rs +++ b/examples/federation/main.rs @@ -1,10 +1,10 @@ -use crate::{error::Error, instance::Instance, lib::generate_object_id, objects::note::MyPost}; +use crate::{error::Error, instance::Instance, utils::generate_object_id, objects::note::MyPost}; use tracing::log::LevelFilter; mod activities; mod error; mod instance; -mod lib; +mod utils; mod objects; #[actix_rt::main] diff --git a/examples/federation/objects/person.rs b/examples/federation/objects/person.rs index 3213d68..af92c53 100644 --- a/examples/federation/objects/person.rs +++ b/examples/federation/objects/person.rs @@ -2,7 +2,7 @@ use crate::{ activities::{accept::Accept, create_note::CreateNote, follow::Follow}, error::Error, instance::InstanceHandle, - lib::generate_object_id, + utils::generate_object_id, objects::note::MyPost, }; use activitypub_federation::{ diff --git a/src/core/activity_queue.rs b/src/core/activity_queue.rs index 698f561..9a9e292 100644 --- a/src/core/activity_queue.rs +++ b/src/core/activity_queue.rs @@ -144,7 +144,7 @@ async fn do_send( request_builder, task.activity.clone(), task.public_key.clone(), - task.private_key.to_owned(), + task.private_key.clone(), task.http_signature_compat, ) .await?;