Use a guard clause instead of wrapping the code inside a conditional expression. 条件分岐のネストが深くなるのはダメ
bad
def hoge if boge? || kuzu? 'sine' end end
good
def hoge 'sine' if boge? || kuzu? end
Don't use parentheses around the condition of an if
.
ifにカッコはいらんわ!
Favor a normal if-statement over a modifier clause in a multiline statement.
def create_transfer_request ContentDepositorChangeEventJob.perform_later(self, 'sample') if on_behalf_of.present? end def create_transfer_request if on_behalf_of.present? ContentDepositorChangeEventJob.perform_later(self, 'sample') end end
Style/IfInsideElse: Style/IfInsideElse:
elseの中にif入れんならelsifにしろ
if hoge? action_b else if hage? action_b else action_c end if hoge? action_b elsif hage? action_b else action_c end
Class: RuboCop::Cop::Style::ConditionalAssignment
is_push ? self.hoge = true : self.hoge = false ↓の方がイケてるっぽい self.hoge = if is_push true else false end