From 23795ca81cafb599da9e4b870111703318695985 Mon Sep 17 00:00:00 2001 From: Romuald Lemesle Date: Fri, 6 Mar 2026 17:02:24 +0100 Subject: [PATCH] [agent] chore(clippy): add clippy on CI --- .circleci/config.yml | 8 ++++++++ src/api/manage_jobs.rs | 4 ++-- src/api/register_agent.rs | 2 +- src/process/agent_job.rs | 9 +++++---- src/process/keep_alive.rs | 4 ++-- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dfc21b58..9546d2c7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,6 +22,7 @@ jobs: # Run checks - run: cargo check - run: cargo fmt -- --check + - run: cargo clippy -- -D warnings - run: cargo build --release - run: cargo test --release - run: | @@ -108,6 +109,7 @@ jobs: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; # Run checks - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" check' + - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" clippy -- -D warnings' - run: git config --global --unset url.ssh://git@github.com.insteadOf - run: git config --global url.ssh://git@github.com.insteadOf https://github.com/ - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' @@ -193,6 +195,7 @@ jobs: - run: . "$HOME/.cargo/env"; rustup target add x86_64-unknown-linux-musl # Run checks - run: cargo check + - run: cargo clippy -- -D warnings - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/x86_64-unknown-linux-musl/release/openaev-agent @@ -253,6 +256,7 @@ jobs: - run: . "$HOME/.cargo/env"; rustup target add aarch64-unknown-linux-musl # Run checks - run: cargo check + - run: cargo clippy -- -D warnings - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/aarch64-unknown-linux-musl/release/openaev-agent @@ -311,6 +315,7 @@ jobs: - run: curl https://sh.rustup.rs -sSf | sh -s -- -y # Run checks - run: cargo check + - run: cargo clippy -- -D warnings - run: . "$HOME/.cargo/env"; cargo build --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/release/openaev-agent @@ -372,6 +377,9 @@ jobs: cargo install cargo-audit # Run checks - run: cargo check + - run: cargo fmt -- --check + - run: cargo clippy -- -D warnings + - run: cargo audit - run: . "$HOME/.cargo/env"; cargo build --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/release/openaev-agent diff --git a/src/api/manage_jobs.rs b/src/api/manage_jobs.rs index 53a4094c..50e98419 100644 --- a/src/api/manage_jobs.rs +++ b/src/api/manage_jobs.rs @@ -42,7 +42,7 @@ impl Client { } } Err(err) => { - error!("Error API list_jobs {}", err.to_string()); + error!("Error API list_jobs {}", err); Err(Error::Internal(err.to_string())) } } @@ -62,7 +62,7 @@ impl Client { } } Err(err) => { - error!("Error API clean_job {}", err.to_string()); + error!("Error API clean_job {}", err); Err(Error::Internal(err.to_string())) } } diff --git a/src/api/register_agent.rs b/src/api/register_agent.rs index 5dca39ff..ce0bf73b 100644 --- a/src/api/register_agent.rs +++ b/src/api/register_agent.rs @@ -114,7 +114,7 @@ impl Client { } } Err(err) => { - error!("Error API register_agent {}", err.to_string()); + error!("Error API register_agent {}", err); Err(Error::Internal(err.to_string())) } } diff --git a/src/process/agent_job.rs b/src/process/agent_job.rs index 6044c839..94ae1627 100644 --- a/src/process/agent_job.rs +++ b/src/process/agent_job.rs @@ -26,8 +26,8 @@ pub fn listen( execution_details.is_elevated, execution_details.executed_by_user.clone(), ); - if jobs.is_ok() { - if let Ok(jobs) = jobs { + match jobs { + Ok(jobs) => { jobs.iter().for_each(|j| { info!("Start handling inject: {:?}", j.asset_agent_inject); // 01. Remove the execution job @@ -43,8 +43,9 @@ pub fn listen( info!("Done handling inject: {:?}", j.asset_agent_inject); }); } - } else { - error!("Fail getting jobs {}", jobs.unwrap_err()) + Err(err) => { + error!("Fail getting jobs {}", err) + } } // Wait for the next ping (30 secs) sleep(Duration::from_secs(30)); diff --git a/src/process/keep_alive.rs b/src/process/keep_alive.rs index f39996af..6df68a2e 100644 --- a/src/process/keep_alive.rs +++ b/src/process/keep_alive.rs @@ -30,8 +30,8 @@ pub fn ping( installation_mode.clone(), service_name.clone(), ); - if register.is_err() { - error!("Fail registering the agent {}", register.unwrap_err()) + if let Err(err) = register { + error!("Fail registering the agent {}", err) } // Wait for the next ping (2 minutes) sleep(Duration::from_secs(120));