]> git.openstreetmap.org Git - rails.git/commitdiff
Fix Style/ExplicitBlockArgument warnings
authorTom Hughes <tom@compton.nu>
Sun, 9 Aug 2020 17:45:01 +0000 (18:45 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 9 Aug 2020 18:06:04 +0000 (19:06 +0100)
.rubocop_todo.yml
app/controllers/api/amf_controller.rb
app/controllers/application_controller.rb
app/mailers/notifier.rb
test/integration/client_applications_test.rb

index 4627479f5dfbc10f166a60468448ecdd7122a5bd..18a5cf6466a190231e029f7229f5cd9b064fc063 100644 (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.
index c05a130981cdf46bb97cea3af2dca125362822dd..fc8a304bbc56513fbe1d1ce089e1354e7621e627 100644 (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
 
index 68baa31154018f304b321050703b033480af0214..3f6abc470f1a3340b5037ece012e8f6dc67fcebd 100644 (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
 
index 3c794cca92f45d376c95ebe4945b150fd713aa22..3e0ba446d59b25d3e2eae72daecbb114eb1dca6d 100644 (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)
index b50a990c688a1b5e54960682fa1a9ad7a2c94444..4c3e9df470197c1a50b2550c1d0645f3f06d519d 100644 (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