diff --git a/Cargo.toml b/Cargo.toml index 386a5cb7..11674411 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,7 @@ equatable_if_let = "warn" explicit_iter_loop = "warn" implicit_clone = "warn" inefficient_to_string = "warn" +items_after_statements = "warn" missing_const_for_fn = "warn" needless_for_each = "warn" needless_pass_by_value = "warn" diff --git a/src/widgets/barchart/bar.rs b/src/widgets/barchart/bar.rs index 70a5ee93..3561f283 100644 --- a/src/widgets/barchart/bar.rs +++ b/src/widgets/barchart/bar.rs @@ -156,10 +156,10 @@ impl<'a> Bar<'a> { ticks: u64, ) { if self.value != 0 { + const TICKS_PER_LINE: u64 = 8; let value = self.value.to_string(); let value_label = self.text_value.as_ref().unwrap_or(&value); let width = value_label.width() as u16; - const TICKS_PER_LINE: u64 = 8; // if we have enough space or the ticks are greater equal than 1 cell (8) // then print the value if width < max_width || (width == max_width && ticks >= TICKS_PER_LINE) { diff --git a/src/widgets/block.rs b/src/widgets/block.rs index d29db034..07252f55 100644 --- a/src/widgets/block.rs +++ b/src/widgets/block.rs @@ -1203,9 +1203,9 @@ mod tests { #[test] fn title() { - let mut buffer = Buffer::empty(Rect::new(0, 0, 15, 3)); use Alignment::*; use Position::*; + let mut buffer = Buffer::empty(Rect::new(0, 0, 15, 3)); Block::bordered() .title(Title::from("A").position(Top).alignment(Left)) .title(Title::from("B").position(Top).alignment(Center)) diff --git a/src/widgets/list.rs b/src/widgets/list.rs index a329f767..834585fd 100755 --- a/src/widgets/list.rs +++ b/src/widgets/list.rs @@ -1793,13 +1793,6 @@ mod tests { #[test] fn test_list_long_lines() { - let items = list_items(vec![ - "Item 0 with a very long line that will be truncated", - "Item 1", - "Item 2", - ]); - let list = List::new(items).highlight_symbol(">>"); - fn test_case(list: List, selected: Option, expected_lines: Vec<&str>) { let mut state = ListState::default(); state.select(selected); @@ -1808,6 +1801,13 @@ mod tests { assert_buffer_eq!(buffer, expected); } + let items = list_items(vec![ + "Item 0 with a very long line that will be truncated", + "Item 1", + "Item 2", + ]); + let list = List::new(items).highlight_symbol(">>"); + test_case( list.clone(), None,