From 46dc4a31638b5aa227e94961bbaa466e1be7ce3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 2 Jul 2024 17:48:35 +0200 Subject: [PATCH] Add and apply Style/MapIntoArray rubocop rule This rule was added in rubocop 1.63.0. --- .rubocop.yml | 3 +++ app/helpers/officing_helper.rb | 5 ++--- app/models/machine_learning.rb | 8 +++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 38df2c729..a5bf87e2f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -715,6 +715,9 @@ Style/InvertibleUnlessCondition: Style/LineEndConcatenation: Enabled: true +Style/MapIntoArray: + Enabled: true + Style/MapToHash: Enabled: true diff --git a/app/helpers/officing_helper.rb b/app/helpers/officing_helper.rb index c95b427ad..3078f3c84 100644 --- a/app/helpers/officing_helper.rb +++ b/app/helpers/officing_helper.rb @@ -1,8 +1,7 @@ module OfficingHelper def booths_for_officer_select_options(officer_assignments) - options = [] - officer_assignments.each do |oa| - options << [oa.booth_assignment.booth.name.to_s, oa.id] + options = officer_assignments.map do |oa| + [oa.booth_assignment.booth.name.to_s, oa.id] end options.sort_by! { |x| x[0] } options_for_select(options, params[:oa]) diff --git a/app/models/machine_learning.rb b/app/models/machine_learning.rb index 6341449bc..f7bb3503e 100644 --- a/app/models/machine_learning.rb +++ b/app/models/machine_learning.rb @@ -191,14 +191,12 @@ class MachineLearning end def scripts_info - scripts_info = [] - Dir[SCRIPTS_FOLDER.join("*.py")].each do |full_path_filename| - scripts_info << { + Dir[SCRIPTS_FOLDER.join("*.py")].map do |full_path_filename| + { name: full_path_filename.split("/").last, description: description_from(full_path_filename) } - end - scripts_info.sort_by { |script_info| script_info[:name] } + end.sort_by { |script_info| script_info[:name] } end def description_from(script_filename)