Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the Style/OptionHash cop in RuboCop #400

Merged
merged 1 commit into from
Feb 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
DisplayCopNames: true
DisplayCopNames: true

Metrics/BlockNesting:
Max: 2
Expand Down Expand Up @@ -64,6 +64,9 @@ Style/HashSyntax:
Style/Lambda:
Enabled: false

Style/OptionHash:
Enabled: true

Style/SpaceAroundOperators:
AllowForAlignment: true

Expand Down
26 changes: 13 additions & 13 deletions lib/http/chainable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,70 @@ module Chainable
# Request a get sans response body
# @param uri
# @option options [Hash]
def head(uri, options = {})
def head(uri, options = {}) # rubocop:disable Style/OptionHash
request :head, uri, options
end

# Get a resource
# @param uri
# @option options [Hash]
def get(uri, options = {})
def get(uri, options = {}) # rubocop:disable Style/OptionHash
request :get, uri, options
end

# Post to a resource
# @param uri
# @option options [Hash]
def post(uri, options = {})
def post(uri, options = {}) # rubocop:disable Style/OptionHash
request :post, uri, options
end

# Put to a resource
# @param uri
# @option options [Hash]
def put(uri, options = {})
def put(uri, options = {}) # rubocop:disable Style/OptionHash
request :put, uri, options
end

# Delete a resource
# @param uri
# @option options [Hash]
def delete(uri, options = {})
def delete(uri, options = {}) # rubocop:disable Style/OptionHash
request :delete, uri, options
end

# Echo the request back to the client
# @param uri
# @option options [Hash]
def trace(uri, options = {})
def trace(uri, options = {}) # rubocop:disable Style/OptionHash
request :trace, uri, options
end

# Return the methods supported on the given URI
# @param uri
# @option options [Hash]
def options(uri, options = {})
def options(uri, options = {}) # rubocop:disable Style/OptionHash
request :options, uri, options
end

# Convert to a transparent TCP/IP tunnel
# @param uri
# @option options [Hash]
def connect(uri, options = {})
def connect(uri, options = {}) # rubocop:disable Style/OptionHash
request :connect, uri, options
end

# Apply partial modifications to a resource
# @param uri
# @option options [Hash]
def patch(uri, options = {})
def patch(uri, options = {}) # rubocop:disable Style/OptionHash
request :patch, uri, options
end

# Make an HTTP request with the given verb
# @param uri
# @option options [Hash]
def request(verb, uri, options = {})
def request(verb, uri, options = {}) # rubocop:disable Style/OptionHash
branch(options).request verb, uri
end

Expand All @@ -85,7 +85,7 @@ def request(verb, uri, options = {})
# @option options [Float] :read Read timeout
# @option options [Float] :write Write timeout
# @option options [Float] :connect Connect timeout
def timeout(klass, options = {})
def timeout(klass, options = {}) # rubocop:disable Style/OptionHash
if klass.is_a? Hash
options = klass
klass = :per_operation
Expand Down Expand Up @@ -168,8 +168,8 @@ def via(*proxy)
# @param opts
# @return [HTTP::Client]
# @see Redirector#initialize
def follow(opts = {})
branch default_options.with_follow opts
def follow(options = {}) # rubocop:disable Style/OptionHash
branch default_options.with_follow options
end

# Make a request with the given headers
Expand Down
2 changes: 1 addition & 1 deletion lib/http/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(default_options = {})
end

# Make an HTTP request
def request(verb, uri, opts = {})
def request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash
opts = @default_options.merge(opts)
uri = make_request_uri(uri, opts)
headers = make_request_headers(opts)
Expand Down
2 changes: 1 addition & 1 deletion lib/http/feature.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module HTTP
class Feature
def initialize(opts = {})
def initialize(opts = {}) # rubocop:disable Style/OptionHash
@opts = opts
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/http/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class << self
attr_accessor :default_socket_class, :default_ssl_socket_class, :default_timeout_class
attr_reader :available_features

def new(options = {})
def new(options = {}) # rubocop:disable Style/OptionHash
return options if options.is_a?(self)
super
end
Expand All @@ -46,7 +46,7 @@ def def_option(name, &interpreter)
end
end

def initialize(options = {})
def initialize(options = {}) # rubocop:disable Style/OptionHash
defaults = {
:response => :auto,
:proxy => {},
Expand Down
2 changes: 1 addition & 1 deletion lib/http/redirector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EndlessRedirectError < TooManyRedirectsError; end
# @param [Hash] opts
# @option opts [Boolean] :strict (true) redirector hops policy
# @option opts [#to_i] :max_hops (5) maximum allowed amount of hops
def initialize(opts = {})
def initialize(opts = {}) # rubocop:disable Style/OptionHash
@strict = opts.fetch(:strict, true)
@max_hops = opts.fetch(:max_hops, 5).to_i
end
Expand Down
2 changes: 1 addition & 1 deletion lib/http/timeout/null.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Null

attr_reader :options, :socket

def initialize(options = {})
def initialize(options = {}) # rubocop:disable Style/OptionHash
@options = options
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/dummy_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DummyServer < WEBrick::HTTPServer
:SSLStartImmediately => true
).freeze

def initialize(options = {})
def initialize(options = {}) # rubocop:disable Style/OptionHash
super(options[:ssl] ? SSL_CONFIG : CONFIG)
mount("/", Servlet)
end
Expand Down