v0.0.2

Ruby formatting,
settled once.

Tuxedo is a fast, opinionated Ruby code formatter written in Rust. Put it in CI with a layout your team chose once, and “move this space” never comes up in code review again.

# Gemfile
gem "tuxedo-r", require: false

$ bundle install
$ bundle exec tuxedo format .

One layout, in both directions

Tuxedo breaks what is too long and joins what was broken by hand, so the same code always comes out the same way. This is its real output, with line_length = 60.

Before
class User < ApplicationRecord
  ROLES = ['admin', 'moderator', 'contributor', 'subscriber']
  validates :email, presence: true,
                    uniqueness: true
  def label(fallback='anonymous') = name || fallback
    private
  def notify(event)
    Mailer.with(user: self, event:, at: Time.now).deliver_later
  end
end
After tuxedo format
class User < ApplicationRecord
  ROLES = [
    "admin",
    "moderator",
    "contributor",
    "subscriber"
  ]
  validates :email, presence: true, uniqueness: true

  def label(fallback = "anonymous") = name || fallback

  private

  def notify(event)
    Mailer.with(
      user: self,
      event:,
      at: Time.now
    ).deliver_later
  end
end

Optimized for the next diff

Where more than one layout is defensible, Tuxedo picks the one that produces the smaller, clearer diff when the code changes later.

All-or-nothing expansion

A collection fits on one line or puts every element on its own. Never bin-packed, so adding one element never reflows its neighbours.

Block indentation

Continuations sit at a fixed indent, never aligned under a bracket or a name, so renaming a variable does not reindent the literal beneath it.

Safe by construction

Every output is parsed again and compared with the original syntax tree. If the meaning changed, the file is left untouched.

2.8 s

format --check over all 3,520 Ruby files in Rails, on 8 threads.

22,779

files across Rails, Thor, ruby/spec, Discourse and Homebrew, formatted and verified.

0

files with a changed meaning, a broken parse, or a change on a second pass.