Search code examples
ruby-on-railscoding-style

Are there any gems which can enforce Ruby code conventions?


Are there any gems which can enforce ruby/rails coding conventions as mentioned by the guides below.

https://github.com/bbatsov/ruby-style-guide
https://github.com/bbatsov/rails-style-guide

Solution

  • My two favorite gems for handling code cleanliness are Reek (https://github.com/troessner/reek) and Cane (https://github.com/square/cane). I don't know that they go down to the nitty-gritty of indentation and spacing, but they detect a lot of Ruby coding conventions that tend to otherwise get overlooked.

    In terms of spacing / indentation / casing and so forth, I'd either look for an editor configuration (e.g., download a Ruby package for TextMate / Sublime Text / EMACS / what have you), or look into the BeautifyRuby gem (https://github.com/CraigWilliams/BeautifyRuby).