chore: linting nursery
This commit is contained in:
@@ -68,15 +68,11 @@ impl<T> StatefulList<T> {
|
|||||||
String::from("")
|
String::from("")
|
||||||
} else {
|
} else {
|
||||||
let len = self.items.len();
|
let len = self.items.len();
|
||||||
let c = if let Some(value) = self.state.selected() {
|
let c = self.state.selected().map_or(0, |value| if len > 0 {
|
||||||
if len > 0 {
|
|
||||||
value + 1
|
value + 1
|
||||||
} else {
|
} else {
|
||||||
value
|
value
|
||||||
}
|
});
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
format!("{}/{}", c, self.items.len())
|
format!("{}/{}", c, self.items.len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +91,7 @@ pub enum State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn get_color(&self) -> Color {
|
pub const fn get_color(&self) -> Color {
|
||||||
match self {
|
match self {
|
||||||
Self::Running => Color::Green,
|
Self::Running => Color::Green,
|
||||||
Self::Removing => Color::LightRed,
|
Self::Removing => Color::LightRed,
|
||||||
@@ -105,7 +101,7 @@ impl State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Dirty way to create order for the state, rather than impl Ord
|
// Dirty way to create order for the state, rather than impl Ord
|
||||||
pub fn order(&self) -> &'static str {
|
pub const fn order(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Running => "a",
|
Self::Running => "a",
|
||||||
Self::Paused => "b",
|
Self::Paused => "b",
|
||||||
@@ -158,7 +154,7 @@ pub enum DockerControls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DockerControls {
|
impl DockerControls {
|
||||||
pub fn get_color(&self) -> Color {
|
pub const fn get_color(&self) -> Color {
|
||||||
match self {
|
match self {
|
||||||
Self::Start => Color::Green,
|
Self::Start => Color::Green,
|
||||||
Self::Stop => Color::Red,
|
Self::Stop => Color::Red,
|
||||||
@@ -205,7 +201,7 @@ pub struct CpuStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CpuStats {
|
impl CpuStats {
|
||||||
pub fn new(value: f64) -> Self {
|
pub const fn new(value: f64) -> Self {
|
||||||
Self { value }
|
Self { value }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +272,7 @@ impl Ord for ByteStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ByteStats {
|
impl ByteStats {
|
||||||
pub fn new(value: u64) -> Self {
|
pub const fn new(value: u64) -> Self {
|
||||||
Self { value }
|
Self { value }
|
||||||
}
|
}
|
||||||
pub fn update(&mut self, value: u64) {
|
pub fn update(&mut self, value: u64) {
|
||||||
@@ -423,8 +419,8 @@ pub struct Columns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Columns {
|
impl Columns {
|
||||||
// (Column titles, minimum header string length)
|
/// (Column titles, minimum header string length)
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
state: (Header::State, 11),
|
state: (Header::State, 11),
|
||||||
status: (Header::Status, 16),
|
status: (Header::Status, 16),
|
||||||
|
|||||||
+1
-5
@@ -259,11 +259,7 @@ impl AppData {
|
|||||||
/// Get the title for log panel for selected container
|
/// Get the title for log panel for selected container
|
||||||
/// will be "logs x/x"
|
/// will be "logs x/x"
|
||||||
pub fn get_log_title(&self) -> String {
|
pub fn get_log_title(&self) -> String {
|
||||||
if let Some(index) = self.get_selected_log_index() {
|
self.get_selected_log_index().map_or_else(|| String::from(""), |index| self.containers.items[index].logs.get_state_title())
|
||||||
self.containers.items[index].logs.get_state_title()
|
|
||||||
} else {
|
|
||||||
String::from("")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// select next selected log line
|
/// select next selected log line
|
||||||
|
|||||||
@@ -102,11 +102,7 @@ impl DockerData {
|
|||||||
let mem_stat = stats.memory_stats.usage.unwrap_or(0);
|
let mem_stat = stats.memory_stats.usage.unwrap_or(0);
|
||||||
let mem_limit = stats.memory_stats.limit.unwrap_or(0);
|
let mem_limit = stats.memory_stats.limit.unwrap_or(0);
|
||||||
|
|
||||||
let some_key = if let Some(networks) = &stats.networks {
|
let some_key = stats.networks.as_ref().and_then(|networks| networks.keys().next().cloned());
|
||||||
networks.keys().next().cloned()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let cpu_stats = Self::calculate_usage(&stats);
|
let cpu_stats = Self::calculate_usage(&stats);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
#![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
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub struct CliArgs {
|
|||||||
impl CliArgs {
|
impl CliArgs {
|
||||||
/// Parse cli arguments
|
/// Parse cli arguments
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let args = CliArgs::parse();
|
let args = Self::parse();
|
||||||
|
|
||||||
// Quit the program if the docker update argument is 0
|
// Quit the program if the docker update argument is 0
|
||||||
// Should maybe change it to check if less than 100
|
// Should maybe change it to check if less than 100
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ pub mod log_sanitizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Change from ansi to tui colors
|
/// Change from ansi to tui colors
|
||||||
fn color_ansi_to_tui(color: CansiColor) -> Color {
|
const fn color_ansi_to_tui(color: CansiColor) -> Color {
|
||||||
match color {
|
match color {
|
||||||
CansiColor::Black | CansiColor::BrightBlack => Color::Black,
|
CansiColor::Black | CansiColor::BrightBlack => Color::Black,
|
||||||
CansiColor::Red => Color::Red,
|
CansiColor::Red => Color::Red,
|
||||||
|
|||||||
+7
-7
@@ -30,7 +30,7 @@ pub enum BoxLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BoxLocation {
|
impl BoxLocation {
|
||||||
pub fn get_indexes(self) -> (usize, usize) {
|
pub const fn get_indexes(self) -> (usize, usize) {
|
||||||
match self {
|
match self {
|
||||||
Self::TopLeft => (0, 0),
|
Self::TopLeft => (0, 0),
|
||||||
Self::TopCentre => (0, 1),
|
Self::TopCentre => (0, 1),
|
||||||
@@ -45,7 +45,7 @@ impl BoxLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Should combine and just return a tuple?
|
// Should combine and just return a tuple?
|
||||||
pub fn get_horizontal_constraints(
|
pub const fn get_horizontal_constraints(
|
||||||
self,
|
self,
|
||||||
blank_vertical: u16,
|
blank_vertical: u16,
|
||||||
text_width: u16,
|
text_width: u16,
|
||||||
@@ -68,7 +68,7 @@ impl BoxLocation {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn get_vertical_constraints(
|
pub const fn get_vertical_constraints(
|
||||||
self,
|
self,
|
||||||
blank_vertical: u16,
|
blank_vertical: u16,
|
||||||
number_lines: u16,
|
number_lines: u16,
|
||||||
@@ -108,7 +108,7 @@ pub enum Loading {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Loading {
|
impl Loading {
|
||||||
pub fn next(&self) -> Self {
|
pub const fn next(&self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::One => Self::Two,
|
Self::One => Self::Two,
|
||||||
Self::Two => Self::Three,
|
Self::Two => Self::Three,
|
||||||
@@ -143,21 +143,21 @@ impl fmt::Display for Loading {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SelectablePanel {
|
impl SelectablePanel {
|
||||||
pub fn title(self) -> &'static str {
|
pub const fn title(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Containers => "Containers",
|
Self::Containers => "Containers",
|
||||||
Self::Logs => "Logs",
|
Self::Logs => "Logs",
|
||||||
Self::Commands => "",
|
Self::Commands => "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn next(self) -> Self {
|
pub const fn next(self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::Containers => Self::Commands,
|
Self::Containers => Self::Commands,
|
||||||
Self::Commands => Self::Logs,
|
Self::Commands => Self::Logs,
|
||||||
Self::Logs => Self::Containers,
|
Self::Logs => Self::Containers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn prev(self) -> Self {
|
pub const fn prev(self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::Containers => Self::Logs,
|
Self::Containers => Self::Logs,
|
||||||
Self::Commands => Self::Containers,
|
Self::Commands => Self::Containers,
|
||||||
|
|||||||
+1
-1
@@ -72,7 +72,7 @@ pub async fn create_ui(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Run a loop to draw the gui
|
/// Run a loop to draw the gui
|
||||||
async fn run_app<B: Backend>(
|
async fn run_app<B: Backend + Send>(
|
||||||
terminal: &mut Terminal<B>,
|
terminal: &mut Terminal<B>,
|
||||||
app_data: Arc<Mutex<AppData>>,
|
app_data: Arc<Mutex<AppData>>,
|
||||||
sender: Sender<InputMessages>,
|
sender: Sender<InputMessages>,
|
||||||
|
|||||||
Reference in New Issue
Block a user