From 71d0faf2375cbd546b87936f3bf80174162a5393 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:37:52 +0000 Subject: [PATCH 1/3] Bump rubocop from 1.61.0 to 1.64.1 Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.61.0 to 1.64.1. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.61.0...v1.64.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 43d0c2236..136f95c74 100644 --- a/Gemfile +++ b/Gemfile @@ -98,7 +98,7 @@ group :development do gem "pronto-eslint", "~> 0.11.1", require: false gem "pronto-rubocop", "~> 0.11.5", require: false gem "pronto-stylelint", "~> 0.10.3", require: false - gem "rubocop", "~> 1.61.0", require: false + gem "rubocop", "~> 1.64.1", require: false gem "rubocop-capybara", "~> 2.21.0", require: false gem "rubocop-factory_bot", "~> 2.26.1", require: false gem "rubocop-performance", "~> 1.21.1", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 69fd3f656..d053f55bb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -536,7 +536,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.61.0) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -544,7 +544,7 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) @@ -765,7 +765,7 @@ DEPENDENCIES rinku (~> 2.0.6) ros-apartment (~> 2.11.0) rspec-rails (~> 6.1.3) - rubocop (~> 1.61.0) + rubocop (~> 1.64.1) rubocop-capybara (~> 2.21.0) rubocop-factory_bot (~> 2.26.1) rubocop-performance (~> 1.21.1) 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 2/3] 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) From 16315e14d2c84ab12fa1b89150efdbcbaaeb0597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 2 Jul 2024 18:22:38 +0200 Subject: [PATCH 3/3] Add and apply Style/SuperArguments rubocop rule This rule was added in rubocop 1.64.0. For clarity, in order to make it obvious that we're modifying the object we received, we're excluding the Ahoy initializer, whose code was copied from the Ahoy documentation. We're also changing the `Types::BaseObject` class so we don't use a variable with the same name as the parameter and we don't get a false positive for this rule. --- .rubocop.yml | 5 +++++ app/controllers/users/omniauth_callbacks_controller.rb | 2 +- app/graphql/types/base_object.rb | 5 ++--- app/lib/acts_as_paranoid_aliases.rb | 2 +- app/mailers/devise_mailer.rb | 4 +--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a5bf87e2f..01608ab60 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -796,6 +796,11 @@ Style/StringLiterals: Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes +Style/SuperArguments: + Enabled: true + Exclude: + - "config/initializers/ahoy.rb" + Style/SymbolProc: Enabled: true AllowedMethods: diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 02186e9e9..9f8116759 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -19,7 +19,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController if resource.registering_with_oauth finish_signup_path else - super(resource) + super end end diff --git a/app/graphql/types/base_object.rb b/app/graphql/types/base_object.rb index 96765f0c9..d98173b6a 100644 --- a/app/graphql/types/base_object.rb +++ b/app/graphql/types/base_object.rb @@ -1,7 +1,7 @@ module Types class BaseObject < GraphQL::Schema::Object def self.field(*args, **kwargs, &) - super(*args, **kwargs, &) + super # The old api contained non-camelized fields # We want to support these for now, but throw a deprecation warning @@ -13,8 +13,7 @@ module Types if field_name.to_s.include?("_") reason = "Snake case fields are deprecated. Please use #{field_name.to_s.camelize(:lower)}." - kwargs = kwargs.merge({ camelize: false, deprecation_reason: reason }) - super(*args, **kwargs, &) + super(*args, **kwargs.merge({ camelize: false, deprecation_reason: reason }), &) end # Make sure associations only return public records diff --git a/app/lib/acts_as_paranoid_aliases.rb b/app/lib/acts_as_paranoid_aliases.rb index 369bdc6c9..76afbbdf0 100644 --- a/app/lib/acts_as_paranoid_aliases.rb +++ b/app/lib/acts_as_paranoid_aliases.rb @@ -27,7 +27,7 @@ module ActsAsParanoidAliases def restore(opts = {}) return false unless hidden? - super(opts) + super update_attribute(:confirmed_hide_at, nil) if self.class.column_names.include? "confirmed_hide_at" after_restore end diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb index a3f3ed271..738dcc9c0 100644 --- a/app/mailers/devise_mailer.rb +++ b/app/mailers/devise_mailer.rb @@ -5,8 +5,6 @@ class DeviseMailer < Devise::Mailer protected def devise_mail(record, action, opts = {}) - I18n.with_locale record.locale do - super(record, action, opts) - end + I18n.with_locale(record.locale) { super } end end