app/models/schedule.rb
Schedule#presentation_events_inc doesn't depend on instance state (maybe move it to another class?) Open
Open
def presentation_events_inc(talk_rank, inc)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Use a guard clause (return unless talk_rank
) instead of wrapping the code inside a conditional expression. Open
Open
if talk_rank
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
# bad
if something
foo || raise('exception')
else
ok
end
# good
foo || raise('exception') if something
ok