Fork me on GitHub

Project Notes

Ruby Style

On style guides and resources for ruby.

Notes

Rubocop finally made it to 1.0 in Oct 2020 after 7+ years on the scene.

RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. (in fact, the RuboCop project is one of the major forces that brought about the style guide in the first place)

After installation, rubocop will evaluate all ruby files under the current directory by default:

$ rubocop

Usually, rubocop is used as part of a continuous integration workflow (to make the build go red on failures).

But lets not get too obsessed by the tools. While rubocop is great, for the most part it will be something one never needs to think about - it will jut be quietly keeping guard during builds.

However, the Ruby Style Guide is well worth diving into every so often, as it is a great way to learn about using the ruby language well.

The basic instllation and setup recipe

Add to the Gemfile

gem 'rubocop', require: false

Automatically generate an initial config:

$ rubocop --auto-gen-config

Updating Rubocop

Rubocop updates can bring some major changes to rules and be a bit of a pain to deal with.

Updating .rubocop.yml to latest version can be automated with mry.

$ gem install mry
# Update to latest version
$ mry .rubocop.yml
# Update to specified version
$ mry --target=0.48.0 .rubocop.yml

Credits and References

About LCK#167 ruby
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.