Skip to content

Commit 6240672

Browse files
nateshollandixti
authored andcommitted
Upgrade RuboCop to v0.68.1 (#549)
* Bump to RuboCop latest version and run autocorrect This is the latest version of rubocop with most of the auto-corrects run. There are a few notes on this: - Performance cops have been refactored out so they require being installed in a new gem. That gem has been included so that we can keep performance cops. - I left out the Layout/AlignHash cop because the code base has it going both ways. I want to put that in its own commit so that it is easy to change or reverse if the maintainers want to go one way or another. * Enable Layout/AlignHash and run auto-correct This commit enables Layout/AlignHash and sets the prefered format to the table format. The docs for this cop can be found here: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Layout/AlignHash
1 parent fec85f6 commit 6240672

20 files changed

Lines changed: 87 additions & 80 deletions

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
require: rubocop-performance
2+
13
AllCops:
24
TargetRubyVersion: 2.3
35
DisplayCopNames: true
46

57
## Layout ######################################################################
68

9+
Layout/AlignHash:
10+
EnforcedColonStyle: table
11+
EnforcedHashRocketStyle: table
12+
713
Layout/DotPosition:
814
EnforcedStyle: trailing
915

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ group :test do
2828
gem "rspec", "~> 3.0"
2929
gem "rspec-its"
3030

31-
gem "rubocop", "= 0.59.2"
31+
gem "rubocop", "= 0.68.1"
32+
gem "rubocop-performance"
3233

3334
gem "yardstick"
3435
end

lib/http/chainable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def timeout(options)
106106
end
107107

108108
branch default_options.merge(
109-
:timeout_class => klass,
109+
:timeout_class => klass,
110110
:timeout_options => options
111111
)
112112
end

lib/http/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Client
1616
extend Forwardable
1717
include Chainable
1818

19-
HTTP_OR_HTTPS_RE = %r{^https?://}i
19+
HTTP_OR_HTTPS_RE = %r{^https?://}i.freeze
2020

2121
def initialize(default_options = {})
2222
@default_options = HTTP::Options.new(default_options)

lib/http/connection.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def initialize(req, options)
4545
send_proxy_connect_request(req)
4646
start_tls(req, options)
4747
reset_timer
48-
rescue IOError, SocketError, SystemCallError => ex
49-
raise ConnectionError, "failed to connect: #{ex}", ex.backtrace
48+
rescue IOError, SocketError, SystemCallError => e
49+
raise ConnectionError, "failed to connect: #{e}", e.backtrace
5050
end
5151

5252
# @see (HTTP::Response::Parser#status_code)
@@ -216,8 +216,8 @@ def read_more(size)
216216
elsif value
217217
@parser << value
218218
end
219-
rescue IOError, SocketError, SystemCallError => ex
220-
raise ConnectionError, "error reading from socket: #{ex}", ex.backtrace
219+
rescue IOError, SocketError, SystemCallError => e
220+
raise ConnectionError, "error reading from socket: #{e}", e.backtrace
221221
end
222222
end
223223
end

lib/http/content_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
module HTTP
44
ContentType = Struct.new(:mime_type, :charset) do
5-
MIME_TYPE_RE = %r{^([^/]+/[^;]+)(?:$|;)}
6-
CHARSET_RE = /;\s*charset=([^;]+)/i
5+
MIME_TYPE_RE = %r{^([^/]+/[^;]+)(?:$|;)}.freeze
6+
CHARSET_RE = /;\s*charset=([^;]+)/i.freeze
77

88
class << self
99
# Parse string and return ContentType struct

lib/http/features/auto_deflate.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def wrap_request(request)
2727
request.headers[Headers::CONTENT_ENCODING] = method
2828

2929
Request.new(
30-
:version => request.version,
31-
:verb => request.verb,
32-
:uri => request.uri,
33-
:headers => request.headers,
34-
:proxy => request.proxy,
35-
:body => deflated_body(request.body),
30+
:version => request.version,
31+
:verb => request.verb,
32+
:uri => request.uri,
33+
:headers => request.headers,
34+
:proxy => request.proxy,
35+
:body => deflated_body(request.body),
3636
:uri_normalizer => request.uri_normalizer
3737
)
3838
end

lib/http/features/auto_inflate.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ def wrap_response(response)
1212
return response unless supported_encoding?(response)
1313

1414
options = {
15-
:status => response.status,
16-
:version => response.version,
17-
:headers => response.headers,
15+
:status => response.status,
16+
:version => response.version,
17+
:headers => response.headers,
1818
:proxy_headers => response.proxy_headers,
19-
:connection => response.connection,
20-
:body => stream_for(response.connection)
19+
:connection => response.connection,
20+
:body => stream_for(response.connection)
2121
}
2222

2323
options[:uri] = response.uri if response.uri

lib/http/headers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class Headers
1313
include Enumerable
1414

1515
# Matches HTTP header names when in "Canonical-Http-Format"
16-
CANONICAL_NAME_RE = /\A[A-Z][a-z]*(?:-[A-Z][a-z]*)*\z/
16+
CANONICAL_NAME_RE = /\A[A-Z][a-z]*(?:-[A-Z][a-z]*)*\z/.freeze
1717

1818
# Matches valid header field name according to RFC.
1919
# @see http://tools.ietf.org/html/rfc7230#section-3.2
20-
COMPLIANT_NAME_RE = /\A[A-Za-z0-9!#\$%&'*+\-.^_`|~]+\z/
20+
COMPLIANT_NAME_RE = /\A[A-Za-z0-9!#\$%&'*+\-.^_`|~]+\z/.freeze
2121

2222
# Class constructor.
2323
def initialize

lib/http/request.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ class UnsupportedSchemeError < RequestError; end
5454

5555
# Default ports of supported schemes
5656
PORTS = {
57-
:http => 80,
58-
:https => 443,
59-
:ws => 80,
60-
:wss => 443
57+
:http => 80,
58+
:https => 443,
59+
:ws => 80,
60+
:wss => 443
6161
}.freeze
6262

6363
# Method is given as a lowercase symbol e.g. :get, :post
@@ -168,8 +168,8 @@ def proxy_connect_header
168168
# Headers to send with proxy connect request
169169
def proxy_connect_headers
170170
connect_headers = HTTP::Headers.coerce(
171-
Headers::HOST => headers[Headers::HOST],
172-
Headers::USER_AGENT => headers[Headers::USER_AGENT]
171+
Headers::HOST => headers[Headers::HOST],
172+
Headers::USER_AGENT => headers[Headers::USER_AGENT]
173173
)
174174

175175
connect_headers[Headers::PROXY_AUTHORIZATION] = proxy_authorization_header if using_authenticated_proxy?

0 commit comments

Comments
 (0)