Skip to content

Commit

Permalink
chore: fix linting warnings (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpasmantier authored Jan 6, 2025
1 parent da2396e commit d207848
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 94 deletions.
75 changes: 38 additions & 37 deletions benches/results_list_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use television_channels::entry::merge_ranges;
use television_channels::entry::{Entry, PreviewType};
use television_screen::colors::ResultsColorscheme;
use television_screen::results::build_results_list;

pub fn results_list_benchmark(c: &mut Criterion) {
let mut icon_color_cache = std::collections::HashMap::default();
// FIXME: there's probably a way to have this as a benchmark asset
Expand All @@ -17,7 +18,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/LICENSE".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -34,7 +35,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/README.md".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -51,7 +52,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/re.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -68,7 +69,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/io.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -85,7 +86,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/gc.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -102,7 +103,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/uu.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -119,7 +120,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/nt.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -136,7 +137,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/dis.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -153,7 +154,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/imp.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -170,7 +171,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/bdb.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -187,7 +188,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/abc.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -204,7 +205,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/cgi.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -221,7 +222,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/bz2.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -238,7 +239,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/grp.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -255,7 +256,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/ast.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -272,7 +273,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/csv.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -289,7 +290,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/pdb.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -306,7 +307,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/pwd.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -323,7 +324,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/ssl.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -340,7 +341,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/tty.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -357,7 +358,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/nis.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -374,7 +375,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/pty.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -391,7 +392,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/cmd.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -408,7 +409,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/tests/utils.py".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -425,7 +426,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/pyproject.toml".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -442,7 +443,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/MAINTAINERS.md".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -459,7 +460,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/enum.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -476,7 +477,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/hmac.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -493,7 +494,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/uuid.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -510,7 +511,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/glob.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -527,7 +528,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/_ast.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -544,7 +545,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/_csv.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -561,7 +562,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/code.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -578,7 +579,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/spwd.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -595,7 +596,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
Entry {
name: "typeshed/stdlib/_msi.pyi".to_string(),
value: None,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand All @@ -619,7 +620,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
}),
line_number: None,
preview_type: PreviewType::Files,
name_match_ranges: Some(merge_ranges(&vec![
name_match_ranges: Some(merge_ranges(&[
(0, 1),
(1, 2),
(2, 3),
Expand Down Expand Up @@ -655,7 +656,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
&mut icon_color_cache,
&colorscheme,
);
})
});
});
}

Expand Down
1 change: 1 addition & 0 deletions crates/television-channels/src/cable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct CableChannelPrototype {

pub const DEFAULT_DELIMITER: &str = " ";

#[allow(clippy::unnecessary_wraps)]
fn default_delimiter() -> Option<String> {
Some(DEFAULT_DELIMITER.to_string())
}
Expand Down
17 changes: 8 additions & 9 deletions crates/television-channels/src/channels/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,17 @@ impl OnAir for Channel {
.with_icon(self.file_icon);

if should_add_name_indices {
entry = entry.with_name_match_ranges(
name_indices.into_iter().map(|i| (i, i + 1)).collect(),
);
let name_indices: Vec<(u32, u32)> =
name_indices.into_iter().map(|i| (i, i + 1)).collect();
entry = entry.with_name_match_ranges(&name_indices);
}

if should_add_value_indices {
entry = entry.with_value_match_ranges(
value_indices
.into_iter()
.map(|i| (i, i + 1))
.collect(),
);
let value_indices: Vec<(u32, u32)> = value_indices
.into_iter()
.map(|i| (i, i + 1))
.collect();
entry = entry.with_value_match_ranges(&value_indices);
}

entry
Expand Down
2 changes: 1 addition & 1 deletion crates/television-channels/src/channels/cable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl OnAir for Channel {
PreviewKind::None => PreviewType::None,
},
)
.with_name_match_ranges(item.match_indices)
.with_name_match_ranges(&item.match_indices)
})
.collect()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/television-channels/src/channels/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl OnAir for Channel {
" ",
)),
)
.with_name_match_ranges(item.match_indices)
.with_name_match_ranges(&item.match_indices)
.with_icon(FileIcon::from(&path))
})
.collect()
Expand Down
Loading

0 comments on commit d207848

Please sign in to comment.