chore: Rust 1.66 linting
This commit is contained in:
@@ -111,7 +111,7 @@ impl<T> StatefulList<T> {
|
|||||||
.state
|
.state
|
||||||
.selected()
|
.selected()
|
||||||
.map_or(0, |value| if len > 0 { value + 1 } else { value });
|
.map_or(0, |value| if len > 0 { value + 1 } else { value });
|
||||||
format!("{}/{}", c, self.items.len())
|
format!("{c}/{}", self.items.len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ impl fmt::Display for State {
|
|||||||
Self::Running => "✓ running",
|
Self::Running => "✓ running",
|
||||||
Self::Unknown => "? unknown",
|
Self::Unknown => "? unknown",
|
||||||
};
|
};
|
||||||
write!(f, "{}", disp)
|
write!(f, "{disp}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ impl fmt::Display for DockerControls {
|
|||||||
Self::Stop => "stop",
|
Self::Stop => "stop",
|
||||||
Self::Unpause => "unpause",
|
Self::Unpause => "unpause",
|
||||||
};
|
};
|
||||||
write!(f, "{}", disp)
|
write!(f, "{disp}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ impl Stats for CpuStats {
|
|||||||
impl fmt::Display for CpuStats {
|
impl fmt::Display for CpuStats {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let disp = format!("{:05.2}%", self.0);
|
let disp = format!("{:05.2}%", self.0);
|
||||||
write!(f, "{:>x$}", disp, x = f.width().unwrap_or(1))
|
write!(f, "{disp:>x$}", x = f.width().unwrap_or(1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ impl fmt::Display for ByteStats {
|
|||||||
x if x >= ONE_KB => format!("{y:.2} kB", y = as_f64 / ONE_KB),
|
x if x >= ONE_KB => format!("{y:.2} kB", y = as_f64 / ONE_KB),
|
||||||
_ => format!("{} B", self.0),
|
_ => format!("{} B", self.0),
|
||||||
};
|
};
|
||||||
write!(f, "{:>x$}", p, x = f.width().unwrap_or(1))
|
write!(f, "{p:>x$}", x = f.width().unwrap_or(1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +429,7 @@ impl ContainerItem {
|
|||||||
self.cpu_stats
|
self.cpu_stats
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|i| (i.0 as f64, i.1 .0 as f64))
|
.map(|i| (i.0 as f64, i.1.0))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -51,7 +51,7 @@ impl fmt::Display for Header {
|
|||||||
Self::Rx => "↓ rx",
|
Self::Rx => "↓ rx",
|
||||||
Self::Tx => "↑ tx",
|
Self::Tx => "↑ tx",
|
||||||
};
|
};
|
||||||
write!(f, "{:>x$}", disp, x = f.width().unwrap_or(1))
|
write!(f, "{disp:>x$}", x = f.width().unwrap_or(1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,9 +280,9 @@ impl AppData {
|
|||||||
let mut name = self.containers.items[index].name.clone();
|
let mut name = self.containers.items[index].name.clone();
|
||||||
name.truncate(32);
|
name.truncate(32);
|
||||||
if logs_len.is_empty() {
|
if logs_len.is_empty() {
|
||||||
format!("- {} ", name)
|
format!("- {name} ")
|
||||||
} else {
|
} else {
|
||||||
format!("{} - {}", logs_len, name)
|
format!("{logs_len} - {name}")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -17,13 +17,13 @@ pub enum AppError {
|
|||||||
impl fmt::Display for AppError {
|
impl fmt::Display for AppError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::DockerCommand(s) => write!(f, "Unable to {} container", s),
|
Self::DockerCommand(s) => write!(f, "Unable to {s} container"),
|
||||||
Self::DockerConnect => write!(f, "Unable to access docker daemon"),
|
Self::DockerConnect => write!(f, "Unable to access docker daemon"),
|
||||||
Self::DockerInterval => write!(f, "Docker update interval needs to be greater than 0"),
|
Self::DockerInterval => write!(f, "Docker update interval needs to be greater than 0"),
|
||||||
Self::InputPoll => write!(f, "Unable to poll user input"),
|
Self::InputPoll => write!(f, "Unable to poll user input"),
|
||||||
Self::MouseCapture(x) => {
|
Self::MouseCapture(x) => {
|
||||||
let reason = if *x { "en" } else { "dis" };
|
let reason = if *x { "en" } else { "dis" };
|
||||||
write!(f, "Unbale to {}able mouse capture", reason)
|
write!(f, "Unable to {reason}able mouse capture")
|
||||||
}
|
}
|
||||||
Self::Terminal => write!(f, "Unable to draw to terminal"),
|
Self::Terminal => write!(f, "Unable to draw to terminal"),
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![warn(clippy::unused_async, clippy::unwrap_used, clippy::expect_used)]
|
#![warn(clippy::unused_async, clippy::unwrap_used, clippy::expect_used)]
|
||||||
// Wanring - These are indeed pedantic
|
// Wanring - These are indeed pedantic
|
||||||
// #![warn(clippy::pedantic)]
|
#![warn(clippy::pedantic)]
|
||||||
// #![warn(clippy::nursery)]
|
#![warn(clippy::nursery)]
|
||||||
// #![allow(clippy::module_name_repetitions, clippy::doc_markdown)]
|
#![allow(clippy::module_name_repetitions, clippy::doc_markdown)]
|
||||||
|
|
||||||
// Only allow when debugging
|
// Only allow when debugging
|
||||||
// #![allow(unused)]
|
// #![allow(unused)]
|
||||||
|
|||||||
+15
-15
@@ -148,7 +148,7 @@ pub fn containers<B: Backend>(
|
|||||||
state_style,
|
state_style,
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!("{}{:>width$}", MARGIN, i.status, width = &widths.status.1),
|
format!("{MARGIN}{:>width$}", i.status, width = &widths.status.1),
|
||||||
state_style,
|
state_style,
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
@@ -161,7 +161,7 @@ pub fn containers<B: Backend>(
|
|||||||
state_style,
|
state_style,
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!("{}{:>width$}", MARGIN, mems, width = &widths.mem.1),
|
format!("{MARGIN}{mems:>width$}", width = &widths.mem.1),
|
||||||
state_style,
|
state_style,
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
@@ -174,19 +174,19 @@ pub fn containers<B: Backend>(
|
|||||||
blue,
|
blue,
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!("{}{:>width$}", MARGIN, i.name, width = widths.name.1),
|
format!("{MARGIN}{:>width$}", i.name, width = widths.name.1),
|
||||||
blue,
|
blue,
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!("{}{:>width$}", MARGIN, i.image, width = widths.image.1),
|
format!("{MARGIN}{:>width$}", i.image, width = widths.image.1),
|
||||||
blue,
|
blue,
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!("{}{:>width$}", MARGIN, i.rx, width = widths.net_rx.1),
|
format!("{MARGIN}{:>width$}", i.rx, width = widths.net_rx.1),
|
||||||
Style::default().fg(Color::Rgb(255, 233, 193)),
|
Style::default().fg(Color::Rgb(255, 233, 193)),
|
||||||
),
|
),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!("{}{:>width$}", MARGIN, i.tx, width = widths.net_tx.1),
|
format!("{MARGIN}{:>width$}", i.tx, width = widths.net_tx.1),
|
||||||
Style::default().fg(Color::Rgb(205, 140, 140)),
|
Style::default().fg(Color::Rgb(205, 140, 140)),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@@ -220,7 +220,7 @@ pub fn logs<B: Backend>(
|
|||||||
let block = generate_block(app_data, area, gui_state, SelectablePanel::Logs);
|
let block = generate_block(app_data, area, gui_state, SelectablePanel::Logs);
|
||||||
let contains_init = gui_state.lock().status_contains(&[Status::Init]);
|
let contains_init = gui_state.lock().status_contains(&[Status::Init]);
|
||||||
if contains_init {
|
if contains_init {
|
||||||
let paragraph = Paragraph::new(format!("parsing logs {}", loading_icon))
|
let paragraph = Paragraph::new(format!("parsing logs {loading_icon}"))
|
||||||
.style(Style::default())
|
.style(Style::default())
|
||||||
.block(block)
|
.block(block)
|
||||||
.alignment(Alignment::Center);
|
.alignment(Alignment::Center);
|
||||||
@@ -309,7 +309,7 @@ fn make_chart<'a, T: Stats + Display>(
|
|||||||
Block::default()
|
Block::default()
|
||||||
.title_alignment(Alignment::Center)
|
.title_alignment(Alignment::Center)
|
||||||
.title(Span::styled(
|
.title(Span::styled(
|
||||||
format!(" {} {} ", name, current),
|
format!(" {name} {current} "),
|
||||||
Style::default()
|
Style::default()
|
||||||
.fg(title_color)
|
.fg(title_color)
|
||||||
.add_modifier(Modifier::BOLD),
|
.add_modifier(Modifier::BOLD),
|
||||||
@@ -327,7 +327,7 @@ fn make_chart<'a, T: Stats + Display>(
|
|||||||
.labels(vec![
|
.labels(vec![
|
||||||
Span::styled("", Style::default().fg(label_color)),
|
Span::styled("", Style::default().fg(label_color)),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!("{}", max),
|
format!("{max}"),
|
||||||
Style::default()
|
Style::default()
|
||||||
.add_modifier(Modifier::BOLD)
|
.add_modifier(Modifier::BOLD)
|
||||||
.fg(label_color),
|
.fg(label_color),
|
||||||
@@ -432,7 +432,7 @@ pub fn heading_bar<B: Backend>(
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let suffix = if help_visible { "exit" } else { "show" };
|
let suffix = if help_visible { "exit" } else { "show" };
|
||||||
let info_text = format!("( h ) {} help {}", suffix, MARGIN,);
|
let info_text = format!("( h ) {suffix} help {MARGIN}",);
|
||||||
let info_width = info_text.chars().count();
|
let info_width = info_text.chars().count();
|
||||||
|
|
||||||
let column_width = usize::from(area.width) - info_width;
|
let column_width = usize::from(area.width) - info_width;
|
||||||
@@ -453,7 +453,7 @@ pub fn heading_bar<B: Backend>(
|
|||||||
.split(area);
|
.split(area);
|
||||||
if has_containers {
|
if has_containers {
|
||||||
// Draw loading icon, or not, and a prefix with a single space
|
// Draw loading icon, or not, and a prefix with a single space
|
||||||
let loading_icon = format!("{:>2}", loading_icon);
|
let loading_icon = format!("{loading_icon:>2}");
|
||||||
let loading_paragraph = Paragraph::new(loading_icon)
|
let loading_paragraph = Paragraph::new(loading_icon)
|
||||||
.block(block(Color::White))
|
.block(block(Color::White))
|
||||||
.alignment(Alignment::Center);
|
.alignment(Alignment::Center);
|
||||||
@@ -507,9 +507,9 @@ fn max_line_width(text: &str) -> usize {
|
|||||||
/// Draw the help box in the centre of the screen
|
/// Draw the help box in the centre of the screen
|
||||||
/// TODO should make every line it's own renderable span
|
/// TODO should make every line it's own renderable span
|
||||||
pub fn help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
pub fn help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
||||||
let title = format!(" {} ", VERSION);
|
let title = format!(" {VERSION} ");
|
||||||
|
|
||||||
let description_text = format!("\n{}", DESCRIPTION);
|
let description_text = format!("\n{DESCRIPTION}");
|
||||||
|
|
||||||
let mut help_text = String::from("\n ( tab ) or ( shift+tab ) to change panels");
|
let mut help_text = String::from("\n ( tab ) or ( shift+tab ) to change panels");
|
||||||
help_text
|
help_text
|
||||||
@@ -527,7 +527,7 @@ pub fn help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
|||||||
help_text.push_str(format!("\n {}", REPO.trim()).as_str());
|
help_text.push_str(format!("\n {}", REPO.trim()).as_str());
|
||||||
|
|
||||||
// Find the maximum line widths & height
|
// Find the maximum line widths & height
|
||||||
let all_text = format!("{}{}{}", NAME_TEXT, description_text, help_text);
|
let all_text = format!("{NAME_TEXT}{description_text}{help_text}");
|
||||||
let mut max_line_width = max_line_width(&all_text);
|
let mut max_line_width = max_line_width(&all_text);
|
||||||
let mut lines = all_text.lines().count();
|
let mut lines = all_text.lines().count();
|
||||||
|
|
||||||
@@ -604,7 +604,7 @@ pub fn error<B: Backend>(f: &mut Frame<'_, B>, error: AppError, seconds: Option<
|
|||||||
_ => String::from("\n\n ( c ) to clear error\n ( q ) to quit oxker"),
|
_ => String::from("\n\n ( c ) to clear error\n ( q ) to quit oxker"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut text = format!("\n{}", error);
|
let mut text = format!("\n{error}");
|
||||||
|
|
||||||
text.push_str(to_push.as_str());
|
text.push_str(to_push.as_str());
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -169,7 +169,7 @@ impl fmt::Display for Loading {
|
|||||||
Self::Nine => '⠇',
|
Self::Nine => '⠇',
|
||||||
Self::Ten => '⠏',
|
Self::Ten => '⠏',
|
||||||
};
|
};
|
||||||
write!(f, "{}", disp)
|
write!(f, "{disp}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ pub async fn create_ui(
|
|||||||
terminal.show_cursor()?;
|
terminal.show_cursor()?;
|
||||||
|
|
||||||
if let Err(err) = res {
|
if let Err(err) = res {
|
||||||
println!("{}", err);
|
println!("{err}");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user