Skip to content

Commit

Permalink
refactor: clippy::semicolon_if_nothing_returned (#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 6fd5f63 commit 27680c0
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 41 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -66,6 +66,7 @@ unsafe_code = "forbid"
[lints.clippy]
explicit_iter_loop = "warn"
needless_for_each = "warn"
semicolon_if_nothing_returned = "warn"

[features]
#! The crate provides a set of optional features that can be enabled in your `cargo.toml` file.
Expand Down
2 changes: 1 addition & 1 deletion src/backend/crossterm.rs
Expand Up @@ -668,6 +668,6 @@ mod tests {
..Default::default()
}),
Style::default().underline_color(Color::Red)
)
);
}
}
28 changes: 14 additions & 14 deletions src/layout/layout.rs
Expand Up @@ -733,7 +733,7 @@ fn configure_constraints(
}
}
Constraint::Length(length) => {
solver.add_constraint(element.has_int_size(length, LENGTH_SIZE_EQ))?
solver.add_constraint(element.has_int_size(length, LENGTH_SIZE_EQ))?;
}
Constraint::Percentage(p) => {
let size = area.size() * f64::from(p) / 100.00;
Expand Down Expand Up @@ -776,7 +776,7 @@ fn configure_flex_constraints(
// constraints are satisfied
Flex::SpaceAround => {
for (left, right) in spacers.iter().tuple_combinations() {
solver.add_constraint(left.has_size(right, SPACER_SIZE_EQ))?
solver.add_constraint(left.has_size(right, SPACER_SIZE_EQ))?;
}
for spacer in spacers {
solver.add_constraint(spacer.has_min_size(spacing, SPACER_SIZE_EQ))?;
Expand All @@ -788,7 +788,7 @@ fn configure_flex_constraints(
// constraints are satisfied, but the first and last spacers are zero size
Flex::SpaceBetween => {
for (left, right) in spacers_except_first_and_last.iter().tuple_combinations() {
solver.add_constraint(left.has_size(right.size(), SPACER_SIZE_EQ))?
solver.add_constraint(left.has_size(right.size(), SPACER_SIZE_EQ))?;
}
for spacer in spacers_except_first_and_last {
solver.add_constraint(spacer.has_min_size(spacing, SPACER_SIZE_EQ))?;
Expand Down Expand Up @@ -1104,7 +1104,7 @@ mod tests {
assert!(!Layout::init_cache(15));
LAYOUT_CACHE.with(|c| {
assert_eq!(c.get().unwrap().borrow().cap().get(), 10);
})
});
}

#[test]
Expand All @@ -1130,7 +1130,7 @@ mod tests {
c.get().unwrap().borrow().cap().get(),
Layout::DEFAULT_CACHE_SIZE
);
})
});
}

#[test]
Expand Down Expand Up @@ -1406,7 +1406,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest]
Expand Down Expand Up @@ -1449,7 +1449,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest]
Expand Down Expand Up @@ -1485,7 +1485,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest] // flex, width, lengths, expected
Expand Down Expand Up @@ -1618,7 +1618,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest]
Expand Down Expand Up @@ -1655,7 +1655,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest]
Expand Down Expand Up @@ -1692,7 +1692,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest]
Expand Down Expand Up @@ -1795,7 +1795,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest]
Expand Down Expand Up @@ -1832,7 +1832,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[rstest]
Expand Down Expand Up @@ -1869,7 +1869,7 @@ mod tests {
#[case] constraints: &[Constraint],
#[case] expected: &str,
) {
letters(flex, constraints, width, expected)
letters(flex, constraints, width, expected);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/style.rs
Expand Up @@ -660,7 +660,7 @@ mod tests {
.bg(Color::Black)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::ITALIC)
)
);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/widgets.rs
Expand Up @@ -438,7 +438,7 @@ impl Widget for &str {
/// [`Rect`].
impl WidgetRef for &str {
fn render_ref(&self, area: Rect, buf: &mut Buffer) {
buf.set_string(area.x, area.y, self, crate::style::Style::default())
buf.set_string(area.x, area.y, self, crate::style::Style::default());
}
}

Expand All @@ -459,7 +459,7 @@ impl Widget for String {
/// without the need to give up ownership of the underlying text.
impl WidgetRef for String {
fn render_ref(&self, area: Rect, buf: &mut Buffer) {
buf.set_string(area.x, area.y, self, crate::style::Style::default())
buf.set_string(area.x, area.y, self, crate::style::Style::default());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/widgets/barchart.rs
Expand Up @@ -848,7 +848,7 @@ mod tests {
.fg(Color::Black)
.bg(Color::White)
.add_modifier(Modifier::BOLD)
)
);
}

#[test]
Expand Down Expand Up @@ -989,7 +989,7 @@ mod tests {

#[test]
fn test_horizontal_bars_label_width_greater_than_bar_with_style() {
test_horizontal_bars_label_width_greater_than_bar(Some(Color::White))
test_horizontal_bars_label_width_greater_than_bar(Some(Color::White));
}

/// Tests horizontal bars label are presents
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/block.rs
Expand Up @@ -1126,7 +1126,7 @@ mod tests {
style: Style::new(),
padding: Padding::zero(),
}
)
);
}

#[test]
Expand Down Expand Up @@ -1198,7 +1198,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/block/padding.rs
Expand Up @@ -168,7 +168,7 @@ mod tests {
top: 3,
bottom: 4
}
)
);
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/chart.rs
Expand Up @@ -1151,7 +1151,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand All @@ -1163,7 +1163,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand All @@ -1175,7 +1175,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand All @@ -1199,7 +1199,7 @@ mod tests {
let mut buffer = Buffer::empty(Rect::new(0, 0, 8, 4));
widget.render(buffer.area, &mut buffer);

assert_eq!(buffer, Buffer::with_lines(vec![" ".repeat(8); 4]))
assert_eq!(buffer, Buffer::with_lines(vec![" ".repeat(8); 4]));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/gauge.rs
Expand Up @@ -457,7 +457,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand All @@ -474,7 +474,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/list.rs
Expand Up @@ -1874,7 +1874,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand All @@ -1886,7 +1886,7 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/paragraph.rs
Expand Up @@ -952,7 +952,7 @@ mod test {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/reflow.rs
Expand Up @@ -628,7 +628,7 @@ mod test {
let (word_wrapper_space, word_wrapper_widths, _) =
run_composer(Composer::WordWrapper { trim: true }, text_space, width);
assert_eq!(word_wrapper_space, vec!["AAAAAAAAAAAAAAA AAAA", "AAA",]);
assert_eq!(word_wrapper_widths, vec![20, 3])
assert_eq!(word_wrapper_widths, vec![20, 3]);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/sparkline.rs
Expand Up @@ -317,6 +317,6 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}
}
2 changes: 1 addition & 1 deletion src/widgets/table/cell.rs
Expand Up @@ -195,6 +195,6 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
)
);
}
}
2 changes: 1 addition & 1 deletion src/widgets/table/row.rs
Expand Up @@ -319,6 +319,6 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::ITALIC)
)
);
}
}
8 changes: 4 additions & 4 deletions src/widgets/table/table.rs
Expand Up @@ -1370,7 +1370,7 @@ mod tests {
assert_eq!(
table.get_columns_widths(30, 0),
&[(0, 10), (10, 10), (20, 10)]
)
);
}

#[test]
Expand All @@ -1379,7 +1379,7 @@ mod tests {
.rows(vec![])
.header(Row::new(vec!["f", "g"]))
.column_spacing(0);
assert_eq!(table.get_columns_widths(10, 0), [(0, 5), (5, 5)])
assert_eq!(table.get_columns_widths(10, 0), [(0, 5), (5, 5)]);
}

#[test]
Expand All @@ -1388,7 +1388,7 @@ mod tests {
.rows(vec![])
.footer(Row::new(vec!["h", "i"]))
.column_spacing(0);
assert_eq!(table.get_columns_widths(10, 0), [(0, 5), (5, 5)])
assert_eq!(table.get_columns_widths(10, 0), [(0, 5), (5, 5)]);
}

fn test_table_with_selection(
Expand Down Expand Up @@ -1787,6 +1787,6 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::CROSSED_OUT)
)
);
}
}
2 changes: 1 addition & 1 deletion src/widgets/tabs.rs
Expand Up @@ -511,6 +511,6 @@ mod tests {
.bg(Color::White)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::ITALIC)
)
);
}
}

0 comments on commit 27680c0

Please sign in to comment.