Code style fixes

This commit is contained in:
Jyri-Petteri Paloposki 2020-10-10 02:27:42 +03:00
parent c6bbc67dab
commit d8acf60049
72 changed files with 458 additions and 594 deletions

View file

@ -1,7 +1,5 @@
module RecurringTodos
class WeeklyRecurrencePattern < AbstractRecurrencePattern
def initialize(user)
super user
end
@ -31,7 +29,7 @@ module RecurringTodos
def validate
super
validate_not_blank(every_x_week, "Every other nth week may not be empty for weekly recurrence setting")
something_set = %w{sunday monday tuesday wednesday thursday friday saturday}.inject(false) { |set, day| set || self.send("on_#{day}") }
something_set = %w{ sunday monday tuesday wednesday thursday friday saturday }.inject(false) { |set, day| set || self.send("on_#{day}") }
errors[:base] << "You must specify at least one day on which the todo recurs" unless something_set
end
@ -61,7 +59,7 @@ module RecurringTodos
if start.wday() == 0
# we went to a new week, go to the nth next week and find first match
# that week. Note that we already went into the next week, so -1
start += (every_x_week-1).week
start += (every_x_week - 1).week
end
unless self.start_from.nil?
# check if the start_from date is later than previous. If so, use
@ -75,12 +73,9 @@ module RecurringTodos
def find_first_day_in_this_week(start)
# check if there are any days left this week for the next todo
start.wday().upto 6 do |i|
return start + (i-start.wday()).days if on_xday(i)
return start + (i - start.wday()).days if on_xday(i)
end
-1
end
end
end