Skip to content

Commit

Permalink
Chore: RuboCop Style/MultilineIfModifier (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
Drenmi authored and olleolleolle committed Mar 4, 2019
1 parent c209c41 commit 5b49e6c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 44 deletions.
14 changes: 2 additions & 12 deletions .rubocop_todo.yml
Expand Up @@ -25,7 +25,7 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 16

# Offense count: 45
# Offense count: 46
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 65
Expand Down Expand Up @@ -125,16 +125,6 @@ Style/ModuleFunction:
Exclude:
- 'lib/faraday/utils.rb'

# Offense count: 5
# Cop supports --auto-correct.
Style/MultilineIfModifier:
Exclude:
- 'lib/faraday/adapter/em_http.rb'
- 'lib/faraday/adapter/em_synchrony.rb'
- 'lib/faraday/adapter/net_http_persistent.rb'
- 'test/adapters/em_http_test.rb'
- 'test/helper.rb'

# Offense count: 1
Style/MultipleComparison:
Exclude:
Expand All @@ -155,7 +145,7 @@ Style/MutableConstant:
- 'lib/faraday/response/raise_error.rb'
- 'lib/faraday/utils.rb'

# Offense count: 275
# Offense count: 276
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Expand Down
16 changes: 9 additions & 7 deletions lib/faraday/adapter/em_http.rb
Expand Up @@ -257,10 +257,12 @@ def check_finished
end
end

begin
require 'openssl'
rescue LoadError
warn 'Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support'
else
require 'faraday/adapter/em_http_ssl_patch'
end if Faraday::Adapter::EMHttp.loaded?
if Faraday::Adapter::EMHttp.loaded?
begin
require 'openssl'
rescue LoadError
warn 'Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support'
else
require 'faraday/adapter/em_http_ssl_patch'
end
end
16 changes: 9 additions & 7 deletions lib/faraday/adapter/em_synchrony.rb
Expand Up @@ -110,10 +110,12 @@ def create_request(env)

require 'faraday/adapter/em_synchrony/parallel_manager'

begin
require 'openssl'
rescue LoadError
warn 'Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support'
else
require 'faraday/adapter/em_http_ssl_patch'
end if Faraday::Adapter::EMSynchrony.loaded?
if Faraday::Adapter::EMSynchrony.loaded?
begin
require 'openssl'
rescue LoadError
warn 'Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support'
else
require 'faraday/adapter/em_http_ssl_patch'
end
end
10 changes: 6 additions & 4 deletions lib/faraday/adapter/net_http_persistent.rb
Expand Up @@ -29,10 +29,12 @@ def proxy_uri(env)
proxy_uri = proxy[:uri].is_a?(::URI::HTTP) ? proxy[:uri].dup : ::URI.parse(proxy[:uri].to_s)
proxy_uri.user = proxy_uri.password = nil
# awful patch for net-http-persistent 2.8 not unescaping user/password
(class << proxy_uri; self; end).class_eval do
define_method(:user) { proxy[:user] }
define_method(:password) { proxy[:password] }
end if proxy[:user]
if proxy[:user]
(class << proxy_uri; self; end).class_eval do
define_method(:user) { proxy[:user] }
define_method(:password) { proxy[:password] }
end
end
end
proxy_uri
end
Expand Down
22 changes: 12 additions & 10 deletions test/adapters/em_http_test.rb
Expand Up @@ -8,17 +8,19 @@ def adapter
:em_http
end

Integration.apply(self, :Parallel, :NonStreaming, :ParallelNonStreaming) do
# https://github.com/eventmachine/eventmachine/pull/289
undef :test_timeout

def test_binds_local_socket
host = '1.2.3.4'
conn = create_connection request: { bind: { host: host } }
assert_equal host, conn.options[:bind][:host]
unless jruby? && ssl_mode?
Integration.apply(self, :Parallel, :NonStreaming, :ParallelNonStreaming) do
# https://github.com/eventmachine/eventmachine/pull/289
undef :test_timeout

def test_binds_local_socket
host = '1.2.3.4'
conn = create_connection request: { bind: { host: host } }
assert_equal host, conn.options[:bind][:host]
end
end
end unless jruby? && ssl_mode?
# https://github.com/eventmachine/eventmachine/issues/180
# https://github.com/eventmachine/eventmachine/issues/180
end

def test_custom_adapter_config
url = URI('https://example.com:1234')
Expand Down
4 changes: 0 additions & 4 deletions test/helper.rb
Expand Up @@ -44,10 +44,6 @@ class TestCase < MiniTest::Test
extend LiveServerConfig
self.live_server = ENV['LIVE']

def test_default
assert true
end unless defined? ::MiniTest

def capture_warnings
old = $stderr
$stderr = StringIO.new
Expand Down

0 comments on commit 5b49e6c

Please sign in to comment.