nightly clippy fixes

This commit is contained in:
Stephan Dilly 2021-06-05 10:28:18 +02:00
parent 6006e7aebd
commit 5b07c48234
39 changed files with 96 additions and 108 deletions

View File

@ -83,7 +83,7 @@ impl AsyncLog {
///
pub fn set_background(&mut self) {
self.background.store(true, Ordering::Relaxed)
self.background.store(true, Ordering::Relaxed);
}
///

View File

@ -245,7 +245,7 @@ fn raw_diff_to_file_diff<'a>(
if h != hunk_header {
adder(&h, &current_lines);
current_lines.clear();
current_hunk = Some(hunk_header)
current_hunk = Some(hunk_header);
}
}
}

View File

@ -118,7 +118,7 @@ pub fn stash_save(
options.insert(StashFlags::INCLUDE_UNTRACKED);
}
if keep_index {
options.insert(StashFlags::KEEP_INDEX)
options.insert(StashFlags::KEEP_INDEX);
}
let id = repo.stash_save2(&sig, message, Some(options))?;

View File

@ -31,7 +31,7 @@ pub fn get_tags(repo_path: &str) -> Result<Tags> {
let mut res = Tags::new();
let mut adder = |key, value: String| {
if let Some(key) = res.get_mut(&key) {
key.push(value)
key.push(value);
} else {
res.insert(key, vec![value]);
}

View File

@ -143,7 +143,7 @@ impl FileTreeItem {
*folded = folded.join(next.info.path());
} else {
self.info.folded =
Some(self.info.path().join(next.info.path()))
Some(self.info.path().join(next.info.path()));
}
self.info.full_path = next.info.full_path;

View File

@ -328,7 +328,7 @@ impl App {
pub fn update(&mut self) -> Result<()> {
log::trace!("update");
self.commit.update()?;
self.commit.update();
self.status_tab.update()?;
self.revlog.update()?;
self.files_tab.update()?;
@ -349,7 +349,7 @@ impl App {
self.status_tab.update_git(ev)?;
self.stashing_tab.update_git(ev)?;
self.files_tab.update_git(ev)?;
self.files_tab.update_git(ev);
self.revlog.update_git(ev)?;
self.blame_file_popup.update_git(ev)?;
self.inspect_commit_popup.update_git(ev)?;
@ -482,15 +482,15 @@ impl App {
fn switch_tab(&mut self, k: KeyEvent) -> Result<()> {
if k == self.key_config.tab_status {
self.set_tab(0)?
self.set_tab(0)?;
} else if k == self.key_config.tab_log {
self.set_tab(1)?
self.set_tab(1)?;
} else if k == self.key_config.tab_files {
self.set_tab(2)?
self.set_tab(2)?;
} else if k == self.key_config.tab_stashing {
self.set_tab(3)?
self.set_tab(3)?;
} else if k == self.key_config.tab_stashes {
self.set_tab(4)?
self.set_tab(4)?;
}
Ok(())
@ -578,14 +578,15 @@ impl App {
InternalEvent::OpenCommit => self.commit.show()?,
InternalEvent::PopupStashing(opts) => {
self.stashmsg_popup.options(opts);
self.stashmsg_popup.show()?
self.stashmsg_popup.show()?;
}
InternalEvent::TagCommit(id) => {
self.tag_commit_popup.open(id)?;
}
InternalEvent::BlameFile(path) => {
self.blame_file_popup.open(&path)?;
flags.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS)
flags
.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS);
}
InternalEvent::CreateBranch => {
self.create_branch_popup.open()?;
@ -603,7 +604,8 @@ impl App {
InternalEvent::TabSwitch => self.set_tab(0)?,
InternalEvent::InspectCommit(id, tags) => {
self.inspect_commit_popup.open(id, tags)?;
flags.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS)
flags
.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS);
}
InternalEvent::SelectCommitInRevlog(id) => {
if let Err(error) = self.revlog.select_commit(id) {
@ -611,36 +613,37 @@ impl App {
InternalEvent::ShowErrorMsg(
error.to_string(),
),
)
);
} else {
self.tags_popup.hide();
flags.insert(NeedsUpdate::ALL)
flags.insert(NeedsUpdate::ALL);
}
}
InternalEvent::OpenExternalEditor(path) => {
self.input.set_polling(false);
self.external_editor_popup.show()?;
self.file_to_open = path;
flags.insert(NeedsUpdate::COMMANDS)
flags.insert(NeedsUpdate::COMMANDS);
}
InternalEvent::Push(branch, force) => {
self.push_popup.push(branch, force)?;
flags.insert(NeedsUpdate::ALL)
flags.insert(NeedsUpdate::ALL);
}
InternalEvent::Pull(branch) => {
self.pull_popup.fetch(branch)?;
flags.insert(NeedsUpdate::ALL)
flags.insert(NeedsUpdate::ALL);
}
InternalEvent::PushTags => {
self.push_tags_popup.push_tags()?;
flags.insert(NeedsUpdate::ALL)
flags.insert(NeedsUpdate::ALL);
}
InternalEvent::StatusLastFileMoved => {
self.status_tab.last_file_moved()?;
}
InternalEvent::OpenFileTree(c) => {
self.revision_files_popup.open(c)?;
flags.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS)
flags
.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS);
}
};
@ -676,7 +679,7 @@ impl App {
{
self.queue.borrow_mut().push_back(
InternalEvent::ShowErrorMsg(e.to_string()),
)
);
} else {
flags.insert(NeedsUpdate::ALL);
self.select_branch_popup.update_branches()?;
@ -688,7 +691,7 @@ impl App {
InternalEvent::ShowErrorMsg(
error.to_string(),
),
)
);
} else {
flags.insert(NeedsUpdate::ALL);
self.tags_popup.update_tags()?;

View File

@ -49,7 +49,7 @@ pub fn process_cmdline() -> Result<CliArgs> {
let arg_matches = app.get_matches();
if arg_matches.is_present("bugreport") {
bug_report::generate_bugreport()?;
bug_report::generate_bugreport();
std::process::exit(0);
}
if arg_matches.is_present("logging") {

View File

@ -1,4 +1,3 @@
use anyhow::Result;
use bugreport::{
bugreport,
collector::{
@ -8,7 +7,7 @@ use bugreport::{
format::Markdown,
};
pub fn generate_bugreport() -> Result<()> {
pub fn generate_bugreport() {
bugreport!()
.info(SoftwareVersion::default())
.info(OperatingSystem::default())
@ -21,5 +20,4 @@ pub fn generate_bugreport() -> Result<()> {
]))
.info(CommandLine::default())
.print::<Markdown>();
Ok(())
}

View File

@ -231,7 +231,7 @@ impl Component for BlameFileComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {
@ -288,7 +288,7 @@ impl BlameFileComponent {
) -> Result<()> {
if self.is_visible() {
if let AsyncNotification::Blame = event {
self.update()?
self.update()?;
}
}

View File

@ -173,7 +173,7 @@ impl Component for BranchListComponent {
if self.visible {
if let Event::Key(e) = ev {
if e == self.key_config.exit_popup {
self.hide()
self.hide();
} else if e == self.key_config.move_down {
return self
.move_selection(ScrollType::Up)
@ -259,7 +259,7 @@ impl Component for BranchListComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {
@ -490,7 +490,7 @@ impl BranchListComponent {
asyncgit::CWD,
&self.branches[self.selection as usize].reference,
)?;
self.hide()
self.hide();
} else {
checkout_remote_branch(
CWD,

View File

@ -82,7 +82,7 @@ impl ChangesComponent {
let path = Path::new(i.path.as_str());
match i.status {
StatusItemType::Deleted => {
sync::stage_addremoved(CWD, path)?
sync::stage_addremoved(CWD, path)?;
}
_ => sync::stage_add_file(CWD, path)?,
};
@ -306,6 +306,6 @@ impl Component for ChangesComponent {
self.files.focused()
}
fn focus(&mut self, focus: bool) {
self.files.focus(focus)
self.files.focus(focus);
}
}

View File

@ -74,10 +74,8 @@ impl CommitComponent {
}
///
pub fn update(&mut self) -> Result<()> {
self.git_branch_name.lookup().map(Some).unwrap_or(None);
Ok(())
pub fn update(&mut self) {
self.git_branch_name.lookup().ok();
}
fn draw_branch_name<B: Backend>(&self, f: &mut Frame<B>) {
@ -370,7 +368,7 @@ impl Component for CommitComponent {
}
fn hide(&mut self) {
self.input.hide()
self.input.hide();
}
fn show(&mut self) -> Result<()> {

View File

@ -69,7 +69,7 @@ impl DetailsComponent {
&mut self,
id: Option<CommitId>,
tags: Option<CommitTags>,
) -> Result<()> {
) {
self.tags.clear();
self.data =
@ -78,10 +78,8 @@ impl DetailsComponent {
self.scroll_top.set(0);
if let Some(tags) = tags {
self.tags.extend(tags)
self.tags.extend(tags);
}
Ok(())
}
fn wrap_commit_details(
@ -377,7 +375,7 @@ impl DrawableComponent for DetailsComponent {
&self.theme,
Self::get_number_of_lines(&self.data, width as usize),
self.scroll_top.get(),
)
);
}
Ok(())

View File

@ -75,7 +75,7 @@ impl CommitDetailsComponent {
id: Option<CommitId>,
tags: Option<CommitTags>,
) -> Result<()> {
self.details.set_commit(id, tags)?;
self.details.set_commit(id, tags);
if let Some(id) = id {
if let Some((fetched_id, res)) =

View File

@ -75,7 +75,7 @@ impl Component for CreateBranchComponent {
}
fn hide(&mut self) {
self.input.hide()
self.input.hide();
}
fn show(&mut self) -> Result<()> {

View File

@ -147,15 +147,13 @@ impl DiffComponent {
(self.current.path.clone(), self.current.is_stage)
}
///
pub fn clear(&mut self, pending: bool) -> Result<()> {
pub fn clear(&mut self, pending: bool) {
self.current = Current::default();
self.diff = None;
self.scroll_top.set(0);
self.selection = Selection::Single(0);
self.selected_hunk = None;
self.pending = pending;
Ok(())
}
///
pub fn update(
@ -163,7 +161,7 @@ impl DiffComponent {
path: String,
is_stage: bool,
diff: FileDiff,
) -> Result<()> {
) {
self.pending = false;
let hash = hash(&diff);
@ -191,8 +189,6 @@ impl DiffComponent {
self.update_selection(old_selection);
}
}
Ok(())
}
fn move_selection(&mut self, move_type: ScrollType) {
@ -808,6 +804,6 @@ impl Component for DiffComponent {
self.focused
}
fn focus(&mut self, focus: bool) {
self.focused = focus
self.focused = focus;
}
}

View File

@ -179,7 +179,7 @@ impl Component for ExternalEditorComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -125,11 +125,11 @@ impl Component for HelpComponent {
if self.visible {
if let Event::Key(e) = ev {
if e == self.key_config.exit_popup {
self.hide()
self.hide();
} else if e == self.key_config.move_down {
self.move_selection(true)
self.move_selection(true);
} else if e == self.key_config.move_up {
self.move_selection(false)
self.move_selection(false);
} else {
}
}
@ -152,7 +152,7 @@ impl Component for HelpComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -227,9 +227,9 @@ impl InspectCommitComponent {
) -> Result<()> {
if self.is_visible() {
if let AsyncNotification::CommitFiles = ev {
self.update()?
self.update()?;
} else if let AsyncNotification::Diff = ev {
self.update_diff()?
self.update_diff()?;
}
}
@ -251,18 +251,18 @@ impl InspectCommitComponent {
self.git_diff.last()?
{
if params == diff_params {
self.diff.update(f.path, false, last)?;
self.diff.update(f.path, false, last);
return Ok(());
}
}
self.git_diff.request(diff_params)?;
self.diff.clear(true)?;
self.diff.clear(true);
return Ok(());
}
}
self.diff.clear(false)?;
self.diff.clear(false);
}
Ok(())

View File

@ -47,9 +47,9 @@ impl DrawableComponent for MsgComponent {
u16::try_from(max).expect("cant fail due to check above");
// dont overflow screen, and dont get too narrow
if width > f.size().width {
width = f.size().width
width = f.size().width;
} else if width < 60 {
width = 60
width = 60;
}
let area = ui::centered_rect_absolute(width, 25, f.size());
@ -107,7 +107,7 @@ impl Component for MsgComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -282,7 +282,7 @@ impl Component for PullComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -297,7 +297,7 @@ impl Component for PushComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -253,7 +253,7 @@ impl Component for PushTagsComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -79,7 +79,7 @@ impl Component for RenameBranchComponent {
}
fn hide(&mut self) {
self.input.hide()
self.input.hide();
}
fn show(&mut self) -> Result<()> {

View File

@ -91,7 +91,7 @@ impl Component for ResetComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -130,7 +130,7 @@ impl Component for RevisionFilesPopup {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -112,7 +112,7 @@ impl Component for StashMsgComponent {
}
fn hide(&mut self) {
self.input.hide()
self.input.hide();
}
fn show(&mut self) -> Result<()> {

View File

@ -106,7 +106,7 @@ impl SyntaxTextComponent {
);
self.current_file =
Some((path, Either::Right(content)))
Some((path, Either::Right(content)));
}
Err(e) => {
self.current_file = Some((
@ -115,7 +115,7 @@ impl SyntaxTextComponent {
"error loading file: {}",
e
)),
))
));
}
}
}
@ -262,6 +262,6 @@ impl Component for SyntaxTextComponent {
/// focus/unfocus this component depending on param
fn focus(&mut self, focus: bool) {
self.focused = focus
self.focused = focus;
}
}

View File

@ -65,7 +65,7 @@ impl Component for TagCommitComponent {
if let Event::Key(e) = ev {
if e == self.key_config.enter {
self.tag()
self.tag();
}
return Ok(EventState::Consumed);
@ -79,7 +79,7 @@ impl Component for TagCommitComponent {
}
fn hide(&mut self) {
self.input.hide()
self.input.hide();
}
fn show(&mut self) -> Result<()> {

View File

@ -158,7 +158,7 @@ impl Component for TagListComponent {
if self.visible {
if let Event::Key(key) = event {
if key == self.key_config.exit_popup {
self.hide()
self.hide();
} else if key == self.key_config.move_up {
self.move_selection(ScrollType::Up);
} else if key == self.key_config.move_down {
@ -215,7 +215,7 @@ impl Component for TagListComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -257,7 +257,7 @@ fn text_append<'a>(txt: Text<'a>, append: Text<'a>) -> Text<'a> {
}
}
} else {
txt = append
txt = append;
}
txt
}
@ -384,7 +384,7 @@ impl Component for TextInputComponent {
}
fn hide(&mut self) {
self.visible = false
self.visible = false;
}
fn show(&mut self) -> Result<()> {

View File

@ -358,7 +358,7 @@ impl StatusTree {
let item = &mut self.tree[i];
let item_path = &item.info.full_path;
if item_path.starts_with(&path) {
item.info.visible = false
item.info.visible = false;
} else {
return;
}
@ -416,7 +416,7 @@ impl StatusTree {
if prefix
.map_or(true, |prefix| item_path.starts_with(prefix))
{
self.tree[i].info.visible = true
self.tree[i].info.visible = true;
} else {
// if we do not set defaults we can early out
if set_defaults {

View File

@ -69,7 +69,7 @@ impl Input {
///
pub fn set_polling(&mut self, enabled: bool) {
self.desired_state.set_and_notify(enabled)
self.desired_state.set_and_notify(enabled);
}
fn shall_poll(&self) -> bool {
@ -111,7 +111,7 @@ impl Input {
if arc_current.load(Ordering::Relaxed) {
log::info!("input polling suspended");
tx.send(InputEvent::State(InputState::Paused))?
tx.send(InputEvent::State(InputState::Paused))?;
}
arc_current.store(false, Ordering::Relaxed);

View File

@ -144,13 +144,13 @@ fn main() -> Result<()> {
//Note: external ed closed, we need to re-hide cursor
terminal.hide_cursor()?;
}
app.event(ev)?
app.event(ev)?;
}
QueueEvent::Tick => app.update()?,
QueueEvent::GitEvent(ev)
if ev != AsyncNotification::FinishUnchanged =>
{
app.update_git(ev)?
app.update_git(ev)?;
}
QueueEvent::GitEvent(..) => (),
QueueEvent::SpinnerUpdate => unreachable!(),
@ -201,7 +201,7 @@ fn draw<B: Backend>(
terminal.draw(|mut f| {
if let Err(e) = app.draw(&mut f) {
log::error!("failed to draw: {:?}", e)
log::error!("failed to draw: {:?}", e);
}
})?;

View File

@ -62,15 +62,10 @@ impl FilesTab {
}
///
pub fn update_git(
&mut self,
ev: AsyncNotification,
) -> Result<()> {
pub fn update_git(&mut self, ev: AsyncNotification) {
if self.is_visible() {
self.files.update(ev);
}
Ok(())
}
}

View File

@ -194,13 +194,13 @@ impl Component for StashList {
if let Event::Key(k) = ev {
if k == self.key_config.enter {
self.pop_stash()
self.pop_stash();
} else if k == self.key_config.stash_apply {
self.apply_stash()
self.apply_stash();
} else if k == self.key_config.stash_drop {
self.drop_stash()
self.drop_stash();
} else if k == self.key_config.stash_open {
self.inspect()
self.inspect();
}
}
}

View File

@ -399,7 +399,7 @@ impl Status {
// maybe the diff changed (outside file change)
if let Some((params, last)) = self.git_diff.last()? {
if params == diff_params {
self.diff.update(path, is_stage, last)?;
self.diff.update(path, is_stage, last);
}
}
} else {
@ -407,13 +407,13 @@ impl Status {
if let Some(diff) =
self.git_diff.request(diff_params)?
{
self.diff.update(path, is_stage, diff)?;
self.diff.update(path, is_stage, diff);
} else {
self.diff.clear(true)?;
self.diff.clear(true);
}
}
} else {
self.diff.clear(false)?;
self.diff.clear(false);
}
Ok(())
@ -488,7 +488,7 @@ impl Status {
}
pub fn abort_merge(&self) {
try_or_popup!(self, "abort merge", sync::abort_merge(CWD))
try_or_popup!(self, "abort merge", sync::abort_merge(CWD));
}
fn commands_nav(

View File

@ -78,5 +78,5 @@ pub fn draw_scrollbar<B: Backend>(
) {
let mut widget = Scrollbar::new(max, pos);
widget.style_pos = theme.scroll_bar_pos();
f.render_widget(widget, r)
f.render_widget(widget, r);
}

View File

@ -71,7 +71,7 @@ pub fn draw_list<'b, B: Backend, L>(
.borders(Borders::ALL)
.border_style(theme.block(selected)),
);
f.render_widget(list, r)
f.render_widget(list, r);
}
pub fn draw_list_block<'b, B: Backend, L>(
@ -83,5 +83,5 @@ pub fn draw_list_block<'b, B: Backend, L>(
L: Iterator<Item = Span<'b>>,
{
let list = ScrollableList::new(items).block(block);
f.render_widget(list, r)
f.render_widget(list, r);
}