Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
Fix clippy warnings
Erik Kundt committed 8 months ago
commit 80d2aa5b0391de54153c8d723c4383005f1610a0
parent 1fbed3e
15 files changed +40 -50
modified bin/cob/issue.rs
@@ -47,7 +47,7 @@ impl Filter {
impl fmt::Display for Filter {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        if let Some(state) = &self.state {
-
            write!(f, "is:{}", state)?;
+
            write!(f, "is:{state}")?;
            f.write_char(' ')?;
        }
        if self.assigned {
modified bin/cob/patch.rs
@@ -48,7 +48,7 @@ impl Filter {
impl fmt::Display for Filter {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        if let Some(state) = &self.status {
-
            write!(f, "is:{}", state)?;
+
            write!(f, "is:{state}")?;
            f.write_char(' ')?;
        }
        if self.authored {
modified bin/commands/inbox.rs
@@ -200,7 +200,7 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul
            let repository = profile.storage.repository(rid).unwrap();

            if let Err(err) = crate::log::enable() {
-
                println!("{}", err);
+
                println!("{err}");
            }
            log::info!("Starting inbox listing interface in project {}..", rid);

modified bin/commands/issue.rs
@@ -203,7 +203,7 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul
            let repository = profile.storage.repository(rid).unwrap();

            if let Err(err) = crate::log::enable() {
-
                println!("{}", err);
+
                println!("{err}");
            }
            log::info!("Starting issue listing interface in project {}..", rid);

modified bin/commands/issue/list.rs
@@ -549,9 +549,9 @@ fn comment(channel: &Channel<Message>) -> Widget<State, Message> {
                                String::new(),
                                |all, (r, acc)| {
                                    if *acc > 1_usize {
-
                                        [all, format!("{}{} ", r, acc)].concat()
+
                                        [all, format!("{r}{acc} ")].concat()
                                    } else {
-
                                        [all, format!("{} ", r)].concat()
+
                                        [all, format!("{r} ")].concat()
                                    }
                                },
                            );
modified bin/commands/patch.rs
@@ -263,7 +263,7 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul
        .map_err(|_| anyhow!("this command must be run in the context of a project"))?;

    if let Err(err) = crate::log::enable() {
-
        println!("{}", err);
+
        println!("{err}");
    }

    match options.op {
modified bin/commands/patch/list/imui.rs
@@ -498,7 +498,7 @@ fn browser_context<'a>(ui: &im::Ui<Message>, app: &'a App) -> Vec<Column<'a>> {
            ),
            Column::new(Span::raw("".to_string()), Constraint::Length(1)),
            Column::new(
-
                Span::raw(format!(" {} ", search))
+
                Span::raw(format!(" {search} "))
                    .into_left_aligned_line()
                    .cyan()
                    .dim()
modified bin/state.rs
@@ -82,8 +82,8 @@ pub struct FileIdentifier {
impl FileIdentifier {
    pub fn new(command: &str, operation: &str, rid: &RepoId, id: Option<&ObjectId>) -> Self {
        let id = match id {
-
            Some(id) => format!("{}-{}-{}-{}", command, operation, rid, id),
-
            _ => format!("{}-{}-{}", command, operation, rid),
+
            Some(id) => format!("{command}-{operation}-{rid}-{id}"),
+
            _ => format!("{command}-{operation}-{rid}"),
        };
        let id = format!("{:x}", md5::compute(id));

modified bin/ui/format.rs
@@ -75,7 +75,7 @@ pub fn author(did: &Did, alias: &Option<Alias>, is_you: bool) -> String {
    };

    if is_you {
-
        format!("{} (you)", author)
+
        format!("{author} (you)")
    } else {
        author
    }
modified bin/ui/items.rs
@@ -305,7 +305,7 @@ impl ToRow<9> for NotificationItem {
        let author = match &self.author.alias {
            Some(alias) => {
                if self.author.you {
-
                    span::alias(&format!("{} (you)", alias))
+
                    span::alias(&format!("{alias} (you)"))
                } else {
                    span::alias(alias)
                }
@@ -390,13 +390,11 @@ impl Filter<NotificationItem> for NotificationItemFilter {
            None => true,
        };

-
        let matches_authors = (!self.authors.is_empty())
-
            .then(|| {
+
        let matches_authors = if !self.authors.is_empty() { {
                self.authors
                    .iter()
                    .any(|other| notif.author.nid == Some(**other))
-
            })
-
            .unwrap_or(true);
+
            } } else { true };

        let matches_search = match &self.search {
            Some(search) => {
@@ -540,7 +538,7 @@ impl ToRow<8> for IssueItem {
        let author = match &self.author.alias {
            Some(alias) => {
                if self.author.you {
-
                    span::alias(&format!("{} (you)", alias))
+
                    span::alias(&format!("{alias} (you)"))
                } else {
                    span::alias(alias)
                }
@@ -613,21 +611,16 @@ impl Filter<IssueItem> for IssueItemFilter {
            true
        };

-
        let matches_authors = (!self.authors.is_empty())
-
            .then(|| {
+
        let matches_authors = if !self.authors.is_empty() { {
                self.authors
                    .iter()
                    .any(|other| issue.author.nid == Some(**other))
-
            })
-
            .unwrap_or(true);
+
            } } else { true };

-
        let matches_assigned = self
-
            .assigned
-
            .then(|| issue.assignees.iter().any(|assignee| assignee.you))
-
            .unwrap_or(true);
+
        let matches_assigned = if self
+
            .assigned { issue.assignees.iter().any(|assignee| assignee.you) } else { true };

-
        let matches_assignees = (!self.assignees.is_empty())
-
            .then(|| {
+
        let matches_assignees = if !self.assignees.is_empty() { {
                self.assignees.iter().any(|other| {
                    issue
                        .assignees
@@ -636,8 +629,7 @@ impl Filter<IssueItem> for IssueItemFilter {
                        .collect::<Vec<_>>()
                        .contains(other)
                })
-
            })
-
            .unwrap_or(true);
+
            } } else { true };

        let matches_search = match &self.search {
            Some(search) => match matcher.fuzzy_match(&issue.title, search) {
@@ -787,7 +779,7 @@ impl ToRow<9> for PatchItem {
        let author = match &self.author.alias {
            Some(alias) => {
                if self.author.you {
-
                    span::alias(&format!("{} (you)", alias))
+
                    span::alias(&format!("{alias} (you)"))
                } else {
                    span::alias(alias)
                }
@@ -860,13 +852,11 @@ impl Filter<PatchItem> for PatchItemFilter {
            true
        };

-
        let matches_authors = (!self.authors.is_empty())
-
            .then(|| {
+
        let matches_authors = if !self.authors.is_empty() { {
                self.authors
                    .iter()
                    .any(|other| patch.author.nid == Some(**other))
-
            })
-
            .unwrap_or(true);
+
            } } else { true };

        let matches_search = match &self.search {
            Some(search) => match matcher.fuzzy_match(&patch.title, search) {
@@ -1008,7 +998,7 @@ impl ToTree<String> for CommentItem {
        let author = match &self.author.alias {
            Some(alias) => {
                if self.author.you {
-
                    span::alias(&format!("{} (you)", alias))
+
                    span::alias(&format!("{alias} (you)"))
                } else {
                    span::alias(alias)
                }
@@ -1320,7 +1310,7 @@ impl ToRow<3> for StatefulHunkItem<'_> {
            };

            if added > 0 {
-
                cell.push(span::default(&format!("+{}", added)).light_green().dim());
+
                cell.push(span::default(&format!("+{added}")).light_green().dim());
            }

            if added > 0 && deleted > 0 {
@@ -1328,7 +1318,7 @@ impl ToRow<3> for StatefulHunkItem<'_> {
            }

            if deleted > 0 {
-
                cell.push(span::default(&format!("-{}", deleted)).light_red().dim());
+
                cell.push(span::default(&format!("-{deleted}")).light_red().dim());
            }

            cell
@@ -1474,7 +1464,7 @@ impl<'a> HunkItem<'a> {
            if count == 1 {
                span::default(" 1 comment ").dim().reversed()
            } else {
-
                span::default(&format!(" {} comments ", count))
+
                span::default(&format!(" {count} comments "))
                    .dim()
                    .reversed()
            }
modified bin/ui/rm.rs
@@ -186,7 +186,7 @@ impl<S, M> View for IssueDetails<S, M> {
            let author = match &issue.author.alias {
                Some(alias) => {
                    if issue.author.you {
-
                        span::alias(&format!("{}", alias))
+
                        span::alias(&format!("{alias}"))
                    } else {
                        span::alias(alias)
                    }
modified examples/selection.rs
@@ -134,7 +134,7 @@ pub async fn main() -> Result<()> {
        items: (0..200)
            .map(|id| Item {
                id,
-
                title: format!("Title of item #{}", id),
+
                title: format!("Title of item #{id}"),
                timestamp: SystemTime::now()
                    .duration_since(UNIX_EPOCH)
                    .expect("Could not read system time")
modified src/ui/rm/widget/input.rs
@@ -525,7 +525,7 @@ impl<S, M> View for TextArea<'_, S, M> {

        if props.show_scroll_progress {
            progress_info.push(Span::styled(
-
                format!("{}%", scroll_progress),
+
                format!("{scroll_progress}%"),
                Style::default().dim(),
            ))
        }
@@ -784,7 +784,7 @@ impl<S, M> TextView<S, M> {
            );
            if (content_height as usize) < content_len {
                // vec![Span::styled(format!("All / {}", content_len), scroll_style)]
-
                scroll = vec![Span::styled(format!("{}%", scroll_progress), scroll_style)];
+
                scroll = vec![Span::styled(format!("{scroll_progress}%"), scroll_style)];
            }
        }

modified src/ui/span.rs
@@ -59,23 +59,23 @@ pub fn notification_type(content: &str) -> Span<'static> {
pub fn step(step: usize, len: usize, fill_zeros: bool) -> Span<'static> {
    if fill_zeros {
        if len > 10 {
-
            badge(&format!("{:-02}/{:-02}", step, len))
+
            badge(&format!("{step:-02}/{len:-02}"))
        } else if len > 100 {
-
            badge(&format!("{:-03}/{:-03}", step, len))
+
            badge(&format!("{step:-03}/{len:-03}"))
        } else if len > 1000 {
-
            badge(&format!("{:-04}/{:-04}", step, len))
+
            badge(&format!("{step:-04}/{len:-04}"))
        } else if len > 10000 {
-
            badge(&format!("{:-05}/{:-05}", step, len))
+
            badge(&format!("{step:-05}/{len:-05}"))
        } else {
-
            badge(&format!("{}/{}", step, len))
+
            badge(&format!("{step}/{len}"))
        }
    } else {
-
        badge(&format!("{}/{}", step, len))
+
        badge(&format!("{step}/{len}"))
    }
}

pub fn progress(step: usize, len: usize) -> Span<'static> {
    let progress = step as f32 / len as f32 * 100_f32;
    let progress = progress as usize;
-
    default(&format!("{}%", progress)).dim()
+
    default(&format!("{progress}%")).dim()
}
modified src/ui/utils.rs
@@ -171,7 +171,7 @@ fn another_function() {
            if idx == lines.len() - 1 {
                actual.push_str(line);
            } else {
-
                actual.push_str(&format!("{}\n", line));
+
                actual.push_str(&format!("{line}\n"));
            }
        }