Fix Style/ExplicitBlockArgument warnings

This commit is contained in:
Tom Hughes 2020-08-09 18:45:01 +01:00
parent 2651db7254
commit 75e135869e
5 changed files with 12 additions and 33 deletions

View file

@ -189,15 +189,6 @@ Rails/OutputSafety:
Rails/TimeZone:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
Style/ExplicitBlockArgument:
Exclude:
- 'app/controllers/api/amf_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/mailers/notifier.rb'
- 'test/integration/client_applications_test.rb'
# Offense count: 572
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.

View file

@ -128,11 +128,9 @@ module Api
[-2, "An unusual error happened (in #{call}). The server said: #{e}"]
end
def amf_handle_error_with_timeout(call, rootobj, rootid)
def amf_handle_error_with_timeout(call, rootobj, rootid, &block)
amf_handle_error(call, rootobj, rootid) do
OSM::Timer.timeout(Settings.api_timeout, OSM::APITimeoutError) do
yield
end
OSM::Timer.timeout(Settings.api_timeout, OSM::APITimeoutError, &block)
end
end

View file

@ -222,20 +222,16 @@ class ApplicationController < ActionController::Base
##
# wrap an api call in a timeout
def api_call_timeout
OSM::Timer.timeout(Settings.api_timeout, Timeout::Error) do
yield
end
def api_call_timeout(&block)
OSM::Timer.timeout(Settings.api_timeout, Timeout::Error, &block)
rescue Timeout::Error
raise OSM::APITimeoutError
end
##
# wrap a web page in a timeout
def web_timeout
OSM::Timer.timeout(Settings.web_timeout, Timeout::Error) do
yield
end
def web_timeout(&block)
OSM::Timer.timeout(Settings.web_timeout, Timeout::Error, &block)
rescue ActionView::Template::Error => e
e = e.cause

View file

@ -202,10 +202,8 @@ class Notifier < ApplicationMailer
end
end
def with_recipient_locale(recipient)
I18n.with_locale Locale.available.preferred(recipient.preferred_languages) do
yield
end
def with_recipient_locale(recipient, &block)
I18n.with_locale(Locale.available.preferred(recipient.preferred_languages), &block)
end
def from_address(name, type, id, digest, user_id = nil)

View file

@ -78,17 +78,13 @@ class ClientApplicationsTest < ActionDispatch::IntegrationTest
##
# utility method to make the HTML screening easier to read.
def assert_in_heading
assert_select "div.content-heading" do
yield
end
def assert_in_heading(&block)
assert_select("div.content-heading", &block)
end
##
# utility method to make the HTML screening easier to read.
def assert_in_body
assert_select "div#content" do
yield
end
def assert_in_body(&block)
assert_select("div#content", &block)
end
end