I was addicted to RuboCop's Style/Bracelets AroundHash Parameters
, so make a note.
I got a warning when I wrote the following.
config.add_notifier :slack, {
webhook_url: 'url',
channel: '#Error notification'
}
The cause is that there is an extra {...}
, but the warning did not disappear even if I simply deleted the parentheses.
From the conclusion, if you write as follows, the warning disappears.
config.add_notifier :slack, webhook_url: 'url', channel: '#Error notification'
This is because in the Ruby grammar, {...}
can be omitted if the last argument is a hash.
I simply erased it and it didn't work because I was warned to write it in one line.
See Resources for details.
that's all
Ruby grammar for Rails beginners to stumble RuboCop | Style/BracesAroundHashParameters EnforcedStyle