summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/api_client.rb2
-rw-r--r--lib/chef/blacklist.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/acl.rb2
-rw-r--r--lib/chef/client.rb2
-rw-r--r--lib/chef/cookbook/metadata.rb4
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb2
-rw-r--r--lib/chef/data_bag_item.rb2
-rw-r--r--lib/chef/decorator.rb2
-rw-r--r--lib/chef/dsl/platform_introspection.rb2
-rw-r--r--lib/chef/encrypted_data_bag_item/assertions.rb2
-rw-r--r--lib/chef/environment.rb2
-rw-r--r--lib/chef/file_access_control/unix.rb8
-rw-r--r--lib/chef/file_access_control/windows.rb8
-rw-r--r--lib/chef/formatters/base.rb2
-rw-r--r--lib/chef/formatters/doc.rb4
-rw-r--r--lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb4
-rw-r--r--lib/chef/formatters/indentable_output_stream.rb2
-rw-r--r--lib/chef/http.rb30
-rw-r--r--lib/chef/json_compat.rb2
-rw-r--r--lib/chef/knife/core/generic_presenter.rb2
-rw-r--r--lib/chef/knife/core/node_presenter.rb4
-rw-r--r--lib/chef/knife/core/text_formatter.rb8
-rw-r--r--lib/chef/knife/supermarket_share.rb2
-rw-r--r--lib/chef/mash.rb4
-rw-r--r--lib/chef/mixin/create_path.rb4
-rw-r--r--lib/chef/mixin/deep_merge.rb10
-rw-r--r--lib/chef/mixin/params_validate.rb10
-rw-r--r--lib/chef/mixin/securable.rb2
-rw-r--r--lib/chef/node.rb4
-rw-r--r--lib/chef/node/attribute.rb16
-rw-r--r--lib/chef/policy_builder/policyfile.rb2
-rw-r--r--lib/chef/provider/http_request.rb2
-rw-r--r--lib/chef/resource.rb2
-rw-r--r--lib/chef/resource/link.rb2
-rw-r--r--lib/chef/resource/mount.rb4
-rw-r--r--lib/chef/resource/remote_file.rb2
-rw-r--r--lib/chef/resource/resource_notification.rb6
-rw-r--r--lib/chef/resource/template.rb4
-rw-r--r--lib/chef/resource_collection/resource_collection_serialization.rb2
-rw-r--r--lib/chef/resource_collection/resource_set.rb2
-rw-r--r--lib/chef/resource_definition.rb4
-rw-r--r--lib/chef/resource_inspector.rb2
-rw-r--r--lib/chef/run_list.rb6
-rw-r--r--lib/chef/run_list/run_list_item.rb2
-rw-r--r--lib/chef/runner.rb2
-rw-r--r--lib/chef/search/query.rb2
-rw-r--r--lib/chef/shell/ext.rb4
-rw-r--r--lib/chef/shell/model_wrapper.rb2
-rw-r--r--lib/chef/whitelist.rb2
49 files changed, 102 insertions, 102 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb
index c2dec0a86f..0b82cfa972 100644
--- a/lib/chef/api_client.rb
+++ b/lib/chef/api_client.rb
@@ -171,7 +171,7 @@ class Chef
# Load a client by name via the API
def self.load(name)
response = http_api.get("clients/#{name}")
- if response.kind_of?(Chef::ApiClient)
+ if response.is_a?(Chef::ApiClient)
response
else
from_hash(response)
diff --git a/lib/chef/blacklist.rb b/lib/chef/blacklist.rb
index b304934a98..abf2139044 100644
--- a/lib/chef/blacklist.rb
+++ b/lib/chef/blacklist.rb
@@ -68,7 +68,7 @@ class Chef
# assumed to contain exact keys (that is, Array elements will not be split
# by "/").
def self.to_array(item)
- return item if item.kind_of? Array
+ return item if item.is_a? Array
parts = item.split("/")
parts.shift if !parts.empty? && parts[0].empty?
diff --git a/lib/chef/chef_fs/file_system/repository/acl.rb b/lib/chef/chef_fs/file_system/repository/acl.rb
index 389c1fd38b..c5d763170b 100644
--- a/lib/chef/chef_fs/file_system/repository/acl.rb
+++ b/lib/chef/chef_fs/file_system/repository/acl.rb
@@ -32,7 +32,7 @@ class Chef
end
def bare_name
- if name == "organization" && parent.kind_of?(AclDir)
+ if name == "organization" && parent.is_a?(AclDir)
"organization.json"
else
name
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 37cc7cd6d1..d0d6b0dd4c 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -902,7 +902,7 @@ class Chef
end
def is_last_element?(index, object)
- object.kind_of?(Array) ? index == object.size - 1 : true
+ object.is_a?(Array) ? index == object.size - 1 : true
end
def assert_cookbook_path_not_empty(run_context)
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index 729a5a4f61..8b4af310ed 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -639,7 +639,7 @@ class Chef
# === Parameters
# arry<Array>:: An array to be validated
def validate_string_array(arry)
- if arry.kind_of?(Array)
+ if arry.is_a?(Array)
arry.each do |choice|
validate( { choice: choice }, { choice: { kind_of: String } } )
end
@@ -652,7 +652,7 @@ class Chef
# === Parameters
# opts<Hash>:: The options hash
def validate_choice_array(opts)
- if opts[:choice].kind_of?(Array)
+ if opts[:choice].is_a?(Array)
case opts[:type]
when "string"
validator = [ String ]
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
index cd66a5048b..dd9cf8fa39 100644
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ b/lib/chef/cookbook_site_streaming_uploader.rb
@@ -79,7 +79,7 @@ class Chef
unless params.nil? || params.empty?
params.each do |key, value|
- if value.kind_of?(File)
+ if value.is_a?(File)
content_file = value
filepath = value.path
filename = File.basename(filepath)
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index b6b1743277..2690fcbe51 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -148,7 +148,7 @@ class Chef
item = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("data/#{data_bag}/#{name}")
end
- if item.kind_of?(DataBagItem)
+ if item.is_a?(DataBagItem)
item
else
item = from_hash(item)
diff --git a/lib/chef/decorator.rb b/lib/chef/decorator.rb
index ac0f8fdfbb..17015bab94 100644
--- a/lib/chef/decorator.rb
+++ b/lib/chef/decorator.rb
@@ -38,7 +38,7 @@ class Chef
# if we wrap a Hash then decorator.kind_of?(Hash) should be true
def kind_of?(klass)
- __getobj__.kind_of?(klass) || super
+ __getobj__.is_a?(klass) || super
end
# reset our methods on the instance if the object changes under us (this also
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb
index dfd20b6329..3f79782798 100644
--- a/lib/chef/dsl/platform_introspection.rb
+++ b/lib/chef/dsl/platform_introspection.rb
@@ -126,7 +126,7 @@ class Chef
end
def assert_valid_platform_values!(platforms, value)
- unless value.kind_of?(Hash)
+ unless value.is_a?(Hash)
msg = "platform dependent values must be specified in the format :platform => {:version => value} "
msg << "you gave a value #{value.inspect} for platform(s) #{platforms}"
raise ArgumentError, msg
diff --git a/lib/chef/encrypted_data_bag_item/assertions.rb b/lib/chef/encrypted_data_bag_item/assertions.rb
index bdd522e039..02baad2a2d 100644
--- a/lib/chef/encrypted_data_bag_item/assertions.rb
+++ b/lib/chef/encrypted_data_bag_item/assertions.rb
@@ -27,7 +27,7 @@ class Chef::EncryptedDataBagItem
module Assertions
def assert_format_version_acceptable!(format_version)
- unless format_version.kind_of?(Integer) && format_version >= Chef::Config[:data_bag_decrypt_minimum_version]
+ unless format_version.is_a?(Integer) && format_version >= Chef::Config[:data_bag_decrypt_minimum_version]
raise UnacceptableEncryptedDataBagItemFormat,
"The encrypted data bag item has format version `#{format_version}', " +
"but the config setting 'data_bag_decrypt_minimum_version' requires version `#{Chef::Config[:data_bag_decrypt_minimum_version]}'"
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index 476aeb4867..87716410db 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -298,7 +298,7 @@ class Chef
end
def self.validate_cookbook_versions(cv)
- return false unless cv.kind_of?(Hash)
+ return false unless cv.is_a?(Hash)
cv.each_value do |version|
return false unless Chef::Environment.validate_cookbook_version(version)
diff --git a/lib/chef/file_access_control/unix.rb b/lib/chef/file_access_control/unix.rb
index b412dbfa1b..4d3ac84eb0 100644
--- a/lib/chef/file_access_control/unix.rb
+++ b/lib/chef/file_access_control/unix.rb
@@ -119,9 +119,9 @@ class Chef
def gid_from_resource(resource)
return nil if resource.nil? || resource.group.nil?
- if resource.group.kind_of?(String)
+ if resource.group.is_a?(String)
diminished_radix_complement( Etc.getgrnam(resource.group).gid )
- elsif resource.group.kind_of?(Integer)
+ elsif resource.group.is_a?(Integer)
resource.group
else
Chef::Log.error("The `group` parameter of the #{@resource} resource is set to an invalid value (#{resource.owner.inspect})")
@@ -268,9 +268,9 @@ class Chef
def uid_from_resource(resource)
return nil if resource.nil? || resource.owner.nil?
- if resource.owner.kind_of?(String)
+ if resource.owner.is_a?(String)
diminished_radix_complement( Etc.getpwnam(resource.owner).uid )
- elsif resource.owner.kind_of?(Integer)
+ elsif resource.owner.is_a?(Integer)
resource.owner
else
Chef::Log.error("The `owner` parameter of the #{@resource} resource is set to an invalid value (#{resource.owner.inspect})")
diff --git a/lib/chef/file_access_control/windows.rb b/lib/chef/file_access_control/windows.rb
index 5090454fff..e14c5a2746 100644
--- a/lib/chef/file_access_control/windows.rb
+++ b/lib/chef/file_access_control/windows.rb
@@ -110,9 +110,9 @@ class Chef
end
def get_sid(value)
- if value.kind_of?(String)
+ if value.is_a?(String)
SID.from_account(value)
- elsif value.kind_of?(SID)
+ elsif value.is_a?(SID)
value
else
raise "Must specify username, group or SID: #{value}"
@@ -121,10 +121,10 @@ class Chef
def securable_object
@securable_object ||= begin
- if file.kind_of?(String)
+ if file.is_a?(String)
so = Chef::ReservedNames::Win32::Security::SecurableObject.new(file.dup)
end
- raise ArgumentError, "'file' must be a valid path or object of type 'Chef::ReservedNames::Win32::Security::SecurableObject'" unless so.kind_of? Chef::ReservedNames::Win32::Security::SecurableObject
+ raise ArgumentError, "'file' must be a valid path or object of type 'Chef::ReservedNames::Win32::Security::SecurableObject'" unless so.is_a? Chef::ReservedNames::Win32::Security::SecurableObject
so
end
diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb
index 95170936a6..0a2e14abd3 100644
--- a/lib/chef/formatters/base.rb
+++ b/lib/chef/formatters/base.rb
@@ -221,7 +221,7 @@ class Chef
end
def is_structured_deprecation?(deprecation)
- deprecation.kind_of?(Chef::Deprecated::Base)
+ deprecation.is_a?(Chef::Deprecated::Base)
end
def is_formatter?
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb
index f29e56094e..5ed75c00eb 100644
--- a/lib/chef/formatters/doc.rb
+++ b/lib/chef/formatters/doc.rb
@@ -293,9 +293,9 @@ class Chef
next if line.nil?
output_record line
- if line.kind_of? String
+ if line.is_a? String
start_line "- #{prefix}#{line}", :green
- elsif line.kind_of? Array
+ elsif line.is_a? Array
# Expanded output - delta
# @todo should we have a resource_update_delta callback?
line.each do |detail|
diff --git a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
index b6fc4c6e14..4a6fa49fe7 100644
--- a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
@@ -143,12 +143,12 @@ class Chef
# "{\"error\":[\"{\\\"non_existent_cookbooks\\\":[\\\"nope\\\"],\\\"cookbooks_with_no_versions\\\":[],\\\"message\\\":\\\"Run list contains invalid items: no such cookbook nope.\\\"}\"]}"
wrapped_error_message = attempt_json_parse(exception.response.body)
- unless wrapped_error_message.kind_of?(Hash) && wrapped_error_message.key?("error")
+ unless wrapped_error_message.is_a?(Hash) && wrapped_error_message.key?("error")
return wrapped_error_message.to_s
end
error_description = Array(wrapped_error_message["error"]).first
- if error_description.kind_of?(Hash)
+ if error_description.is_a?(Hash)
return error_description
end
diff --git a/lib/chef/formatters/indentable_output_stream.rb b/lib/chef/formatters/indentable_output_stream.rb
index f7e44be493..e4ad600436 100644
--- a/lib/chef/formatters/indentable_output_stream.rb
+++ b/lib/chef/formatters/indentable_output_stream.rb
@@ -112,7 +112,7 @@ class Chef
end
def from_args(colors, merge_options = {})
- if colors.size == 1 && colors[0].kind_of?(Hash)
+ if colors.size == 1 && colors[0].is_a?(Hash)
merge_options.merge(colors[0])
else
merge_options.merge({ colors: colors })
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 3cee587fd5..3239aac442 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -155,7 +155,7 @@ class Chef
rescue Net::HTTPClientException => e
http_attempts += 1
response = e.response
- if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
+ if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
Chef::Log.trace("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
retry
else
@@ -180,21 +180,21 @@ class Chef
method, url, processed_headers, data = apply_request_middleware(method, url, headers, data)
response, rest_request, return_value = send_http_request(method, url, processed_headers, data) do |http_response|
- if http_response.kind_of?(Net::HTTPSuccess)
+ if http_response.is_a?(Net::HTTPSuccess)
tempfile = stream_to_tempfile(url, http_response, tempfile, &progress_block)
end
apply_stream_complete_middleware(http_response, rest_request, return_value)
end
- return nil if response.kind_of?(Net::HTTPRedirection)
+ return nil if response.is_a?(Net::HTTPRedirection)
- unless response.kind_of?(Net::HTTPSuccess)
+ unless response.is_a?(Net::HTTPSuccess)
response.error!
end
tempfile
rescue Net::HTTPClientException => e
http_attempts += 1
response = e.response
- if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
+ if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
Chef::Log.trace("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
retry
else
@@ -227,15 +227,15 @@ class Chef
method, url, processed_headers, data = apply_request_middleware(method, url, headers, data)
response, rest_request, return_value = send_http_request(method, url, processed_headers, data) do |http_response|
- if http_response.kind_of?(Net::HTTPSuccess)
+ if http_response.is_a?(Net::HTTPSuccess)
tempfile = stream_to_tempfile(url, http_response, tempfile)
end
apply_stream_complete_middleware(http_response, rest_request, return_value)
end
- return nil if response.kind_of?(Net::HTTPRedirection)
+ return nil if response.is_a?(Net::HTTPRedirection)
- unless response.kind_of?(Net::HTTPSuccess)
+ unless response.is_a?(Net::HTTPSuccess)
response.error!
end
@@ -250,7 +250,7 @@ class Chef
rescue Net::HTTPClientException => e
http_attempts += 1
response = e.response
- if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
+ if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
Chef::Log.trace("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
retry
else
@@ -358,7 +358,7 @@ class Chef
# @api private
def success_response?(response)
- response.kind_of?(Net::HTTPSuccess) || response.kind_of?(Net::HTTPRedirection)
+ response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPRedirection)
end
# Runs a synchronous HTTP request, with no middleware applied (use #request
@@ -377,9 +377,9 @@ class Chef
end
@last_response = response
- if response.kind_of?(Net::HTTPSuccess)
+ if response.is_a?(Net::HTTPSuccess)
[response, request, return_value]
- elsif response.kind_of?(Net::HTTPNotModified) # Must be tested before Net::HTTPRedirection because it's subclass.
+ elsif response.is_a?(Net::HTTPNotModified) # Must be tested before Net::HTTPRedirection because it's subclass.
[response, request, false]
elsif redirect_location = redirected_to(response)
if %i{GET HEAD}.include?(method)
@@ -413,7 +413,7 @@ class Chef
http_attempts += 1
response, request, return_value = yield
# handle HTTP 50X Error
- if response.kind_of?(Net::HTTPServerError) && !Chef::Config.local_mode
+ if response.is_a?(Net::HTTPServerError) && !Chef::Config.local_mode
if http_retry_count - http_attempts + 1 > 0
sleep_time = 1 + (2**http_attempts) + rand(2**http_attempts)
Chef::Log.error("Server returned error #{response.code} for #{url}, retrying #{http_attempts}/#{http_retry_count} in #{sleep_time}s")
@@ -499,9 +499,9 @@ class Chef
# @api private
def redirected_to(response)
- return nil unless response.kind_of?(Net::HTTPRedirection)
+ return nil unless response.is_a?(Net::HTTPRedirection)
# Net::HTTPNotModified is undesired subclass of Net::HTTPRedirection so test for this
- return nil if response.kind_of?(Net::HTTPNotModified)
+ return nil if response.is_a?(Net::HTTPNotModified)
response["location"]
end
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb
index 13a2c43dbb..cc750e16ee 100644
--- a/lib/chef/json_compat.rb
+++ b/lib/chef/json_compat.rb
@@ -42,7 +42,7 @@ class Chef
# JSON gem requires top level object to be a Hash or Array (otherwise
# you get the "must contain two octets" error). Yajl doesn't impose the
# same limitation. For compatibility, we re-impose this condition.
- unless obj.kind_of?(Hash) || obj.kind_of?(Array)
+ unless obj.is_a?(Hash) || obj.is_a?(Array)
raise Chef::Exceptions::JSON::ParseError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})"
end
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index 6ee0d1ea06..e219e29707 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -201,7 +201,7 @@ class Chef
end
end
# necessary (?) for coercing objects (the run_list object?) to hashes
- ( !data.kind_of?(Array) && data.respond_to?(:to_hash) ) ? data.to_hash : data
+ ( !data.is_a?(Array) && data.respond_to?(:to_hash) ) ? data.to_hash : data
end
def format_cookbook_list_for_display(item)
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index a77e9d7a65..3f1feb9d16 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -61,7 +61,7 @@ class Chef
end
def summarize_json(data)
- if data.kind_of?(Chef::Node)
+ if data.is_a?(Chef::Node)
node = data
result = {}
@@ -92,7 +92,7 @@ class Chef
# the volume of output is adjusted accordingly. Uses colors if enabled
# in the ui object.
def summarize(data)
- if data.kind_of?(Chef::Node)
+ if data.is_a?(Chef::Node)
node = data
# special case ec2 with their split horizon whatsis.
ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
diff --git a/lib/chef/knife/core/text_formatter.rb b/lib/chef/knife/core/text_formatter.rb
index 8775e2e76f..e0df395545 100644
--- a/lib/chef/knife/core/text_formatter.rb
+++ b/lib/chef/knife/core/text_formatter.rb
@@ -28,7 +28,7 @@ class Chef
@ui = ui
@data = if data.respond_to?(:display_hash)
data.display_hash
- elsif data.kind_of?(Array)
+ elsif data.is_a?(Array)
data
elsif data.respond_to?(:to_hash)
data.to_hash
@@ -48,7 +48,7 @@ class Chef
justify_width = data.keys.map { |k| k.to_s.size }.max.to_i + 1
data.sort.each do |key, value|
# key: ['value'] should be printed as key: value
- if value.kind_of?(Array) && value.size == 1 && is_singleton(value[0])
+ if value.is_a?(Array) && value.size == 1 && is_singleton(value[0])
value = value[0]
end
if is_singleton(value)
@@ -62,7 +62,7 @@ class Chef
lines.each { |line| buffer << " #{line}\n" }
end
end
- elsif data.kind_of?(Array)
+ elsif data.is_a?(Array)
data.each_index do |index|
item = data[index]
buffer << text_format(data[index])
@@ -77,7 +77,7 @@ class Chef
end
def is_singleton(value)
- !(value.kind_of?(Array) || value.respond_to?(:keys))
+ !(value.is_a?(Array) || value.respond_to?(:keys))
end
end
end
diff --git a/lib/chef/knife/supermarket_share.rb b/lib/chef/knife/supermarket_share.rb
index 51e8d3dbe5..f178b4ab35 100644
--- a/lib/chef/knife/supermarket_share.rb
+++ b/lib/chef/knife/supermarket_share.rb
@@ -113,7 +113,7 @@ class Chef
data = noauth_rest.get("#{config[:supermarket_site]}/api/v1/cookbooks/#{@name_args[0]}")
data["category"]
rescue => e
- return "Other" if e.kind_of?(Net::HTTPClientException) && e.response.code == "404"
+ return "Other" if e.is_a?(Net::HTTPClientException) && e.response.code == "404"
ui.fatal("Unable to reach Supermarket: #{e.message}. Increase log verbosity (-VV) for more information.")
Chef::Log.trace("\n#{e.backtrace.join("\n")}")
diff --git a/lib/chef/mash.rb b/lib/chef/mash.rb
index 8b9e115dd1..404d6d622f 100644
--- a/lib/chef/mash.rb
+++ b/lib/chef/mash.rb
@@ -72,7 +72,7 @@ class Mash < Hash
super
# Handle nested values
each do |k, v|
- if v.kind_of?(Mash) || v.is_a?(Array)
+ if v.is_a?(Mash) || v.is_a?(Array)
self[k] = v.dup
end
end
@@ -210,7 +210,7 @@ class Mash < Hash
#
# @api private
def convert_key(key)
- key.kind_of?(Symbol) ? key.to_s : key
+ key.is_a?(Symbol) ? key.to_s : key
end
# @param value<Object> The value to convert.
diff --git a/lib/chef/mixin/create_path.rb b/lib/chef/mixin/create_path.rb
index 455110b1a2..78cf71af0b 100644
--- a/lib/chef/mixin/create_path.rb
+++ b/lib/chef/mixin/create_path.rb
@@ -29,11 +29,11 @@ class Chef
# === Returns
# The created file_path.
def create_path(file_path)
- unless file_path.kind_of?(String) || file_path.kind_of?(Array)
+ unless file_path.is_a?(String) || file_path.is_a?(Array)
raise ArgumentError, "file_path must be a string or an array!"
end
- if file_path.kind_of?(String)
+ if file_path.is_a?(String)
file_path = File.expand_path(file_path).split(File::SEPARATOR)
file_path.shift if file_path[0] == ""
# Check if path starts with a separator or drive letter (Windows)
diff --git a/lib/chef/mixin/deep_merge.rb b/lib/chef/mixin/deep_merge.rb
index 1ecd00eb2d..4f400b7595 100644
--- a/lib/chef/mixin/deep_merge.rb
+++ b/lib/chef/mixin/deep_merge.rb
@@ -30,8 +30,8 @@ class Chef
extend self
def merge(first, second)
- first = Mash.new(first) unless first.kind_of?(Mash)
- second = Mash.new(second) unless second.kind_of?(Mash)
+ first = Mash.new(first) unless first.is_a?(Mash)
+ second = Mash.new(second) unless second.is_a?(Mash)
DeepMerge.deep_merge(second, first)
end
@@ -62,7 +62,7 @@ class Chef
when nil
dest
when Hash
- if dest.kind_of?(Hash)
+ if dest.is_a?(Hash)
source.each do |src_key, src_value|
if dest.key?(src_key)
dest[src_key] = deep_merge!(src_value, dest[src_key])
@@ -74,7 +74,7 @@ class Chef
dest = source
end
when Array
- if dest.kind_of?(Array)
+ if dest.is_a?(Array)
dest |= source
else
dest = source
@@ -103,7 +103,7 @@ class Chef
# values when there is a conflict.
def hash_only_merge!(merge_onto, merge_with)
# If there are two Hashes, recursively merge.
- if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)
+ if merge_onto.is_a?(Hash) && merge_with.is_a?(Hash)
merge_with.each do |key, merge_with_value|
value =
if merge_onto.key?(key)
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
index cb6a99d4f3..ba280f9eb9 100644
--- a/lib/chef/mixin/params_validate.rb
+++ b/lib/chef/mixin/params_validate.rb
@@ -90,13 +90,13 @@ class Chef
# looking for _pv_:symbol as methods. Assuming it find them, it calls the right
# one.
#++
- raise ArgumentError, "Options must be a hash" unless opts.kind_of?(Hash)
- raise ArgumentError, "Validation Map must be a hash" unless map.kind_of?(Hash)
+ raise ArgumentError, "Options must be a hash" unless opts.is_a?(Hash)
+ raise ArgumentError, "Validation Map must be a hash" unless map.is_a?(Hash)
@validation_message ||= {}
map.each do |key, validation|
- unless key.kind_of?(Symbol) || key.kind_of?(String)
+ unless key.is_a?(Symbol) || key.is_a?(String)
raise ArgumentError, "Validation map keys must be symbols or strings!"
end
@@ -194,7 +194,7 @@ class Chef
unless value.nil?
to_be = Array(to_be)
to_be.each do |tb|
- return true if value.kind_of?(tb)
+ return true if value.is_a?(tb)
end
raise Exceptions::ValidationFailed, _validation_message(key, "Option #{key} must be a kind of #{to_be}! You passed #{value.inspect}.")
end
@@ -320,7 +320,7 @@ class Chef
# ```
#
def _pv_callbacks(opts, key, callbacks)
- raise ArgumentError, "Callback list must be a hash!" unless callbacks.kind_of?(Hash)
+ raise ArgumentError, "Callback list must be a hash!" unless callbacks.is_a?(Hash)
value = _pv_opts_lookup(opts, key)
unless value.nil?
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb
index 92e07e4e0f..d90b906f91 100644
--- a/lib/chef/mixin/securable.rb
+++ b/lib/chef/mixin/securable.rb
@@ -44,7 +44,7 @@ class Chef
arg,
callbacks: {
"not in valid numeric range" => lambda do |m|
- if m.kind_of?(String)
+ if m.is_a?(String)
m =~ /^0/ || m = "0#{m}"
end
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index a9c37c92de..1701f00c0f 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -547,7 +547,7 @@ class Chef
end
def self.from_hash(o)
- return o if o.kind_of? Chef::Node
+ return o if o.is_a? Chef::Node
node = new
node.name(o["name"])
@@ -667,7 +667,7 @@ class Chef
end
def ==(other)
- if other.kind_of?(self.class)
+ if other.is_a?(self.class)
name == other.name
else
false
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index ae3e3bd7ac..bc4983384b 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -582,7 +582,7 @@ class Chef
# needed for __path__
def convert_key(key)
- key.kind_of?(Symbol) ? key.to_s : key
+ key.is_a?(Symbol) ? key.to_s : key
end
NIL = Object.new
@@ -590,7 +590,7 @@ class Chef
# @api private
def deep_merge!(merge_onto, merge_with)
# If there are two Hashes, recursively merge.
- if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)
+ if merge_onto.is_a?(Hash) && merge_with.is_a?(Hash)
merge_with.each do |key, merge_with_value|
value =
if merge_onto.key?(key)
@@ -604,7 +604,7 @@ class Chef
end
merge_onto
- elsif merge_onto.kind_of?(Array) && merge_with.kind_of?(Array)
+ elsif merge_onto.is_a?(Array) && merge_with.is_a?(Array)
merge_onto |= merge_with
# If merge_with is NIL, don't replace merge_onto
@@ -613,9 +613,9 @@ class Chef
# In all other cases, replace merge_onto with merge_with
else
- if merge_with.kind_of?(Hash)
+ if merge_with.is_a?(Hash)
Chef::Node::ImmutableMash.new(merge_with)
- elsif merge_with.kind_of?(Array)
+ elsif merge_with.is_a?(Array)
Chef::Node::ImmutableArray.new(merge_with)
else
merge_with
@@ -626,7 +626,7 @@ class Chef
# @api private
def hash_only_merge!(merge_onto, merge_with)
# If there are two Hashes, recursively merge.
- if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)
+ if merge_onto.is_a?(Hash) && merge_with.is_a?(Hash)
merge_with.each do |key, merge_with_value|
value =
if merge_onto.key?(key)
@@ -646,9 +646,9 @@ class Chef
# In all other cases, replace merge_onto with merge_with
else
- if merge_with.kind_of?(Hash)
+ if merge_with.is_a?(Hash)
Chef::Node::ImmutableMash.new(merge_with)
- elsif merge_with.kind_of?(Array)
+ elsif merge_with.is_a?(Array)
Chef::Node::ImmutableArray.new(merge_with)
else
merge_with
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb
index 3e1a2e81c6..88e5b48696 100644
--- a/lib/chef/policy_builder/policyfile.rb
+++ b/lib/chef/policy_builder/policyfile.rb
@@ -340,7 +340,7 @@ class Chef
unless policy.key?("cookbook_locks")
errors << "Policyfile is missing cookbook_locks element"
end
- if run_list.kind_of?(Array)
+ if run_list.is_a?(Array)
run_list_errors = run_list.select do |maybe_recipe_spec|
validate_recipe_spec(maybe_recipe_spec)
end
diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb
index 6859385f7b..3f475f005f 100644
--- a/lib/chef/provider/http_request.rb
+++ b/lib/chef/provider/http_request.rb
@@ -120,7 +120,7 @@ class Chef
private
def check_message(message)
- if message.kind_of?(Proc)
+ if message.is_a?(Proc)
message.call
else
message
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 6e2c139456..93384e456a 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -750,7 +750,7 @@ class Chef
# @see Chef::Resource.action_class
#
def provider(arg = nil)
- klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
+ klass = if arg.is_a?(String) || arg.is_a?(Symbol)
lookup_provider_constant(arg)
else
arg
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
index dd618845bf..81ca2f5600 100644
--- a/lib/chef/resource/link.rb
+++ b/lib/chef/resource/link.rb
@@ -56,7 +56,7 @@ class Chef
property :link_type, [String, Symbol],
description: "The type of link: :symbolic or :hard.",
- coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg },
+ coerce: proc { |arg| arg.is_a?(String) ? arg.to_sym : arg },
equal_to: %i{symbolic hard}, default: :symbolic
property :group, [String, Integer],
diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb
index b800387975..a9e6b3374b 100644
--- a/lib/chef/resource/mount.rb
+++ b/lib/chef/resource/mount.rb
@@ -45,7 +45,7 @@ class Chef
property :device_type, [String, Symbol],
description: "The type of device: :device, :label, or :uuid",
- coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg },
+ coerce: proc { |arg| arg.is_a?(String) ? arg.to_sym : arg },
default: :device,
equal_to: RUBY_PLATFORM =~ /solaris/i ? %i{ device } : %i{ device label uuid }
@@ -62,7 +62,7 @@ class Chef
property :options, [Array, String, nil],
description: "An array or comma separated list of options for the mount.",
- coerce: proc { |arg| arg.kind_of?(String) ? arg.split(",") : arg },
+ coerce: proc { |arg| arg.is_a?(String) ? arg.split(",") : arg },
default: %w{defaults}
property :dump, [Integer, FalseClass],
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index 4b35b18edf..cba3908b0c 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -172,7 +172,7 @@ class Chef
end
def absolute_uri?(source)
- Chef::Provider::RemoteFile::Fetcher.network_share?(source) || (source.kind_of?(String) && as_uri(source).absolute?)
+ Chef::Provider::RemoteFile::Fetcher.network_share?(source) || (source.is_a?(String) && as_uri(source).absolute?)
rescue URI::InvalidURIError
false
end
diff --git a/lib/chef/resource/resource_notification.rb b/lib/chef/resource/resource_notification.rb
index f9cad8232f..7e93fff433 100644
--- a/lib/chef/resource/resource_notification.rb
+++ b/lib/chef/resource/resource_notification.rb
@@ -53,13 +53,13 @@ class Chef
#
# @return [void]
def resolve_resource_reference(resource_collection)
- return resource if resource.kind_of?(Chef::Resource) && notifying_resource.kind_of?(Chef::Resource)
+ return resource if resource.is_a?(Chef::Resource) && notifying_resource.is_a?(Chef::Resource)
- unless resource.kind_of?(Chef::Resource)
+ unless resource.is_a?(Chef::Resource)
fix_resource_reference(resource_collection)
end
- unless notifying_resource.kind_of?(Chef::Resource)
+ unless notifying_resource.is_a?(Chef::Resource)
fix_notifier_reference(resource_collection)
end
end
diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb
index 443dd40470..3ff568b1a1 100644
--- a/lib/chef/resource/template.rb
+++ b/lib/chef/resource/template.rb
@@ -109,7 +109,7 @@ class Chef
"`helper(:method)` requires a block argument (e.g., `helper(:method) { code }`)"
end
- unless method_name.kind_of?(Symbol)
+ unless method_name.is_a?(Symbol)
raise Exceptions::ValidationFailed,
"method_name argument to `helper(method_name)` must be a symbol (e.g., `helper(:method) { code }`)"
end
@@ -163,7 +163,7 @@ class Chef
"Passing both a module and block to #helpers is not supported. Call #helpers multiple times instead"
elsif block_given?
@inline_helper_modules << block
- elsif module_name.kind_of?(::Module)
+ elsif module_name.is_a?(::Module)
@helper_modules << module_name
elsif module_name.nil?
raise Exceptions::ValidationFailed,
diff --git a/lib/chef/resource_collection/resource_collection_serialization.rb b/lib/chef/resource_collection/resource_collection_serialization.rb
index 75adddefb8..57e2e27e6a 100644
--- a/lib/chef/resource_collection/resource_collection_serialization.rb
+++ b/lib/chef/resource_collection/resource_collection_serialization.rb
@@ -58,7 +58,7 @@ class Chef
end
def is_chef_resource!(arg)
- unless arg.kind_of?(Chef::Resource)
+ unless arg.is_a?(Chef::Resource)
raise ArgumentError, "Cannot insert a #{arg.class} into a resource collection: must be a subclass of Chef::Resource"
end
diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb
index c3d7322b5d..6b51ace3c1 100644
--- a/lib/chef/resource_collection/resource_set.rb
+++ b/lib/chef/resource_collection/resource_set.rb
@@ -156,7 +156,7 @@ class Chef
def find_resource_by_hash(arg)
results = []
arg.each do |resource_type, name_list|
- instance_names = name_list.kind_of?(Array) ? name_list : [ name_list ]
+ instance_names = name_list.is_a?(Array) ? name_list : [ name_list ]
instance_names.each do |instance_name|
results << lookup(create_key(resource_type, instance_name))
end
diff --git a/lib/chef/resource_definition.rb b/lib/chef/resource_definition.rb
index d36eef1c6b..40c15a1baa 100644
--- a/lib/chef/resource_definition.rb
+++ b/lib/chef/resource_definition.rb
@@ -35,13 +35,13 @@ class Chef
end
def define(resource_name, prototype_params = nil, &block)
- unless resource_name.kind_of?(Symbol)
+ unless resource_name.is_a?(Symbol)
raise ArgumentError, "You must use a symbol when defining a new resource!"
end
@name = resource_name
if prototype_params
- unless prototype_params.kind_of?(Hash)
+ unless prototype_params.is_a?(Hash)
raise ArgumentError, "You must pass a hash as the prototype parameters for a definition."
end
diff --git a/lib/chef/resource_inspector.rb b/lib/chef/resource_inspector.rb
index 940440de7c..8d92db04b6 100644
--- a/lib/chef/resource_inspector.rb
+++ b/lib/chef/resource_inspector.rb
@@ -25,7 +25,7 @@ require_relative "json_compat"
module ResourceInspector
def self.get_default(default)
- if default.kind_of?(Chef::DelayedEvaluator)
+ if default.is_a?(Chef::DelayedEvaluator)
# ideally we'd get the block we pass to `lazy`, but the best we can do
# is to get the source location, which then results in reparsing the source
# code for the resource ourselves and just no
diff --git a/lib/chef/run_list.rb b/lib/chef/run_list.rb
index de9e4ad612..e04e763fe6 100644
--- a/lib/chef/run_list.rb
+++ b/lib/chef/run_list.rb
@@ -70,7 +70,7 @@ class Chef
alias :add :<<
def ==(other)
- if other.kind_of?(Chef::RunList)
+ if other.is_a?(Chef::RunList)
other.run_list_items == @run_list_items
else
return false unless other.respond_to?(:size) && (other.size == @run_list_items.size)
@@ -123,7 +123,7 @@ class Chef
def reset!(*args)
@run_list_items.clear
args.flatten.each do |item|
- if item.kind_of?(Chef::RunList)
+ if item.is_a?(Chef::RunList)
item.each { |r| self << r }
else
self << item
@@ -153,7 +153,7 @@ class Chef
end
def coerce_to_run_list_item(item)
- item.kind_of?(RunListItem) ? item : parse_entry(item)
+ item.is_a?(RunListItem) ? item : parse_entry(item)
end
def expansion_for_data_source(environment, data_source, opts = {})
diff --git a/lib/chef/run_list/run_list_item.rb b/lib/chef/run_list/run_list_item.rb
index e9e4f85ce3..30b9bbe562 100644
--- a/lib/chef/run_list/run_list_item.rb
+++ b/lib/chef/run_list/run_list_item.rb
@@ -80,7 +80,7 @@ class Chef
end
def ==(other)
- if other.kind_of?(String)
+ if other.is_a?(String)
to_s == other.to_s
else
other.respond_to?(:type) && other.respond_to?(:name) && other.respond_to?(:version) && other.type == @type && other.name == @name && other.version == @version
diff --git a/lib/chef/runner.rb b/lib/chef/runner.rb
index f3f4c9e9d9..c1d4a9b3a9 100644
--- a/lib/chef/runner.rb
+++ b/lib/chef/runner.rb
@@ -118,7 +118,7 @@ class Chef
collected_failures.client_run_failure(error) unless error.nil?
delayed_actions.each do |notification|
result = run_delayed_notification(notification)
- if result.kind_of?(Exception)
+ if result.is_a?(Exception)
collected_failures.notification_failure(result)
end
end
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index d80f5d810a..5a9c1f6d41 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -113,7 +113,7 @@ class Chef
end
def validate_type(t)
- unless t.kind_of?(String) || t.kind_of?(Symbol)
+ unless t.is_a?(String) || t.is_a?(Symbol)
msg = "Invalid search object type #{t.inspect} (#{t.class}), must be a String or Symbol." +
"Usage: search(:node, QUERY[, OPTIONAL_ARGS])" +
" `knife search environment QUERY (options)`"
diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb
index 5260832e91..843126b4f2 100644
--- a/lib/chef/shell/ext.rb
+++ b/lib/chef/shell/ext.rb
@@ -47,8 +47,8 @@ module Shell
unless jobs.respond_to?(:session_select)
def jobs.select_shell_session(target_context) # rubocop:disable Lint/NestedMethodDefinition
- session = if target_context.kind_of?(Class)
- select_session_by_context { |main| main.kind_of?(target_context) }
+ session = if target_context.is_a?(Class)
+ select_session_by_context { |main| main.is_a?(target_context) }
else
select_session_by_context { |main| main.equal?(target_context) }
end
diff --git a/lib/chef/shell/model_wrapper.rb b/lib/chef/shell/model_wrapper.rb
index bfeadc8793..0ad4329c7f 100644
--- a/lib/chef/shell/model_wrapper.rb
+++ b/lib/chef/shell/model_wrapper.rb
@@ -82,7 +82,7 @@ module Shell
# the user wanted instead of the URI=>object stuff
def list_objects
objects = @model_class.method(:list).arity == 0 ? @model_class.list : @model_class.list(true)
- objects.map { |obj| Array(obj).find { |o| o.kind_of?(@model_class) } }
+ objects.map { |obj| Array(obj).find { |o| o.is_a?(@model_class) } }
end
def format_query(query)
diff --git a/lib/chef/whitelist.rb b/lib/chef/whitelist.rb
index 3f23aff240..8309580e81 100644
--- a/lib/chef/whitelist.rb
+++ b/lib/chef/whitelist.rb
@@ -73,7 +73,7 @@ class Chef
# assumed to contain exact keys (that is, Array elements will not be split
# by "/").
def self.to_array(item)
- return item if item.kind_of? Array
+ return item if item.is_a? Array
parts = item.split("/")
parts.shift if !parts.empty? && parts[0].empty?