From 11b962da8f28f594bd8be1e58e663fcb058e1ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 4 Sep 2023 18:59:52 +0200 Subject: [PATCH] Add and apply Style/MinMaxComparison rubocop rule This rule was added in rubocop 1.42.0. --- .rubocop.yml | 3 +++ app/helpers/shifts_helper.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0db5b5e83..3781f9659 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -646,6 +646,9 @@ Style/MapToHash: Style/MethodDefParentheses: Enabled: true +Style/MinMaxComparison: + Enabled: true + Style/MutableConstant: Enabled: true diff --git a/app/helpers/shifts_helper.rb b/app/helpers/shifts_helper.rb index deb4d62b6..01552a730 100644 --- a/app/helpers/shifts_helper.rb +++ b/app/helpers/shifts_helper.rb @@ -9,7 +9,7 @@ module ShiftsHelper return [] if polls.blank? 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 end date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny], booth) @@ -25,7 +25,7 @@ module ShiftsHelper def start_date(polls) start_date = polls.map(&:starts_at).min.to_date - start_date < Date.current ? Date.current : start_date + [start_date, Date.current].max end def end_date(polls)