Add and apply Style/MinMaxComparison rubocop rule

This rule was added in rubocop 1.42.0.
This commit is contained in:
Javi Martín
2023-09-04 18:59:52 +02:00
parent daa35845da
commit 11b962da8f
2 changed files with 5 additions and 2 deletions

View File

@@ -646,6 +646,9 @@ Style/MapToHash:
Style/MethodDefParentheses: Style/MethodDefParentheses:
Enabled: true Enabled: true
Style/MinMaxComparison:
Enabled: true
Style/MutableConstant: Style/MutableConstant:
Enabled: true Enabled: true

View File

@@ -9,7 +9,7 @@ module ShiftsHelper
return [] if polls.blank? return [] if polls.blank?
dates = polls.map(&:ends_at).map(&:to_date).sort.reduce([]) do |total, date| dates = polls.map(&:ends_at).map(&:to_date).sort.reduce([]) do |total, date|
initial_date = date < Date.current ? Date.current : date initial_date = [date, Date.current].max
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
end end
date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny], booth) date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny], booth)
@@ -25,7 +25,7 @@ module ShiftsHelper
def start_date(polls) def start_date(polls)
start_date = polls.map(&:starts_at).min.to_date start_date = polls.map(&:starts_at).min.to_date
start_date < Date.current ? Date.current : start_date [start_date, Date.current].max
end end
def end_date(polls) def end_date(polls)