From 6a2d68f28a868d170f7ae4334046f21e704b14c8 Mon Sep 17 00:00:00 2001 From: KMY Date: Thu, 21 Dec 2023 10:42:45 +0900 Subject: [PATCH] Revert "Fix lint" This reverts commit a828efa9be3437ff15ff496258af3e1239571e6f. --- app/helpers/application_helper.rb | 2 +- app/models/account.rb | 4 ++-- app/models/concerns/remotable.rb | 16 ++++++++-------- app/models/form/admin_settings.rb | 14 +++++++------- spec/requests/omniauth_callbacks_spec.rb | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2a189ea602..e7fb1e1cdf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -110,7 +110,7 @@ module ApplicationHelper def can?(action, record) return false if record.nil? - policy(record).public_send(:"#{action}?") + policy(record).public_send("#{action}?") end def fa_icon(icon, attributes = {}) diff --git a/app/models/account.rb b/app/models/account.rb index 6702ff897d..0d4af2f909 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -496,8 +496,8 @@ class Account < ApplicationRecord end def inverse_alias(key, original_key) - define_method(:"#{key}=") do |value| - public_send(:"#{original_key}=", !ActiveModel::Type::Boolean.new.cast(value)) + define_method("#{key}=") do |value| + public_send("#{original_key}=", !ActiveModel::Type::Boolean.new.cast(value)) end define_method(key) do diff --git a/app/models/concerns/remotable.rb b/app/models/concerns/remotable.rb index 6118e204a1..bd8b6f4eb9 100644 --- a/app/models/concerns/remotable.rb +++ b/app/models/concerns/remotable.rb @@ -7,7 +7,7 @@ module Remotable def remotable_attachment(attachment_name, limit, suppress_errors: true, download_on_assign: true, attribute_name: nil) attribute_name ||= :"#{attachment_name}_remote_url" - define_method(:"download_#{attachment_name}!") do |url = nil| + define_method("download_#{attachment_name}!") do |url = nil| url ||= self[attribute_name] return if url.blank? @@ -24,29 +24,29 @@ module Remotable Request.new(:get, url).perform do |response| raise Mastodon::UnexpectedResponseError, response unless (200...300).cover?(response.code) - public_send(:"#{attachment_name}=", ResponseWithLimit.new(response, limit)) + public_send("#{attachment_name}=", ResponseWithLimit.new(response, limit)) end rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError => e Rails.logger.debug { "Error fetching remote #{attachment_name}: #{e}" } - public_send(:"#{attachment_name}=", nil) if public_send(:"#{attachment_name}_file_name").present? + public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present? raise e unless suppress_errors rescue Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Paperclip::Error, Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => e Rails.logger.debug { "Error fetching remote #{attachment_name}: #{e}" } - public_send(:"#{attachment_name}=", nil) if public_send(:"#{attachment_name}_file_name").present? + public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present? end nil end - define_method(:"#{attribute_name}=") do |url| - return if self[attribute_name] == url && public_send(:"#{attachment_name}_file_name").present? + define_method("#{attribute_name}=") do |url| + return if self[attribute_name] == url && public_send("#{attachment_name}_file_name").present? self[attribute_name] = url if has_attribute?(attribute_name) - public_send(:"download_#{attachment_name}!", url) if download_on_assign + public_send("download_#{attachment_name}!", url) if download_on_assign end - alias_method(:"reset_#{attachment_name}!", "download_#{attachment_name}!") + alias_method("reset_#{attachment_name}!", "download_#{attachment_name}!") end end end diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 55730a9361..d36586ccd0 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -118,7 +118,7 @@ class Form::AdminSettings KEYS.each do |key| define_method(key) do - return instance_variable_get(:"@#{key}") if instance_variable_defined?(:"@#{key}") + return instance_variable_get("@#{key}") if instance_variable_defined?("@#{key}") stored_value = if UPLOAD_KEYS.include?(key) SiteUpload.where(var: key).first_or_initialize(var: key) @@ -130,12 +130,12 @@ class Form::AdminSettings Setting.public_send(key) end - instance_variable_set(:"@#{key}", stored_value) + instance_variable_set("@#{key}", stored_value) end end UPLOAD_KEYS.each do |key| - define_method(:"#{key}=") do |file| + define_method("#{key}=") do |file| value = public_send(key) value.file = file rescue Mastodon::DimensionsValidationError => e @@ -150,13 +150,13 @@ class Form::AdminSettings return false unless errors.empty? && valid? KEYS.each do |key| - next unless instance_variable_defined?(:"@#{key}") + next unless instance_variable_defined?("@#{key}") if UPLOAD_KEYS.include?(key) public_send(key).save else setting = Setting.where(var: key).first_or_initialize(var: key) - setting.update(value: typecast_value(key, instance_variable_get(:"@#{key}"))) + setting.update(value: typecast_value(key, instance_variable_get("@#{key}"))) end end end @@ -177,9 +177,9 @@ class Form::AdminSettings def validate_site_uploads UPLOAD_KEYS.each do |key| - next unless instance_variable_defined?(:"@#{key}") + next unless instance_variable_defined?("@#{key}") - upload = instance_variable_get(:"@#{key}") + upload = instance_variable_get("@#{key}") next if upload.valid? upload.errors.each do |error| diff --git a/spec/requests/omniauth_callbacks_spec.rb b/spec/requests/omniauth_callbacks_spec.rb index 0d37c41140..27aa5ec506 100644 --- a/spec/requests/omniauth_callbacks_spec.rb +++ b/spec/requests/omniauth_callbacks_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' describe 'OmniAuth callbacks' do shared_examples 'omniauth provider callbacks' do |provider| - subject { post send :"user_#{provider}_omniauth_callback_path" } + subject { post send "user_#{provider}_omniauth_callback_path" } context 'with full information in response' do before do