Skip to content

Commit

Permalink
rust 1.83 clippy (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebadob authored Nov 29, 2024
1 parent 23bb22b commit d022fa1
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ requested claims.
However, if you used to communicate with the Rauthy API directly, you should be aware of this change. The
`User.family_name` is now optional in all situations.

[]()
[#631](https://github.com/sebadob/rauthy/pull/631)

### Changes

Expand Down
1 change: 0 additions & 1 deletion src/api/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ use utoipa::{openapi, OpenApi};
(name = "deprecated", description = "Deprecated endpoints - will be removed in a future version"),
),
)]

pub struct ApiDoc;

impl ApiDoc {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/tests/handler_users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn test_users() -> Result<(), Box<dyn Error>> {
// post a new user
let new_user = NewUserRequest {
given_name: "Alfred".to_string(),
family_name: "Batman".to_string(),
family_name: Some("Batman".to_string()),
email: "[email protected]".to_string(),
language: Language::En,
roles: vec![
Expand Down Expand Up @@ -56,7 +56,7 @@ async fn test_users() -> Result<(), Box<dyn Error>> {
let alfred = res.json::<UserResponse>().await?;
assert_eq!(alfred.email, "[email protected]");
assert_eq!(alfred.given_name, "Alfred");
assert_eq!(alfred.family_name, "Batman");
assert_eq!(alfred.family_name.as_deref(), Some("Batman"));
assert!(alfred.roles.contains(&"admin".to_string()));
assert!(alfred.roles.contains(&"user".to_string()));
assert!(alfred.groups.is_some());
Expand Down
2 changes: 1 addition & 1 deletion src/bin/tests/zzb_handler_password_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async fn test_password_policy() -> Result<(), Box<dyn Error>> {
// post a new user
let new_user = NewUserRequest {
given_name: "IT Test".to_string(),
family_name: "Testy".to_string(),
family_name: Some("Testy".to_string()),
email: "[email protected]".to_string(),
language: Language::En,
roles: vec!["user".to_string()],
Expand Down
4 changes: 2 additions & 2 deletions src/models/src/entity/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ impl User {

pub fn get_roles(&self) -> Vec<String> {
let mut res = Vec::new();
if self.roles.ne("") {
if !self.roles.is_empty() {
self.roles
.split(',')
.for_each(|r| res.push(r.trim().to_owned()));
Expand Down Expand Up @@ -1584,7 +1584,7 @@ impl User {
}

pub fn push_role(&mut self, role: &str) {
if self.roles.ne("") {
if !self.roles.is_empty() {
self.roles = format!("{},{}", self.roles, role);
} else {
role.clone_into(&mut self.roles);
Expand Down
2 changes: 1 addition & 1 deletion src/models/src/entity/webids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ mod tests {
issuer: "http://localhost:8080/auth/v1".to_string(),
email: "[email protected]".to_string(),
given_name: "Given".to_string(),
family_name: "Family".to_string(),
family_name: Some("Family".to_string()),
language: Language::En,
};

Expand Down
6 changes: 1 addition & 5 deletions src/models/src/events/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,7 @@ impl EventListener {
.collect::<Vec<&sse::Event>>();

let evt_len = events_filtered.len();
let skip = if latest > evt_len {
0
} else {
evt_len - latest
};
let skip = evt_len.saturating_sub(latest);

for event in events_filtered.iter().skip(skip) {
match time::timeout(Duration::from_secs(5), tx.send((*event).clone()))
Expand Down

0 comments on commit d022fa1

Please sign in to comment.