From 5655702c49a459c20780f662389da746be21d34e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Aug 2022 19:51:46 +0000 Subject: [PATCH 1/2] Bump rubocop-performance from 1.11.4 to 1.14.3 Bumps [rubocop-performance](https://github.com/rubocop/rubocop-performance) from 1.11.4 to 1.14.3. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.11.4...v1.14.3) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 568dd8b80..2d3af057f 100644 --- a/Gemfile +++ b/Gemfile @@ -109,7 +109,7 @@ group :development do gem "pronto-rubocop", "~> 0.11.2", require: false gem "pronto-scss", "~> 0.11.0", require: false gem "rubocop", "~> 1.35.1", require: false - gem "rubocop-performance", "~> 1.11.4", require: false + gem "rubocop-performance", "~> 1.14.3", require: false gem "rubocop-rails", "~> 2.15.2", require: false gem "rubocop-rspec", "~> 2.4.0", require: false gem "rvm1-capistrano3", "~> 1.4.0", require: false diff --git a/Gemfile.lock b/Gemfile.lock index e27060c86..ff3054bd1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -562,7 +562,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) - rubocop-performance (1.11.4) + rubocop-performance (1.14.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.15.2) @@ -782,7 +782,7 @@ DEPENDENCIES ros-apartment (~> 2.11.0) rspec-rails (~> 5.1.2) rubocop (~> 1.35.1) - rubocop-performance (~> 1.11.4) + rubocop-performance (~> 1.14.3) rubocop-rails (~> 2.15.2) rubocop-rspec (~> 2.4.0) rvm1-capistrano3 (~> 1.4.0) From efc46fe6c8ce25f0d2f17053b807b3c321b49d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 26 Aug 2022 23:47:57 +0200 Subject: [PATCH 2/2] Add Performance/StringIdentifierArgument rule It was added in rubocop-performance 1.13.0. We were already applying it in most places. We aren't adding it for performance reasons but in order to make the code more consistent. --- .rubocop.yml | 3 +++ app/controllers/concerns/flag_actions.rb | 4 ++-- app/controllers/concerns/polymorphic.rb | 4 ++-- app/models/concerns/skip_validation.rb | 2 +- app/models/direct_upload.rb | 2 +- lib/comment_tree.rb | 2 +- spec/models/related_content_spec.rb | 4 ++-- spec/shared/system/relationable.rb | 4 ++-- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f47dd6fb6..cd70fa112 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -224,6 +224,9 @@ Performance/EndWith: Performance/StartWith: Enabled: true +Performance/StringIdentifierArgument: + Enabled: true + Performance/Sum: Enabled: true diff --git a/app/controllers/concerns/flag_actions.rb b/app/controllers/concerns/flag_actions.rb index acbc96882..7042a04fc 100644 --- a/app/controllers/concerns/flag_actions.rb +++ b/app/controllers/concerns/flag_actions.rb @@ -17,9 +17,9 @@ module FlagActions def flaggable if resource_model.to_s == "Budget::Investment" - instance_variable_get("@investment") + instance_variable_get(:@investment) elsif resource_model.to_s == "Legislation::Proposal" - instance_variable_get("@proposal") + instance_variable_get(:@proposal) else instance_variable_get("@#{resource_model.to_s.downcase}") end diff --git a/app/controllers/concerns/polymorphic.rb b/app/controllers/concerns/polymorphic.rb index 2a5188c26..53d18b21c 100644 --- a/app/controllers/concerns/polymorphic.rb +++ b/app/controllers/concerns/polymorphic.rb @@ -3,9 +3,9 @@ module Polymorphic def resource if resource_model.to_s == "Budget::Investment" - @resource ||= instance_variable_get("@investment") + @resource ||= instance_variable_get(:@investment) elsif resource_model.to_s == "Legislation::Proposal" - @resource ||= instance_variable_get("@proposal") + @resource ||= instance_variable_get(:@proposal) else @resource ||= instance_variable_get("@#{resource_name}") end diff --git a/app/models/concerns/skip_validation.rb b/app/models/concerns/skip_validation.rb index 2a3dbcdc1..7c1a3c549 100644 --- a/app/models/concerns/skip_validation.rb +++ b/app/models/concerns/skip_validation.rb @@ -13,7 +13,7 @@ module SkipValidation _validate_callbacks.each do |callback| if callback.raw_filter.is_a?(validator_class) - callback.raw_filter.instance_variable_set("@attributes", callback.raw_filter.attributes - [field]) + callback.raw_filter.instance_variable_set(:@attributes, callback.raw_filter.attributes - [field]) end end end diff --git a/app/models/direct_upload.rb b/app/models/direct_upload.rb index 6d6eb7470..c5e535906 100644 --- a/app/models/direct_upload.rb +++ b/app/models/direct_upload.rb @@ -22,7 +22,7 @@ class DirectUpload # Refactor @relation = if @resource.respond_to?(:images) && ((@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?) - @resource.images.send("build", relation_attributtes) + @resource.images.send(:build, relation_attributtes) elsif @resource.class.reflections[@resource_relation].macro == :has_one @resource.send("build_#{resource_relation}", relation_attributtes) else diff --git a/lib/comment_tree.rb b/lib/comment_tree.rb index d5743f311..c43e619c4 100644 --- a/lib/comment_tree.rb +++ b/lib/comment_tree.rb @@ -19,7 +19,7 @@ class CommentTree end def base_comments - if @valuations && commentable.respond_to?("valuations") + if @valuations && commentable.respond_to?(:valuations) commentable.valuations else commentable.comments diff --git a/spec/models/related_content_spec.rb b/spec/models/related_content_spec.rb index 827a50597..a41e5bd64 100644 --- a/spec/models/related_content_spec.rb +++ b/spec/models/related_content_spec.rb @@ -79,11 +79,11 @@ describe RelatedContent do create(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable, author: build(:user)) 2.times do - related_content.send("score_positive", build(:user)) + related_content.send(:score_positive, build(:user)) end 6.times do - related_content.send("score_negative", build(:user)) + related_content.send(:score_negative, build(:user)) end end diff --git a/spec/shared/system/relationable.rb b/spec/shared/system/relationable.rb index 28612d413..4b744fe35 100644 --- a/spec/shared/system/relationable.rb +++ b/spec/shared/system/relationable.rb @@ -173,11 +173,11 @@ shared_examples "relationable" do |relationable_model_name| related_content = create(:related_content, parent_relationable: relationable, child_relationable: related1, author: build(:user)) 2.times do - related_content.send("score_positive", build(:user)) + related_content.send(:score_positive, build(:user)) end 6.times do - related_content.send("score_negative", build(:user)) + related_content.send(:score_negative, build(:user)) end login_as(user)