Skip to content

Commit eea202b

Browse files
author
Naseschwarz
committed
Fix clippy remarks
1 parent fce84ae commit eea202b

File tree

20 files changed

+64
-50
lines changed

20 files changed

+64
-50
lines changed

asyncgit/src/sync/branch/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ pub fn config_is_pull_rebase(repo_path: &RepoPath) -> Result<bool> {
271271
let value =
272272
rebase.value().map(String::from).unwrap_or_default();
273273
return Ok(value == "true");
274-
};
274+
}
275275

276276
Ok(false)
277277
}
@@ -701,7 +701,7 @@ mod tests_branches {
701701
&root.as_os_str().to_str().unwrap().into();
702702

703703
let upstream_merge_res =
704-
get_branch_upstream_merge(&repo_path, "master");
704+
get_branch_upstream_merge(repo_path, "master");
705705
assert!(
706706
upstream_merge_res.is_ok_and(|v| v.as_ref().is_none())
707707
);
@@ -721,12 +721,12 @@ mod tests_branches {
721721
config
722722
.set_str(
723723
&format!("branch.{branch_name}.merge"),
724-
&upstrem_merge,
724+
upstrem_merge,
725725
)
726726
.expect("fail set branch merge config");
727727

728728
let upstream_merge_res =
729-
get_branch_upstream_merge(&repo_path, &branch_name);
729+
get_branch_upstream_merge(repo_path, branch_name);
730730
assert!(upstream_merge_res
731731
.as_ref()
732732
.is_ok_and(|v| v.as_ref().is_some()));

asyncgit/src/sync/remotes/push.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Write;
2+
13
use crate::{
24
error::{Error, Result},
35
progress::ProgressPercent,
@@ -182,7 +184,8 @@ pub fn push_raw(
182184
if let Ok(Some(branch_upstream_merge)) =
183185
get_branch_upstream_merge(repo_path, branch)
184186
{
185-
push_ref.push_str(&format!(":{branch_upstream_merge}"));
187+
write!(&mut push_ref, ":{branch_upstream_merge}")
188+
.map_err(|e| Error::Generic(e.to_string()))?;
186189
}
187190
}
188191

@@ -289,7 +292,7 @@ mod tests {
289292

290293
// Attempt force push,
291294
// should work as it forces the push through
292-
assert!(!push_branch(
295+
assert!(push_branch(
293296
&tmp_other_repo_dir.path().to_str().unwrap().into(),
294297
"origin",
295298
"master",
@@ -298,7 +301,7 @@ mod tests {
298301
None,
299302
None,
300303
)
301-
.is_err());
304+
.is_ok());
302305
}
303306

304307
#[test]

asyncgit/src/sync/stash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mod tests {
144144
let repo_path: &RepoPath =
145145
&root.as_os_str().to_str().unwrap().into();
146146

147-
assert!(!stash_save(repo_path, None, true, false).is_ok());
147+
assert!(stash_save(repo_path, None, true, false).is_err());
148148

149149
assert!(get_stashes(repo_path).unwrap().is_empty());
150150
}

asyncgit/src/sync/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ mod tests {
242242
let root = repo.path().parent().unwrap();
243243
let repo_path = root.as_os_str().to_str().unwrap();
244244

245-
assert!(!stage_add_file(&repo_path.into(), file_path).is_ok());
245+
assert!(stage_add_file(&repo_path.into(), file_path).is_err());
246246
}
247247

248248
#[test]
@@ -440,7 +440,7 @@ mod tests {
440440
let repo_path: &RepoPath =
441441
&root.as_os_str().to_str().unwrap().into();
442442

443-
assert!(!get_head(repo_path).is_ok());
443+
assert!(get_head(repo_path).is_err());
444444

445445
Ok(())
446446
}

filetreelist/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl TreeItemInfo {
5555
Path::new(
5656
self.full_path
5757
.components()
58-
.last()
58+
.next_back()
5959
.and_then(|c| c.as_os_str().to_str())
6060
.unwrap_or_default(),
6161
)

filetreelist/src/treeitems_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'a> Iterator for TreeItemsIterator<'a> {
3535
*i += 1;
3636
} else {
3737
self.increments = Some(0);
38-
};
38+
}
3939

4040
loop {
4141
if !init {

src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl App {
275275
3 => self.stashing_tab.draw(f, chunks_main[1])?,
276276
4 => self.stashlist_tab.draw(f, chunks_main[1])?,
277277
_ => bail!("unknown tab"),
278-
};
278+
}
279279
}
280280

281281
self.draw_popups(f)?;
@@ -905,7 +905,7 @@ impl App {
905905
InternalEvent::CommitSearch(options) => {
906906
self.revlog.search(options);
907907
}
908-
};
908+
}
909909

910910
Ok(flags)
911911
}
@@ -997,7 +997,7 @@ impl App {
997997
undo_last_commit(&self.repo.borrow())
998998
);
999999
}
1000-
};
1000+
}
10011001

10021002
flags.insert(NeedsUpdate::ALL);
10031003

@@ -1019,7 +1019,7 @@ impl App {
10191019
));
10201020

10211021
self.tags_popup.update_tags()?;
1022-
};
1022+
}
10231023
Ok(())
10241024
}
10251025

src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn setup_logging(path_override: Option<PathBuf>) -> Result<()> {
139139
path
140140
};
141141

142-
println!("Logging enabled. Log written to: {path:?}");
142+
println!("Logging enabled. Log written to: {}", path.display());
143143

144144
WriteLogger::init(
145145
LevelFilter::Trace,

src/components/changes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl ChangesComponent {
9292
&self.repo.borrow(),
9393
path,
9494
)?,
95-
};
95+
}
9696
} else {
9797
let config =
9898
self.options.borrow().status_show_untracked();

src/components/commitlist.rs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -490,24 +490,36 @@ impl CommitList {
490490
txt.push(splitter.clone());
491491
}
492492

493-
let style_hash = normal
494-
.then(|| theme.commit_hash(selected))
495-
.unwrap_or_else(|| theme.commit_unhighlighted());
496-
let style_time = normal
497-
.then(|| theme.commit_time(selected))
498-
.unwrap_or_else(|| theme.commit_unhighlighted());
499-
let style_author = normal
500-
.then(|| theme.commit_author(selected))
501-
.unwrap_or_else(|| theme.commit_unhighlighted());
502-
let style_tags = normal
503-
.then(|| theme.tags(selected))
504-
.unwrap_or_else(|| theme.commit_unhighlighted());
505-
let style_branches = normal
506-
.then(|| theme.branch(selected, true))
507-
.unwrap_or_else(|| theme.commit_unhighlighted());
508-
let style_msg = normal
509-
.then(|| theme.text(true, selected))
510-
.unwrap_or_else(|| theme.commit_unhighlighted());
493+
let style_hash = if normal {
494+
theme.commit_hash(selected)
495+
} else {
496+
theme.commit_unhighlighted()
497+
};
498+
let style_time = if normal {
499+
theme.commit_time(selected)
500+
} else {
501+
theme.commit_unhighlighted()
502+
};
503+
let style_author = if normal {
504+
theme.commit_author(selected)
505+
} else {
506+
theme.commit_unhighlighted()
507+
};
508+
let style_tags = if normal {
509+
theme.tags(selected)
510+
} else {
511+
theme.commit_unhighlighted()
512+
};
513+
let style_branches = if normal {
514+
theme.branch(selected, true)
515+
} else {
516+
theme.commit_unhighlighted()
517+
};
518+
let style_msg = if normal {
519+
theme.text(true, selected)
520+
} else {
521+
theme.commit_unhighlighted()
522+
};
511523

512524
// commit hash
513525
txt.push(Span::styled(Cow::from(&*e.hash_short), style_hash));

src/components/textinput.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl TextInputComponent {
176176
)
177177
.title(self.title.clone()),
178178
);
179-
};
179+
}
180180
text_area
181181
});
182182
}

src/components/utils/filetree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl FileTreeItem {
9090

9191
match path
9292
.components()
93-
.last()
93+
.next_back()
9494
.map(std::path::Component::as_os_str)
9595
.map(OsStr::to_string_lossy)
9696
.map(String::from)

src/popups/commit.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,8 @@ impl CommitPopup {
470470

471471
let mut msg = msg.to_owned();
472472
if let (Some(user), Some(mail)) = (user, mail) {
473-
msg.push_str(&format!(
474-
"\n\nSigned-off-by: {user} <{mail}>"
475-
));
473+
use std::fmt::Write;
474+
write!(msg, "\n\nSigned-off-by: {user} <{mail}>")?;
476475
}
477476

478477
Ok(msg)

src/popups/create_remote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,6 @@ impl CreateRemotePopup {
209209

210210
self.hide();
211211
}
212-
};
212+
}
213213
}
214214
}

src/popups/file_revlog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ impl Component for FileRevlogPopup {
521521
InspectCommitOpen::new(commit_id),
522522
),
523523
));
524-
};
524+
}
525525
} else if key_match(key, self.key_config.keys.blame) {
526526
if let Some(open_request) =
527527
self.open_request.clone()

src/popups/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl OptionsPopup {
207207
.borrow_mut()
208208
.diff_hunk_lines_change(true);
209209
}
210-
};
210+
}
211211
} else {
212212
match self.selection {
213213
AppOption::StatusShowUntracked => {
@@ -246,7 +246,7 @@ impl OptionsPopup {
246246
.borrow_mut()
247247
.diff_hunk_lines_change(false);
248248
}
249-
};
249+
}
250250
}
251251

252252
self.queue

src/tabs/stashing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl Component for Stashing {
245245
} else {
246246
Ok(EventState::NotConsumed)
247247
};
248-
};
248+
}
249249
}
250250

251251
Ok(EventState::NotConsumed)

src/tabs/stashlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl StashList {
102102
Action::StashDrop(ids) => self.drop(repo, ids)?,
103103
Action::StashPop(id) => self.pop(repo, *id)?,
104104
_ => (),
105-
};
105+
}
106106

107107
Ok(())
108108
}

src/tabs/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl Status {
348348

349349
self.diff.focus(true);
350350
}
351-
};
351+
}
352352

353353
self.update_diff()?;
354354

src/ui/scrollbar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Scrollbar {
4949
let right = area.right().saturating_sub(1);
5050
if right <= area.left() {
5151
return;
52-
};
52+
}
5353

5454
let (bar_top, bar_height) = {
5555
let scrollbar_area = area.inner(Margin {
@@ -86,7 +86,7 @@ impl Scrollbar {
8686
let bottom = area.bottom().saturating_sub(1);
8787
if bottom <= area.top() {
8888
return;
89-
};
89+
}
9090

9191
let (bar_left, bar_width) = {
9292
let scrollbar_area = area.inner(Margin {

0 commit comments

Comments
 (0)