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.
This commit is contained in:
Javi Martín
2022-08-26 23:47:57 +02:00
parent 5655702c49
commit efc46fe6c8
8 changed files with 14 additions and 11 deletions

View File

@@ -224,6 +224,9 @@ Performance/EndWith:
Performance/StartWith: Performance/StartWith:
Enabled: true Enabled: true
Performance/StringIdentifierArgument:
Enabled: true
Performance/Sum: Performance/Sum:
Enabled: true Enabled: true

View File

@@ -17,9 +17,9 @@ module FlagActions
def flaggable def flaggable
if resource_model.to_s == "Budget::Investment" if resource_model.to_s == "Budget::Investment"
instance_variable_get("@investment") instance_variable_get(:@investment)
elsif resource_model.to_s == "Legislation::Proposal" elsif resource_model.to_s == "Legislation::Proposal"
instance_variable_get("@proposal") instance_variable_get(:@proposal)
else else
instance_variable_get("@#{resource_model.to_s.downcase}") instance_variable_get("@#{resource_model.to_s.downcase}")
end end

View File

@@ -3,9 +3,9 @@ module Polymorphic
def resource def resource
if resource_model.to_s == "Budget::Investment" if resource_model.to_s == "Budget::Investment"
@resource ||= instance_variable_get("@investment") @resource ||= instance_variable_get(:@investment)
elsif resource_model.to_s == "Legislation::Proposal" elsif resource_model.to_s == "Legislation::Proposal"
@resource ||= instance_variable_get("@proposal") @resource ||= instance_variable_get(:@proposal)
else else
@resource ||= instance_variable_get("@#{resource_name}") @resource ||= instance_variable_get("@#{resource_name}")
end end

View File

@@ -13,7 +13,7 @@ module SkipValidation
_validate_callbacks.each do |callback| _validate_callbacks.each do |callback|
if callback.raw_filter.is_a?(validator_class) 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 end
end end

View File

@@ -22,7 +22,7 @@ class DirectUpload
# Refactor # Refactor
@relation = if @resource.respond_to?(:images) && @relation = if @resource.respond_to?(:images) &&
((@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?) ((@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 elsif @resource.class.reflections[@resource_relation].macro == :has_one
@resource.send("build_#{resource_relation}", relation_attributtes) @resource.send("build_#{resource_relation}", relation_attributtes)
else else

View File

@@ -19,7 +19,7 @@ class CommentTree
end end
def base_comments def base_comments
if @valuations && commentable.respond_to?("valuations") if @valuations && commentable.respond_to?(:valuations)
commentable.valuations commentable.valuations
else else
commentable.comments commentable.comments

View File

@@ -79,11 +79,11 @@ describe RelatedContent do
create(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable, author: build(:user)) create(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable, author: build(:user))
2.times do 2.times do
related_content.send("score_positive", build(:user)) related_content.send(:score_positive, build(:user))
end end
6.times do 6.times do
related_content.send("score_negative", build(:user)) related_content.send(:score_negative, build(:user))
end end
end end

View File

@@ -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)) related_content = create(:related_content, parent_relationable: relationable, child_relationable: related1, author: build(:user))
2.times do 2.times do
related_content.send("score_positive", build(:user)) related_content.send(:score_positive, build(:user))
end end
6.times do 6.times do
related_content.send("score_negative", build(:user)) related_content.send(:score_negative, build(:user))
end end
login_as(user) login_as(user)