From de280f06c5e2ab72bcc65c53b9c610bd7105371a Mon Sep 17 00:00:00 2001 From: James Herdman Date: Tue, 26 Feb 2019 09:04:05 -0500 Subject: [PATCH] chore: RuboCop Layout/DotPosition I've had to increase the maximum class length permitted by RuboCop. In fixing the dot position of Connection I've increased the length of said class. Let's deal with refactoring Connection later. --- .rubocop_todo.yml | 12 +----------- lib/faraday/adapter/em_http.rb | 16 ++++++++-------- lib/faraday/autoload.rb | 5 +++-- lib/faraday/connection.rb | 6 ++++-- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f1e4dd05d..cecfb101b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,16 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Exclude: - - 'lib/faraday/adapter/em_http.rb' - - 'lib/faraday/autoload.rb' - - 'lib/faraday/connection.rb' - # Offense count: 1 # Cop supports --auto-correct. Layout/EmptyLinesAroundAccessModifier: @@ -249,7 +239,7 @@ Metrics/BlockLength: # Offense count: 5 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 216 + Max: 217 # Offense count: 20 Metrics/CyclomaticComplexity: diff --git a/lib/faraday/adapter/em_http.rb b/lib/faraday/adapter/em_http.rb index 988ce2b6c..fd2d54651 100644 --- a/lib/faraday/adapter/em_http.rb +++ b/lib/faraday/adapter/em_http.rb @@ -104,17 +104,17 @@ def perform_request(env) if parallel?(env) manager = env[:parallel_manager] manager.add { - perform_single_request(env). - callback { env[:response].finish(env) } + perform_single_request(env) + .callback { env[:response].finish(env) } } else unless EventMachine.reactor_running? error = nil # start EM, block until request is completed EventMachine.run do - perform_single_request(env). - callback { EventMachine.stop }. - errback { |client| + perform_single_request(env) + .callback { EventMachine.stop } + .errback { |client| error = error_message(client) EventMachine.stop } @@ -123,9 +123,9 @@ def perform_request(env) else # EM is running: instruct upstream that this is an async request env[:parallel_manager] = true - perform_single_request(env). - callback { env[:response].finish(env) }. - errback { + perform_single_request(env) + .callback { env[:response].finish(env) } + .errback { # TODO: no way to communicate the error in async mode raise NotImplementedError } diff --git a/lib/faraday/autoload.rb b/lib/faraday/autoload.rb index 932977fe2..9d5a18c7c 100644 --- a/lib/faraday/autoload.rb +++ b/lib/faraday/autoload.rb @@ -47,8 +47,9 @@ def load_autoloaded_constants # # @return [Array] def all_loaded_constants - constants.map { |c| const_get(c) }. - select { |a| a.respond_to?(:loaded?) && a.loaded? } + constants + .map { |c| const_get(c) } + .select { |a| a.respond_to?(:loaded?) && a.loaded? } end end diff --git a/lib/faraday/connection.rb b/lib/faraday/connection.rb index b6c742ca6..80e55a647 100644 --- a/lib/faraday/connection.rb +++ b/lib/faraday/connection.rb @@ -549,8 +549,10 @@ def with_uri_credentials(uri) end def set_authorization_header(header_type, *args) - header = Faraday::Request.lookup_middleware(header_type). - header(*args) + header = Faraday::Request + .lookup_middleware(header_type) + .header(*args) + headers[Faraday::Request::Authorization::KEY] = header end