Skip to content

Commit

Permalink
refactor: clippy::similar_names (#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 060d26b commit a6036ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -84,6 +84,7 @@ needless_pass_by_value = "warn"
redundant_closure_for_method_calls = "warn"
return_self_not_must_use = "warn"
semicolon_if_nothing_returned = "warn"
similar_names = "warn"
too_many_lines = "warn"
trivially_copy_pass_by_ref = "warn"
uninlined_format_args = "warn"
Expand Down
8 changes: 4 additions & 4 deletions src/style/stylize.rs
Expand Up @@ -393,12 +393,12 @@ mod tests {

#[test]
fn repeated_attributes() {
let cyan_bg = Style::default().bg(Color::Cyan);
let cyan_fg = Style::default().fg(Color::Cyan);
let bg = Style::default().bg(Color::Cyan);
let fg = Style::default().fg(Color::Cyan);

// Behavior: the last one set is the definitive one
assert_eq!("hello".on_red().on_cyan(), Span::styled("hello", cyan_bg));
assert_eq!("hello".red().cyan(), Span::styled("hello", cyan_fg));
assert_eq!("hello".on_red().on_cyan(), Span::styled("hello", bg));
assert_eq!("hello".red().cyan(), Span::styled("hello", fg));
}

#[test]
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/block.rs
Expand Up @@ -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
/// 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>
#[allow(clippy::similar_names)]
fn render_right_titles(&self, position: Position, area: Rect, buf: &mut Buffer) {
let titles = self.filtered_titles(position, Alignment::Right);
let mut titles_area = self.titles_area(area, position);
Expand Down Expand Up @@ -745,6 +746,7 @@ impl Block<'_> {
/// 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
/// 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) {
let titles = self
.filtered_titles(position, Alignment::Center)
Expand Down Expand Up @@ -779,6 +781,7 @@ impl 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) {
let titles = self.filtered_titles(position, Alignment::Left);
let mut titles_area = self.titles_area(area, position);
Expand Down

0 comments on commit a6036ad

Please sign in to comment.