Skip to content

Commit 8b50a24

Browse files
authored
refactor: clean up clippy warnings across workspace (#1556)
1 parent e74e57f commit 8b50a24

File tree

76 files changed

+653
-501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+653
-501
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ tracing-appender = { git = "https://github.com/CBenoit/tracing.git", rev = "4209
4141
# Declare the custom cfgs.
4242
unexpected_cfgs = { level = "warn", check-cfg = [
4343
'cfg(build_profile, values("dev","release","production"))',
44+
'cfg(tokio_unstable)',
4445
]}
4546

4647
# == Safer unsafe == #
@@ -58,7 +59,8 @@ keyword_idents = "warn"
5859
noop_method_call = "warn"
5960

6061
# == Compile-time / optimization == #
61-
unused_crate_dependencies = "warn"
62+
# TODO: re-enable after cleanup
63+
# unused_crate_dependencies = "warn"
6264
unused_macro_rules = "warn"
6365

6466
[workspace.dependencies]

crates/devolutions-agent-shared/src/date_version.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ impl fmt::Display for DateVersion {
7979

8080
#[cfg(test)]
8181
mod tests {
82+
#![allow(clippy::unwrap_used, reason = "test code can panic on errors")]
83+
8284
use super::*;
8385

8486
#[test]

crates/devolutions-agent-shared/src/update_json.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pub struct ProductUpdateInfo {
4444

4545
#[cfg(test)]
4646
mod tests {
47+
#![allow(clippy::unwrap_used, reason = "test code can panic on errors")]
48+
4749
use super::*;
4850

4951
#[test]

crates/devolutions-pedm-shared/devolutions-pedm-client-http/src/apis/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ pub struct APIClient {
88
}
99

1010
impl APIClient {
11-
pub fn new<C: hyper::client::connect::Connect>(configuration: Configuration<C>) -> APIClient
11+
pub fn new<C>(configuration: Configuration<C>) -> APIClient
1212
where
13-
C: Clone + std::marker::Send + Sync + 'static,
13+
C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync + 'static,
1414
{
1515
let rc = Rc::new(configuration);
1616

crates/devolutions-pedm-shared/devolutions-pedm-client-http/src/models/authenticode_signature_status.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use crate::models;
1212
use serde::{Deserialize, Serialize};
1313

14-
///
1514
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
1615
pub enum AuthenticodeSignatureStatus {
1716
#[serde(rename = "Valid")]

crates/devolutions-pedm-shared/devolutions-pedm-client-http/src/models/elevation_kind.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use crate::models;
1212
use serde::{Deserialize, Serialize};
1313

14-
///
1514
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
1615
pub enum ElevationKind {
1716
#[serde(rename = "AutoApprove")]

crates/devolutions-pedm-shared/devolutions-pedm-client-http/src/models/elevation_method.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use crate::models;
1212
use serde::{Deserialize, Serialize};
1313

14-
///
1514
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
1615
pub enum ElevationMethod {
1716
#[serde(rename = "LocalAdmin")]

crates/devolutions-pedm/src/db/libsql.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl Database for LibsqlConn {
222222
}
223223

224224
async fn get_profiles(&self) -> Result<Vec<Profile>, DbError> {
225-
let mut stmt = self
225+
let stmt = self
226226
.prepare(
227227
"
228228
SELECT
@@ -247,7 +247,7 @@ impl Database for LibsqlConn {
247247
}
248248

249249
async fn get_profiles_for_user(&self, user: &User) -> Result<Vec<Profile>, DbError> {
250-
let mut stmt = self
250+
let stmt = self
251251
.prepare(
252252
"
253253
SELECT DISTINCT
@@ -336,7 +336,7 @@ impl Database for LibsqlConn {
336336
params![
337337
profile.name.as_str(),
338338
match &profile.description {
339-
Some(description) => Value::Text(description.to_string()),
339+
Some(description) => Value::Text(description.clone()),
340340
None => Value::Null,
341341
},
342342
elevation_method,
@@ -361,7 +361,7 @@ impl Database for LibsqlConn {
361361
profile.id,
362362
profile.name.as_str(),
363363
match &profile.description {
364-
Some(description) => Value::Text(description.to_string()),
364+
Some(description) => Value::Text(description.clone()),
365365
None => Value::Null,
366366
},
367367
elevation_method,
@@ -592,7 +592,7 @@ impl Database for LibsqlConn {
592592
}
593593

594594
async fn get_users(&self) -> Result<Vec<User>, DbError> {
595-
let mut stmt = self
595+
let stmt = self
596596
.prepare("SELECT id, account_name, domain_name, account_sid, domain_sid FROM user")
597597
.await?;
598598

@@ -626,7 +626,7 @@ impl Database for LibsqlConn {
626626
}
627627

628628
async fn get_jit_elevation_log(&self, id: i64) -> Result<Option<JitElevationLogRow>, DbError> {
629-
let mut stmt = self
629+
let stmt = self
630630
.prepare(
631631
"SELECT
632632
j.id,
@@ -765,7 +765,7 @@ impl Database for LibsqlConn {
765765
params.push(limit.into());
766766
params.push(offset.into());
767767

768-
let mut stmt = self.prepare(&select_sql).await?;
768+
let stmt = self.prepare(&select_sql).await?;
769769
let mut rows = stmt.query(libsql::params_from_iter(params)).await?;
770770

771771
let mut results = Vec::new();
@@ -807,6 +807,8 @@ fn parse_micros(micros: i64) -> Result<DateTime<Utc>, ParseTimestampError> {
807807

808808
#[cfg(test)]
809809
mod tests {
810+
#![allow(clippy::unwrap_used, reason = "test code can panic on errors")]
811+
810812
use chrono::{TimeZone, Utc};
811813

812814
use super::parse_micros;

crates/devolutions-pedm/src/db/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#![cfg_attr(
2+
unix,
3+
expect(
4+
dead_code,
5+
reason = "only used in the windows implementation, nothing is planned for linux yet"
6+
)
7+
)]
8+
19
use core::fmt;
210
use std::ops::Deref;
311
use std::sync::Arc;
@@ -247,6 +255,7 @@ pub(crate) struct DbHandle {
247255
}
248256

249257
impl DbHandle {
258+
#[expect(clippy::result_large_err, reason = "suppressing for now")] // FIXME: Re-evaluate this suppression.
250259
pub(crate) fn insert_jit_elevation_result(
251260
&self,
252261
result: ElevationResult,
@@ -265,9 +274,7 @@ impl DbHandle {
265274
}
266275
},
267276
Err(error) => {
268-
let DbRequest::InsertJitElevationResult { result, .. } = error.0 else {
269-
unreachable!()
270-
};
277+
let DbRequest::InsertJitElevationResult { result, .. } = error.0;
271278

272279
Err(DbHandleError {
273280
db_error: None,

crates/devolutions-pedm/src/db/pg.rs

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
#![expect(unused_variables, reason = "work in progress")]
2+
13
use std::ops::Deref;
24

35
use async_trait::async_trait;
46
use bb8::Pool;
57
use bb8_postgres::PostgresConnectionManager;
68
use chrono::{DateTime, Utc};
7-
use devolutions_pedm_shared::policy::ElevationResult;
9+
use devolutions_pedm_shared::policy::{Assignment, ElevationResult, Profile, User};
810
use tokio_postgres::NoTls;
911

10-
use crate::log::{JitElevationLogPage, JitElevationLogQueryOptions};
12+
use crate::log::{JitElevationLogPage, JitElevationLogQueryOptions, JitElevationLogRow};
1113

1214
use super::{Database, DbError};
1315

@@ -113,4 +115,44 @@ impl Database for PgPool {
113115
) -> Result<JitElevationLogPage, DbError> {
114116
unimplemented!()
115117
}
118+
119+
async fn get_profiles(&self) -> Result<Vec<Profile>, DbError> {
120+
unimplemented!()
121+
}
122+
123+
async fn get_profiles_for_user(&self, user: &User) -> Result<Vec<Profile>, DbError> {
124+
unimplemented!()
125+
}
126+
127+
async fn get_profile(&self, id: i64) -> Result<Option<Profile>, DbError> {
128+
unimplemented!()
129+
}
130+
131+
async fn insert_profile(&self, profile: &Profile) -> Result<(), DbError> {
132+
unimplemented!()
133+
}
134+
135+
async fn delete_profile(&self, id: i64) -> Result<(), DbError> {
136+
unimplemented!()
137+
}
138+
139+
async fn get_assignments(&self) -> Result<Vec<Assignment>, DbError> {
140+
unimplemented!()
141+
}
142+
143+
async fn get_assignment(&self, profile: &Profile) -> Result<Assignment, DbError> {
144+
unimplemented!()
145+
}
146+
147+
async fn set_assignments(&self, profile_id: i64, users: Vec<User>) -> Result<(), DbError> {
148+
unimplemented!()
149+
}
150+
151+
async fn set_user_profile(&self, user: &User, profile_id: i64) -> Result<(), DbError> {
152+
unimplemented!()
153+
}
154+
155+
async fn get_user_profile(&self, user: &User) -> Result<Option<Profile>, DbError> {
156+
unimplemented!()
157+
}
116158
}

0 commit comments

Comments
 (0)