Skip to content

Commit

Permalink
refactor(lints): add lints to scrollbar (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo authored and joshka committed Mar 4, 2024
1 parent e02f476 commit 37b957c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions examples/scrollbar.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -107,6 +110,7 @@ fn run_app<B: Backend>(
}
}

#[allow(clippy::too_many_lines, clippy::cast_possible_truncation)]
fn ui(f: &mut Frame, app: &mut App) {
let size = f.size();

Expand Down
11 changes: 10 additions & 1 deletion 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};
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 37b957c

Please sign in to comment.