Skip to content

Commit b98aad0

Browse files
committed
linting fixes
1 parent 1674659 commit b98aad0

9 files changed

Lines changed: 300 additions & 309 deletions

lib/ice_cube/validations/by_set_pos_helper.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def interval_bounds(interval_type, step_time, week_start: nil)
2626
start_day_of_week = TimeUtil.sym_to_wday(week_start)
2727
step_time_day_of_week = step_time_date.wday
2828
days_delta = step_time_day_of_week - start_day_of_week
29-
days_to_start = days_delta >= 0 ? days_delta : 7 + days_delta
29+
days_to_start = (days_delta >= 0) ? days_delta : 7 + days_delta
3030
start_of_week_date = step_time_date - days_to_start
3131
end_of_week_date = start_of_week_date + 6
3232
[
@@ -69,9 +69,9 @@ def interval_bounds(interval_type, step_time, week_start: nil)
6969
def build_filtered_schedule(rule, start_time, interval_start)
7070
# Strip BYSETPOS/COUNT/UNTIL so the candidate set is complete, and avoid
7171
# recursive BYSETPOS evaluation when we rebuild the temporary rule.
72-
filtered_hash = rule.to_hash.reject { |key, _| [:by_set_pos, :count, :until].include?(key) }
72+
filtered_hash = rule.to_hash.except(:by_set_pos, :count, :until)
7373
if filtered_hash[:validations]
74-
filtered_hash[:validations] = filtered_hash[:validations].reject { |key, _| key == :by_set_pos }
74+
filtered_hash[:validations] = filtered_hash[:validations].except(:by_set_pos)
7575
filtered_hash.delete(:validations) if filtered_hash[:validations].empty?
7676
end
7777

@@ -81,11 +81,11 @@ def build_filtered_schedule(rule, start_time, interval_start)
8181
# We must anchor the temp schedule to the interval boundary for expanded units,
8282
# while preserving DTSTART's value for implicit (non-expanded) units.
8383
v = rule.validations
84-
expands_day = v[:day] || v[:day_of_month] || v[:day_of_week] || v[:day_of_year]
84+
expands_day = v[:day] || v[:day_of_month] || v[:day_of_week] || v[:day_of_year]
8585
expands_month = v[:month_of_year]
86-
expands_hour = v[:hour_of_day]
87-
expands_min = v[:minute_of_hour]
88-
expands_sec = v[:second_of_minute]
86+
expands_hour = v[:hour_of_day]
87+
expands_min = v[:minute_of_hour]
88+
expands_sec = v[:second_of_minute]
8989

9090
# Anchor date: determine based on which date components are expanded.
9191
# WeeklyRule is special: "day" expansion means weekdays within the week.
@@ -115,8 +115,8 @@ def build_filtered_schedule(rule, start_time, interval_start)
115115
# This ensures the candidate set starts at the interval boundary for expanded
116116
# units while preserving implicit time-of-day anchors from DTSTART.
117117
hour = expands_hour ? interval_start.hour : start_time.hour
118-
min = expands_min ? interval_start.min : start_time.min
119-
sec = expands_sec ? interval_start.sec : start_time.sec
118+
min = expands_min ? interval_start.min : start_time.min
119+
sec = expands_sec ? interval_start.sec : start_time.sec
120120

121121
# Preserve sub-second precision from DTSTART to ensure occurrences.index(step_time)
122122
# can find exact matches when DTSTART has fractional seconds.

lib/ice_cube/validations/daily_by_set_pos.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Validations::DailyBySetPos
33
def by_set_pos(*by_set_pos)
44
by_set_pos.flatten!
55
by_set_pos.each do |set_pos|
6-
unless (-366..366).include?(set_pos) && set_pos != 0
6+
unless (-366..366).cover?(set_pos) && set_pos != 0
77
raise ArgumentError, "Expecting number in [-366, -1] or [1, 366], got #{set_pos} (#{by_set_pos})"
88
end
99
end

lib/ice_cube/validations/hourly_by_set_pos.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Validations::HourlyBySetPos
33
def by_set_pos(*by_set_pos)
44
by_set_pos.flatten!
55
by_set_pos.each do |set_pos|
6-
unless (-366..366).include?(set_pos) && set_pos != 0
6+
unless (-366..366).cover?(set_pos) && set_pos != 0
77
raise ArgumentError, "Expecting number in [-366, -1] or [1, 366], got #{set_pos} (#{by_set_pos})"
88
end
99
end

lib/ice_cube/validations/minutely_by_set_pos.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Validations::MinutelyBySetPos
33
def by_set_pos(*by_set_pos)
44
by_set_pos.flatten!
55
by_set_pos.each do |set_pos|
6-
unless (-366..366).include?(set_pos) && set_pos != 0
6+
unless (-366..366).cover?(set_pos) && set_pos != 0
77
raise ArgumentError, "Expecting number in [-366, -1] or [1, 366], got #{set_pos} (#{by_set_pos})"
88
end
99
end

lib/ice_cube/validations/monthly_by_set_pos.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module IceCube
2-
32
module Validations::MonthlyBySetPos
43
def by_set_pos(*by_set_pos)
54
by_set_pos.flatten!
65
by_set_pos.each do |set_pos|
7-
unless (-366..366).include?(set_pos) && set_pos != 0
6+
unless (-366..366).cover?(set_pos) && set_pos != 0
87
raise ArgumentError, "Expecting number in [-366, -1] or [1, 366], got #{set_pos} (#{by_set_pos})"
98
end
109
end
@@ -15,7 +14,6 @@ def by_set_pos(*by_set_pos)
1514
end
1615

1716
class Validation
18-
1917
attr_reader :rule, :by_set_pos
2018

2119
def initialize(by_set_pos, rule)
@@ -45,7 +43,7 @@ def validate(step_time, start_time)
4543
# occurrence to positive/negative positions.
4644
occurrences = new_schedule.occurrences_between(start_of_month, end_of_month)
4745
index = occurrences.index(step_time)
48-
if index == nil
46+
if index.nil?
4947
1
5048
else
5149
positive_set_pos = index + 1
@@ -73,7 +71,5 @@ def build_ical(builder)
7371

7472
nil
7573
end
76-
7774
end
78-
7975
end

lib/ice_cube/validations/secondly_by_set_pos.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Validations::SecondlyBySetPos
33
def by_set_pos(*by_set_pos)
44
by_set_pos.flatten!
55
by_set_pos.each do |set_pos|
6-
unless (-366..366).include?(set_pos) && set_pos != 0
6+
unless (-366..366).cover?(set_pos) && set_pos != 0
77
raise ArgumentError, "Expecting number in [-366, -1] or [1, 366], got #{set_pos} (#{by_set_pos})"
88
end
99
end

lib/ice_cube/validations/weekly_by_set_pos.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Validations::WeeklyBySetPos
33
def by_set_pos(*by_set_pos)
44
by_set_pos.flatten!
55
by_set_pos.each do |set_pos|
6-
unless (-366..366).include?(set_pos) && set_pos != 0
6+
unless (-366..366).cover?(set_pos) && set_pos != 0
77
raise ArgumentError, "Expecting number in [-366, -1] or [1, 366], got #{set_pos} (#{by_set_pos})"
88
end
99
end
@@ -14,7 +14,6 @@ def by_set_pos(*by_set_pos)
1414
end
1515

1616
class Validation
17-
1817
attr_reader :rule, :by_set_pos
1918

2019
def initialize(by_set_pos, rule)

lib/ice_cube/validations/yearly_by_set_pos.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
module IceCube
2-
32
module Validations::YearlyBySetPos
4-
53
def by_set_pos(*by_set_pos)
64
by_set_pos.flatten!
75
by_set_pos.each do |set_pos|
8-
unless (-366..366).include?(set_pos) && set_pos != 0
6+
unless (-366..366).cover?(set_pos) && set_pos != 0
97
raise ArgumentError, "Expecting number in [-366, -1] or [1, 366], got #{set_pos} (#{by_set_pos})"
108
end
119
end
@@ -16,11 +14,9 @@ def by_set_pos(*by_set_pos)
1614
end
1715

1816
class Validation
19-
2017
attr_reader :rule, :by_set_pos
2118

2219
def initialize(by_set_pos, rule)
23-
2420
@by_set_pos = by_set_pos
2521
@rule = rule
2622
end
@@ -48,7 +44,7 @@ def validate(step_time, start_time)
4844
occurrences = new_schedule.occurrences_between(start_of_year, end_of_year)
4945

5046
index = occurrences.index(step_time)
51-
if index == nil
47+
if index.nil?
5248
1
5349
else
5450
positive_set_pos = index + 1

0 commit comments

Comments
 (0)