Refactor with the help of Clippy (#462)

We add clippy as our build — also rectifying the missing `plume-cli` build!

In the next step we follow clippy's advise and fix some of the "simple" mistakes in our code, such as style or map usage.

Finally, we refactor some hard bits that need extraction of new types, or refactoring of function call-types, especially those that thread thru macros, and, of course functions with ~15 parameters should probably be rethought.
This commit is contained in:
Igor Galić
2019-03-19 14:37:56 +01:00
committed by Baptiste Gelez
parent 570d7fe2d0
commit 732f514da7
34 changed files with 393 additions and 297 deletions
+5 -5
View File
@@ -161,10 +161,10 @@ pub fn password_reset_request(
i18n!(intl.catalog, "Password reset"),
i18n!(intl.catalog, "Here is the link to reset your password: {0}"; link)
) {
match *mail.lock().unwrap() {
Some(ref mut mail) => { mail.send(message.into()).map_err(|_| eprintln!("Couldn't send password reset mail")).ok(); }
None => {}
}
if let Some(ref mut mail) = *mail.lock().unwrap() {
mail
.send(message.into())
.map_err(|_| eprintln!("Couldn't send password reset mail")).ok(); }
}
}
render!(session::password_reset_request_ok(
@@ -214,7 +214,7 @@ pub fn password_reset(
form.validate()
.and_then(|_| {
let mut requests = requests.lock().unwrap();
let req = requests.iter().find(|x| x.id == token.clone()).ok_or(to_validation(0))?.clone();
let req = requests.iter().find(|x| x.id == token.clone()).ok_or_else(|| to_validation(0))?.clone();
if req.creation_date.elapsed().as_secs() < 60 * 60 * 2 { // Reset link is only valid for 2 hours
requests.retain(|r| *r != req);
let user = User::find_by_email(&*conn, &req.mail).map_err(to_validation)?;