From 37b957c7e167a7ecda07b8a60cee5de71efcc55e Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Tue, 27 Feb 2024 12:03:45 +0100 Subject: [PATCH] refactor(lints): add lints to scrollbar (#974) --- examples/scrollbar.rs | 4 ++++ src/widgets/scrollbar.rs | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/scrollbar.rs b/examples/scrollbar.rs index 40a831d7..5ed7c0fd 100644 --- a/examples/scrollbar.rs +++ b/examples/scrollbar.rs @@ -13,6 +13,9 @@ //! [examples]: https://github.com/ratatui-org/ratatui/blob/main/examples //! [examples readme]: https://github.com/ratatui-org/ratatui/blob/main/examples/README.md +#![warn(clippy::pedantic)] +#![allow(clippy::wildcard_imports)] + use std::{ error::Error, io, @@ -107,6 +110,7 @@ fn run_app( } } +#[allow(clippy::too_many_lines, clippy::cast_possible_truncation)] fn ui(f: &mut Frame, app: &mut App) { let size = f.size(); diff --git a/src/widgets/scrollbar.rs b/src/widgets/scrollbar.rs index 65e33e74..498d1e11 100644 --- a/src/widgets/scrollbar.rs +++ b/src/widgets/scrollbar.rs @@ -1,3 +1,12 @@ +#![warn(clippy::pedantic)] +#![allow( + clippy::cast_possible_truncation, + clippy::cast_precision_loss, + clippy::cast_sign_loss, + clippy::module_name_repetitions, + clippy::wildcard_imports +)] + use std::iter; use strum::{Display, EnumString}; @@ -523,7 +532,7 @@ impl Scrollbar<'_> { /// /// This method returns the length of the start, thumb, and end as a tuple. fn part_lengths(&self, area: Rect, state: &ScrollbarState) -> (usize, usize, usize) { - let track_length = self.track_length_excluding_arrow_heads(area) as f64; + let track_length = f64::from(self.track_length_excluding_arrow_heads(area)); let viewport_length = self.viewport_length(state, area) as f64; // Ensure that the position of the thumb is within the bounds of the content taking into