From 69ba400b6967220c5032ccf6a5e993d01b4dd98b Mon Sep 17 00:00:00 2001 From: glyph Date: Wed, 12 Jan 2022 13:15:04 +0200 Subject: [PATCH] satisfy clippy nightly warnings --- Cargo.lock | 4 ++-- peach-lib/src/password_utils.rs | 8 ++++---- peach-lib/src/sbot_client.rs | 2 +- peach-network/src/network.rs | 2 +- peach-web/README.md | 2 +- peach-web/src/routes/status/device.rs | 13 ++++--------- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d3ed44..206cc1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2492,8 +2492,8 @@ dependencies = [ "jsonrpc-http-server 18.0.0", "jsonrpc-test 18.0.0", "log 0.4.14", - "miniserde", "peach-stats", + "serde_json", ] [[package]] @@ -2585,7 +2585,7 @@ dependencies = [ [[package]] name = "peach-web" -version = "0.4.17" +version = "0.5.0" dependencies = [ "env_logger 0.8.4", "log 0.4.14", diff --git a/peach-lib/src/password_utils.rs b/peach-lib/src/password_utils.rs index ea3ec41..9b427a2 100644 --- a/peach-lib/src/password_utils.rs +++ b/peach-lib/src/password_utils.rs @@ -7,7 +7,7 @@ use crate::{config_manager, error::PeachError, sbot_client}; /// and returns Err if the supplied password is incorrect. pub fn verify_password(password: &str) -> Result<(), PeachError> { let real_admin_password_hash = config_manager::get_admin_password_hash()?; - let password_hash = hash_password(&password.to_string()); + let password_hash = hash_password(password); if real_admin_password_hash == password_hash { Ok(()) } else { @@ -29,7 +29,7 @@ pub fn validate_new_passwords(new_password1: &str, new_password2: &str) -> Resul /// Sets a new password for the admin user pub fn set_new_password(new_password: &str) -> Result<(), PeachError> { - let new_password_hash = hash_password(&new_password.to_string()); + let new_password_hash = hash_password(new_password); config_manager::set_admin_password_hash(&new_password_hash)?; Ok(()) @@ -49,7 +49,7 @@ pub fn hash_password(password: &str) -> String { /// Sets a new temporary password for the admin user /// which can be used to reset the permanent password pub fn set_new_temporary_password(new_password: &str) -> Result<(), PeachError> { - let new_password_hash = hash_password(&new_password.to_string()); + let new_password_hash = hash_password(new_password); config_manager::set_temporary_password_hash(&new_password_hash)?; Ok(()) @@ -59,7 +59,7 @@ pub fn set_new_temporary_password(new_password: &str) -> Result<(), PeachError> /// and returns Err if the supplied temp_password is incorrect pub fn verify_temporary_password(password: &str) -> Result<(), PeachError> { let temporary_admin_password_hash = config_manager::get_temporary_password_hash()?; - let password_hash = hash_password(&password.to_string()); + let password_hash = hash_password(password); if temporary_admin_password_hash == password_hash { Ok(()) } else { diff --git a/peach-lib/src/sbot_client.rs b/peach-lib/src/sbot_client.rs index 1e28e87..bb6cf36 100644 --- a/peach-lib/src/sbot_client.rs +++ b/peach-lib/src/sbot_client.rs @@ -67,7 +67,7 @@ pub fn create_invite(uses: i32) -> Result { .arg(uses.to_string()) .output()?; let text_output = std::str::from_utf8(&output.stdout)?; - let output = text_output.replace("\n", ""); + let output = text_output.replace('\n', ""); Ok(output) } diff --git a/peach-network/src/network.rs b/peach-network/src/network.rs index 96b7334..b68139c 100644 --- a/peach-network/src/network.rs +++ b/peach-network/src/network.rs @@ -138,7 +138,7 @@ pub fn available_networks(iface: &str) -> Result>, NetworkError // we only want to return the auth / crypto flags if flags_vec[0] != "[ESS]" { // parse auth / crypto flag and assign it to protocol - protocol.push_str(flags_vec[0].replace("[", "").replace("]", "").as_str()); + protocol.push_str(flags_vec[0].replace('[', "").replace(']', "").as_str()); } let ssid = v[4].to_string(); let response = Scan { diff --git a/peach-web/README.md b/peach-web/README.md index 3034da0..05b8e3e 100644 --- a/peach-web/README.md +++ b/peach-web/README.md @@ -1,6 +1,6 @@ # peach-web -[![Build Status](https://travis-ci.com/peachcloud/peach-web.svg?branch=master)](https://travis-ci.com/peachcloud/peach-web) ![Generic badge](https://img.shields.io/badge/version-0.4.12-.svg) +[![Build Status](https://travis-ci.com/peachcloud/peach-web.svg?branch=master)](https://travis-ci.com/peachcloud/peach-web) ![Generic badge](https://img.shields.io/badge/version-0.5.0-.svg) ## Web Interface for PeachCloud diff --git a/peach-web/src/routes/status/device.rs b/peach-web/src/routes/status/device.rs index 7a368aa..dd3845b 100644 --- a/peach-web/src/routes/status/device.rs +++ b/peach-web/src/routes/status/device.rs @@ -117,16 +117,11 @@ impl StatusContext { } // test if go-sbot is running - let sbot_is_online: bool; let sbot_is_online_result = sbot_client::is_sbot_online(); - match sbot_is_online_result { - Ok(val) => { - sbot_is_online = val; - } - Err(_err) => { - sbot_is_online = false; - } - } + let sbot_is_online: bool = match sbot_is_online_result { + Ok(val) => val, + Err(_err) => false, + }; StatusContext { back: None,