Skip to content

Configure nightly rustfmt#48

Merged
leynos merged 4 commits intomainfrom
codex/update-.rustfmt.toml-and-ci-workflow
Jun 16, 2025
Merged

Configure nightly rustfmt#48
leynos merged 4 commits intomainfrom
codex/update-.rustfmt.toml-and-ci-workflow

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 16, 2025

Summary

  • set up .rustfmt.toml with custom formatting rules
  • document nightly formatter in AGENTS.md
  • use nightly rustfmt in CI workflow
  • apply formatter changes across the codebase

Testing

  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test
  • npx -y markdownlint-cli2 '**/*.md' (fails: MD012, MD013, MD040, MD033)
  • nixie docs/*.md

https://chatgpt.com/codex/tasks/task_e_684f7ca843f48322a2b98efdace740ae

Summary by Sourcery

Configure and enforce nightly rustfmt across the project

New Features:

  • Add a .rustfmt.toml with custom formatting options
  • Pin the nightly-2025-06-10 toolchain and components in rust-toolchain.toml

Enhancements:

  • Reformat the entire codebase and tests using the new nightly rustfmt rules

CI:

  • Install and run rustfmt from the nightly toolchain in CI for formatting checks

Documentation:

  • Document the nightly cargo +nightly fmt workflow in AGENTS.md

Summary by CodeRabbit

  • Chores

    • Updated CI workflow to use a fixed nightly Rust toolchain version for formatting checks.
    • Introduced a custom Rust formatting configuration for consistent code style.
    • Revised contributor documentation to clarify formatting and linting steps with the specified toolchain.
    • Added rust-toolchain configuration to specify nightly Rust version and required components.
    • Modified release workflow to explicitly use the stable Rust toolchain for cross-compilation.
  • Style

    • Improved code formatting and reorganised import statements for better readability and consistency.
    • Enhanced documentation comments for clarity and line wrapping across code and tests.
  • Documentation

    • Refined doc comments and example code for improved clarity and readability.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 16, 2025

Reviewer's Guide

Sets up and enforces a nightly Rust formatter by pinning the toolchain, adding a custom .rustfmt.toml, updating CI and documentation, and then reformatting the entire codebase to conform to the new rules.

File-Level Changes

Change Details Files
Configure nightly rustfmt and pin toolchain
  • Added .rustfmt.toml with custom formatting rules
  • Created rust-toolchain.toml to lock nightly channel and components
  • Updated CI workflow to install rustfmt for nightly and run cargo +nightly fmt --all -- --check
  • Adjusted release workflow to build with stable toolchain via cross +stable build
.rustfmt.toml
rust-toolchain.toml
.github/workflows/ci.yml
.github/workflows/release.yml
Document nightly formatter usage
  • Replaced generic cargo fmt step with explicit cargo +nightly-2025-06-10 fmt --all command
  • Updated AGENTS.md to describe nightly formatter commands and order of lint/test invocations
AGENTS.md
Reformat codebase to match new rules
  • Applied multiline if let and chained conditions formatting
  • Wrapped and reflowed doc comments to the configured width
  • Condensed single-line functions and adjusted import layouts
  • Reorganized test fixtures and example code to adhere to comment and string wrapping
src/lib.rs
src/html.rs
src/main.rs
src/reflow.rs
tests/integration.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 16, 2025

Walkthrough

The changes introduce a .rustfmt.toml file to enforce consistent Rust code formatting and update the CI workflow to use a specific nightly toolchain for formatting checks. A rust-toolchain.toml file is added to specify the nightly Rust version and components. Documentation and import statements across several source and test files are reorganised and reformatted for clarity, with no changes to logic or public interfaces. The release workflow is updated to explicitly use the stable Rust toolchain.

Changes

File(s) Change Summary
.github/workflows/ci.yml Formatting step now installs rustfmt for nightly-2025-06-10 and runs formatting checks using this fixed nightly toolchain.
.github/workflows/release.yml Release build step changed to use stable Rust toolchain explicitly with cross +stable build.
.rustfmt.toml New file specifying detailed Rust code formatting rules and enabling unstable formatting features.
rust-toolchain.toml New file specifying nightly-2025-06-10 Rust toolchain with rustfmt and clippy components.
AGENTS.md Updated formatting instructions to specify nightly toolchain; clarified command order and wording around warnings.
src/html.rs, src/lib.rs, src/main.rs Reorganised and consolidated import statements; reformatted doc comments for readability; no logic changes.
src/reflow.rs Reordered import statements for clarity; no logic or control flow changes.
tests/integration.rs Consolidated imports, reformatted doc comments and example code, improved style; no changes to test logic or outcomes.

Possibly related PRs

  • Fix unpinned action wireframe#57: Modifies CI workflow to pin Rust toolchain versions, related to Rust toolchain setup but focuses on stable Rust rather than nightly and rustfmt component installation.

Poem

In the warren, code is neat,
Rusty carrots, formatting sweet.
Nightly tools now lead the dance,
Imports grouped in tidy stance.
Docs reflowed with gentle care,
Tests and comments, light as air.
🥕 Hop along—our code’s debonair!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9a1468 and f05ed6b.

📒 Files selected for processing (5)
  • .github/workflows/release.yml (1 hunks)
  • rust-toolchain.toml (1 hunks)
  • src/html.rs (8 hunks)
  • src/lib.rs (11 hunks)
  • tests/integration.rs (15 hunks)
✅ Files skipped from review due to trivial changes (3)
  • rust-toolchain.toml
  • src/html.rs
  • src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (1)
.github/workflows/release.yml (1)

82-82: Explicit stable toolchain invocation for release builds is appropriate.

Specifying cross +stable build guarantees usage of the stable Rust toolchain here, decoupling it from any local overrides and aligning with the repository’s stable/nightly distinction. LGTM.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch codex/update-.rustfmt.toml-and-ci-workflow
  • Post Copyable Unit Tests in Comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes - here's some feedback:

  • Consider adding a rust-toolchain.toml to pin the nightly toolchain version so contributors don’t need to update the CI workflow whenever the formatter version changes.
  • Most functions formatted to single-line bodies now use explicit return—you may want to drop those return keywords for a more idiomatic expression-based style in Rust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding a rust-toolchain.toml to pin the nightly toolchain version so contributors don’t need to update the CI workflow whenever the formatter version changes.
- Most functions formatted to single-line bodies now use explicit `return`—you may want to drop those `return` keywords for a more idiomatic expression-based style in Rust.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/integration.rs (1)

23-23: Consider idiomatic returns in one-line fixtures.

One-line functions using explicit return could drop the return keyword and trailing semicolon for a more idiomatic implicit return:

fn broken_table() -> Vec<String> {
    lines_vec!("| A | B |    |", "| 1 | 2 |  | 3 | 4 |")
}

Also applies to: 54-54, 98-98, 101-101

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0d469 and f9a1468.

📒 Files selected for processing (8)
  • .github/workflows/ci.yml (1 hunks)
  • .rustfmt.toml (1 hunks)
  • AGENTS.md (1 hunks)
  • src/html.rs (5 hunks)
  • src/lib.rs (9 hunks)
  • src/main.rs (2 hunks)
  • src/reflow.rs (1 hunks)
  • tests/integration.rs (14 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/reflow.rs (1)
src/lib.rs (2)
  • format_separator_cells (73-100)
  • split_cells (36-70)
src/lib.rs (1)
src/html.rs (2)
  • convert_html_tables (282-325)
  • lines (157-160)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (20)
.rustfmt.toml (1)

1-14: New rustfmt configuration
The .rustfmt.toml settings are comprehensive and align with the project’s style guidelines, enforcing import grouping, comment wrapping, and shorthand syntax consistently.

src/reflow.rs (1)

8-8: Import ordering adjusted
The use crate::{format_separator_cells, split_cells}; statement is repositioned to follow external imports, matching the configured import grouping rules.

src/main.rs (3)

1-5: Grouped std imports
Consolidating all std::{fs, io::{self, Read}, path::{Path, PathBuf}} imports into a single block improves readability and adheres to the new import layout rules.


41-42: Refined doc comment for main
The revised sentences break at 100 characters and clarify the function’s responsibilities, matching the comment wrapping configuration.


47-48: Enhanced return documentation
The updated # Returns section clearly states success and error conditions, improving the API docs.

src/html.rs (5)

9-9: Standard library import grouped first
Moving use std::sync::LazyLock; into the std group aligns with the imports_granularity = "Crate" and group_imports settings.


11-11: External crate imports ordered
The html5ever import is now grouped after the std imports, complying with the StdExternalCrate grouping rule.


181-182: Updated doc for push_html_line buffering
The description now succinctly states how lines are buffered and processed upon closure of an HTML table.


184-186: Expanded depth-tracking details
Additional sentences explain nesting depth updates and buffer management, improving clarity for maintainers.


224-227: Example formatting refined
The code example for html_table_to_markdown is now formatted across two lines for the vec! invocation, enhancing readability in docs.

src/lib.rs (7)

16-18: Reordered imports and reexport
The std::{fs, path::Path} import and pub use html::convert_html_tables; reexport are aligned with crate-level grouping for consistency.


24-25: split_cells doc updated
The new comment lines wrap at 100 characters and clearly describe the trimming and splitting behaviour.


108-110: reflow_table documentation enhanced
The description now details behaviour when column counts mismatch, aiding users in understanding fallback logic.


116-120: reflow_table example clarified
The sample invocation and output assertion are now better formatted and illustrate expected usage more clearly.


176-177: process_stream_inner doc refined
The updated doc now summarises how tables are reflowed and code blocks preserved, aligning with the formatting rules.


379-380: process_stream doc improved
The combined description succinctly covers HTML conversion, table reflow, and text wrapping in one place.


493-494: rewrite example doc added import comment
Including the use mdtablefix::rewrite; snippet makes the code sample self-contained.

tests/integration.rs (2)

1-1: Consolidated import formatting is clear.

Grouping fs::File and io::Write under a single std import improves readability and adheres to the new style rules.


14-15: Doc comment wrapping aligns with style guide.

Reflowing and wrapping comments improves readability and consistency with the configured rustfmt width settings. No logic changes here.

Also applies to: 28-29, 129-130, 149-150, 231-232, 251-252, 254-255, 258-266, 286-288, 532-533, 547-551, 555-556, 577-578, 624-625

AGENTS.md (1)

97-101: Nightly toolchain formatting instructions updated correctly.

The instructions now explicitly pin nightly-2025-06-10 for rustfmt, clippy, and tests, matching the CI workflow.

Comment thread .github/workflows/ci.yml
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 16, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 16, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 16, 2025

@sourcery-ai review

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Code Health Improved (2 files improve in Code Health)

Gates Passed
6 Quality Gates Passed

See analysis details in CodeScene

View Improvements
File Code Health Impact Categories Improved
html.rs 7.22 → 7.33 Bumpy Road Ahead, Deep, Nested Complexity
lib.rs 7.28 → 7.62 Bumpy Road Ahead, Deep, Nested Complexity

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.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes - here's some feedback:

  • Please split the PR into separate commits—one for adding nightly rustfmt and CI updates and another for the mass reformat—to simplify review and future rollbacks.
  • Verify that replacing cross build with cross +stable build in the release workflow aligns with your toolchain requirements and doesn't conflict with the nightly pin.
  • Some conditional expressions are now awkwardly split across lines (e.g. if let ... && ...); consider tweaking rustfmt settings to keep such conditions on a single line for readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Please split the PR into separate commits—one for adding nightly rustfmt and CI updates and another for the mass reformat—to simplify review and future rollbacks.
- Verify that replacing `cross build` with `cross +stable build` in the release workflow aligns with your toolchain requirements and doesn't conflict with the nightly pin.
- Some conditional expressions are now awkwardly split across lines (e.g. `if let ... && ...`); consider tweaking rustfmt settings to keep such conditions on a single line for readability.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 16, 2025

@coderabbitai Please create a new GitHub issue for the following:

Some conditional expressions are now awkwardly split across lines (e.g. if let ... && ...); consider extracting relevant conditionals as predicate functions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 16, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@leynos I've created a GitHub issue to track the concern about awkward conditional expressions being split across lines after the rustfmt changes. The issue has been assigned to you and includes backlinks to this PR and your comment for reference.


🏁 Script executed:

#!/bin/bash
# Create a GitHub issue for the awkward conditional expressions concern
gh issue create \
  --title "Improve readability of conditional expressions split across lines by rustfmt" \
  --body "After configuring nightly rustfmt in PR #48, some conditional expressions are now awkwardly split across lines (e.g. \`if let ... && ...\`). These could be improved by extracting relevant conditionals as predicate functions to enhance code readability.

**Background**
This issue arose from the rustfmt formatting changes introduced in PR #48.

**Backlinks**
- Original PR: https://github.com/leynos/mdtablefix/pull/48
- Comment: https://github.com/leynos/mdtablefix/pull/48#issuecomment-$(gh api repos/leynos/mdtablefix/pulls/48/comments | jq -r '.[-1].id // "latest"')

**Requested by:** @leynos" \
  --assignee leynos

Length of output: 786


@leynos ✅ I've successfully created GitHub issue #49 to track the concern about improving readability of conditional expressions that are now awkwardly split across lines by rustfmt. The issue has been assigned to you and includes the proper backlinks to this PR and your comment for reference.

@leynos leynos merged commit 4fa9f52 into main Jun 16, 2025
3 checks passed
@leynos leynos deleted the codex/update-.rustfmt.toml-and-ci-workflow branch June 16, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant