refactor: clippy::similar_names (#974)

This commit is contained in:
EdJoPaTo 2024-03-02 13:19:57 +01:00 committed by Josh McKinney
parent 060d26b6dc
commit a6036ad789
No known key found for this signature in database
GPG key ID: 722287396A903BC5
3 changed files with 8 additions and 4 deletions

View file

@ -84,6 +84,7 @@ needless_pass_by_value = "warn"
redundant_closure_for_method_calls = "warn" redundant_closure_for_method_calls = "warn"
return_self_not_must_use = "warn" return_self_not_must_use = "warn"
semicolon_if_nothing_returned = "warn" semicolon_if_nothing_returned = "warn"
similar_names = "warn"
too_many_lines = "warn" too_many_lines = "warn"
trivially_copy_pass_by_ref = "warn" trivially_copy_pass_by_ref = "warn"
uninlined_format_args = "warn" uninlined_format_args = "warn"

View file

@ -393,12 +393,12 @@ mod tests {
#[test] #[test]
fn repeated_attributes() { fn repeated_attributes() {
let cyan_bg = Style::default().bg(Color::Cyan); let bg = Style::default().bg(Color::Cyan);
let cyan_fg = Style::default().fg(Color::Cyan); let fg = Style::default().fg(Color::Cyan);
// Behavior: the last one set is the definitive one // Behavior: the last one set is the definitive one
assert_eq!("hello".on_red().on_cyan(), Span::styled("hello", cyan_bg)); assert_eq!("hello".on_red().on_cyan(), Span::styled("hello", bg));
assert_eq!("hello".red().cyan(), Span::styled("hello", cyan_fg)); assert_eq!("hello".red().cyan(), Span::styled("hello", fg));
} }
#[test] #[test]

View file

@ -711,6 +711,7 @@ impl Block<'_> {
/// be cut off if the block is too small to fit all titles. This is not ideal and should be /// be cut off if the block is too small to fit all titles. This is not ideal and should be
/// the left side of that leftmost that is cut off. This is due to the line being truncated /// the left side of that leftmost that is cut off. This is due to the line being truncated
/// incorrectly. See <https://github.com/ratatui-org/ratatui/issues/932> /// incorrectly. See <https://github.com/ratatui-org/ratatui/issues/932>
#[allow(clippy::similar_names)]
fn render_right_titles(&self, position: Position, area: Rect, buf: &mut Buffer) { fn render_right_titles(&self, position: Position, area: Rect, buf: &mut Buffer) {
let titles = self.filtered_titles(position, Alignment::Right); let titles = self.filtered_titles(position, Alignment::Right);
let mut titles_area = self.titles_area(area, position); let mut titles_area = self.titles_area(area, position);
@ -745,6 +746,7 @@ impl Block<'_> {
/// Currently this method aligns the titles to the left inside a centered area. This is not /// Currently this method aligns the titles to the left inside a centered area. This is not
/// ideal and should be fixed in the future to align the titles to the center of the block and /// ideal and should be fixed in the future to align the titles to the center of the block and
/// truncate both sides of the titles if the block is too small to fit all titles. /// truncate both sides of the titles if the block is too small to fit all titles.
#[allow(clippy::similar_names)]
fn render_center_titles(&self, position: Position, area: Rect, buf: &mut Buffer) { fn render_center_titles(&self, position: Position, area: Rect, buf: &mut Buffer) {
let titles = self let titles = self
.filtered_titles(position, Alignment::Center) .filtered_titles(position, Alignment::Center)
@ -779,6 +781,7 @@ impl Block<'_> {
} }
/// Render titles aligned to the left of the block /// Render titles aligned to the left of the block
#[allow(clippy::similar_names)]
fn render_left_titles(&self, position: Position, area: Rect, buf: &mut Buffer) { fn render_left_titles(&self, position: Position, area: Rect, buf: &mut Buffer) {
let titles = self.filtered_titles(position, Alignment::Left); let titles = self.filtered_titles(position, Alignment::Left);
let mut titles_area = self.titles_area(area, position); let mut titles_area = self.titles_area(area, position);