Skip to content

Commit f3cc562

Browse files
committed
clippy: auto fix
1 parent 63f8b6f commit f3cc562

File tree

13 files changed

+29
-32
lines changed

13 files changed

+29
-32
lines changed

src/auth.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ impl AuthorizationService {
2929

3030
let claims = UserClaims { user, exp: exp_date };
3131

32-
let token = encode(&Header::default(), &claims, &EncodingKey::from_secret(key)).unwrap();
33-
34-
token
32+
encode(&Header::default(), &claims, &EncodingKey::from_secret(key)).unwrap()
3533
}
3634

3735
pub async fn verify_jwt(&self, token: &str) -> Result<UserClaims, ServiceError> {

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ impl Configuration {
135135
eprintln!("Creating config file..");
136136
let config = Configuration::default();
137137
let _ = config.save_to_file().await;
138-
return Err(ConfigError::Message(format!(
139-
"Please edit the config.TOML in the root folder and restart the tracker."
140-
)));
138+
return Err(ConfigError::Message(
139+
"Please edit the config.TOML in the root folder and restart the tracker.".to_string(),
140+
));
141141
}
142142

143143
let torrust_config: TorrustConfig = match config.try_into() {

src/databases/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::models::tracker_key::TrackerKey;
1111
use crate::models::user::{User, UserAuthentication, UserCompact, UserProfile};
1212

1313
/// Database drivers.
14-
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
14+
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
1515
pub enum DatabaseDriver {
1616
Sqlite3,
1717
Mysql,

src/databases/mysql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl Database for MysqlDatabase {
323323
i += 1;
324324
}
325325
}
326-
if category_filters.len() > 0 {
326+
if !category_filters.is_empty() {
327327
format!(
328328
"INNER JOIN torrust_categories tc ON tt.category_id = tc.category_id AND ({}) ",
329329
category_filters

src/databases/sqlite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl Database for SqliteDatabase {
318318
i += 1;
319319
}
320320
}
321-
if category_filters.len() > 0 {
321+
if !category_filters.is_empty() {
322322
format!(
323323
"INNER JOIN torrust_categories tc ON tt.category_id = tc.category_id AND ({}) ",
324324
category_filters

src/errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::databases::database::DatabaseError;
1010

1111
pub type ServiceResult<V> = Result<V, ServiceError>;
1212

13-
#[derive(Debug, Display, PartialEq, Error)]
13+
#[derive(Debug, Display, PartialEq, Eq, Error)]
1414
#[allow(dead_code)]
1515
pub enum ServiceError {
1616
#[display(fmt = "internal server error")]
@@ -182,7 +182,6 @@ impl ResponseError for ServiceError {
182182
HttpResponseBuilder::new(self.status_code())
183183
.append_header((header::CONTENT_TYPE, "application/json; charset=UTF-8"))
184184
.body(serde_json::to_string(&ErrorToResponse { error: self.to_string() }).unwrap())
185-
.into()
186185
}
187186
}
188187

src/models/torrent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::models::torrent_file::Torrent;
44
use crate::routes::torrent::CreateTorrent;
55

66
#[allow(dead_code)]
7-
#[derive(Debug, PartialEq, Serialize, Deserialize, sqlx::FromRow)]
7+
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
88
pub struct TorrentListing {
99
pub torrent_id: i64,
1010
pub uploader: String,

src/models/torrent_file.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ use sha1::{Digest, Sha1};
66
use crate::config::Configuration;
77
use crate::utils::hex::{bytes_to_hex, hex_to_bytes};
88

9-
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
9+
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
1010
pub struct TorrentNode(String, i64);
1111

12-
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
12+
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
1313
pub struct TorrentFile {
1414
pub path: Vec<String>,
1515
pub length: i64,
1616
#[serde(default)]
1717
pub md5sum: Option<String>,
1818
}
1919

20-
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
20+
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
2121
pub struct TorrentInfo {
2222
pub name: String,
2323
#[serde(default)]
@@ -160,7 +160,7 @@ impl Torrent {
160160

161161
pub fn file_size(&self) -> i64 {
162162
if self.info.length.is_some() {
163-
return self.info.length.unwrap();
163+
self.info.length.unwrap()
164164
} else {
165165
match &self.info.files {
166166
None => 0,
@@ -176,15 +176,15 @@ impl Torrent {
176176
}
177177
}
178178

179-
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
179+
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
180180
pub struct DbTorrentFile {
181181
pub path: Option<String>,
182182
pub length: i64,
183183
#[serde(default)]
184184
pub md5sum: Option<String>,
185185
}
186186

187-
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
187+
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
188188
pub struct DbTorrentInfo {
189189
pub name: String,
190190
pub pieces: String,
@@ -194,7 +194,7 @@ pub struct DbTorrentInfo {
194194
pub root_hash: i64,
195195
}
196196

197-
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
197+
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
198198
pub struct DbTorrentAnnounceUrl {
199199
pub tracker_url: String,
200200
}

src/models/user.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct UserAuthentication {
1313
pub password_hash: String,
1414
}
1515

16-
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, sqlx::FromRow)]
16+
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, sqlx::FromRow)]
1717
pub struct UserProfile {
1818
pub user_id: i64,
1919
pub username: String,

src/routes/category.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub async fn delete_category(
5757
return Err(ServiceError::Unauthorized);
5858
}
5959

60-
let _ = app_data.database.delete_category(&payload.name).await?;
60+
app_data.database.delete_category(&payload.name).await?;
6161

6262
Ok(HttpResponse::Ok().json(OkResponse {
6363
data: payload.name.clone(),

0 commit comments

Comments
 (0)