Skip to content

Formatter: emit canonical blank lines between class sections and methods (BT-985)#1029

Merged
jamesc merged 2 commits intomainfrom
worktree-BT-985
Mar 1, 2026
Merged

Formatter: emit canonical blank lines between class sections and methods (BT-985)#1029
jamesc merged 2 commits intomainfrom
worktree-BT-985

Conversation

@jamesc
Copy link
Owner

@jamesc jamesc commented Mar 1, 2026

Summary

  • Always emit a blank line between class leading comments (e.g. license block) and the doc comment/class header
  • Always emit a blank line before the first method in a class body, regardless of whether state declarations exist
  • Emit a blank line between consecutive methods within a class

Fixes: https://linear.app/beamtalk/issue/BT-985

Test plan

  • beamtalk fmt-check examples/getting-started/src/hello.bt reports no diff
  • All idempotency tests pass (hello.bt, hanoi.bt, point.bt)
  • just ci passes (2371 Rust tests, 886 stdlib/BUnit, 2208 Erlang tests)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved generated-code formatting: ensures a blank line between leading comments and doc headers.
    • Consistently inserts blank lines between consecutive instance methods, between consecutive class-side methods, and between the last instance method and the first class-side method when both exist.
    • No public or exported signatures were added, removed, or changed.

…BT-985)

- Always emit blank line between class leading comments and doc/header
- Always emit blank line before first method regardless of state
- Emit blank line between consecutive methods within a class

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 1, 2026 11:41
@coderabbitai
Copy link

coderabbitai bot commented Mar 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f2978c5 and a171910.

📒 Files selected for processing (1)
  • crates/beamtalk-core/src/unparse/mod.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/beamtalk-core/src/unparse/mod.rs

📝 Walkthrough

Walkthrough

Adjusts the unparser's formatting for class-like constructs: inserts a blank line after non-doc leading comments, always adds a blank before the first method when methods exist, separates consecutive instance and class-side methods, and ensures a blank line between instance and class-side method groups.

Changes

Cohort / File(s) Summary
Unparser formatting
crates/beamtalk-core/src/unparse/mod.rs
Inserted blank-line emission after non-doc leading comments; changed method-block blank-line insertion to run unconditionally when any methods exist; switched instance- and class-side method iterations to enumerate and added separators between consecutive methods and between instance vs class-side groups.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding canonical blank lines between class sections and methods in the formatter. It is specific, clear, and directly reflects the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch worktree-BT-985

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

Copy link

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/beamtalk-core/src/unparse/mod.rs`:
- Around line 197-201: The loop over class.class_methods currently only inserts
a blank line when i > 0, so the first class-side method isn’t separated from
preceding instance methods; update the condition in the class.class_methods
iteration so a blank line is also emitted when i == 0 and class.instance_methods
is non-empty (i.e., change the if to check `if i > 0 || (i == 0 &&
!class.instance_methods.is_empty())` or equivalent), ensuring you still call
docs.push(line()) in that case (references: class.class_methods,
class.instance_methods, docs.push(line())).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa5989 and f2978c5.

📒 Files selected for processing (1)
  • crates/beamtalk-core/src/unparse/mod.rs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Beamtalk AST unparser/formatter to emit canonical blank-line spacing within class definitions, aligning formatted output with the BT-985 formatting rules.

Changes:

  • Emit a blank line between class leading comments and the doc comment/class header.
  • Always emit a blank line before the first method in a class when any methods exist (independent of state/classState presence).
  • Emit a blank line between consecutive methods (instance-side and class-side) within their respective method lists.

Address Copilot and CodeRabbit review feedback: emit a blank line
between the last instance method and the first class-side method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jamesc jamesc merged commit a1858cf into main Mar 1, 2026
5 checks passed
@jamesc jamesc deleted the worktree-BT-985 branch March 1, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants