From e92a2bfd4ea558f51cb30e44bf1e974a28562f3e Mon Sep 17 00:00:00 2001 From: xscriptor Date: Wed, 24 Jun 2026 20:16:16 +0200 Subject: [PATCH] add ci checker and solve warnings --- ci-check.sh | 16 ++++++++++++++++ src/app/mod.rs | 5 +---- src/cli/helpers.rs | 6 ++---- 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100755 ci-check.sh diff --git a/ci-check.sh b/ci-check.sh new file mode 100755 index 0000000..a78891e --- /dev/null +++ b/ci-check.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "=== cargo fmt --check ===" +cargo fmt --check + +echo "" +echo "=== cargo clippy -- -D warnings ===" +cargo clippy -- -D warnings + +echo "" +echo "=== cargo test ===" +cargo test + +echo "" +echo "All CI checks passed." diff --git a/src/app/mod.rs b/src/app/mod.rs index a74aecc..7f0b9b2 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -185,10 +185,7 @@ impl App { // Validate any stored token at startup. If the /user endpoint returns 401, // the token is stale – clear it so subsequent requests don't carry a bad header. - let auth_user = match github.fetch_authenticated_user() { - Ok(user) => user, - Err(_) => None, - }; + let auth_user: Option = github.fetch_authenticated_user().unwrap_or_default(); if auth_user.is_none() && token.is_some() { log::warn!("stored token rejected by GitHub, clearing it"); let _ = auth::clear_token(); diff --git a/src/cli/helpers.rs b/src/cli/helpers.rs index 638f8ad..cf001ad 100644 --- a/src/cli/helpers.rs +++ b/src/cli/helpers.rs @@ -110,8 +110,7 @@ pub fn resolve_full_name(repo: &str) -> Result { // ── API helpers ───────────────────────────────────────────────────────── pub fn handle_api_error(full_name: &str, e: &anyhow::Error) -> String { - let msg = e - .downcast_ref::() + e.downcast_ref::() .map(|gh_err| match gh_err { GitHubError::Api { status, body } if *status == 404 || body.contains("Not Found") => { format!("repository '{full_name}' not found on GitHub") @@ -128,8 +127,7 @@ pub fn handle_api_error(full_name: &str, e: &anyhow::Error) -> String { } _ => format!("{gh_err}"), }) - .unwrap_or_else(|| format!("{e}")); - msg + .unwrap_or_else(|| format!("{e}")) } pub fn make_client() -> Result> {