]> source.dussan.org Git - redmine.git/commitdiff
Fix RuboCop offense Performance/StringIdentifierArgument (#39888).
authorGo MAEDA <maeda@farend.jp>
Wed, 20 Dec 2023 09:23:05 +0000 (09:23 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 20 Dec 2023 09:23:05 +0000 (09:23 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22535 e93f8b46-1217-0410-a6f0-8f06a7374b81

19 files changed:
app/controllers/settings_controller.rb
app/helpers/application_helper.rb
app/helpers/my_helper.rb
app/models/auth_source_ldap.rb
app/models/comment.rb
app/models/custom_field_value.rb
app/models/import.rb
app/models/issue.rb
app/models/mail_handler.rb
app/models/project.rb
app/models/query.rb
app/models/setting.rb
lib/redmine/ciphering.rb
lib/redmine/configuration.rb
lib/redmine/helpers/gantt.rb
lib/redmine/plugin.rb
lib/redmine/wiki_formatting/textile/redcloth3.rb
test/unit/auth_source_ldap_test.rb
test/unit/lib/redmine/safe_attributes_test.rb

index 9a595f3f23bcb4941ae274696fe99b6b851cc75b..9fb08d651176854f27264927c7bd99a870eb914c 100644 (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
index e1b22eb755517eef4f0c3af14b2d1683d26f9b3a..148d07b3edd7127a6b4c8c744bf6a8f83b2c912d 100644 (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
index b7151f999ed4417804d79d08f4cd8806d9d95c3e..1abecce96a9498cd274573a47f6f3b6c1059a18e 100644 (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
 
index a2d43b7f70634e81eb16f743b06b48583f89f79f..9cafd9b0ef7f9707fb14869e3a55fabf83637ff9 100644 (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
index 0954bd707794d8028e4f28308967f720104631c2..525a3a4ab3b364fd53fdcbdc9883c76004946907 100644 (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
index ee154af2c3801bebdccfab9ea197fe5ff14d7707..88fadf28062500ca3680eda0629e09dbcc954cdd 100644 (file)
@@ -23,7 +23,7 @@ class CustomFieldValue
 
   def initialize(attributes={})
     attributes.each do |name, v|
-      send "#{name}=", v
+      send :"#{name}=", v
     end
   end
 
index 2674606bb5ed94699a85c39440a5b6a5a2f5b73b..8fcb769d3f8e3b8bb83699b2bafe74b1d4408479 100644 (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
index ac0786d335514435aed64c871dc1bfbb7039aa1c..120bddd9b3a7bfc57e47c64e417b1b1836fd3d25 100644 (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
index ecedd2ccfc03b34a61a5819c8f377d00464ad041..b1f8d304aae88c1819b80ba18a37039a81dfc451 100644 (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
 
index 1bf5f913c38744454c62f64ed9dd55c230392701..082e83f55b14852660f0fba39ad2a8b602534b75 100644 (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,
index f0c29ea98d509641019e0e7a52c8420a077051d0..31ffe6a13d4a5764167baf9b5a05674c121055fe 100644 (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)
index a44f92ce31f35846046443a8e02d2058bfc577fc..8ee5b1f502f103ada833e0cd45da6f1eb0ae4e76 100644 (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
index 2806ae14da346b099e1fde36954fddbaece99269..f3397446fd0443a5453dad78e66315e28da20d58 100644 (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
index 3e604cab3a6f46676e8aa2a4d7f3b59ca6a54f8b..43506836f55367a78b210a4388b60e89c90450df 100644 (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
 
index b33fc3223c68b774f86c5afdf663b215d0ba860c..a7b0d715dd91a7024d28396270e85893a8da9b13 100644 (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
index 0fb762de94d4a4c224c13a6568fb065e5473828a..8107a5a39244f571c91d00cf814b0d5668562f3a 100644 (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
index e319d90dbe5af526b8e663425df5c887b698bfbe..f545bdf91a57615d50b871952149efce6c9a397d 100644 (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
index 1dbdb3b73280689e45997f6bfa5c69d8aae9bc65..97b11f53fd00867c5b05be1fe965b6786746ec72 100644 (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
 
index 4f031b816d1da3e72b84d7b2398096074164a1cc..99059f326778e62dcea10237a34b86e2824b4f41 100644 (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