Ruby is a sweet language, but sometimes is too sweet… If you have some unfavorite ruby syntax, e.g. unless
, until
, safe navigation, endless methods etc, you can now easily forbid it using the new rubocop extension - GitHub - fatkodima/rubocop-disable_syntax: A RuboCop plugin that allows to disable some unfavorite ruby syntax, such as `unless`, safe navigation etc.
Everything is enabled by default. Currently, it allows to disable the following syntax:
unless
- nounless
keywordternary
- no ternary operator (condition ? foo : bar
)safe_navigation
- no safe navigation operator (&.
)endless_methods
- no endless methods (def foo = 1
)arguments_forwarding
- no arguments forwarding (foo(...)
,foo(*)
,foo(**)
,foo(&)
)numbered_parameters
- no numbered parameters (foo.each { puts _1 }
)pattern_matching
- no pattern matchingshorthand_hash_syntax
- no shorthand hash syntax ({ x:, y: }
)and_or_not
- noand
/or
/not
keywords (should use&&
/||
/!
instead)until
- nountil
keywordpercent_literals
- no any%
style literals (%w[foo bar]
,%i[foo bar]
,%q("str")
,%r{/regex/}
)