summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-15 13:15:15 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-15 13:15:15 -0500
commit6d027a4cf528ae0da0d1de4651f3abf42ecb2e10 (patch)
tree0970927aa52b9456d53c4c4d6c86fdd380285227
parent190619cd6d502681ffb40d33ce1d8261f82ef322 (diff)
downloadnbsh-6d027a4cf528ae0da0d1de4651f3abf42ecb2e10.tar.gz
nbsh-6d027a4cf528ae0da0d1de4651f3abf42ecb2e10.zip
clippy
-rw-r--r--src/main.rs9
-rw-r--r--src/state/history.rs40
-rw-r--r--src/state/mod.rs2
-rw-r--r--src/state/readline.rs4
4 files changed, 35 insertions, 20 deletions
diff --git a/src/main.rs b/src/main.rs
index da1facf..c698b91 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,16 @@
+// will uncomment this once it is closer to release
+// #![warn(clippy::cargo)]
#![warn(clippy::pedantic)]
#![warn(clippy::nursery)]
-#![allow(clippy::future_not_send)]
+#![warn(clippy::as_conversions)]
+#![warn(clippy::get_unwrap)]
+#![allow(clippy::cognitive_complexity)]
#![allow(clippy::missing_const_for_fn)]
+#![allow(clippy::similar_names)]
#![allow(clippy::struct_excessive_bools)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_lines)]
-#![allow(clippy::unused_self)]
+#![allow(clippy::type_complexity)]
mod builtins;
mod env;
diff --git a/src/state/history.rs b/src/state/history.rs
index b606951..af8e07a 100644
--- a/src/state/history.rs
+++ b/src/state/history.rs
@@ -18,6 +18,8 @@ impl History {
}
}
+ // render always happens on the main task
+ #[allow(clippy::future_not_send)]
pub async fn render(
&self,
out: &mut impl textmode::Textmode,
@@ -34,7 +36,7 @@ impl History {
let focused = focus.map_or(false, |focus| idx == focus);
used_lines += entry.lines(self.size.1, focused && !scrolling);
out.move_to(
- (self.size.0 as usize - used_lines).try_into().unwrap(),
+ (usize::from(self.size.0) - used_lines).try_into().unwrap(),
0,
);
entry.render(
@@ -60,6 +62,8 @@ impl History {
Ok(())
}
+ // render always happens on the main task
+ #[allow(clippy::future_not_send)]
pub async fn render_fullscreen(
&self,
out: &mut impl textmode::Textmode,
@@ -188,7 +192,7 @@ impl History {
let entry = entry.lock_arc().await;
let focused = focus.map_or(false, |focus| idx == focus);
used_lines += entry.lines(self.size.1, focused && !scrolling);
- if used_lines > self.size.0 as usize {
+ if used_lines > usize::from(self.size.0) {
break;
}
iter.add(idx, entry);
@@ -279,7 +283,7 @@ impl Entry {
scrolling: bool,
offset: time::UtcOffset,
) {
- self.set_bgcolor(out, focused);
+ set_bgcolor(out, focused);
out.set_fgcolor(textmode::color::YELLOW);
let entry_count_width = format!("{}", entry_count + 1).len();
let idx_str = format!("{}", idx + 1);
@@ -288,7 +292,7 @@ impl Entry {
out.write_str(" ");
out.reset_attributes();
- self.set_bgcolor(out, focused);
+ set_bgcolor(out, focused);
if let Some(info) = self.exit_info {
if info.status.signal().is_some() {
out.set_fgcolor(textmode::color::MAGENTA);
@@ -303,7 +307,7 @@ impl Entry {
}
out.reset_attributes();
- self.set_bgcolor(out, focused);
+ set_bgcolor(out, focused);
out.write_str("$ ");
if self.running() {
out.set_bgcolor(textmode::Color::Rgb(16, 64, 16));
@@ -311,7 +315,7 @@ impl Entry {
out.write_str(&self.cmd);
out.reset_attributes();
- self.set_bgcolor(out, focused);
+ set_bgcolor(out, focused);
let time = self.exit_info.map_or_else(
|| {
format!(
@@ -330,9 +334,9 @@ impl Entry {
},
);
let cur_pos = out.screen().cursor_position();
- out.write_str(
- &" ".repeat(width as usize - time.len() - 1 - cur_pos.1 as usize),
- );
+ out.write_str(&" ".repeat(
+ usize::from(width) - time.len() - 1 - usize::from(cur_pos.1),
+ ));
out.write_str(&time);
out.write_str(" ");
out.reset_attributes();
@@ -411,14 +415,6 @@ impl Entry {
out.reset_attributes();
}
- fn set_bgcolor(&self, out: &mut impl textmode::Textmode, focus: bool) {
- if focus {
- out.set_bgcolor(textmode::Color::Rgb(32, 32, 64));
- } else {
- out.set_bgcolor(textmode::Color::Rgb(32, 32, 32));
- }
- }
-
pub async fn send_input(&self, bytes: Vec<u8>) {
if self.running() {
self.input.send(bytes).await.unwrap();
@@ -469,7 +465,7 @@ impl Entry {
if focused && self.running() {
last_row = std::cmp::max(
last_row,
- screen.cursor_position().0 as usize + 1,
+ usize::from(screen.cursor_position().0) + 1,
);
}
last_row
@@ -578,3 +574,11 @@ fn run_process(
}
});
}
+
+fn set_bgcolor(out: &mut impl textmode::Textmode, focus: bool) {
+ if focus {
+ out.set_bgcolor(textmode::Color::Rgb(32, 32, 64));
+ } else {
+ out.set_bgcolor(textmode::Color::Rgb(32, 32, 32));
+ }
+}
diff --git a/src/state/mod.rs b/src/state/mod.rs
index 2fcaf3f..ec77725 100644
--- a/src/state/mod.rs
+++ b/src/state/mod.rs
@@ -44,6 +44,8 @@ impl State {
}
}
+ // render always happens on the main task
+ #[allow(clippy::future_not_send)]
pub async fn render(
&self,
out: &mut impl textmode::Textmode,
diff --git a/src/state/readline.rs b/src/state/readline.rs
index 585d6b6..a6cb50d 100644
--- a/src/state/readline.rs
+++ b/src/state/readline.rs
@@ -15,6 +15,8 @@ impl Readline {
}
}
+ // render always happens on the main task
+ #[allow(clippy::future_not_send)]
pub async fn render(
&self,
out: &mut impl textmode::Textmode,
@@ -75,6 +77,8 @@ impl Readline {
self.size = size;
}
+ // self will be used eventually
+ #[allow(clippy::unused_self)]
pub fn lines(&self) -> usize {
2 // XXX handle wrapping
}