Conversation
Enforce consistent formatting by running cargo fmt --check before tests. The codebase is already formatted, so this just prevents future regressions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdded CI pre-test validation steps (cargo fmt -- --check and cargo clippy -- -D warnings) to Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions
participant Repo as Repository
participant Toolchain as Rust Toolchain (rustfmt/clippy)
participant Test as cargo test
GH->>Repo: checkout
GH->>Toolchain: ensure toolchain (rust-toolchain.toml)
GH->>Toolchain: run `cargo fmt -- --check`
alt fmt passes
GH->>Toolchain: run `cargo clippy -- -D warnings`
alt clippy passes
GH->>Test: run `cargo test`
else clippy fails
GH-->>Repo: fail CI (clippy warnings treated as errors)
end
else fmt fails
GH-->>Repo: fail CI (formatting mismatch)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
rustfmt is not installed by default for pinned toolchains. Adding it to rust-toolchain.toml ensures it's available in CI and for local devs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add cargo clippy -- -D warnings to CI pipeline. Include clippy component in rust-toolchain.toml. Fix the only clippy warning: move Regex::new() outside the loop in activity handler. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gets Use std::sync::LazyLock to compile the lightning tip regex once per process instead of once per request. Keep clippy without --all-targets for now — test code has 45 pre-existing warnings that would need a separate cleanup PR. Noted as follow-up. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/rest/v4/activity.rs (1)
1-16:⚠️ Potential issue | 🟡 MinorReorder and group imports to match repo rules.
Line 13 introduces
stdimports before all external imports are complete, and the groups are not separated by blank lines.Suggested fix
use crate::db; use crate::db::main::invoice::schema::{InvoiceStatus, InvoicedService}; use crate::db::main::MainPool; use crate::rest::error::RestApiError; use crate::rest::error::RestResult; + use actix_web::get; use actix_web::web::Data; use actix_web::web::Json; use actix_web::web::Query; use regex::Regex; use serde::Deserialize; use serde::Serialize; -use std::sync::LazyLock; use time::Duration; use time::OffsetDateTime; + +use std::sync::LazyLock;As per coding guidelines "Organize imports in order: internal crate modules (
use crate::), external crate imports, thenuse std::imports, with blank lines between groups".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/rest/v4/activity.rs` around lines 1 - 16, Reorder and group the imports so crate-local imports come first, external crates next, and std imports last, with a blank line between each group; specifically move all use crate::... lines (use crate::db; use crate::db::main::invoice::schema::{InvoiceStatus, InvoicedService}; use crate::db::main::MainPool; use crate::rest::error::{RestApiError, RestResult};) to the top, then the external imports (actix_web items like get and web::{Data, Json, Query}, regex::Regex, serde::{Deserialize, Serialize}, time::{Duration, OffsetDateTime}), and finally the std import(s) such as std::sync::LazyLock, ensuring blank lines separate the three groups and preserving the existing symbols and names.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/rest/v4/activity.rs`:
- Around line 17-18: The static declaration for TIP_RE (the LazyLock<Regex>
initialization) is failing rustfmt; run `cargo fmt` and update the formatting of
the static TIP_RE = LazyLock::new(...) initializer to match rustfmt's expected
layout (reflow the closure/Regex::new call so the declaration is formatted per
rustfmt) and commit the resulting changes so `cargo fmt -- --check` passes CI.
---
Outside diff comments:
In `@src/rest/v4/activity.rs`:
- Around line 1-16: Reorder and group the imports so crate-local imports come
first, external crates next, and std imports last, with a blank line between
each group; specifically move all use crate::... lines (use crate::db; use
crate::db::main::invoice::schema::{InvoiceStatus, InvoicedService}; use
crate::db::main::MainPool; use crate::rest::error::{RestApiError, RestResult};)
to the top, then the external imports (actix_web items like get and web::{Data,
Json, Query}, regex::Regex, serde::{Deserialize, Serialize}, time::{Duration,
OffsetDateTime}), and finally the std import(s) such as std::sync::LazyLock,
ensuring blank lines separate the three groups and preserving the existing
symbols and names.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9b1a9bef-57f0-41bf-b1ec-cb67d1e843d9
📒 Files selected for processing (3)
.github/workflows/preview.ymlrust-toolchain.tomlsrc/rest/v4/activity.rs
✅ Files skipped from review due to trivial changes (1)
- rust-toolchain.toml
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/preview.yml
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the single "run cargo fmt" note with a full pre-commit checklist (fmt, clippy, test) and document the rust-toolchain.toml pin. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add formatting and linting to CI
Summary by CodeRabbit