Skip to content

chore: address cargo clippy warnings and fix failing tests#1289

Open
Kayd-06 wants to merge 1 commit intomofa-org:mainfrom
Kayd-06:fix-clippy-warnings
Open

chore: address cargo clippy warnings and fix failing tests#1289
Kayd-06 wants to merge 1 commit intomofa-org:mainfrom
Kayd-06:fix-clippy-warnings

Conversation

@Kayd-06
Copy link
Copy Markdown
Contributor

@Kayd-06 Kayd-06 commented Mar 16, 2026

Summary

This PR addresses several cargo clippy warnings to improve code quality, maintainability, and compilation reliability across the workspace. It focuses on resolving type complexity warnings, simplifying conditional logic, streamlining vector initialization, and fixing type inference issues in tests/benches to ensure the entire workspace compiles seamlessly.


Context

While running cargo clippy and cargo test across the workspace, several warnings and compilation errors were identified in mofa-foundation, mofa-kernel, mofa-cli, and mofa-local-llm.

  • Complex tuples were making the budget enforcer hard to read.
  • Nested if let blocks were unnecessarily deep.
  • Missing type annotations and traits in tests/benches were causing compilation failures on certain configurations.

This change is needed to guarantee a warning-free and fully compilable codebase for all targets and features.


Changes

  • mofa-foundation: Refactored BudgetEnforcer to use explicit SessionUsage and DailyUsage structs instead of complex tuples (f64, u64).
  • mofa-foundation & mofa-local-llm: Added missing type annotations to mcp_integration tests and brought the ModelProvider trait into scope for inference benchmarks to resolve compilation errors.
  • mofa-foundation: Replaced approximate PI constant in workflow/state.rs tests to satisfy clippy::approx_constant.
  • mofa-kernel: Collapsed nested if let x = y { if z { ... } } blocks into cleaner if let x = y && z let-chains in budget.rs.
  • mofa-cli: Streamlined vector initialization in doctor.rs by combining .push() statements into a single vec![] macro.

How you Tested

  1. Ran cargo clippy --all-targets --all-features to ensure all addressed warnings were resolved.
  2. Ran cargo test -p mofa-foundation -p mofa-kernel -p mofa-cli to verify that unit and integration tests (including the previously failing ones) pass successfully.
  3. Examined code changes manually to ensure behavior remained identical.

Screenshots / Logs (if applicable)

N/A


Breaking Changes

  • No breaking changes
  • Breaking change (describe below)

Checklist

Code Quality

  • Code follows Rust idioms and project conventions
  • cargo fmt run
  • cargo clippy passes without warnings

Testing

  • Tests added/updated
  • cargo test passes locally without any error

Documentation

  • Public APIs documented
  • README / docs updated (if needed)

PR Hygiene

  • PR is small and focused (one logical change)
  • Branch is up to date with main
  • No unrelated commits
  • Commit messages explain why, not only what

Deployment Notes (if applicable)

N/A


Additional Notes for Reviewers

N/A

@Kayd-06 Kayd-06 changed the title chore: manual fixes to address type complexity and type annotation cl… chore: address cargo clippy warnings and fix failing tests Mar 16, 2026
@Kayd-06 Kayd-06 force-pushed the fix-clippy-warnings branch from 849088f to fac74df Compare March 17, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant