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: Rails/TimeZone:
Enabled: false 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 # Offense count: 572
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.

View file

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

View file

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

View file

@ -202,10 +202,8 @@ class Notifier < ApplicationMailer
end end
end end
def with_recipient_locale(recipient) def with_recipient_locale(recipient, &block)
I18n.with_locale Locale.available.preferred(recipient.preferred_languages) do I18n.with_locale(Locale.available.preferred(recipient.preferred_languages), &block)
yield
end
end end
def from_address(name, type, id, digest, user_id = nil) 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. # utility method to make the HTML screening easier to read.
def assert_in_heading def assert_in_heading(&block)
assert_select "div.content-heading" do assert_select("div.content-heading", &block)
yield
end
end end
## ##
# utility method to make the HTML screening easier to read. # utility method to make the HTML screening easier to read.
def assert_in_body def assert_in_body(&block)
assert_select "div#content" do assert_select("div#content", &block)
yield
end
end end
end end