summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Oram <dev@mitmaro.ca>2022-02-09 09:17:40 -0330
committerTim Oram <dev@mitmaro.ca>2022-02-09 10:20:26 -0330
commit8f71c1d25a9b454ba989404a1cdaad704f71e308 (patch)
tree3d2ea1bc3fde81d964c32b54a6b336f89d40776c
parent889bd039d1240b1e5c8de9d3c08dcb706f86dafb (diff)
Fix disabled lints in the view crate
-rw-r--r--src/view/src/lib.rs21
-rw-r--r--src/view/src/render_slice/mod.rs6
-rw-r--r--src/view/src/testutil.rs8
-rw-r--r--src/view/src/util.rs1
4 files changed, 22 insertions, 14 deletions
diff --git a/src/view/src/lib.rs b/src/view/src/lib.rs
index 8093988..29849e9 100644
--- a/src/view/src/lib.rs
+++ b/src/view/src/lib.rs
@@ -73,16 +73,8 @@
#![allow(
clippy::as_conversions,
clippy::else_if_without_else,
- clippy::exhaustive_structs,
- clippy::float_arithmetic,
clippy::integer_division,
- clippy::module_name_repetitions,
- clippy::new_without_default,
- clippy::non_ascii_literal,
- clippy::panic,
- clippy::too_many_lines,
- clippy::unwrap_used,
- clippy::wildcard_enum_match_arm
+ clippy::module_name_repetitions
)]
//! Git Interactive Rebase Tool - View Module
@@ -131,6 +123,7 @@ pub use self::{
const TITLE: &str = "Git Interactive Rebase Tool";
const TITLE_SHORT: &str = "Git Rebase";
const TITLE_HELP_INDICATOR_LABEL: &str = "Help: ";
+const SCROLLBAR_INDICATOR_CHARACTER: &str = "\u{2588}"; // "█"
/// Represents a view.
#[derive(Debug)]
@@ -225,8 +218,14 @@ impl<C: Tui> View<C> {
if show_scroll_bar {
self.display.move_from_end_of_line(1)?;
self.display.color(DisplayColor::Normal, true)?;
- self.display
- .draw_str(if scroll_indicator_index == index { "█" } else { " " })?;
+ self.display.draw_str(
+ if scroll_indicator_index == index {
+ SCROLLBAR_INDICATOR_CHARACTER
+ }
+ else {
+ " "
+ },
+ )?;
}
self.display.color(DisplayColor::Normal, false)?;
self.display.set_style(false, false, false)?;
diff --git a/src/view/src/render_slice/mod.rs b/src/view/src/render_slice/mod.rs
index 833eefd..9227087 100644
--- a/src/view/src/render_slice/mod.rs
+++ b/src/view/src/render_slice/mod.rs
@@ -33,6 +33,7 @@ pub struct RenderSlice {
}
impl RenderSlice {
+ #[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {
actions: VecDeque::new(),
@@ -113,7 +114,8 @@ impl RenderSlice {
#[allow(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
- clippy::cast_sign_loss
+ clippy::cast_sign_loss,
+ clippy::float_arithmetic
)]
pub(crate) fn get_scroll_index(&self) -> usize {
if self.lines_count == 0 || self.scroll_position.get_top_position() == 0 {
@@ -249,7 +251,7 @@ impl RenderSlice {
);
}
- #[allow(clippy::cognitive_complexity)]
+ #[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
fn rebuild(&mut self, view_data: &ViewData) {
let leading_lines_length = view_data.get_leading_lines().len();
let trailing_lines_length = view_data.get_trailing_lines().len();
diff --git a/src/view/src/testutil.rs b/src/view/src/testutil.rs
index 44c7ece..2a4a514 100644
--- a/src/view/src/testutil.rs
+++ b/src/view/src/testutil.rs
@@ -9,6 +9,8 @@ use super::{action::ViewAction, render_slice::RenderAction, view_data::ViewData,
const STARTS_WITH: &str = "{{StartsWith}}";
const ENDS_WITH: &str = "{{EndsWith}}";
const ANY_LINE: &str = "{{Any}}";
+const VISIBLE_SPACE_REPLACEMENT: &str = "\u{b7}"; // "·"
+const VISIBLE_TAB_REPLACEMENT: &str = " \u{2192}"; // " →"
/// Assert the rendered output from a `ViewData`.
#[macro_export]
@@ -29,6 +31,7 @@ macro_rules! render_line {
/// Options for the `assert_rendered_output!` macro
#[derive(Debug, Copy, Clone)]
+#[non_exhaustive]
pub struct AssertRenderOptions {
/// Ignore trailing whitespace
pub ignore_trailing_whitespace: bool,
@@ -44,7 +47,8 @@ impl Default for AssertRenderOptions {
}
fn replace_invisibles(line: &str) -> String {
- line.replace(' ', "·").replace('\t', " →")
+ line.replace(' ', VISIBLE_SPACE_REPLACEMENT)
+ .replace('\t', VISIBLE_TAB_REPLACEMENT)
}
fn render_style(color: DisplayColor, dimmed: bool, underline: bool, reversed: bool) -> String {
@@ -166,6 +170,7 @@ fn render_view_data(view_data: &ViewData) -> Vec<String> {
lines
}
+#[allow(clippy::panic)]
fn expand_expected(expected: &[String]) -> Vec<String> {
expected
.iter()
@@ -371,6 +376,7 @@ fn action_to_string(action: ViewAction) -> String {
/// Context for a `ViewSender` test.
#[derive(Debug)]
+#[non_exhaustive]
pub struct TestContext {
/// The sender instance.
pub sender: ViewSender,
diff --git a/src/view/src/util.rs b/src/view/src/util.rs
index 24e022c..5c2a006 100644
--- a/src/view/src/util.rs
+++ b/src/view/src/util.rs
@@ -5,6 +5,7 @@ use super::ViewSender;
/// Utility function to handle scroll events.
#[inline]
#[must_use]
+#[allow(clippy::wildcard_enum_match_arm)]
pub fn handle_view_data_scroll(event: Event, view_sender: &ViewSender) -> Option<Event> {
match event {
Event::Meta(meta_event) if meta_event == MetaEvent::ScrollLeft => view_sender.scroll_left(),