feat: cargo clippy

This commit is contained in:
Louis-Marie Baer 2024-02-27 05:08:14 +01:00
parent 5ef88ad895
commit d811f60b00
10 changed files with 26 additions and 34 deletions

View file

@ -411,7 +411,7 @@ For more information, see link below:
//---------------------------------------------------------------------------------------------------- Visuals
use egui::epaint::{Rounding, Shadow, Stroke};
use egui::{style::Spacing, Color32, Visuals};
use egui::{Color32, Visuals};
use egui::style::{Selection, WidgetVisuals, Widgets};
use once_cell::sync::Lazy;

View file

@ -817,13 +817,13 @@ impl GupaxP2poolApi {
"GupaxP2poolApi | Deleting old folder at [{}]...",
path.display()
);
std::fs::remove_dir_all(&path)?;
std::fs::remove_dir_all(path)?;
info!(
"GupaxP2poolApi | Creating new default folder at [{}]...",
path.display()
);
create_gupax_p2pool_dir(&path)?;
Self::create_all_files(&path)?;
create_gupax_p2pool_dir(path)?;
Self::create_all_files(path)?;
Ok(())
}

View file

@ -18,8 +18,7 @@
use crate::State;
use crate::{constants::*, macros::*, update::*, ErrorState, Restart, Tab};
use egui::{
Button, Checkbox, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit,
TextStyle, TextStyle::Monospace, Vec2,
Button, Checkbox, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, Vec2,
};
use log::*;
use serde::{Deserialize, Serialize};
@ -81,7 +80,7 @@ impl crate::disk::Gupax {
restart: &Arc<Mutex<Restart>>,
width: f32,
height: f32,
frame: &mut eframe::Frame,
_frame: &mut eframe::Frame,
_ctx: &egui::Context,
ui: &mut egui::Ui,
) {
@ -512,7 +511,7 @@ impl crate::disk::Gupax {
lock!(file_window).thread = true;
thread::spawn(move || {
match rfd::FileDialog::new()
.set_title(&format!("Select {} Binary for Gupax", name))
.set_title(format!("Select {} Binary for Gupax", name))
.pick_file()
{
Some(path) => {

View file

@ -1260,7 +1260,7 @@ impl Helper {
// 1a. Create PTY
debug!("XMRig | Creating PTY...");
let pty = portable_pty::native_pty_system();
let mut pair = pty
let pair = pty
.openpty(portable_pty::PtySize {
rows: 100,
cols: 1000,
@ -2393,7 +2393,7 @@ impl PubXmrigApi {
// Formats raw private data into ready-to-print human readable version.
fn update_from_priv(public: &Arc<Mutex<Self>>, private: PrivXmrigApi) {
let mut public = lock!(public);
let hashrate_raw = match private.hashrate.total.get(0) {
let hashrate_raw = match private.hashrate.total.first() {
Some(Some(h)) => *h,
_ => 0.0,
};

View file

@ -29,14 +29,14 @@ compile_error!("gupax is only built for windows/macos/linux");
// egui/eframe
use eframe::{egui, NativeOptions};
use egui::{
Align, Button, CentralPanel, Color32, FontFamily::Proportional, FontId, Hyperlink, Key, Label,
Layout, Modifiers, RichText, SelectableLabel, Spinner, Stroke, TextEdit, TextStyle,
Align, Button, CentralPanel, Color32, FontId, Hyperlink, Key, Label,
Layout, Modifiers, RichText, SelectableLabel, Spinner, TextEdit, TextStyle,
TextStyle::*, TopBottomPanel, Vec2,
};
use egui_extras::RetainedImage;
// Logging
use env_logger::{
fmt::style::{AnsiColor, Style},
fmt::style::{Style},
Builder, WriteStyle,
};
use log::*;
@ -237,7 +237,7 @@ impl App {
let cpu = sysinfo.cpus()[0].brand();
let mut json: Vec<Benchmark> =
serde_json::from_slice(include_bytes!("cpu.json")).unwrap();
json.sort_by(|a, b| cmp_f64(strsim::jaro(&b.cpu, &cpu), strsim::jaro(&a.cpu, &cpu)));
json.sort_by(|a, b| cmp_f64(strsim::jaro(&b.cpu, cpu), strsim::jaro(&a.cpu, cpu)));
json
};
info!("App Init | Assuming user's CPU is: {}", benchmarks[0].cpu);
@ -494,7 +494,7 @@ impl App {
og.p2pool.selected_index,
app.og_node_vec.len()
);
let (name, node) = match app.og_node_vec.get(0) {
let (name, node) = match app.og_node_vec.first() {
Some(zero) => zero.clone(),
None => Node::new_tuple(),
};
@ -517,7 +517,7 @@ impl App {
og.xmrig.selected_index,
app.og_pool_vec.len()
);
let (name, pool) = match app.og_pool_vec.get(0) {
let (name, pool) = match app.og_pool_vec.first() {
Some(zero) => zero.clone(),
None => Pool::new_tuple(),
};
@ -627,7 +627,7 @@ impl App {
continue;
}
let (ip, rpc, zmq) = RemoteNode::get_ip_rpc_zmq(&pinged_node.ip);
let (ip, rpc, zmq) = RemoteNode::get_ip_rpc_zmq(pinged_node.ip);
let node = Node {
ip: ip.into(),
@ -1868,17 +1868,11 @@ impl eframe::App for App {
// They don't need to be compared anyway.
debug!("App | Checking diff between [og] & [state]");
let og = lock!(self.og);
if og.status != self.state.status
self.diff = og.status != self.state.status
|| og.gupax != self.state.gupax
|| og.p2pool != self.state.p2pool
|| og.xmrig != self.state.xmrig
|| self.og_node_vec != self.node_vec
|| self.og_pool_vec != self.pool_vec
{
self.diff = true;
} else {
self.diff = false;
}
|| self.og_node_vec != self.node_vec || self.og_pool_vec != self.pool_vec;
drop(og);
// Top: Tabs

View file

@ -20,7 +20,7 @@ use egui::Color32;
use hyper::{client::HttpConnector, Body, Client, Request};
use log::*;
use rand::{thread_rng, Rng};
use serde::{Deserialize, Serialize};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
@ -414,7 +414,7 @@ impl Ping {
let mut handles = Vec::with_capacity(REMOTE_NODE_LENGTH);
let node_vec = arc_mut!(Vec::with_capacity(REMOTE_NODE_LENGTH));
for (ip, _, rpc, zmq) in REMOTE_NODES {
for (ip, _, rpc, _zmq) in REMOTE_NODES {
let client = client.clone();
let ping = Arc::clone(&ping);
let node_vec = Arc::clone(&node_vec);

View file

@ -22,7 +22,7 @@ use egui::{
Slider, Spinner, TextEdit, TextStyle::*,
};
use log::*;
use regex::Regex;
use std::sync::{Arc, Mutex};
impl crate::disk::P2pool {

View file

@ -21,9 +21,9 @@ use once_cell::sync::Lazy;
use regex::Regex;
//---------------------------------------------------------------------------------------------------- Lazy
pub static REGEXES: Lazy<Regexes> = Lazy::new(|| Regexes::new());
pub static P2POOL_REGEX: Lazy<P2poolRegex> = Lazy::new(|| P2poolRegex::new());
pub static XMRIG_REGEX: Lazy<XmrigRegex> = Lazy::new(|| XmrigRegex::new());
pub static REGEXES: Lazy<Regexes> = Lazy::new(Regexes::new);
pub static P2POOL_REGEX: Lazy<P2poolRegex> = Lazy::new(P2poolRegex::new);
pub static XMRIG_REGEX: Lazy<XmrigRegex> = Lazy::new(XmrigRegex::new);
//---------------------------------------------------------------------------------------------------- [Regexes] struct
// General purpose Regexes, mostly used in the GUI.

View file

@ -20,8 +20,7 @@ use crate::{
ImgXmrig, PayoutView, PubP2poolApi, PubXmrigApi, Submenu, Sys,
};
use egui::{
Hyperlink, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, TextStyle,
TextStyle::Monospace, TextStyle::Name,
Hyperlink, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, TextStyle, TextStyle::Name,
};
use log::*;
use std::sync::{Arc, Mutex};

View file

@ -21,7 +21,7 @@ use egui::{
Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, Slider, TextEdit, TextStyle::*,
};
use log::*;
use regex::Regex;
use std::sync::{Arc, Mutex};
impl crate::disk::Xmrig {