Fix RuboCop offense Performance/StringIdentifierArgument (#39888).

git-svn-id: https://svn.redmine.org/redmine/trunk@22535 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2023-12-20 09:23:05 +00:00
parent 21a48d79f4
commit 380444f085
19 changed files with 28 additions and 28 deletions

View File

@@ -70,12 +70,12 @@ class SettingsController < ApplicationController
if request.post?
setting = params[:settings] ? params[:settings].permit!.to_h : {}
Setting.send "plugin_#{@plugin.id}=", setting
Setting.send :"plugin_#{@plugin.id}=", setting
flash[:notice] = l(:notice_successful_update)
redirect_to plugin_settings_path(@plugin)
else
@partial = @plugin.settings[:partial]
@settings = Setting.send "plugin_#{@plugin.id}"
@settings = Setting.send :"plugin_#{@plugin.id}"
end
rescue Redmine::PluginNotFound
render_404

View File

@@ -1503,7 +1503,7 @@ module ApplicationHelper
# Render the error messages for the given objects
def error_messages_for(*objects)
objects = objects.filter_map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}
objects = objects.filter_map {|o| o.is_a?(String) ? instance_variable_get(:"@#{o}") : o}
errors = objects.map {|o| o.errors.full_messages}.flatten
render_error_messages(errors)
end

View File

@@ -61,7 +61,7 @@ module MyHelper
return nil
end
else
send "render_#{block_definition[:name]}_block", block, settings
send :"render_#{block_definition[:name]}_block", block, settings
end
end

View File

@@ -86,7 +86,7 @@ class AuthSourceLdap < AuthSource
# Returns true if this source can be searched for users
def searchable?
!account.to_s.include?("$login") && %w(login firstname lastname mail).all? {|a| send("attr_#{a}?")}
!account.to_s.include?("$login") && %w(login firstname lastname mail).all? {|a| send(:"attr_#{a}?")}
end
# Searches the source for users and returns an array of results

View File

@@ -41,7 +41,7 @@ class Comment < ActiveRecord::Base
def send_notification
event = "#{commented.class.name.underscore}_comment_added"
if Setting.notified_events.include?(event)
Mailer.public_send("deliver_#{event}", self)
Mailer.public_send(:"deliver_#{event}", self)
end
end
end

View File

@@ -23,7 +23,7 @@ class CustomFieldValue
def initialize(attributes={})
attributes.each do |name, v|
send "#{name}=", v
send :"#{name}=", v
end
end

View File

@@ -184,7 +184,7 @@ class Import < ActiveRecord::Base
def do_callbacks(position, object)
if callbacks = (settings['callbacks'] || {}).delete(position)
callbacks.each do |name, args|
send "#{name}_callback", object, *args
send :"#{name}_callback", object, *args
end
save!
end

View File

@@ -472,7 +472,7 @@ class Issue < ActiveRecord::Base
%w(project project_id tracker tracker_id).each do |attr|
if attrs.has_key?(attr)
send "#{attr}=", attrs.delete(attr)
send :"#{attr}=", attrs.delete(attr)
end
end
super(attrs, *args)
@@ -2067,7 +2067,7 @@ class Issue < ActiveRecord::Base
def clear_disabled_fields
if tracker
tracker.disabled_core_fields.each do |attribute|
send "#{attribute}=", nil
send :"#{attribute}=", nil
end
self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first.id
self.done_ratio ||= 0

View File

@@ -578,7 +578,7 @@ class MailHandler < ActionMailer::Base
def self.assign_string_attribute_with_limit(object, attribute, value, limit=nil)
limit ||= object.class.columns_hash[attribute.to_s].limit || 255
value = value.to_s.slice(0, limit)
object.send("#{attribute}=", value)
object.send(:"#{attribute}=", value)
end
private_class_method :assign_string_attribute_with_limit

View File

@@ -944,7 +944,7 @@ class Project < ActiveRecord::Base
end
to_be_copied.each do |name|
send "copy_#{name}", project
send :"copy_#{name}", project
end
Redmine::Hook.call_hook(:model_project_copy_before_save,
:source_project => project,

View File

@@ -1110,7 +1110,7 @@ class Query < ActiveRecord::Base
custom_field = column.custom_field
send :total_for_custom_field, custom_field, scope
else
send "total_for_#{column.name}", scope
send :"total_for_#{column.name}", scope
end
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)

View File

@@ -169,7 +169,7 @@ class Setting < ActiveRecord::Base
/\s*,\s*/]
].each do |enable_regex, regex_field, delimiter|
if settings.key?(regex_field) || settings.key?(enable_regex)
regexp = Setting.send("#{enable_regex}?")
regexp = Setting.send(:"#{enable_regex}?")
if settings.key?(enable_regex)
regexp = settings[enable_regex].to_s != '0'
end

View File

@@ -73,7 +73,7 @@ module Redmine
transaction do
all.each do |object|
clear = object.send(attribute)
object.send "#{attribute}=", clear
object.send :"#{attribute}=", clear
raise(ActiveRecord::Rollback) unless object.save(validate: false)
end
end ? true : false

View File

@@ -66,7 +66,7 @@ module Redmine
"Please update your config/configuration.yml to use :#$1 delivery method instead."
end
v.symbolize_keys! if v.respond_to?(:symbolize_keys!)
ActionMailer::Base.send("#{k}=", v)
ActionMailer::Base.send(:"#{k}=", v)
end
end

View File

@@ -270,8 +270,8 @@ module Redmine
def render_object_row(object, options)
class_name = object.class.name.downcase
send("subject_for_#{class_name}", object, options) unless options[:only] == :lines || options[:only] == :selected_columns
send("line_for_#{class_name}", object, options) unless options[:only] == :subjects || options[:only] == :selected_columns
send(:"subject_for_#{class_name}", object, options) unless options[:only] == :lines || options[:only] == :selected_columns
send(:"line_for_#{class_name}", object, options) unless options[:only] == :subjects || options[:only] == :selected_columns
column_content_for_issue(object, options) if options[:only] == :selected_columns && options[:column].present? && object.is_a?(Issue)
options[:top] += options[:top_increment]
@number_of_rows += 1
@@ -361,14 +361,14 @@ module Redmine
end
def subject(label, options, object=nil)
send "#{options[:format]}_subject", options, label, object
send :"#{options[:format]}_subject", options, label, object
end
def line(start_date, end_date, done_ratio, markers, label, options, object=nil)
options[:zoom] ||= 1
options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
coords = coordinates(start_date, end_date, done_ratio, options[:zoom])
send "#{options[:format]}_task", options, coords, markers, label, object
send :"#{options[:format]}_task", options, coords, markers, label, object
end
# Generates a gantt image

View File

@@ -71,7 +71,7 @@ module Redmine
class_eval do
names.each do |name|
define_method(name) do |*args|
args.empty? ? instance_variable_get("@#{name}") : instance_variable_set("@#{name}", *args)
args.empty? ? instance_variable_get(:"@#{name}") : instance_variable_set(:"@#{name}", *args)
end
end
end

View File

@@ -255,7 +255,7 @@ class RedCloth3 < String
# #=>"<h1>A &lt;b&gt;bold&lt;/b&gt; man</h1>"
#
def initialize( string, restrictions = [] )
restrictions.each { |r| method( "#{r}=" ).call( true ) }
restrictions.each { |r| method( :"#{r}=" ).call( true ) }
super( string )
end
@@ -724,10 +724,10 @@ class RedCloth3 < String
# pass to prefix handler
replacement = nil
if respond_to? "textile_#{tag}", true
replacement = method( "textile_#{tag}" ).call( tag, atts, cite, content )
elsif respond_to? "textile_#{tagpre}_", true
replacement = method( "textile_#{tagpre}_" ).call( tagpre, num, atts, cite, content )
if respond_to? :"textile_#{tag}", true
replacement = method( :"textile_#{tag}" ).call( tag, atts, cite, content )
elsif respond_to? :"textile_#{tagpre}_", true
replacement = method( :"textile_#{tagpre}_" ).call( tagpre, num, atts, cite, content )
end
text.gsub!( $& ) { replacement } if replacement
end

View File

@@ -130,7 +130,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
assert_equal 'example1@redmine.org', attributes[:mail]
assert_equal auth.id, attributes[:auth_source_id]
attributes.each_key do |attribute|
assert User.new.respond_to?("#{attribute}="), "Unexpected :#{attribute} attribute returned"
assert User.new.respond_to?(:"#{attribute}="), "Unexpected :#{attribute} attribute returned"
end
end

View File

@@ -25,7 +25,7 @@ class Redmine::SafeAttributesTest < ActiveSupport::TestCase
class Base
def attributes=(attrs)
attrs.each do |key, value|
send("#{key}=", value)
send(:"#{key}=", value)
end
end
end