Skip to content

Commit

Permalink
chore: Rust 1.66 linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjackwills committed Dec 15, 2022
1 parent 7899b77 commit bf9dcac
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
12 changes: 6 additions & 6 deletions src/app_data/container_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<T> StatefulList<T> {
.state
.selected()
.map_or(0, |value| if len > 0 { value + 1 } else { value });
format!("{}/{}", c, self.items.len())
format!("{c}/{}", self.items.len())
}
}
}
Expand Down Expand Up @@ -191,7 +191,7 @@ impl fmt::Display for State {
Self::Running => "✓ running",
Self::Unknown => "? unknown",
};
write!(f, "{}", disp)
write!(f, "{disp}")
}
}

Expand Down Expand Up @@ -237,7 +237,7 @@ impl fmt::Display for DockerControls {
Self::Stop => "stop",
Self::Unpause => "unpause",
};
write!(f, "{}", disp)
write!(f, "{disp}")
}
}

Expand Down Expand Up @@ -292,7 +292,7 @@ impl Stats for CpuStats {
impl fmt::Display for CpuStats {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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))
}
}

Expand Down Expand Up @@ -346,7 +346,7 @@ impl fmt::Display for ByteStats {
x if x >= ONE_KB => format!("{y:.2} kB", y = as_f64 / ONE_KB),
_ => format!("{} B", self.0),
};
write!(f, "{:>x$}", p, x = f.width().unwrap_or(1))
write!(f, "{p:>x$}", x = f.width().unwrap_or(1))
}
}

Expand Down Expand Up @@ -429,7 +429,7 @@ impl ContainerItem {
self.cpu_stats
.iter()
.enumerate()
.map(|i| (i.0 as f64, i.1 .0 as f64))
.map(|i| (i.0 as f64, i.1.0))
.collect::<Vec<_>>()
}

Expand Down
6 changes: 3 additions & 3 deletions src/app_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl fmt::Display for Header {
Self::Rx => "↓ rx",
Self::Tx => "↑ tx",
};
write!(f, "{:>x$}", disp, x = f.width().unwrap_or(1))
write!(f, "{disp:>x$}", x = f.width().unwrap_or(1))
}
}

Expand Down Expand Up @@ -280,9 +280,9 @@ impl AppData {
let mut name = self.containers.items[index].name.clone();
name.truncate(32);
if logs_len.is_empty() {
format!("- {} ", name)
format!("- {name} ")
} else {
format!("{} - {}", logs_len, name)
format!("{logs_len} - {name}")
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/app_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ pub enum AppError {
impl fmt::Display for AppError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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::DockerInterval => write!(f, "Docker update interval needs to be greater than 0"),
Self::InputPoll => write!(f, "Unable to poll user input"),
Self::MouseCapture(x) => {
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"),
}
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![forbid(unsafe_code)]
#![warn(clippy::unused_async, clippy::unwrap_used, clippy::expect_used)]
// Wanring - These are indeed pedantic
// #![warn(clippy::pedantic)]
// #![warn(clippy::nursery)]
// #![allow(clippy::module_name_repetitions, clippy::doc_markdown)]
#![warn(clippy::pedantic)]
#![warn(clippy::nursery)]
#![allow(clippy::module_name_repetitions, clippy::doc_markdown)]

// Only allow when debugging
// #![allow(unused)]
Expand Down
30 changes: 15 additions & 15 deletions src/ui/draw_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn containers<B: Backend>(
state_style,
),
Span::styled(
format!("{}{:>width$}", MARGIN, i.status, width = &widths.status.1),
format!("{MARGIN}{:>width$}", i.status, width = &widths.status.1),
state_style,
),
Span::styled(
Expand All @@ -161,7 +161,7 @@ pub fn containers<B: Backend>(
state_style,
),
Span::styled(
format!("{}{:>width$}", MARGIN, mems, width = &widths.mem.1),
format!("{MARGIN}{mems:>width$}", width = &widths.mem.1),
state_style,
),
Span::styled(
Expand All @@ -174,19 +174,19 @@ pub fn containers<B: Backend>(
blue,
),
Span::styled(
format!("{}{:>width$}", MARGIN, i.name, width = widths.name.1),
format!("{MARGIN}{:>width$}", i.name, width = widths.name.1),
blue,
),
Span::styled(
format!("{}{:>width$}", MARGIN, i.image, width = widths.image.1),
format!("{MARGIN}{:>width$}", i.image, width = widths.image.1),
blue,
),
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)),
),
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)),
),
]);
Expand Down Expand Up @@ -220,7 +220,7 @@ pub fn logs<B: Backend>(
let block = generate_block(app_data, area, gui_state, SelectablePanel::Logs);
let contains_init = gui_state.lock().status_contains(&[Status::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())
.block(block)
.alignment(Alignment::Center);
Expand Down Expand Up @@ -309,7 +309,7 @@ fn make_chart<'a, T: Stats + Display>(
Block::default()
.title_alignment(Alignment::Center)
.title(Span::styled(
format!(" {} {} ", name, current),
format!(" {name} {current} "),
Style::default()
.fg(title_color)
.add_modifier(Modifier::BOLD),
Expand All @@ -327,7 +327,7 @@ fn make_chart<'a, T: Stats + Display>(
.labels(vec![
Span::styled("", Style::default().fg(label_color)),
Span::styled(
format!("{}", max),
format!("{max}"),
Style::default()
.add_modifier(Modifier::BOLD)
.fg(label_color),
Expand Down Expand Up @@ -432,7 +432,7 @@ pub fn heading_bar<B: Backend>(
.collect::<Vec<_>>();

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 column_width = usize::from(area.width) - info_width;
Expand All @@ -453,7 +453,7 @@ pub fn heading_bar<B: Backend>(
.split(area);
if has_containers {
// 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)
.block(block(Color::White))
.alignment(Alignment::Center);
Expand Down Expand Up @@ -507,9 +507,9 @@ fn max_line_width(text: &str) -> usize {
/// Draw the help box in the centre of the screen
/// TODO should make every line it's own renderable span
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");
help_text
Expand All @@ -527,7 +527,7 @@ pub fn help_box<B: Backend>(f: &mut Frame<'_, B>) {
help_text.push_str(format!("\n {}", REPO.trim()).as_str());

// 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 lines = all_text.lines().count();

Expand Down Expand Up @@ -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"),
};

let mut text = format!("\n{}", error);
let mut text = format!("\n{error}");

text.push_str(to_push.as_str());

Expand Down
2 changes: 1 addition & 1 deletion src/ui/gui_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl fmt::Display for Loading {
Self::Nine => '⠇',
Self::Ten => '⠏',
};
write!(f, "{}", disp)
write!(f, "{disp}")
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub async fn create_ui(
terminal.show_cursor()?;

if let Err(err) = res {
println!("{}", err);
println!("{err}");
}
Ok(())
}
Expand Down

0 comments on commit bf9dcac

Please sign in to comment.