Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy errors when running CI #808

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/bin/create_test_torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ fn main() {
// Attempt to create and write to the file
let mut file = match File::create(&file_path) {
Ok(file) => file,
Err(e) => panic!("Failed to create file {file_path:?}: {e}"),
Err(e) => panic!("Failed to create file {}: {e}", file_path.display()),
};

if let Err(e) = file.write_all(&bytes) {
panic!("Failed to write to file {file_path:?}: {e}");
panic!("Failed to write to file {}: {e}", file_path.display());
}

println!("File successfully written to {file_path:?}");
}
Err(e) => panic!("Error encoding torrent: {e}"),
};
}
}
2 changes: 1 addition & 1 deletion src/console/commands/seeder/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub async fn run() -> anyhow::Result<()> {
info!(target:"seeder", "Uploaded torrent: {}", json.yellow());
}
Err(err) => print!("Error uploading torrent {err:?}"),
};
}

if i != args.number_of_torrents {
sleep(Duration::from_secs(args.interval));
Expand Down
2 changes: 1 addition & 1 deletion src/mailer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lazy_static! {
println!("Parsing error(s): {e}");
::std::process::exit(1);
}
};
}

tera.autoescape_on(vec![".html", ".sql"]);
tera.register_filter("do_nothing", do_nothing_filter);
Expand Down
3 changes: 2 additions & 1 deletion src/services/torrent.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Torrent service.
use std::fmt::Write as _;
use std::sync::Arc;

use bittorrent_primitives::info_hash::InfoHash;
Expand Down Expand Up @@ -550,7 +551,7 @@ impl Index {

// Add trackers from torrent file to magnet link
for tracker in &torrent_response.trackers {
magnet.push_str(&format!("&tr={}", urlencoding::encode(tracker)));
let _ = write!(&mut magnet, "&tr={}", urlencoding::encode(tracker));
}

torrent_response.magnet_link = magnet;
Expand Down
2 changes: 1 addition & 1 deletion src/services/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl RegistrationService {

if self.user_profile_repository.verify_email(&user_id).await.is_err() {
return Err(ServiceError::DatabaseError);
};
}

Ok(true)
}
Expand Down
2 changes: 1 addition & 1 deletion src/web/api/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async fn start_server(
.serve(router.into_make_service_with_connect_info::<std::net::SocketAddr>())
.await
.expect("API server should be running"),
};
}
}

#[derive(Error, Debug)]
Expand Down
8 changes: 4 additions & 4 deletions src/web/api/server/v1/contexts/torrent/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,28 +336,28 @@ async fn build_add_torrent_request_from_payload(mut payload: Multipart) -> Resul
let data = field.bytes().await.unwrap();
if data.is_empty() {
continue;
};
}
title = String::from_utf8(data.to_vec()).map_err(|_| errors::Request::TitleIsNotValidUtf8)?;
}
"description" => {
let data = field.bytes().await.unwrap();
if data.is_empty() {
continue;
};
}
description = String::from_utf8(data.to_vec()).map_err(|_| errors::Request::DescriptionIsNotValidUtf8)?;
}
"category" => {
let data = field.bytes().await.unwrap();
if data.is_empty() {
continue;
};
}
category = String::from_utf8(data.to_vec()).map_err(|_| errors::Request::CategoryIsNotValidUtf8)?;
}
"tags" => {
let data = field.bytes().await.unwrap();
if data.is_empty() {
continue;
};
}
let string_data = String::from_utf8(data.to_vec()).map_err(|_| errors::Request::TagsArrayIsNotValidUtf8)?;
tags = serde_json::from_str(&string_data).map_err(|_| errors::Request::TagsArrayIsNotValidJson)?;
}
Expand Down
8 changes: 2 additions & 6 deletions tests/e2e/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl TestEnv {
pub fn provides_a_private_tracker(&self) -> bool {
if !self.is_shared() {
return false;
};
}

match self.server_settings() {
Some(settings) => settings.tracker.private,
Expand Down Expand Up @@ -148,11 +148,7 @@ impl TestEnv {
State::RunningShared => {
let connect_url_env_var = ENV_VAR_DB_CONNECT_URL;

if let Ok(connect_url) = env::var(connect_url_env_var) {
Some(connect_url)
} else {
None
}
env::var(connect_url_env_var).ok()
}
State::RunningIsolated => internal_connect_url,
State::Stopped => None,
Expand Down