mirror of
https://github.com/funamitech/mastodon
synced 2024-11-23 22:57:05 +09:00
Apply Rubocop Performance/BlockGivenWithExplicitBlock (#23441)
* Apply Rubocop Performance/BlockGivenWithExplicitBlock * Unprefix used block parameter
This commit is contained in:
parent
26ac2447b4
commit
0d1f192c54
@ -67,7 +67,7 @@ module ApplicationHelper
|
|||||||
def link_to_login(name = nil, html_options = nil, &block)
|
def link_to_login(name = nil, html_options = nil, &block)
|
||||||
target = new_user_session_path
|
target = new_user_session_path
|
||||||
|
|
||||||
html_options = name if block_given?
|
html_options = name if block
|
||||||
|
|
||||||
if omniauth_only? && Devise.mappings[:user].omniauthable? && User.omniauth_providers.size == 1
|
if omniauth_only? && Devise.mappings[:user].omniauthable? && User.omniauth_providers.size == 1
|
||||||
target = omniauth_authorize_path(:user, User.omniauth_providers[0])
|
target = omniauth_authorize_path(:user, User.omniauth_providers[0])
|
||||||
@ -75,7 +75,7 @@ module ApplicationHelper
|
|||||||
html_options[:method] = :post
|
html_options[:method] = :post
|
||||||
end
|
end
|
||||||
|
|
||||||
if block_given?
|
if block
|
||||||
link_to(target, html_options, &block)
|
link_to(target, html_options, &block)
|
||||||
else
|
else
|
||||||
link_to(name, target, html_options)
|
link_to(name, target, html_options)
|
||||||
|
@ -213,7 +213,7 @@ module JsonLdHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_jsonld_context(url, _options = {}, &_block)
|
def load_jsonld_context(url, _options = {}, &block)
|
||||||
json = Rails.cache.fetch("jsonld:context:#{url}", expires_in: 30.days, raw: true) do
|
json = Rails.cache.fetch("jsonld:context:#{url}", expires_in: 30.days, raw: true) do
|
||||||
request = Request.new(:get, url)
|
request = Request.new(:get, url)
|
||||||
request.add_headers('Accept' => 'application/ld+json')
|
request.add_headers('Accept' => 'application/ld+json')
|
||||||
@ -226,6 +226,6 @@ module JsonLdHelper
|
|||||||
|
|
||||||
doc = JSON::LD::API::RemoteDocument.new(json, documentUrl: url)
|
doc = JSON::LD::API::RemoteDocument.new(json, documentUrl: url)
|
||||||
|
|
||||||
block_given? ? yield(doc) : doc
|
block ? yield(doc) : doc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ module Extractor
|
|||||||
return [] if entities.empty?
|
return [] if entities.empty?
|
||||||
|
|
||||||
entities = remove_overlapping_entities(entities)
|
entities = remove_overlapping_entities(entities)
|
||||||
entities.each(&block) if block_given?
|
entities.each(&block) if block
|
||||||
entities
|
entities
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class Trends::History
|
|||||||
end
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each(&block)
|
||||||
if block_given?
|
if block
|
||||||
(0...7).map { |i| yield(get(i.days.ago)) }
|
(0...7).map { |i| yield(get(i.days.ago)) }
|
||||||
else
|
else
|
||||||
to_enum(:each)
|
to_enum(:each)
|
||||||
|
Loading…
Reference in New Issue
Block a user