diff --git a/asyncgit/src/lib.rs b/asyncgit/src/lib.rs index d18c04ea..f9269939 100644 --- a/asyncgit/src/lib.rs +++ b/asyncgit/src/lib.rs @@ -3,7 +3,7 @@ #![forbid(unsafe_code)] #![forbid(missing_docs)] #![deny(clippy::all)] -#![deny(clippy::result_unwrap_used)] +#![deny(clippy::unwrap_used)] #![deny(clippy::panic)] pub mod cached; diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index 75c75af2..cbeb0567 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -219,8 +219,10 @@ fn raw_diff_to_file_diff<'a>( }; let new_file_diff = if diff.deltas().len() == 1 { - // it's safe to unwrap here because we check first that diff.deltas has a single element. - let delta: DiffDelta = diff.deltas().next().unwrap(); + let delta: DiffDelta = diff + .deltas() + .next() + .expect("it's safe to unwrap here because we check first that diff.deltas has a single element"); if delta.status() == Delta::Untracked { let relative_path = @@ -272,7 +274,10 @@ fn raw_diff_to_file_diff<'a>( } if !current_lines.is_empty() { - adder(¤t_hunk.unwrap(), ¤t_lines); + adder( + ¤t_hunk.expect("invalid hunk"), + ¤t_lines, + ); } if new_file_diff { diff --git a/asyncgit/src/sync/hunks.rs b/asyncgit/src/sync/hunks.rs index e56c7694..e0e86dad 100644 --- a/asyncgit/src/sync/hunks.rs +++ b/asyncgit/src/sync/hunks.rs @@ -23,7 +23,8 @@ pub fn stage_hunk( let mut opt = ApplyOptions::new(); opt.hunk_callback(|hunk| { - let header = HunkHeader::from(hunk.unwrap()); + let header = + HunkHeader::from(hunk.expect("hunk unavailable")); hash(&header) == hunk_hash }); @@ -117,7 +118,8 @@ pub fn unstage_hunk( let mut hunk_idx = 0; let mut opt = ApplyOptions::new(); opt.hunk_callback(|_hunk| { - let res = if hunk_idx == hunk_index.unwrap() { + let res = if hunk_idx == hunk_index.expect("invalid hunk") + { count += 1; true } else { diff --git a/scopetime/src/lib.rs b/scopetime/src/lib.rs index 649d2c59..f863013f 100644 --- a/scopetime/src/lib.rs +++ b/scopetime/src/lib.rs @@ -2,7 +2,7 @@ #![forbid(unsafe_code)] #![forbid(missing_docs)] -#![deny(clippy::result_unwrap_used)] +#![deny(clippy::unwrap_used)] use std::time::Instant; diff --git a/src/components/filetree.rs b/src/components/filetree.rs index b7c77c23..30a37e8a 100644 --- a/src/components/filetree.rs +++ b/src/components/filetree.rs @@ -109,7 +109,7 @@ impl FileTreeComponent { if let Some(item) = self.tree.selected_item() { match item.kind { FileTreeItemKind::File(_) => true, - _ => false, + FileTreeItemKind::Path(..) => false, } } else { false @@ -206,7 +206,7 @@ impl FileTreeComponent { StatusItemType::New => '+', StatusItemType::Deleted => '-', StatusItemType::Renamed => 'R', - _ => ' ', + StatusItemType::Typechange => ' ', } } } diff --git a/src/components/utils/filetree.rs b/src/components/utils/filetree.rs index a48f650c..ce59aa20 100644 --- a/src/components/utils/filetree.rs +++ b/src/components/utils/filetree.rs @@ -192,7 +192,8 @@ impl FileTreeItems { index: usize, ) -> usize { if let Some(parent_path) = Path::new(path).parent() { - let parent_path = parent_path.to_str().unwrap(); + let parent_path = + parent_path.to_str().expect("invalid path"); for i in (0..=index).rev() { let item = &self.items[i]; let item_path = &item.info.full_path; @@ -216,18 +217,16 @@ impl FileTreeItems { ancestors.reverse(); for c in &ancestors { - if c.parent().is_some() { - let path_string = String::from(c.to_str().unwrap()); - if !paths_added.contains(c) { - paths_added.insert(c); - let is_collapsed = - collapsed.contains(&path_string); - nodes.push(FileTreeItem::new_path( - c, - path_string, - is_collapsed, - )?); - } + if c.parent().is_some() && !paths_added.contains(c) { + paths_added.insert(c); + let path_string = + String::from(c.to_str().expect("invalid path")); + let is_collapsed = collapsed.contains(&path_string); + nodes.push(FileTreeItem::new_path( + c, + path_string, + is_collapsed, + )?); } } diff --git a/src/components/utils/statustree.rs b/src/components/utils/statustree.rs index 04caaef6..1c930385 100644 --- a/src/components/utils/statustree.rs +++ b/src/components/utils/statustree.rs @@ -332,8 +332,8 @@ impl StatusTree { inner_collapsed = Some(format!("{}/", &item_path)); } - if prefix.is_none() - || item_path.starts_with(prefix.unwrap()) + if prefix + .map_or(true, |prefix| item_path.starts_with(prefix)) { self.tree[i].info.visible = true } else { diff --git a/src/main.rs b/src/main.rs index 1c453b08..fe6d1e05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ #![deny(clippy::cargo)] #![deny(clippy::pedantic)] #![deny(clippy::nursery)] -#![deny(clippy::result_unwrap_used)] +#![deny(clippy::unwrap_used)] #![deny(clippy::panic)] #![allow(clippy::module_name_repetitions)] #![allow(clippy::multiple_crate_versions)] @@ -141,8 +141,8 @@ fn main() -> Result<()> { { app.update_git(ev)? } + QueueEvent::GitEvent(..) => (), QueueEvent::SpinnerUpdate => unreachable!(), - _ => (), } draw(&mut terminal, &app)?; diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 89af6970..5de60676 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -137,7 +137,7 @@ impl Status { match self.focus { Focus::WorkDir => self.index_wd.is_file_seleted(), Focus::Stage => self.index.is_file_seleted(), - _ => false, + Focus::Diff => false, } } diff --git a/src/ui/style.rs b/src/ui/style.rs index d45cce61..dc632d87 100644 --- a/src/ui/style.rs +++ b/src/ui/style.rs @@ -110,7 +110,7 @@ impl Theme { StatusItemType::Renamed => { Style::default().fg(self.diff_file_moved) } - _ => Style::default(), + StatusItemType::Typechange => Style::default(), }; self.apply_select(style, selected) @@ -155,7 +155,7 @@ impl Theme { DiffLineType::Header => Style::default() .fg(self.disabled_fg) .modifier(Modifier::BOLD), - _ => Style::default().fg(if selected { + DiffLineType::None => Style::default().fg(if selected { self.command_fg } else { Color::Reset