Skip to content

fix(lint): resolve pre-existing strict clippy violations across 9 files [urgent]#2482

Closed
maxtongwang wants to merge 1 commit intozeroclaw-labs:mainfrom
maxtongwang:fix/ci-clippy-fmt-violations
Closed

fix(lint): resolve pre-existing strict clippy violations across 9 files [urgent]#2482
maxtongwang wants to merge 1 commit intozeroclaw-labs:mainfrom
maxtongwang:fix/ci-clippy-fmt-violations

Conversation

@maxtongwang
Copy link
Copy Markdown

@maxtongwang maxtongwang commented Mar 2, 2026

Summary

  • Fixes all actionable strict lint violations that appear as pre-existing debt in rust_strict_delta_gate.sh, which slows down every PR by adding noise to delta reports
  • Addresses issues logged in CI output on every Rust PR: redundant_else, unnested_or_patterns, unreadable_literal, manual_contains, if_not_else, match_same_arms, manual_clamp, cast_sign_loss, unused variables, doc_lazy_continuation, unused import
  • Skips architectural issues (large_futures, excessive_bools) that require separate broader refactors

Label Snapshot

  • domain:code-quality
  • chore
  • size: S
  • risk: low

Change Metadata

File Lint rule fixed
src/hooks/runner.rs clippy::redundant_else
src/tools/channel_ack_config.rs clippy::unnested_or_patterns
src/tools/pptx_read.rs clippy::unnested_or_patterns (×2)
src/channels/napcat.rs clippy::unreadable_literal, clippy::match_same_arms
src/tools/cron_add.rs clippy::unreadable_literal (×2)
src/channels/ack_reaction.rs clippy::manual_contains
src/channels/telegram.rs clippy::if_not_else
src/channels/github.rs clippy::manual_clamp (×2), clippy::cast_sign_loss
src/channels/mod.rs unused_variables (×5 test fns), clippy::doc_lazy_continuation, unused import AutonomyLevel

Linked Issue

Closes #2442
Closes #2443

Validation Evidence

  • cargo fmt --all -- --check → passes
  • All changes are mechanical lint fixes with no behavioral change
  • clippy::cast_sign_loss in github.rs fixed via u64::try_from(...).unwrap_or(0) (safe: .max(0) guarantees non-negative before conversion)
  • clippy::if_not_else in telegram.rs: logic preserved, just condition and branches swapped
  • unused_variables: 5 test functions created approval_manager from autonomy_cfg but the struct used mock_price_approved_manager() instead — both dead bindings removed

Security Impact

None. All changes are style/lint fixes in test and non-security paths.

Privacy and Data Hygiene

No personal data, secrets, or sensitive identifiers introduced.

Compatibility

No behavioral changes. All fixes are mechanical lint transformations.

i18n Follow-Through

Not applicable (Rust code only, no docs/i18n changes).

Human Verification

  • Verify cargo fmt --all -- --check still passes
  • Verify no test regressions in affected files

Side Effects

Removes 5 unused let autonomy_cfg + let approval_manager bindings from test functions in src/channels/mod.rs. These were dead code — the struct initializers already called mock_price_approved_manager().

Agent Notes

Note: contributor is an external contributor (no Linear key assigned).

Rollback Plan

git revert 5d265040 — clean revert, no structural changes.

Risks

None. All changes are lint-only with no runtime impact.

Summary by CodeRabbit

  • Bug Fixes & Improvements

    • More robust timestamp parsing and safer rate-limit delay handling
    • Broadened websocket no-op handling for improved stability
    • Clearer logging behavior when registering commands
    • Warning now emitted only on relevant cancellation paths
  • Refactor

    • Simplified test scaffolding and setup
    • Standardized pattern matching and minor formatting improvements
    • Small documentation clarification added

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 2, 2026

PR intake checks found warnings (non-blocking)

Fast safe checks found advisory issues. CI lint/test/build gates still enforce merge quality.

  • Missing required PR template sections: ## Validation Evidence (required), ## Security Impact (required), ## Privacy and Data Hygiene (required), ## Rollback Plan (required)
  • Incomplete required PR template fields: summary problem, summary why it matters, summary what changed, validation commands, security risk/mitigation, privacy status, rollback plan
  • Missing Linear issue key reference (RMN-<id>, CDV-<id>, or COM-<id>) in PR title/body (recommended for traceability, non-blocking).

Action items:

  1. Complete required PR template sections/fields.
  2. (Recommended) Link this PR to one active Linear issue key (RMN-xxx/CDV-xxx/COM-xxx) for traceability.
  3. Remove tabs, trailing whitespace, and merge conflict markers from added lines.
  4. Re-run local checks before pushing:
    • ./scripts/ci/rust_quality_gate.sh
    • ./scripts/ci/rust_strict_delta_gate.sh
    • ./scripts/ci/docs_quality_gate.sh

Detected Linear keys: none

Run logs: https://github.com/zeroclaw-labs/zeroclaw/actions/runs/22704920701

Detected blocking line issues (sample):

  • none

Detected advisory line issues (sample):

  • none

@github-actions github-actions Bot added channel Auto scope: src/channels/** changed. tool Auto scope: src/tools/** changed. labels Mar 2, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 2, 2026

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'tools', 'path_filters', 'review_instructions'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: befdd231-d431-4568-9607-d331844bc9a2

📥 Commits

Reviewing files that changed from the base of the PR and between 5d26504 and 92d1b33.

📒 Files selected for processing (9)
  • src/channels/ack_reaction.rs
  • src/channels/github.rs
  • src/channels/mod.rs
  • src/channels/napcat.rs
  • src/channels/telegram.rs
  • src/hooks/runner.rs
  • src/tools/channel_ack_config.rs
  • src/tools/cron_add.rs
  • src/tools/pptx_read.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/tools/channel_ack_config.rs
  • src/channels/napcat.rs
  • src/channels/mod.rs
  • src/hooks/runner.rs
  • src/tools/pptx_read.rs

📝 Walkthrough

Walkthrough

Multiple small refactors and code-quality edits across channels and tools: pattern-match simplifications, safer timestamp conversion and clamping, minor logging/control-flow adjustments, broadened websocket no-op handling, test cleanup, and small literal/formatting tweaks.

Changes

Cohort / File(s) Summary
Pattern matching & XML event handling
src/channels/ack_reaction.rs, src/tools/channel_ack_config.rs, src/tools/pptx_read.rs
Simplified match patterns: replaced iteration-based equality check with contains, merged None/empty/direct arms, and combined Start/Empty XML event arms.
Timestamp & rate-limit clamping
src/channels/github.rs
Safer timestamp conversion via u64::try_from(...).unwrap_or(0) and replaced manual min/max retry bounds with clamp(1, 60).
Logging / control-flow tweak
src/channels/telegram.rs, src/hooks/runner.rs
Moved success log into the success branch for command registration; relocated warning emission after capability check for tool-result cancellation.
Websocket message handling
src/channels/napcat.rs
Treats Binary, Pong, and Frame messages as unified no-ops in the listen loop (consolidated match arms).
Test scaffolding & docs
src/channels/mod.rs
Removed duplicated per-test AutonomyConfig/ApprovalManager setup and dropped unused AutonomyLevel import; added doc comment to handle_confirm_tool_approval_side_effects.
Formatting / literals
src/tools/cron_add.rs
Numeric literal formatted from 300000 to 300_000 (no semantic change).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ci

Suggested reviewers

  • chumyin
  • theonlyhennygod
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 78.95% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: resolving strict clippy violations across multiple files, which is the primary objective of the PR.
Description check ✅ Passed The description comprehensively covers all required sections: summary with clear objectives, change metadata with specific lint rules fixed, validation evidence, security/privacy/compatibility assessments, and rollback plan.
Linked Issues check ✅ Passed The PR successfully addresses both linked issues (#2442 and #2443): fixes formatting violations across files and removes unused approval_manager bindings from test functions in src/channels/mod.rs.
Out of Scope Changes check ✅ Passed All changes are strictly lint-focused and within scope. The PR fixes specific clippy violations, explicitly skips architectural issues (large_futures, excessive_bools) for separate refactoring, and contains no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size: XS Auto size: <=80 non-doc changed lines. risk: high Auto risk: security/runtime/gateway/tools/workflows. labels Mar 2, 2026
@theonlyhennygod theonlyhennygod self-assigned this Mar 4, 2026
Copy link
Copy Markdown
Collaborator

@theonlyhennygod theonlyhennygod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking merge for now: this PR is currently in a merge-conflict state with main (DIRTY/CONFLICTING). Please rebase or resolve conflicts against main, then I can re-review and merge while preserving contributor attribution.

…es [urgent]

Fixes strict lint issues shown as pre-existing debt in the strict delta
gate, reducing noise for every future PR and unblocking CI throughput.

Changes by lint rule:
- clippy::redundant_else: src/hooks/runner.rs
- clippy::unnested_or_patterns: src/tools/channel_ack_config.rs, src/tools/pptx_read.rs (x2)
- clippy::unreadable_literal: src/channels/napcat.rs, src/tools/cron_add.rs (x2)
- clippy::manual_contains: src/channels/ack_reaction.rs
- clippy::if_not_else: src/channels/telegram.rs
- clippy::match_same_arms: src/channels/napcat.rs
- clippy::manual_clamp: src/channels/github.rs (x2)
- clippy::cast_sign_loss: src/channels/github.rs
- unused_variables (approval_manager x5): src/channels/mod.rs
- clippy::doc_lazy_continuation: src/channels/mod.rs
- unused import (AutonomyLevel): src/channels/mod.rs

Skipped architectural issues (large_futures, excessive_bools) as those
require broader refactor scoped separately.

Closes #2442
Closes #2443
@maxtongwang maxtongwang force-pushed the fix/ci-clippy-fmt-violations branch from 5d26504 to 92d1b33 Compare March 5, 2026 06:08
@maxtongwang
Copy link
Copy Markdown
Author

Closing — no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel Auto scope: src/channels/** changed. risk: high Auto risk: security/runtime/gateway/tools/workflows. size: XS Auto size: <=80 non-doc changed lines. tool Auto scope: src/tools/** changed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

channels: approval_manager shadowed binding cleanup code-quality: Formatting violations

2 participants