Skip to content

Commit

Permalink
Revert "Fix lint"
Browse files Browse the repository at this point in the history
This reverts commit a828efa.
  • Loading branch information
kmycode committed Dec 21, 2023
1 parent a21c0b9 commit 6a2d68f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def class_for_scope(scope)
def can?(action, record)
return false if record.nil?

policy(record).public_send(:"#{action}?")
policy(record).public_send("#{action}?")

Check failure on line 113 in app/helpers/application_helper.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{action}?" instead of "#{action}?".

Check failure on line 113 in app/helpers/application_helper.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{action}?" instead of "#{action}?".
end

def fa_icon(icon, attributes = {})
Expand Down
4 changes: 2 additions & 2 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ def from_text(text)
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|

Check failure on line 499 in app/models/account.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{key}=" instead of "#{key}=".

Check failure on line 499 in app/models/account.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{key}=" instead of "#{key}=".
public_send("#{original_key}=", !ActiveModel::Type::Boolean.new.cast(value))

Check failure on line 500 in app/models/account.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{original_key}=" instead of "#{original_key}=".

Check failure on line 500 in app/models/account.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{original_key}=" instead of "#{original_key}=".
end

define_method(key) do
Expand Down
16 changes: 8 additions & 8 deletions app/models/concerns/remotable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|

Check failure on line 10 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"download_#{attachment_name}!" instead of "download_#{attachment_name}!".

Check failure on line 10 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"download_#{attachment_name}!" instead of "download_#{attachment_name}!".
url ||= self[attribute_name]

return if url.blank?
Expand All @@ -24,29 +24,29 @@ def remotable_attachment(attachment_name, limit, suppress_errors: true, download
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))

Check failure on line 27 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}=" instead of "#{attachment_name}=".

Check failure on line 27 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}=" instead of "#{attachment_name}=".
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?

Check failure on line 31 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}=" instead of "#{attachment_name}=".

Check failure on line 31 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}_file_name" instead of "#{attachment_name}_file_name".

Check failure on line 31 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}=" instead of "#{attachment_name}=".

Check failure on line 31 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}_file_name" instead of "#{attachment_name}_file_name".
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?

Check failure on line 35 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}=" instead of "#{attachment_name}=".

Check failure on line 35 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}_file_name" instead of "#{attachment_name}_file_name".

Check failure on line 35 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}=" instead of "#{attachment_name}=".

Check failure on line 35 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attachment_name}_file_name" instead of "#{attachment_name}_file_name".
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|

Check failure on line 41 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attribute_name}=" instead of "#{attribute_name}=".

Check failure on line 41 in app/models/concerns/remotable.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/StringIdentifierArgument: Use :"#{attribute_name}=" instead of "#{attribute_name}=".
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
14 changes: 7 additions & 7 deletions app/models/form/admin_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -150,13 +150,13 @@ def save
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
Expand All @@ -177,9 +177,9 @@ def typecast_value(key, value)

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|
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/omniauth_callbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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
Expand Down

0 comments on commit 6a2d68f

Please sign in to comment.