Conversation
Reviewer's GuideThis PR refactors and enhances test suites by extracting shared utilities, simplifying fixtures, adding and parameterising new tests, and correcting minor inconsistencies in test inputs. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 8 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughExpand and clarify documentation across several test modules, simplify test fixtures, refactor repeated assertion logic into helpers, re-enable and update a previously commented-out test, and introduce parameterised and new test cases to improve coverage and maintainability. No changes are made to the core implementation or test logic. Changes
Sequence Diagram(s)sequenceDiagram
participant TestRunner
participant HelperFunction
participant ReflowTable
TestRunner->>ReflowTable: Call reflow_table(input)
ReflowTable-->>TestRunner: Return table rows
TestRunner->>HelperFunction: assert_uniform_column_widths(rows)
HelperFunction-->>TestRunner: Assert all rows have uniform column widths
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Poem
✨ 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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
tests/table/mod.rs(4 hunks)tests/table/uniform.rs(3 hunks)tests/wrap/cli.rs(1 hunks)tests/wrap/footnotes.rs(2 hunks)tests/wrap/links.rs(1 hunks)tests/wrap/paragraphs.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: 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.
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.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
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().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
tests/wrap/cli.rstests/wrap/links.rstests/wrap/footnotes.rstests/wrap/paragraphs.rstests/table/mod.rstests/table/uniform.rs
⚙️ CodeRabbit Configuration File
**/*.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 and docs must follow en-GB-oxendict (-ize / -our) 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/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/wrap/cli.rstests/wrap/links.rstests/wrap/footnotes.rstests/wrap/paragraphs.rstests/table/mod.rstests/table/uniform.rs
🧬 Code Graph Analysis (1)
tests/wrap/footnotes.rs (2)
src/process.rs (1)
process_stream(206-214)tests/wrap.rs (1)
test_wrap_footnote_multiline(168-175)
🔇 Additional comments (13)
tests/table/mod.rs (5)
3-17: Excellent documentation enhancement.The expanded module documentation provides comprehensive coverage of the test module's scope and organisation. This follows the mandatory requirement for module-level documentation and significantly improves code maintainability.
27-27: Good simplification of fixture.Removing the intermediate variable binding improves code clarity whilst maintaining identical functionality.
42-42: Consistent fixture simplification.The removal of intermediate variable binding maintains consistency with other fixture improvements in this file.
117-117: Fixture simplification maintains consistency.The direct return pattern aligns with other fixture improvements in this module.
122-122: Final fixture simplification completes the pattern.This change maintains consistency with the other fixture improvements throughout the module.
tests/table/uniform.rs (2)
5-18: Excellent extraction of common assertion logic.The helper function properly centralises column width validation logic, improving code reuse and maintainability. The implementation correctly handles pipe-delimited table parsing and includes appropriate edge case handling.
20-46: Effective test refactoring improves maintainability.The refactoring successfully eliminates code duplication by utilising the helper function whilst preserving test behaviour. Re-enabling
test_uniform_example_oneimproves test coverage.tests/wrap/links.rs (1)
55-55: LGTM! Simplified test input improves readability.Removing the line continuation character makes the test input clearer and more maintainable whilst preserving the same test behaviour.
tests/wrap/paragraphs.rs (2)
2-4: LGTM! Enhanced documentation clarifies test scope.The expanded documentation clearly explains the purpose of paragraph wrapping tests, including the specific behaviour for long words that cannot be broken.
22-32: LGTM! Parameterised tests improve coverage.The parameterised approach efficiently tests multiple long word lengths (100, 150, 200 characters) whilst maintaining the same test logic. This follows the coding guideline to use
rstestfor avoiding test repetition.tests/wrap/cli.rs (1)
2-5: LGTM! Documentation clarifies CLI test purpose.The expanded documentation clearly explains that these tests validate the
--wrapcommand-line flag functionality, improving code maintainability and understanding.tests/wrap/footnotes.rs (2)
2-5: LGTM! Enhanced documentation clarifies footnote test scope.The expanded documentation clearly explains the validation of footnote wrapping behaviour, including indentation preservation and inline code span integrity.
19-30: LGTM! New test improves footnote coverage.The new test effectively validates footnote handling with blank lines, ensuring:
- Blank lines are preserved (line 27)
- Indentation is maintained for continuation lines (line 28)
- 80-character limit compliance (line 29)
This adds valuable test coverage for a specific footnote formatting scenario.
Summary
Testing
make fmtmake lintmake testmake markdownlintmake nixie(fails: current working directory was deleted)https://chatgpt.com/codex/tasks/task_e_688b9626896883228d4be55799327917
Summary by Sourcery
Introduce a helper for verifying uniform table column widths, refactor table tests to use it and streamline fixtures, enhance wrapping test coverage with parameterised scenarios for long words and blank-line footnotes, and fix escaping in a link test.
New Features:
Bug Fixes:
Enhancements: