Conversation
Reviewer's GuideThis PR enriches the documentation with minimal usage examples for all public push queue and extractor APIs and introduces a new Payload::new helper. Class diagram for updated PushQueues and PushHandle APIsclassDiagram
class PushQueues {
+fn bounded(high_capacity: usize, low_capacity: usize) -> (Self, PushHandle<F>)
+async fn recv(&mut self) -> Option<(PushPriority, F)>
+fn close(&mut self)
}
class PushHandle {
+async fn push_high_priority(&self, frame: F) -> Result<(), PushError>
+async fn push_low_priority(&self, frame: F) -> Result<(), PushError>
+fn try_push(&self, frame: F, priority: PushPriority, policy: PushPolicy) -> Result<(), PushError>
}
PushQueues --> PushHandle : creates
class PushPriority
class PushError
class PushPolicy
PushHandle o-- PushPriority
PushHandle o-- PushError
PushHandle o-- PushPolicy
PushQueues o-- PushPriority
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThis update adds detailed Rustdoc code examples to several public methods in Changes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
📄 Source: CodeRabbit Inference Engine (AGENTS.md) List of files the instruction was applied to:
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
⚙️ Source: CodeRabbit Configuration File List of files the instruction was applied to:
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (4)
✨ 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.
Actionable comments posted: 3
♻️ Duplicate comments (1)
src/push.rs (1)
96-110: Same runtime overhead note applies here — see previous comment.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/extractor.rs(3 hunks)src/push.rs(6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
src/extractor.rssrc/push.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
src/extractor.rssrc/push.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build-test
- GitHub Check: Analyze (actions)
🔇 Additional comments (2)
src/extractor.rs (2)
77-103: LGTM – concise and covers both branches
286-300: LGTM – clear demonstration of peer address extraction
|
@coderabbitai review |
|
@sourcery-ai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/extractor.rs:87` </location>
<code_context>
+ /// ```
+ /// use wireframe::extractor::Payload;
+ ///
+ /// let mut payload = Payload { data: b"abcd" };
+ /// payload.advance(2);
+ /// assert_eq!(payload.data, b"cd" as &[u8]);
+ /// ```
pub fn advance(&mut self, count: usize) {
</code_context>
<issue_to_address>
Direct struct field initialization in examples may encourage usage of private/internal fields.
Consider updating the example to use a constructor or associated function for `Payload` initialization, or clarify if direct field access is intended.
</issue_to_address>
### Comment 2
<location> `src/extractor.rs:103` </location>
<code_context>
+ /// ```
+ /// use wireframe::extractor::Payload;
+ ///
+ /// let mut payload = Payload { data: b"bytes" };
+ /// assert_eq!(payload.remaining(), 5);
+ /// payload.advance(2);
+ /// assert_eq!(payload.remaining(), 3);
+ /// ```
#[must_use]
</code_context>
<issue_to_address>
Example for `remaining` repeats the direct field initialization concern.
Consider updating the example to use a constructor or clarify if direct field access is intended for the public API.
Suggested implementation:
```rust
/// ```
/// use wireframe::extractor::Payload;
///
/// let mut payload = Payload::new(b"bytes");
/// assert_eq!(payload.remaining(), 5);
/// payload.advance(2);
/// assert_eq!(payload.remaining(), 3);
/// ```
```
```rust
/// Creates a new `Payload` from a byte slice.
pub fn new(data: &'static [u8]) -> Self {
Self { data }
}
pub fn state<T>(&self) -> Option<SharedState<T>>
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes - here's some feedback:
- The async doc examples could be more concise by using
#[tokio::test]instead of defining a fullmainfunction in each code block. - There’s a lot of repetitive setup across the examples—consider grouping common imports or extracting shared boilerplate to keep each snippet focused on its unique behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The async doc examples could be more concise by using `#[tokio::test]` instead of defining a full `main` function in each code block.
- There’s a lot of repetitive setup across the examples—consider grouping common imports or extracting shared boilerplate to keep each snippet focused on its unique behavior.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/extractor.rs (1)
37-56: Example still depends on hiddenTypeIdplumbingAlthough the user-visible part of the doctest no longer shows
TypeIdmanipulation, the hidden lines (# …) still construct the request by hand. This continues to rely on internal representation that could drift. Prefer creating the request via a public helper (e.g.WireframeApp::test_request()or similar) so the example remains stable and self-contained.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/extractor.rs(5 hunks)src/push.rs(6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
src/push.rssrc/extractor.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
src/push.rssrc/extractor.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build-test
- GitHub Check: Analyze (actions)
🔇 Additional comments (9)
src/extractor.rs (3)
96-105: LGTM – example clearly demonstrates slice advancement
112-122: LGTM – example forremainingis concise and correct
305-319: ConnectionInfo example is clear and user-focusedThe doctest demonstrates extraction without exposing internals – good improvement.
src/push.rs (6)
66-80: Doc-test achieves intent; runtime cost is acceptableSwitching to
#[tokio::test]keeps the example executable while avoiding a standalone runtime in each doctest – thanks for adopting the earlier suggestion.
96-110: Low-priority example mirrors the high-priority path accurately
126-141: Good assert on concrete error variantMatching the exact
PushError::QueueFullguards against future behavioural drift.
180-194: Queue construction example is clear and covers end-to-end flow
215-229: Recv example accurately illustrates priority bias
242-250: Closing queues example is minimal and sufficient
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/extractor.rs(5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
src/extractor.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
src/extractor.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (actions)
- GitHub Check: build-test
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
README.md(1 hunks)src/extractor.rs(5 hunks)tests/app_data.rs(1 hunks)tests/extractor.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
tests/app_data.rstests/extractor.rssrc/extractor.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
tests/app_data.rstests/extractor.rssrc/extractor.rs
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...
**/*.md: Validate Markdown files usingmarkdownlint *.md **/*.md.
Runmdformat-allafter any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using thenixieCLI. The tool is already installed; runnixie *.md **/*.mddirectly instead of usingnpx.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
README.md
`**/*.md`: * Avoid 2nd person or 1st person pronouns ("I", "you", "we") * Use en...
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-oxendic spelling and grammar.
- Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
- Code blocks should be wrapped to 120 columns.
- Headings must not be wrapped.
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
README.md
🧬 Code Graph Analysis (1)
tests/extractor.rs (1)
src/extractor.rs (3)
std(270-270)new(120-120)new(210-210)
🪛 GitHub Actions: CI
tests/extractor.rs
[warning] 34-38: Prettier formatting check failed. Code style differs from expected formatting. Run 'cargo fmt --all -- --write' to fix code style issues.
🔇 Additional comments (17)
tests/app_data.rs (1)
15-16: LGTM! Excellent use of the new API.The refactoring from manual
HashMapconstruction to usingMessageRequest::default()andinsert_state()simplifies the test setup and removes coupling to internal implementation details. This makes the tests more maintainable and aligns well with the API improvements.README.md (1)
237-238: LGTM! Proper use of the encapsulated API.The change from direct field access (
payload.data) to usingpayload.as_ref()correctly adapts to the encapsulation of thePayloadstruct. This maintains the same functionality while using the public API, which is more stable and maintainable.tests/extractor.rs (3)
24-24: LGTM! Good use of the new constructor.Using
Payload::new()instead of manual field construction is cleaner and aligns with the encapsulation improvements in thePayloadstruct.
37-37: LGTM! Cleaner struct initialisation.Using struct update syntax with
Default::default()is more idiomatic and maintainable than manually specifying each field.
50-51: LGTM! Excellent modernisation of the test setup.Using
insert_state()instead of manualHashMapconstruction removes coupling to internal implementation details and makes the test more readable and maintainable.src/extractor.rs (12)
37-52: LGTM! Comprehensive documentation with practical examples.The documentation example effectively demonstrates the usage of the
state()method whilst cleverly hiding the internal setup details. The hidden lines ensure the example compiles whilst keeping the public API front and centre.
64-86: LGTM! Valuable addition to the public API.The
insert_state()method provides a clean, public way to add shared state without exposing internal implementation details. The documentation example is clear and demonstrates typical usage patterns.
90-100: LGTM! Clear and practical documentation.The struct-level documentation with examples effectively demonstrates both constructor usage and the
AsReftrait implementation, making the API more discoverable.
104-105: LGTM! Proper encapsulation of internal data.Making the
datafield private is excellent encapsulation that prevents external code from directly manipulating the internal state. This is complemented well by theAsRef<[u8]>trait implementation for controlled access.
107-121: LGTM! Well-implemented constructor with good documentation.The constructor is properly marked with
#[inline]and#[must_use]attributes, and the documentation example clearly demonstrates its usage. The implementation is straightforward and correct.
123-126: LGTM! Ergonomic trait implementation.The
From<&[u8]>implementation with#[inline]provides a convenient way to createPayloadinstances, improving the API's ergonomics whilst maintaining performance.
128-130: LGTM! Clean abstraction for data access.The
AsRef<[u8]>implementation provides controlled, read-only access to the internal data without exposing implementation details. This is a much better approach than public field access.
137-146: LGTM! Clear documentation with practical example.The documentation effectively demonstrates how
advance()modifies the payload state, making the behaviour clear to users of the API.
153-163: LGTM! Comprehensive example showing method interaction.The documentation example nicely demonstrates both
remaining()andadvance()methods working together, which helps users understand the payload's stateful nature.
198-207: LGTM! Good documentation for the deprecated method.The example properly demonstrates the usage whilst the deprecation notice guides users towards the preferred
Fromtrait implementation.
283-291: LGTM! Clear demonstration of transparent access.The documentation example effectively shows how the
Derefimplementation enables transparent access to the underlying shared state.
346-360: LGTM! Comprehensive example showing typical usage.The documentation example demonstrates both the extractor pattern and the method usage, providing practical guidance for users of the API.
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
tests/extractor.rs (1)
52-59: Consider consolidating common setup withrstestfixturesEach test re-creates a default
MessageRequestandPayload. A small fixture would eliminate repetition and makes later additions (e.g., tracing spans) trivial:#[fixture] fn empty_req() -> MessageRequest { MessageRequest::default() } #[fixture] fn empty_payload() -> Payload<'static> { Payload::default() }Adopting this pattern keeps tests DRY and aligns with the project testing guidelines.
♻️ Duplicate comments (1)
tests/extractor.rs (1)
37-40: Pipeline still flags formatting – runcargo fmtThe earlier CI warning on this block suggests rustfmt places the closing brace and semicolon on the same line:
let req = MessageRequest { peer_addr: Some(addr), ..Default::default() };Running
cargo fmt --all -- --writewill settle any brace/indent discrepancies.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
tests/extractor.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
tests/extractor.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
tests/extractor.rs
🧬 Code Graph Analysis (1)
tests/extractor.rs (1)
src/extractor.rs (4)
std(270-270)new(120-120)new(210-210)req(269-269)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-test
| let bytes = msg.to_bytes().unwrap(); | ||
| let mut payload = Payload { | ||
| data: bytes.as_slice(), | ||
| }; | ||
| let mut payload = Payload::new(bytes.as_slice()); |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Prefer .expect() over .unwrap() for explicit failure context
Using .expect() communicates why the operation must succeed and aligns with the project guidelines favouring expect for test code.
- let bytes = msg.to_bytes().unwrap();
+ let bytes = msg.to_bytes().expect("serialising TestMsg should succeed");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let bytes = msg.to_bytes().unwrap(); | |
| let mut payload = Payload { | |
| data: bytes.as_slice(), | |
| }; | |
| let mut payload = Payload::new(bytes.as_slice()); | |
| let bytes = msg.to_bytes().expect("serialising TestMsg should succeed"); | |
| let mut payload = Payload::new(bytes.as_slice()); |
🤖 Prompt for AI Agents
In tests/extractor.rs at lines 23 to 24, replace the use of `.unwrap()` on
`msg.to_bytes()` with `.expect()` and provide a clear message explaining why the
operation must succeed. This change improves failure context and aligns with
project guidelines for test code.
|
@coderabbitai new Github Issue please: 52-59: Consider consolidating common setup with rstest fixtures Each test re-creates a default MessageRequest and Payload. A small fixture would eliminate repetition and makes later additions (e.g., tracing spans) trivial: #[fixture] #[fixture] Adopting this pattern keeps tests DRY and aligns with the project testing guidelines. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll create a GitHub issue for consolidating the common test setup with rstest fixtures. 🏁 Script executed: Length of output: 1108 @leynos I've successfully created the GitHub issue for consolidating common test setup with rstest fixtures. Issue Created: #170 - Consolidate common test setup with rstest fixtures The issue has been assigned to you and includes:
The issue is now ready for you to prioritise and implement when convenient. |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary
Testing
make fmtmake lintmake testcargo test --dochttps://chatgpt.com/codex/tasks/task_e_686720a89cd48322a2f82dbe55aa00a4
Summary by Sourcery
Add minimal usage examples as doc tests to public functions in push and extractor modules to illustrate API usage and verify documentation examples.
Documentation: