Ruby Style Guide

Ruby is the main language at Shopify. We are primarily a Ruby shop and we are probably one of the largest out there. Ruby is the go-to language for new web projects and scripting.

We expect all developers at Shopify to have at least a passing understanding of Ruby. It’s a great language. It will make you a better developer no matter what you work in day to day. What follows is a loose coding style to follow while developing in Ruby.

We recommend using RuboCop in your Ruby projects to help you adopt this Style Guide. To know how to install and use RuboCop please refer to RuboCop’s official documentation.

We offer a default RuboCop configuration you can inherit from and be in sync with this Style Guide. Just add the following code to the top of your project’s RuboCop configuration file:

  inherit_from:
    - https://shopify.github.io/ruby-style-guide/rubocop.yml

After running RuboCop via bundle exec rubocop it will create a local copy of the Style Guide configuration, something like .rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml. Make sure to commit that file to git. Future changes to the Style Guide will be reflected on that file and you will see them in you git diff. For more information about inheriting configuration from a remote URL please check RuboCop’s documentation.

General

Formatting

Syntax

Naming

Comments

Classes & Modules

Exceptions

Collections

Strings

Regular expressions

Percent Literals

Testing

The rest