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:
Enabled: true
Performance/StringIdentifierArgument:
Enabled: true
Performance/Sum:
Enabled: true

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

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))
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)