mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 06:15:59 +01:00
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:
@@ -70,12 +70,12 @@ class SettingsController < ApplicationController
|
|||||||
|
|
||||||
if request.post?
|
if request.post?
|
||||||
setting = params[:settings] ? params[:settings].permit!.to_h : {}
|
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)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to plugin_settings_path(@plugin)
|
redirect_to plugin_settings_path(@plugin)
|
||||||
else
|
else
|
||||||
@partial = @plugin.settings[:partial]
|
@partial = @plugin.settings[:partial]
|
||||||
@settings = Setting.send "plugin_#{@plugin.id}"
|
@settings = Setting.send :"plugin_#{@plugin.id}"
|
||||||
end
|
end
|
||||||
rescue Redmine::PluginNotFound
|
rescue Redmine::PluginNotFound
|
||||||
render_404
|
render_404
|
||||||
|
|||||||
@@ -1503,7 +1503,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
# Render the error messages for the given objects
|
# Render the error messages for the given objects
|
||||||
def error_messages_for(*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
|
errors = objects.map {|o| o.errors.full_messages}.flatten
|
||||||
render_error_messages(errors)
|
render_error_messages(errors)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ module MyHelper
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
send "render_#{block_definition[:name]}_block", block, settings
|
send :"render_#{block_definition[:name]}_block", block, settings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class AuthSourceLdap < AuthSource
|
|||||||
|
|
||||||
# Returns true if this source can be searched for users
|
# Returns true if this source can be searched for users
|
||||||
def searchable?
|
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
|
end
|
||||||
|
|
||||||
# Searches the source for users and returns an array of results
|
# Searches the source for users and returns an array of results
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Comment < ActiveRecord::Base
|
|||||||
def send_notification
|
def send_notification
|
||||||
event = "#{commented.class.name.underscore}_comment_added"
|
event = "#{commented.class.name.underscore}_comment_added"
|
||||||
if Setting.notified_events.include?(event)
|
if Setting.notified_events.include?(event)
|
||||||
Mailer.public_send("deliver_#{event}", self)
|
Mailer.public_send(:"deliver_#{event}", self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class CustomFieldValue
|
|||||||
|
|
||||||
def initialize(attributes={})
|
def initialize(attributes={})
|
||||||
attributes.each do |name, v|
|
attributes.each do |name, v|
|
||||||
send "#{name}=", v
|
send :"#{name}=", v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class Import < ActiveRecord::Base
|
|||||||
def do_callbacks(position, object)
|
def do_callbacks(position, object)
|
||||||
if callbacks = (settings['callbacks'] || {}).delete(position)
|
if callbacks = (settings['callbacks'] || {}).delete(position)
|
||||||
callbacks.each do |name, args|
|
callbacks.each do |name, args|
|
||||||
send "#{name}_callback", object, *args
|
send :"#{name}_callback", object, *args
|
||||||
end
|
end
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
%w(project project_id tracker tracker_id).each do |attr|
|
%w(project project_id tracker tracker_id).each do |attr|
|
||||||
if attrs.has_key?(attr)
|
if attrs.has_key?(attr)
|
||||||
send "#{attr}=", attrs.delete(attr)
|
send :"#{attr}=", attrs.delete(attr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
super(attrs, *args)
|
super(attrs, *args)
|
||||||
@@ -2067,7 +2067,7 @@ class Issue < ActiveRecord::Base
|
|||||||
def clear_disabled_fields
|
def clear_disabled_fields
|
||||||
if tracker
|
if tracker
|
||||||
tracker.disabled_core_fields.each do |attribute|
|
tracker.disabled_core_fields.each do |attribute|
|
||||||
send "#{attribute}=", nil
|
send :"#{attribute}=", nil
|
||||||
end
|
end
|
||||||
self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first.id
|
self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first.id
|
||||||
self.done_ratio ||= 0
|
self.done_ratio ||= 0
|
||||||
|
|||||||
@@ -578,7 +578,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
def self.assign_string_attribute_with_limit(object, attribute, value, limit=nil)
|
def self.assign_string_attribute_with_limit(object, attribute, value, limit=nil)
|
||||||
limit ||= object.class.columns_hash[attribute.to_s].limit || 255
|
limit ||= object.class.columns_hash[attribute.to_s].limit || 255
|
||||||
value = value.to_s.slice(0, limit)
|
value = value.to_s.slice(0, limit)
|
||||||
object.send("#{attribute}=", value)
|
object.send(:"#{attribute}=", value)
|
||||||
end
|
end
|
||||||
private_class_method :assign_string_attribute_with_limit
|
private_class_method :assign_string_attribute_with_limit
|
||||||
|
|
||||||
|
|||||||
@@ -944,7 +944,7 @@ class Project < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
to_be_copied.each do |name|
|
to_be_copied.each do |name|
|
||||||
send "copy_#{name}", project
|
send :"copy_#{name}", project
|
||||||
end
|
end
|
||||||
Redmine::Hook.call_hook(:model_project_copy_before_save,
|
Redmine::Hook.call_hook(:model_project_copy_before_save,
|
||||||
:source_project => project,
|
:source_project => project,
|
||||||
|
|||||||
@@ -1110,7 +1110,7 @@ class Query < ActiveRecord::Base
|
|||||||
custom_field = column.custom_field
|
custom_field = column.custom_field
|
||||||
send :total_for_custom_field, custom_field, scope
|
send :total_for_custom_field, custom_field, scope
|
||||||
else
|
else
|
||||||
send "total_for_#{column.name}", scope
|
send :"total_for_#{column.name}", scope
|
||||||
end
|
end
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class Setting < ActiveRecord::Base
|
|||||||
/\s*,\s*/]
|
/\s*,\s*/]
|
||||||
].each do |enable_regex, regex_field, delimiter|
|
].each do |enable_regex, regex_field, delimiter|
|
||||||
if settings.key?(regex_field) || settings.key?(enable_regex)
|
if settings.key?(regex_field) || settings.key?(enable_regex)
|
||||||
regexp = Setting.send("#{enable_regex}?")
|
regexp = Setting.send(:"#{enable_regex}?")
|
||||||
if settings.key?(enable_regex)
|
if settings.key?(enable_regex)
|
||||||
regexp = settings[enable_regex].to_s != '0'
|
regexp = settings[enable_regex].to_s != '0'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ module Redmine
|
|||||||
transaction do
|
transaction do
|
||||||
all.each do |object|
|
all.each do |object|
|
||||||
clear = object.send(attribute)
|
clear = object.send(attribute)
|
||||||
object.send "#{attribute}=", clear
|
object.send :"#{attribute}=", clear
|
||||||
raise(ActiveRecord::Rollback) unless object.save(validate: false)
|
raise(ActiveRecord::Rollback) unless object.save(validate: false)
|
||||||
end
|
end
|
||||||
end ? true : false
|
end ? true : false
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ module Redmine
|
|||||||
"Please update your config/configuration.yml to use :#$1 delivery method instead."
|
"Please update your config/configuration.yml to use :#$1 delivery method instead."
|
||||||
end
|
end
|
||||||
v.symbolize_keys! if v.respond_to?(:symbolize_keys!)
|
v.symbolize_keys! if v.respond_to?(:symbolize_keys!)
|
||||||
ActionMailer::Base.send("#{k}=", v)
|
ActionMailer::Base.send(:"#{k}=", v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -270,8 +270,8 @@ module Redmine
|
|||||||
|
|
||||||
def render_object_row(object, options)
|
def render_object_row(object, options)
|
||||||
class_name = object.class.name.downcase
|
class_name = object.class.name.downcase
|
||||||
send("subject_for_#{class_name}", object, options) unless options[:only] == :lines || 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
|
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)
|
column_content_for_issue(object, options) if options[:only] == :selected_columns && options[:column].present? && object.is_a?(Issue)
|
||||||
options[:top] += options[:top_increment]
|
options[:top] += options[:top_increment]
|
||||||
@number_of_rows += 1
|
@number_of_rows += 1
|
||||||
@@ -361,14 +361,14 @@ module Redmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def subject(label, options, object=nil)
|
def subject(label, options, object=nil)
|
||||||
send "#{options[:format]}_subject", options, label, object
|
send :"#{options[:format]}_subject", options, label, object
|
||||||
end
|
end
|
||||||
|
|
||||||
def line(start_date, end_date, done_ratio, markers, label, options, object=nil)
|
def line(start_date, end_date, done_ratio, markers, label, options, object=nil)
|
||||||
options[:zoom] ||= 1
|
options[:zoom] ||= 1
|
||||||
options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
|
options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
|
||||||
coords = coordinates(start_date, end_date, done_ratio, 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
|
end
|
||||||
|
|
||||||
# Generates a gantt image
|
# Generates a gantt image
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ module Redmine
|
|||||||
class_eval do
|
class_eval do
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
define_method(name) do |*args|
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class RedCloth3 < String
|
|||||||
# #=>"<h1>A <b>bold</b> man</h1>"
|
# #=>"<h1>A <b>bold</b> man</h1>"
|
||||||
#
|
#
|
||||||
def initialize( string, restrictions = [] )
|
def initialize( string, restrictions = [] )
|
||||||
restrictions.each { |r| method( "#{r}=" ).call( true ) }
|
restrictions.each { |r| method( :"#{r}=" ).call( true ) }
|
||||||
super( string )
|
super( string )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -724,10 +724,10 @@ class RedCloth3 < String
|
|||||||
|
|
||||||
# pass to prefix handler
|
# pass to prefix handler
|
||||||
replacement = nil
|
replacement = nil
|
||||||
if respond_to? "textile_#{tag}", true
|
if respond_to? :"textile_#{tag}", true
|
||||||
replacement = method( "textile_#{tag}" ).call( tag, atts, cite, content )
|
replacement = method( :"textile_#{tag}" ).call( tag, atts, cite, content )
|
||||||
elsif respond_to? "textile_#{tagpre}_", true
|
elsif respond_to? :"textile_#{tagpre}_", true
|
||||||
replacement = method( "textile_#{tagpre}_" ).call( tagpre, num, atts, cite, content )
|
replacement = method( :"textile_#{tagpre}_" ).call( tagpre, num, atts, cite, content )
|
||||||
end
|
end
|
||||||
text.gsub!( $& ) { replacement } if replacement
|
text.gsub!( $& ) { replacement } if replacement
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||||||
assert_equal 'example1@redmine.org', attributes[:mail]
|
assert_equal 'example1@redmine.org', attributes[:mail]
|
||||||
assert_equal auth.id, attributes[:auth_source_id]
|
assert_equal auth.id, attributes[:auth_source_id]
|
||||||
attributes.each_key do |attribute|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Redmine::SafeAttributesTest < ActiveSupport::TestCase
|
|||||||
class Base
|
class Base
|
||||||
def attributes=(attrs)
|
def attributes=(attrs)
|
||||||
attrs.each do |key, value|
|
attrs.each do |key, value|
|
||||||
send("#{key}=", value)
|
send(:"#{key}=", value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user