Fix formatting for short functions#247
Conversation
Reviewer's GuideInline trivial functions into single-line bodies and leverage Rust let-chains to simplify nested conditionals for more concise, consistent formatting. Class diagram for updated function signatures and inlined methodsclassDiagram
class Connection {
+set_fairness(fairness: FairnessConfig)
+set_response(stream: Option<FrameStream<F, E>>)
+shutdown_token() CancellationToken
-after_low()
-reset_high_counter()
-wait_shutdown(token: CancellationToken)
-recv_push(rx: &mut mpsc::Receiver<F>) Option<F>
}
class ActorState {
-is_active() bool
-is_shutting_down() bool
-is_done() bool
}
class PushHandle {
+from_arc(arc: Arc<PushHandleInner<F>>) Self
+downgrade() Weak<PushHandleInner<F>>
}
class Server {
+worker_count() usize
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Gates Failed
Enforce advisory code health rules
(1 file with Complex Conditional)
Gates Passed
5 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| push.rs | 1 advisory rule | 10.00 → 9.69 | Suppress |
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
| if let Some(r) = rate | ||
| && (r == 0 || r > MAX_PUSH_RATE) |
There was a problem hiding this comment.
❌ New issue: Complex Conditional
PushQueues.bounded_with_rate_dlq has 1 complex conditionals with 2 branches, threshold = 2
There was a problem hiding this comment.
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix.
There was a problem hiding this comment.
@leynos I'll suggest a fix for the complex conditional issue by extracting the rate validation logic into a predicate function, following your coding guidelines.
Suggested Fix
Extract the rate validation logic into a predicate function:
/// Check if a rate value is invalid (zero or exceeds maximum).
fn is_invalid_rate(rate: usize) -> bool {
rate == 0 || rate > MAX_PUSH_RATE
}Then replace the complex conditional with:
if let Some(r) = rate
&& is_invalid_rate(r)
{
return Err(PushConfigError::InvalidRate(r));
}AI Coding Agent Prompt
In the file src/push.rs, refactor the rate validation logic in the `bounded_with_rate_dlq` method to comply with the complexity guidelines:
1. Add a new private function `is_invalid_rate` that takes a `usize` parameter and returns `bool`
2. The function should return `true` if the rate is 0 or greater than `MAX_PUSH_RATE`
3. Add a doc comment explaining the function's purpose
4. Place the function before the `PushQueues` impl block
5. Replace the complex conditional `r == 0 || r > MAX_PUSH_RATE` with a call to `is_invalid_rate(r)`
6. Keep the existing let-guard pattern structure intact
This refactoring will reduce the cyclomatic complexity while maintaining the same validation behavior.
2a3c599
into
codex/replace-eprintln-with-tracing-macros
* Replace eprintln with tracing macros * Add structured tracing and context * Format short functions (#247)
Summary
if/letchains flagged by clippyTesting
CARGO="cargo +nightly-2025-07-22" make lintCARGO="cargo +nightly-2025-07-22" make testhttps://chatgpt.com/codex/tasks/task_e_688d4557f43883228c256f232d28bc85
Summary by Sourcery
Inline trivial getter and setter functions and collapse simple conditional chains using new let-else syntax across connection, push, and server modules to satisfy Clippy style guidelines.
Enhancements: