Custom Rubocop rules to add
Custom cops to implement
-
Line breaks after guard clauses
# bad return unless condition do_stuff # good return unless condition do_stuff
-
Line breaks around conditional blocks
# bad do_something if condition do_extra_stuff end do_something_more # good do_something if condition do_extra_stuff end do_something_more
A good example to get started is probably https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb.
Also, as discussed with @DouweM, here is a list of potential custom Rubocop cops we'd want to add in the future:
- Arrays should always use
[]
instead of any other possible syntax. E.g.:['foo', 'bar']
,%w[foo bar]
,%i[foo bar]
instead of%w(foo bar)
or%i{foo bar}
...
- Official style-guide rule recommends always using
()
: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces / https://github.com/bbatsov/ruby-style-guide#percent-w / https://github.com/bbatsov/ruby-style-guide#percent-i
Related to #17478 (closed).
Edited by Rémy Coutable