DEV: move send => public_send in lib folder

DEV: move send => public_send in lib folder

This handles most of the cases in lib where we were using send instead of public_send

diff --git a/lib/auth/auth_provider.rb b/lib/auth/auth_provider.rb
index d8705cc..853d2fb 100644
--- a/lib/auth/auth_provider.rb
+++ b/lib/auth/auth_provider.rb
@@ -2,7 +2,7 @@ class Auth::AuthProvider
   include ActiveModel::Serialization
 
   def initialize(params = {})
-    params.each { |key, value| send "#{key}=", value }
+    params.each { |key, value| public_send "#{key}=", value }
   end
 
   def self.auth_attributes
diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rb
index 7e296a4..50d80e9 100644
--- a/lib/composer_messages_finder.rb
+++ b/lib/composer_messages_finder.rb
@@ -14,7 +14,7 @@ class ComposerMessagesFinder
     return if editing_post?
 
     self.class.check_methods.each do |m|
-      msg = send(m)
+      msg = public_send(m)
       return msg if msg.present?
     end
 
diff --git a/lib/freedom_patches/inflector_backport.rb b/lib/freedom_patches/inflector_backport.rb
index cc97659..66c60e5 100644
--- a/lib/freedom_patches/inflector_backport.rb
+++ b/lib/freedom_patches/inflector_backport.rb
@@ -25,7 +25,7 @@ module ActiveSupport
           found = true
           data = cache.fetch(arguments) { found = false }
           unless found
-            cache[arguments] = data = send(uncached, *arguments)
+            cache[arguments] = data = public_send(uncached, *arguments)
           end
           # so cache is never corrupted
           data.dup
@@ -48,7 +48,7 @@ module ActiveSupport
 
           define_method(method_name) do |*arguments|
             ActiveSupport::Inflector.clear_memoize!
-            send(orig, *arguments)
+            public_send(orig, *arguments)
           end
         end
       end
diff --git a/lib/guardian.rb b/lib/guardian.rb
index 7bbb3bd..3d62e18 100644
--- a/lib/guardian.rb
+++ b/lib/guardian.rb
@@ -118,7 +118,7 @@ class Guardian
   def can_see?(obj)
     if obj
       see_method = method_name_for :see, obj
-      return (see_method ? send(see_method, obj) : true)
+      return (see_method ? public_send(see_method, obj) : true)
     end
   end
 
@@ -137,7 +137,7 @@ class Guardian
     end
     create_method = :"can_create_#{target}?"
 
-    return send(create_method, parent) if respond_to?(create_method)
+    return public_send(create_method, parent) if respond_to?(create_method)
 
     true
   end
@@ -479,7 +479,7 @@ class Guardian
   def can_do?(action, obj)
     if obj && authenticated?
       action_method = method_name_for action, obj
-      return (action_method ? send(action_method, obj) : true)
+      return (action_method ? public_send(action_method, obj) : true)
     else
       false
     end
diff --git a/lib/promotion.rb b/lib/promotion.rb
index c10f2bb..8e070b5 100644
--- a/lib/promotion.rb
+++ b/lib/promotion.rb
@@ -17,7 +17,7 @@ class Promotion
     return false if @user.trust_level >= TrustLevel[2]
 
     review_method = :"review_tl#{@user.trust_level}"
-    return send(review_method) if respond_to?(review_method)
+    return public_send(review_method) if respond_to?(review_method)
 
     false
   end
diff --git a/lib/rate_limiter/on_create_record.rb b/lib/rate_limiter/on_create_record.rb
index 3a8483c..c4689ad 100644
--- a/lib/rate_limiter/on_create_record.rb
+++ b/lib/rate_limiter/on_create_record.rb
@@ -38,7 +38,7 @@ class RateLimiter
         self.after_create do |*args|
           next if @rate_limits_disabled
 
-          if rate_limiter = send(limiter_method)
+          if rate_limiter = public_send(limiter_method)
             rate_limiter.performed!
             @performed ||= {}
             @performed[limiter_method] = true
@@ -47,14 +47,14 @@ class RateLimiter
 
         self.after_destroy do
           next if @rate_limits_disabled
-          if rate_limiter = send(limiter_method)
+          if rate_limiter = public_send(limiter_method)
             rate_limiter.rollback!
           end
         end
 
         self.after_rollback do
           next if @rate_limits_disabled
-          if rate_limiter = send(limiter_method)
+          if rate_limiter = public_send(limiter_method)
             if @performed.present? && @performed[limiter_method]
               rate_limiter.rollback!
               @performed[limiter_method] = false
diff --git a/lib/search.rb b/lib/search.rb
index fbc1e8c..db25ecd 100644
--- a/lib/search.rb
+++ b/lib/search.rb
@@ -612,6 +612,7 @@ class Search
   def find_grouped_results
     if @results.type_filter.present?
       raise Discourse::InvalidAccess.new("invalid type filter") unless Search.facets.include?(@results.type_filter)
+      # calling protected methods
       send("#{@results.type_filter}_search")
     else
       unless @search_context
diff --git a/lib/search/grouped_search_results.rb b/lib/search/grouped_search_results.rb
index 1f32eaa..055682a 100644
--- a/lib/search/grouped_search_results.rb
+++ b/lib/search/grouped_search_results.rb
@@ -55,9 +55,9 @@ class Search
     def add(object)
       type = object.class.to_s.downcase.pluralize
 
-      if @type_filter.present? && send(type).length == Search.per_filter
+      if @type_filter.present? && public_send(type).length == Search.per_filter
         @more_full_page_results = true
-      elsif !@type_filter.present? && send(type).length == Search.per_facet
+      elsif !@type_filter.present? && public_send(type).length == Search.per_facet
         instance_variable_set("@more_#{type}".to_sym, true)
       else
         (self.public_send(type)) << object
diff --git a/lib/single_sign_on.rb b/lib/single_sign_on.rb
index fd5b83e..359006c 100644
--- a/lib/single_sign_on.rb
+++ b/lib/single_sign_on.rb
@@ -64,8 +64,6 @@ class SingleSignOn
     decoded = Base64.decode64(parsed["sso"])
     decoded_hash = Rack::Utils.parse_query(decoded)
 
-    return_sso_url = decoded_hash['return_sso_url']
-
     if sso.sign(parsed["sso"]) != parsed["sig"]
       diags = "\n\nsso: #{parsed["sso"]}\n\nsig: #{parsed["sig"]}\n\nexpected sig: #{sso.sign(parsed["sso"])}"
       if parsed["sso"] =~ /[^a-zA-Z0-9=\r\n\/+]/m
@@ -94,7 +92,7 @@ class SingleSignOn
   end
 
   def diagnostics
-    SingleSignOn::ACCESSORS.map { |a| "#{a}: #{send(a)}" }.join("\n")
+    SingleSignOn::ACCESSORS.map { |a| "#{a}: #{public_send(a)}" }.join("\n")
   end
 
   def sso_secret
diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb
index 80332cc..59dc8b7 100644
--- a/lib/site_setting_extension.rb
+++ b/lib/site_setting_extension.rb
@@ -13,6 +13,7 @@ module SiteSettingExtension
   # for site locale
   def self.extended(klass)
     if GlobalSetting.respond_to?(:default_locale) && GlobalSetting.default_locale.present?
+      # protected
       klass.send :setup_shadowed_methods, :default_locale, GlobalSetting.default_locale
     end
   end
diff --git a/lib/site_settings/type_supervisor.rb b/lib/site_settings/type_supervisor.rb
index da210d8..29fda70 100644
--- a/lib/site_settings/type_supervisor.rb
+++ b/lib/site_settings/type_supervisor.rb
@@ -219,7 +219,7 @@ class SiteSettings::TypeSupervisor
 
     validate_method = "validate_#{name}"
     if self.respond_to? validate_method
-      send(validate_method, val)
+      public_send(validate_method, val)
     end
   end
 
diff --git a/lib/sql_builder.rb b/lib/sql_builder.rb
index d43da3d..fdf0a85 100644
--- a/lib/sql_builder.rb
+++ b/lib/sql_builder.rb
@@ -110,7 +110,7 @@ class SqlBuilder
     values.map! do |row|
       mapped = klass.new
       setters.each_with_index do |name, index|
-        mapped.send name, row[index]
+        mapped.public_send name, row[index]
       end
       mapped
     end
diff --git a/lib/topics_bulk_action.rb b/lib/topics_bulk_action.rb
index 4b26187..0db1bb1 100644
--- a/lib/topics_bulk_action.rb
+++ b/lib/topics_bulk_action.rb
@@ -21,6 +21,7 @@ class TopicsBulkAction
 
   def perform!
     raise Discourse::InvalidParameters.new(:operation) unless TopicsBulkAction.operations.include?(@operation[:type])
+    # careful these are private methods, we need send
     send(@operation[:type])
     @changed_ids
   end

GitHub sha: e2bcf550