Autofix Rubocop Style/RedundantBegin (#23703)
This commit is contained in:
parent
167709f6b0
commit
2177daeae9
69 changed files with 458 additions and 695 deletions
|
@ -4,13 +4,11 @@ class DomainValidator < ActiveModel::EachValidator
|
|||
def validate_each(record, attribute, value)
|
||||
return if value.blank?
|
||||
|
||||
domain = begin
|
||||
if options[:acct]
|
||||
value.split('@').last
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
domain = if options[:acct]
|
||||
value.split('@').last
|
||||
else
|
||||
value
|
||||
end
|
||||
|
||||
record.errors.add(attribute, I18n.t('domain_validator.invalid_domain')) unless compliant?(domain)
|
||||
end
|
||||
|
|
|
@ -4,16 +4,14 @@ class ExistingUsernameValidator < ActiveModel::EachValidator
|
|||
def validate_each(record, attribute, value)
|
||||
return if value.blank?
|
||||
|
||||
usernames_and_domains = begin
|
||||
value.split(',').map do |str|
|
||||
username, domain = str.strip.gsub(/\A@/, '').split('@', 2)
|
||||
domain = nil if TagManager.instance.local_domain?(domain)
|
||||
usernames_and_domains = value.split(',').map do |str|
|
||||
username, domain = str.strip.gsub(/\A@/, '').split('@', 2)
|
||||
domain = nil if TagManager.instance.local_domain?(domain)
|
||||
|
||||
next if username.blank?
|
||||
next if username.blank?
|
||||
|
||||
[str, username, domain]
|
||||
end.compact
|
||||
end
|
||||
[str, username, domain]
|
||||
end.compact
|
||||
|
||||
usernames_with_no_accounts = usernames_and_domains.filter_map do |(str, username, domain)|
|
||||
str unless Account.find_remote(username, domain)
|
||||
|
|
|
@ -35,13 +35,11 @@ class ImportValidator < ActiveModel::Validator
|
|||
def validate_following_import(import, row_count)
|
||||
base_limit = FollowLimitValidator.limit_for_account(import.account)
|
||||
|
||||
limit = begin
|
||||
if import.overwrite?
|
||||
base_limit
|
||||
else
|
||||
base_limit - import.account.following_count
|
||||
end
|
||||
end
|
||||
limit = if import.overwrite?
|
||||
base_limit
|
||||
else
|
||||
base_limit - import.account.following_count
|
||||
end
|
||||
|
||||
import.errors.add(:data, I18n.t('users.follow_limit_reached', limit: base_limit)) if row_count > limit
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue