.erb or .rb, you're coming with me.
— RuboCop
Ruumba is RuboCop's sidekick, allowing you to lint your .erb Rubies as well as your regular-type ones.
- Ruby 2.4+
λ gem install ruumbaCommand line:
λ ruumba directory_of_erb_files/Rake task:
require 'ruumba/rake_task'
Ruumba::RakeTask.new(:ruumba) do |t|
t.dir = %w(lib/views)
# You can specify CLI options too:
t.options = { arguments: %w[-c .ruumba.yml] }
endThen:
λ bundle exec rake ruumbaBy default, RuboCop only scans .rb files and so does Ruumba. If you want shown
paths to reflect original paths, you can add create a .ruumba.yml config file
with the following contents:
AllCops:
Include:
- '**/*.erb'You can then disable the .rb extension auto-append and use your config file:
λ ruumba -D -e app/views -c .ruumba.ymlSince Ruumba rewrites new files from .erb files contents, some formatting cops
cannot apply. You can disable them in your Ruumba config file:
Style/FrozenStringLiteralComment:
Enabled: false
Layout/HashAlignment:
Enabled: false
Layout/ParameterAlignment:
Enabled: false
Layout/IndentationWidth:
Enabled: false
Layout/TrailingEmptyLines:
Enabled: falseYou can use ruumba -a or ruumba -D to look for other cops if this list is
missing some.
You might want to include your existing RuboCop config file by appending this in front of your Ruumba config:
inherit_from: .rubocop.yml- Branch (
git checkout -b fancy-new-feature) - Commit (
git commit -m "Fanciness!") - Test (
bundle exec rake spec) - Lint (
bundle exec rake rubocop) - Push (
git push origin fancy-new-feature) - Ye Olde Pulle Requeste