Rufo – opinionated Ruby code formatter

Rufo is an opinionated Ruby code formatter focused on applying a consistent style without aggressively destroying deliberate layout decisions that already make source code easier to read. It offers relatively little configuration compared with tools that expose large collections of individual formatting rules.

Rufo works from the structure of the Ruby program rather than performing simple textual substitutions. It combines parsed source information with lexical tokens, an approach that lets the formatter understand the surrounding program while retaining information such as comments and intentional layout.

This is free and open source software.

Key Features

  • Formats individual Ruby files or entire directory trees from the command line.
  • Accepts Ruby source through standard input for pipelines and editor integrations.
  • Provides a check mode that reports files whose formatting would change.
  • Uses Ruby’s Ripper parser and lexer to understand source structure and tokens.
  • Preserves comments by working with lexical information as well as the parsed program shape.
  • Uses a deliberately limited configuration model rather than exposing a large collection of style switches.
  • Reads project-specific settings from a .rufo file.
  • Preserves several forms of intentional alignment by default instead of normalizing every spacing choice.
  • Supports aligned method calls, arguments, parameters and array layouts where the existing formatting is considered valid.
  • Has no runtime dependencies beyond Ruby itself.
  • Can be configured to run automatically when files are saved in supported editors.
  • Has integrations or documented plugins for Vim, Emacs, Visual Studio Code, Sublime Text and other editors.
  • Can format code on demand as well as through automated editor workflows.
  • Returns distinct exit statuses for unchanged input, errors and files whose formatted output differs from the source.

Website: github.com/ruby-formatter/rufo
Support:
Developer: Ary Borenszweig
License: MIT License

Rufo is written in Ruby. Learn Ruby with our recommended free books and free tutorials.


Related Software

Ruby Code Formatters
RuboCopChecks style, detects potential problems, and autocorrects offences
Standard RubyCombines linting and automatic fixes with a shared set of rules
rubyfmtApplies a consistent style with minimal configuration required
Syntax TreeToolkit for parsing, inspecting, and transforming source files
RufoKeeps source files tidy with an opinionated approach to style
alofmtDelivers fast, deterministic formatting for consistent results

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted