commit: 3e90987c8b0c620b6fc104350b8eb16d17d7e80a
parent: 2151fd315023a7f6849c6c9a519cd01deac09aa1
Author: Eugen Rochko <eugen@zeonfederated.com>
Date: Fri, 17 Nov 2017 02:06:26 +0100
Fix some rubocop style issues (#5730)
Diffstat:
7 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
@@ -104,7 +104,7 @@ class ApplicationController < ActionController::Base
unless uncached_ids.empty?
uncached = klass.where(id: uncached_ids).with_includes.map { |item| [item.id, item] }.to_h
- uncached.values.each do |item|
+ uncached.each_value do |item|
Rails.cache.write(item.cache_key, item)
end
end
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb
@@ -62,7 +62,7 @@ class Auth::SessionsController < Devise::SessionsController
if user_params[:otp_attempt].present? && session[:otp_user_id]
authenticate_with_two_factor_via_otp(user)
- elsif user && user.valid_password?(user_params[:password])
+ elsif user&.valid_password?(user_params[:password])
prompt_for_two_factor(user)
end
end
diff --git a/app/helpers/admin/filter_helper.rb b/app/helpers/admin/filter_helper.rb
@@ -18,7 +18,7 @@ module Admin::FilterHelper
def selected?(more_params)
new_url = filtered_url_for(more_params)
- filter_link_class(new_url) == 'selected' ? true : false
+ filter_link_class(new_url) == 'selected'
end
private
diff --git a/app/lib/extractor.rb b/app/lib/extractor.rb
@@ -5,7 +5,8 @@ module Extractor
module_function
- def extract_mentions_or_lists_with_indices(text) # :yields: username, list_slug, start, end
+ # :yields: username, list_slug, start, end
+ def extract_mentions_or_lists_with_indices(text)
return [] unless text =~ Twitter::Regex[:at_signs]
possible_entries = []
diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb
@@ -24,12 +24,12 @@ class Web::PushSubscription < ApplicationRecord
end
def pushable?(notification)
- data && data.key?('alerts') && data['alerts'][notification.type.to_s]
+ data&.key?('alerts') && data['alerts'][notification.type.to_s]
end
def as_payload
payload = { id: id, endpoint: endpoint }
- payload[:alerts] = data['alerts'] if data && data.key?('alerts')
+ payload[:alerts] = data['alerts'] if data&.key?('alerts')
payload
end
diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb
@@ -26,7 +26,7 @@ class BatchedRemoveStatusService < BaseService
statuses.each(&:destroy)
# Batch by source account
- statuses.group_by(&:account_id).each do |_, account_statuses|
+ statuses.group_by(&:account_id).each_value do |account_statuses|
account = account_statuses.first.account
unpush_from_home_timelines(account, account_statuses)
diff --git a/app/services/resolve_remote_account_service.rb b/app/services/resolve_remote_account_service.rb
@@ -124,11 +124,11 @@ class ResolveRemoteAccountService < BaseService
end
def auto_suspend?
- domain_block && domain_block.suspend?
+ domain_block&.suspend?
end
def auto_silence?
- domain_block && domain_block.silence?
+ domain_block&.silence?
end
def domain_block