summaryrefslogtreecommitdiff
path: root/lib/chef/http
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-12-21 10:43:29 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-12-21 10:43:29 -0800
commita6a880342ff0324df5ebc1192b898af9864d4c34 (patch)
treea7b8f06a3ffaaa1ec2f8d5795945fb2d6083bf6e /lib/chef/http
parent81e4f3ee85fc4e9bef11c3468dcd1cb8d30f4cea (diff)
downloadchef-a6a880342ff0324df5ebc1192b898af9864d4c34.tar.gz
Style/NumericPredicate comparison stylelcg/numericpredicate
Apparently rubocop thinks the default behavior should be that we have to rewrite every use of `foo == 0` into `foo.zero?` which is a big pile of NOPE for me. After discovering that `.zero?` is actually slower, I'd prefer to go the other direction. Same for `positive?` and `negative?`. These are the only uses of `zero?` in the chef/chef codebase, while I'm pretty sure the inverse rule would touch nearly every file. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/http')
-rw-r--r--lib/chef/http/json_input.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/http/json_input.rb b/lib/chef/http/json_input.rb
index 4cc1aa2e10..7cf2e4012f 100644
--- a/lib/chef/http/json_input.rb
+++ b/lib/chef/http/json_input.rb
@@ -33,7 +33,7 @@ class Chef
def handle_request(method, url, headers = {}, data = false)
if data && should_encode_as_json?(headers)
- headers.delete_if { |key, _value| key.casecmp("content-type").zero? }
+ headers.delete_if { |key, _value| key.casecmp("content-type") == 0 }
headers["Content-Type"] = "application/json"
json_opts = {}
json_opts[:validate_utf8] = opts[:validate_utf8] if opts.has_key?(:validate_utf8)
@@ -64,7 +64,7 @@ class Chef
# ruby/Net::HTTP don't enforce capitalized headers (it normalizes them
# for you before sending the request), so we have to account for all
# the variations we might find
- requested_content_type = headers.find { |k, v| k.casecmp("content-type").zero? }
+ requested_content_type = headers.find { |k, v| k.casecmp("content-type") == 0 }
requested_content_type.nil? || requested_content_type.last.include?("json")
end