diff options
92 files changed, 158 insertions, 158 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb index 5c78da41ec..c2dec0a86f 100644 --- a/lib/chef/api_client.rb +++ b/lib/chef/api_client.rb @@ -157,7 +157,7 @@ class Chef def self.list(inflate = false) if inflate - response = Hash.new + response = {} Chef::Search::Query.new.search(:client) do |n| n = json_create(n) if n.instance_of?(Hash) response[n.name] = n diff --git a/lib/chef/api_client_v1.rb b/lib/chef/api_client_v1.rb index 20d1989d38..f3f83cad4e 100644 --- a/lib/chef/api_client_v1.rb +++ b/lib/chef/api_client_v1.rb @@ -190,7 +190,7 @@ class Chef def self.list(inflate = false) if inflate - response = Hash.new + response = {} Chef::Search::Query.new.search(:client) do |n| n = from_hash(n) if n.instance_of?(Hash) response[n.name] = n diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb index 13c0332cd8..34ece80e19 100644 --- a/lib/chef/cookbook_manifest.rb +++ b/lib/chef/cookbook_manifest.rb @@ -223,7 +223,7 @@ class Chef # See #preferred_manifest_record for a description an individual manifest record. def generate_manifest manifest = Mash.new({ - all_files: Array.new, + all_files: [], }) @checksums = {} diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index e149947603..959318a020 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -96,7 +96,7 @@ class Chef @root_paths = root_paths @frozen = false - @all_files = Array.new + @all_files = [] @file_vendor = nil @cookbook_manifest = Chef::CookbookManifest.new(self) @@ -279,8 +279,8 @@ class Chef def relative_filenames_in_preferred_directory(node, segment, dirname) preferences = preferences_for_path(node, segment, dirname) - filenames_by_pref = Hash.new - preferences.each { |pref| filenames_by_pref[pref] = Array.new } + filenames_by_pref = {} + preferences.each { |pref| filenames_by_pref[pref] = [] } files_for(segment).each do |manifest_record| manifest_record_path = manifest_record[:path] @@ -319,8 +319,8 @@ class Chef # description of entries of the returned Array. def preferred_manifest_records_for_directory(node, segment, dirname) preferences = preferences_for_path(node, segment, dirname) - records_by_pref = Hash.new - preferences.each { |pref| records_by_pref[pref] = Array.new } + records_by_pref = {} + preferences.each { |pref| records_by_pref[pref] = [] } files_for(segment).each do |manifest_record| manifest_record_path = manifest_record[:path] diff --git a/lib/chef/dsl/data_query.rb b/lib/chef/dsl/data_query.rb index 88562df190..ad60852087 100644 --- a/lib/chef/dsl/data_query.rb +++ b/lib/chef/dsl/data_query.rb @@ -38,7 +38,7 @@ class Chef if Kernel.block_given? || args.length >= 4 Chef::Search::Query.new.search(*args, &block) else - results = Array.new + results = [] Chef::Search::Query.new.search(*args) do |o| results << o end diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index 6633813762..476aeb4867 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -42,7 +42,7 @@ class Chef @description = "" @default_attributes = Mash.new @override_attributes = Mash.new - @cookbook_versions = Hash.new + @cookbook_versions = {} @chef_server_rest = chef_server_rest end @@ -158,7 +158,7 @@ class Chef # reset because everything we need will be in the params, this is necessary because certain constraints # may have been removed in the params and need to be removed from cookbook_versions as well. bkup_cb_versions = cookbook_versions - cookbook_versions(Hash.new) + cookbook_versions({}) valid = true begin @@ -229,7 +229,7 @@ class Chef def self.list(inflate = false) if inflate - response = Hash.new + response = {} Chef::Search::Query.new.search(:environment) do |e| response[e.name] = e unless e.nil? end diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb index 1955dbb165..2d4a56a91b 100644 --- a/lib/chef/file_cache.rb +++ b/lib/chef/file_cache.rb @@ -158,7 +158,7 @@ class Chef # === Returns # [String] - An array of file cache keys matching the glob def find(glob_pattern) - keys = Array.new + keys = [] Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(file_cache_path), glob_pattern)].each do |f| if File.file?(f) keys << f[/^#{Regexp.escape(Dir[Chef::Util::PathHelper.escape_glob_dir(file_cache_path)].first) + File::Separator}(.+)/, 1] diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 927b47ee0a..4be53af5c8 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -283,9 +283,9 @@ class Chef long: "--hint HINT_NAME[=HINT_FILE]", description: "Specify an Ohai hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.", proc: Proc.new { |h| - Chef::Config[:knife][:hints] ||= Hash.new + Chef::Config[:knife][:hints] ||= {} name, path = h.split("=") - Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : Hash.new + Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : {} } # bootstrap override: url of a an installer shell script touse in place of omnitruck diff --git a/lib/chef/knife/cookbook_show.rb b/lib/chef/knife/cookbook_show.rb index d1e7220650..97e771a183 100644 --- a/lib/chef/knife/cookbook_show.rb +++ b/lib/chef/knife/cookbook_show.rb @@ -57,7 +57,7 @@ class Chef case @name_args.length when 4 # We are showing a specific file - node = Hash.new + node = {} node[:fqdn] = config[:fqdn] if config.key?(:fqdn) node[:platform] = config[:platform] if config.key?(:platform) node[:platform_version] = config[:platform_version] if config.key?(:platform_version) diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index 96a4c766a5..6ee0d1ea06 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -207,7 +207,7 @@ class Chef def format_cookbook_list_for_display(item) if config[:with_uri] item.inject({}) do |collected, (cookbook, versions)| - collected[cookbook] = Hash.new + collected[cookbook] = {} versions["versions"].each do |ver| collected[cookbook][ver["version"]] = ver["url"] end diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb index 820c572f1f..8bf419e49a 100644 --- a/lib/chef/knife/core/status_presenter.rb +++ b/lib/chef/knife/core/status_presenter.rb @@ -108,7 +108,7 @@ class Chef end end - line_parts = Array.new + line_parts = [] if node["ohai_time"] hours, minutes, seconds = time_difference_in_hms(node["ohai_time"]) diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb index 050c9b404f..78cf2df3a5 100644 --- a/lib/chef/knife/data_bag_from_file.rb +++ b/lib/chef/knife/data_bag_from_file.rb @@ -98,7 +98,7 @@ class Chef end def normalize_item_paths(args) - paths = Array.new + paths = [] args.each do |path| if File.directory?(path) paths.concat(Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path), "*.json"))) diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb index b2aa7b5dc9..a089ee8f1b 100644 --- a/lib/chef/knife/search.rb +++ b/lib/chef/knife/search.rb @@ -83,7 +83,7 @@ class Chef result_items = [] result_count = 0 - search_args = Hash.new + search_args = {} search_args[:fuzz] = true search_args[:start] = config[:start] if config[:start] search_args[:rows] = config[:rows] if config[:rows] @@ -97,7 +97,7 @@ class Chef begin q.search(@type, @query, search_args) do |item| - formatted_item = Hash.new + formatted_item = {} if config[:id_only] formatted_item = format_for_display({ "id" => item["__display_name"] }) elsif item.is_a?(Hash) @@ -169,7 +169,7 @@ class Chef # and the path is an array with the path elements as strings (in order) # See lib/chef/search/query.rb for more examples of this. def create_result_filter(filter_string) - final_filter = Hash.new + final_filter = {} filter_string.delete!(" ") filters = filter_string.split(",") filters.each do |f| @@ -180,7 +180,7 @@ class Chef end def create_result_filter_from_attributes(filter_array) - final_filter = Hash.new + final_filter = {} filter_array.each do |f| final_filter[f] = f.split(".") end diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index 301839b2b7..78cf238848 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -225,7 +225,7 @@ class Chef end def search_nodes - list = Array.new + list = [] query = Chef::Search::Query.new required_attributes = { fqdn: ["fqdn"], cloud: ["cloud"] } @@ -433,7 +433,7 @@ class Chef break when /^on (.+?); (.+)$/ raw_list = $1.split(" ") - server_list = Array.new + server_list = [] session.servers.each do |session_server| server_list << session_server if raw_list.include?(session_server.host) end diff --git a/lib/chef/knife/supermarket_list.rb b/lib/chef/knife/supermarket_list.rb index ee0ed0b54c..700d928af8 100644 --- a/lib/chef/knife/supermarket_list.rb +++ b/lib/chef/knife/supermarket_list.rb @@ -39,7 +39,7 @@ class Chef def run if config[:with_uri] - cookbooks = Hash.new + cookbooks = {} get_cookbook_list.each { |k, v| cookbooks[k] = v["cookbook"] } ui.output(format_for_display(cookbooks)) else diff --git a/lib/chef/knife/tag_delete.rb b/lib/chef/knife/tag_delete.rb index e7e6e21a38..1c9f2185d7 100644 --- a/lib/chef/knife/tag_delete.rb +++ b/lib/chef/knife/tag_delete.rb @@ -41,7 +41,7 @@ class Chef end node = Chef::Node.load name - deleted_tags = Array.new + deleted_tags = [] tags.each do |tag| unless node.tags.delete(tag).nil? deleted_tags << tag diff --git a/lib/chef/mixin/api_version_request_handling.rb b/lib/chef/mixin/api_version_request_handling.rb index a4e657ac9e..c2f7a3203f 100644 --- a/lib/chef/mixin/api_version_request_handling.rb +++ b/lib/chef/mixin/api_version_request_handling.rb @@ -35,7 +35,7 @@ class Chef return nil if exception.response.code != "406" || exception.response["x-ops-server-api-version"].nil? # intersection of versions the server and client support, will be of length zero if no intersection - server_supported_client_versions = Array.new + server_supported_client_versions = [] header = Chef::JSONCompat.from_json(exception.response["x-ops-server-api-version"]) min_server_version = Integer(header["min_version"]) diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb index 96e1b8d34e..ec7f675825 100644 --- a/lib/chef/mixin/windows_architecture_helper.rb +++ b/lib/chef/mixin/windows_architecture_helper.rb @@ -49,8 +49,8 @@ class Chef node ||= begin os_arch = ENV["PROCESSOR_ARCHITEW6432"] || ENV["PROCESSOR_ARCHITECTURE"] - Hash.new.tap do |n| - n[:kernel] = Hash.new + {}.tap do |n| + n[:kernel] = {} n[:kernel][:machine] = os_arch == "AMD64" ? :x86_64 : :i386 end end diff --git a/lib/chef/node.rb b/lib/chef/node.rb index cefd656609..a9c37c92de 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -580,7 +580,7 @@ class Chef def self.list_by_environment(environment, inflate = false) if inflate - response = Hash.new + response = {} Chef::Search::Query.new.search(:node, "chef_environment:#{environment}") { |n| response[n.name] = n unless n.nil? } response else @@ -590,7 +590,7 @@ class Chef def self.list(inflate = false) if inflate - response = Hash.new + response = {} Chef::Search::Query.new.search(:node) do |n| n = Chef::Node.from_hash(n) response[n.name] = n unless n.nil? diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index 994d5c37e4..b4a7a39ba0 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -151,7 +151,7 @@ class Chef end def to_h - h = Hash.new + h = {} each_pair do |k, v| h[k] = case v diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 992d2ae144..6a196081ca 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -117,11 +117,11 @@ class Chef @int_name = "nil" elsif line.match(addr_regex)[2] == "" @int_name = line.match(addr_regex)[1] - @interfaces[@int_name] = Hash.new + @interfaces[@int_name] = {} @interfaces[@int_name]["mtu"] = (line =~ /mtu (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /mtu/ && @interfaces[@int_name]["mtu"].nil? else @int_name = "#{line.match(addr_regex)[1]}:#{line.match(addr_regex)[2]}" - @interfaces[@int_name] = Hash.new + @interfaces[@int_name] = {} @interfaces[@int_name]["mtu"] = (line =~ /mtu (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /mtu/ && @interfaces[@int_name]["mtu"].nil? end else diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb index 838cac4b5a..154072827e 100644 --- a/lib/chef/recipe.rb +++ b/lib/chef/recipe.rb @@ -59,7 +59,7 @@ class Chef @recipe_name = recipe_name @run_context = run_context # TODO: 5/19/2010 cw/tim: determine whether this can be removed - @params = Hash.new + @params = {} end # Used in DSL mixins diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index d5f830063f..eea44e5c69 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -121,7 +121,7 @@ class Chef end @before = nil - @params = Hash.new + @params = {} @provider = nil @allowed_actions = self.class.allowed_actions.to_a @action = self.class.default_action @@ -676,7 +676,7 @@ class Chef # json is encoded as expected def as_json(*a) safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS - instance_vars = Hash.new + instance_vars = {} safe_ivars.each do |iv| instance_vars[iv.to_s.sub(/^@/, "")] = instance_variable_get(iv) end diff --git a/lib/chef/resource/apt_package.rb b/lib/chef/resource/apt_package.rb index b94c480a29..020905d86a 100644 --- a/lib/chef/resource/apt_package.rb +++ b/lib/chef/resource/apt_package.rb @@ -42,7 +42,7 @@ class Chef property :response_file_variables, Hash, description: "A Hash of response file variables in the form of {'VARIABLE' => 'VALUE'}.", - default: lazy { Hash.new }, desired_state: false + default: lazy { {} }, desired_state: false end end diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb index ad8e228152..dbc6a998cc 100644 --- a/lib/chef/resource/cron.rb +++ b/lib/chef/resource/cron.rb @@ -160,7 +160,7 @@ class Chef property :environment, Hash, description: "A Hash of environment variables in the form of ({'ENV_VARIABLE' => 'VALUE'}).", - default: lazy { Hash.new } + default: lazy { {} } private diff --git a/lib/chef/resource/cron_d.rb b/lib/chef/resource/cron_d.rb index 2c3b0bcb9f..3ebf415c50 100644 --- a/lib/chef/resource/cron_d.rb +++ b/lib/chef/resource/cron_d.rb @@ -159,7 +159,7 @@ class Chef property :environment, Hash, description: "A Hash containing additional arbitrary environment variables under which the cron job will be run in the form of ``({'ENV_VARIABLE' => 'VALUE'})``.", - default: lazy { Hash.new } + default: lazy { {} } property :mode, [String, Integer], description: "The octal mode of the generated crontab file.", diff --git a/lib/chef/resource/dpkg_package.rb b/lib/chef/resource/dpkg_package.rb index 9e49dded46..116e17d6a6 100644 --- a/lib/chef/resource/dpkg_package.rb +++ b/lib/chef/resource/dpkg_package.rb @@ -35,7 +35,7 @@ class Chef property :response_file_variables, Hash, description: "A Hash of response file variables in the form of {'VARIABLE' => 'VALUE'}.", - default: lazy { Hash.new }, desired_state: false + default: lazy { {} }, desired_state: false end end end diff --git a/lib/chef/resource/git.rb b/lib/chef/resource/git.rb index dfb2921f97..4d5f4ac091 100644 --- a/lib/chef/resource/git.rb +++ b/lib/chef/resource/git.rb @@ -25,7 +25,7 @@ class Chef property :additional_remotes, Hash, description: "A Hash of additional remotes that are added to the git repository configuration.", - default: lazy { Hash.new } + default: lazy { {} } alias :branch :revision alias :reference :revision diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb index efcb807ed4..efcb379640 100644 --- a/lib/chef/resource/http_request.rb +++ b/lib/chef/resource/http_request.rb @@ -33,7 +33,7 @@ class Chef property :url, String, identity: true, description: "The URL to which an HTTP request is sent." - property :headers, Hash, default: lazy { Hash.new }, + property :headers, Hash, default: lazy { {} }, description: "A Hash of custom headers." def initialize(name, run_context = nil) diff --git a/lib/chef/resource/openssl_x509_certificate.rb b/lib/chef/resource/openssl_x509_certificate.rb index 54971e421d..20cf998239 100644 --- a/lib/chef/resource/openssl_x509_certificate.rb +++ b/lib/chef/resource/openssl_x509_certificate.rb @@ -70,7 +70,7 @@ class Chef property :extensions, Hash, description: "Hash of X509 Extensions entries, in format { 'keyUsage' => { 'values' => %w( keyEncipherment digitalSignature), 'critical' => true } }.", - default: lazy { Hash.new } + default: lazy { {} } property :subject_alt_name, Array, description: "Array of Subject Alternative Name entries, in format DNS:example.com or IP:1.2.3.4.", diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index 7dcfeb3c2c..4b35b18edf 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -88,7 +88,7 @@ class Chef property :ftp_active_mode, [ TrueClass, FalseClass ], default: false - property :headers, Hash, default: lazy { Hash.new } + property :headers, Hash, default: lazy { {} } property :show_progress, [ TrueClass, FalseClass ], default: false diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index 27002c4a03..443dd40470 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -60,7 +60,7 @@ class Chef property :variables, Hash, description: "The variables property of the template resource can be used to reference a partial template file by using a Hash.", - default: lazy { Hash.new } + default: lazy { {} } property :cookbook, String, description: "The cookbook in which a file is located (if it is not located in the current cookbook). The default value is the current cookbook.", diff --git a/lib/chef/resource_collection/resource_collection_serialization.rb b/lib/chef/resource_collection/resource_collection_serialization.rb index fb9480a780..75adddefb8 100644 --- a/lib/chef/resource_collection/resource_collection_serialization.rb +++ b/lib/chef/resource_collection/resource_collection_serialization.rb @@ -23,7 +23,7 @@ class Chef module ResourceCollectionSerialization # Serialize this object as a hash def to_h - instance_vars = Hash.new + instance_vars = {} instance_variables.each do |iv| instance_vars[iv] = instance_variable_get(iv) end diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb index afd80799a1..2bcbc8de0f 100644 --- a/lib/chef/resource_collection/resource_list.rb +++ b/lib/chef/resource_collection/resource_list.rb @@ -40,7 +40,7 @@ class Chef def_delegators :resources, *(direct_access_methods) def initialize - @resources = Array.new + @resources = [] @insert_after_idx = nil end diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb index c515e68b38..c3d7322b5d 100644 --- a/lib/chef/resource_collection/resource_set.rb +++ b/lib/chef/resource_collection/resource_set.rb @@ -36,7 +36,7 @@ class Chef NAMELESS_RESOURCE_MATCH = /^([^\[\]\s]+)$/.freeze def initialize - @resources_by_key = Hash.new + @resources_by_key = {} end def keys @@ -89,7 +89,7 @@ class Chef # Raises an ArgumentError if you feed it bad lookup information # Raises a Runtime Error if it can't find the resources you are looking for. def find(*args) - results = Array.new + results = [] args.each do |arg| case arg when Hash @@ -154,7 +154,7 @@ class Chef end def find_resource_by_hash(arg) - results = Array.new + results = [] arg.each do |resource_type, name_list| instance_names = name_list.kind_of?(Array) ? name_list : [ name_list ] instance_names.each do |instance_name| @@ -174,7 +174,7 @@ class Chef rescue Chef::Exceptions::ResourceNotFound => e if arg =~ MULTIPLE_RESOURCE_MATCH begin - results = Array.new + results = [] resource_type = $1 arg =~ /^.+\[(.+)\]$/ resource_list = $1 diff --git a/lib/chef/resource_definition.rb b/lib/chef/resource_definition.rb index 9d91fb4cb3..d36eef1c6b 100644 --- a/lib/chef/resource_definition.rb +++ b/lib/chef/resource_definition.rb @@ -29,7 +29,7 @@ class Chef def initialize(node = nil) @name = nil - @params = Hash.new + @params = {} @recipe = nil @node = node end diff --git a/lib/chef/resource_definition_list.rb b/lib/chef/resource_definition_list.rb index 0dbc115ada..d28a8f4bd5 100644 --- a/lib/chef/resource_definition_list.rb +++ b/lib/chef/resource_definition_list.rb @@ -26,7 +26,7 @@ class Chef attr_accessor :defines def initialize - @defines = Hash.new + @defines = {} end def define(resource_name, prototype_params = nil, &block) diff --git a/lib/chef/role.rb b/lib/chef/role.rb index a73b9d5183..0652708f70 100644 --- a/lib/chef/role.rb +++ b/lib/chef/role.rb @@ -192,7 +192,7 @@ class Chef # Get the list of all roles from the API. def self.list(inflate = false) if inflate - response = Hash.new + response = {} Chef::Search::Query.new.search(:role) do |n| response[n.name] = n unless n.nil? end diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb index 49b904aeed..467b2997fd 100644 --- a/lib/chef/run_context.rb +++ b/lib/chef/run_context.rb @@ -185,7 +185,7 @@ class Chef @logger = logger || Chef::Log.with_child @cookbook_collection = cookbook_collection self.node = node if node - @definitions = Hash.new + @definitions = {} @loaded_recipes_hash = {} @loaded_attributes_hash = {} @reboot_info = {} @@ -313,7 +313,7 @@ class Chef # @see DSL::IncludeRecipe#include_recipe # def include_recipe(*recipe_names, current_cookbook: nil) - result_recipes = Array.new + result_recipes = [] recipe_names.flatten.each do |recipe_name| if result = load_recipe(recipe_name, current_cookbook: current_cookbook) result_recipes << result diff --git a/lib/chef/run_list/run_list_expansion.rb b/lib/chef/run_list/run_list_expansion.rb index c60a7e64d3..99fcdcfd58 100644 --- a/lib/chef/run_list/run_list_expansion.rb +++ b/lib/chef/run_list/run_list_expansion.rb @@ -64,7 +64,7 @@ class Chef def initialize(environment, run_list_items, source = nil) @environment = environment - @missing_roles_with_including_role = Array.new + @missing_roles_with_including_role = [] @run_list_items = run_list_items.dup @source = source diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb index 182c749b46..6083dae953 100644 --- a/lib/chef/run_list/versioned_recipe_list.rb +++ b/lib/chef/run_list/versioned_recipe_list.rb @@ -26,7 +26,7 @@ class Chef def initialize super - @versions = Hash.new + @versions = {} end def add_recipe(name, version = nil) diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb index 46e5c15b8f..d80f5d810a 100644 --- a/lib/chef/search/query.rb +++ b/lib/chef/search/query.rb @@ -122,10 +122,10 @@ class Chef end def hashify_args(*args) - return Hash.new if args.empty? + return {} if args.empty? return args.first if args.first.is_a?(Hash) - args_h = Hash.new + args_h = {} # If we have 4 arguments, the first is the now-removed sort option, so # just ignore it. args.pop(0) if args.length == 4 diff --git a/lib/chef/train_transport.rb b/lib/chef/train_transport.rb index fdb4b5305a..fa7e85c9c1 100644 --- a/lib/chef/train_transport.rb +++ b/lib/chef/train_transport.rb @@ -94,7 +94,7 @@ class Chef def self.build_transport(logger = Chef::Log.with_child(subsystem: "transport")) # TODO: Consider supporting parsing the protocol from a URI passed to `--target` # - train_config = Hash.new + train_config = {} # Load the target_mode config context from Chef::Config, and place any valid settings into the train configuration tm_config = Chef::Config.target_mode diff --git a/lib/chef/user.rb b/lib/chef/user.rb index 99ade65150..91749cc158 100644 --- a/lib/chef/user.rb +++ b/lib/chef/user.rb @@ -181,7 +181,7 @@ class Chef # into the form # { "USERNAME" => "URI" } def self.transform_ohc_list_response(response) - new_response = Hash.new + new_response = {} response.each do |u| name = u["user"]["username"] new_response[name] = Chef::Config[:chef_server_url] + "/users/#{name}" diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb index baf3a67ec5..786bc3a057 100644 --- a/lib/chef/user_v1.rb +++ b/lib/chef/user_v1.rb @@ -313,7 +313,7 @@ class Chef # into the form # { "USERNAME" => "URI" } def self.transform_list_response(response) - new_response = Hash.new + new_response = {} response.each do |u| name = u["user"]["username"] new_response[name] = Chef::Config[:chef_server_url] + "/users/#{name}" diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb index 63cc16fa39..e6c6147b42 100644 --- a/lib/chef/util/dsc/lcm_output_parser.rb +++ b/lib/chef/util/dsc/lcm_output_parser.rb @@ -80,7 +80,7 @@ class Chef def self.test_dsc_parser(lcm_output) lcm_output ||= "" - current_resource = Hash.new + current_resource = {} resources = [] lcm_output.lines.each do |line| @@ -110,7 +110,7 @@ class Chef def self.what_if_parser(lcm_output) lcm_output ||= "" - current_resource = Hash.new + current_resource = {} resources = [] lcm_output.lines.each do |line| diff --git a/lib/chef/util/windows/net_use.rb b/lib/chef/util/windows/net_use.rb index 0c870b5121..9e6735429b 100644 --- a/lib/chef/util/windows/net_use.rb +++ b/lib/chef/util/windows/net_use.rb @@ -38,7 +38,7 @@ class Chef::Util::Windows::NetUse < Chef::Util::Windows def add(args) if args.class == String remote = args - args = Hash.new + args = {} args[:remote] = remote end args[:local] ||= use_name diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb index 93e09d3c83..7994bd3c12 100644 --- a/lib/chef/win32/version.rb +++ b/lib/chef/win32/version.rb @@ -80,7 +80,7 @@ class Chef @sku = get_product_info(@major_version, @minor_version, @sp_major_version, @sp_minor_version) end - marketing_names = Array.new + marketing_names = [] # General Windows checks WIN_VERSIONS.each do |k, v| diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb index 855a38b9cf..89701802b3 100644 --- a/spec/functional/dsl/reboot_pending_spec.rb +++ b/spec/functional/dsl/reboot_pending_spec.rb @@ -36,7 +36,7 @@ describe Chef::DSL::RebootPending, :windows_only do let(:reg_key) { nil } let(:original_set) { false } - before(:all) { @any_flag = Hash.new } + before(:all) { @any_flag = {} } after { @any_flag[reg_key] = original_set } diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index 95e7b6454c..929c4dc693 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -31,7 +31,7 @@ describe Chef::Knife::Ssh do @server.stop end - let(:ssh_config) { Hash.new } + let(:ssh_config) { {} } before do allow(Net::SSH).to receive(:configuration_for).and_return(ssh_config) end diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb index 0354c3a33c..3b07fdd367 100644 --- a/spec/support/shared/unit/platform_introspector.rb +++ b/spec/support/shared/unit/platform_introspector.rb @@ -43,7 +43,7 @@ shared_examples_for "a platform introspector" do end it "returns a default value when there is no known platform" do - node = Hash.new + node = {} expect(platform_introspector.value_for_platform(@platform_hash)).to eq("default") end diff --git a/spec/support/shared/unit/windows_script_resource.rb b/spec/support/shared/unit/windows_script_resource.rb index 5b559bb83b..29238a3917 100644 --- a/spec/support/shared/unit/windows_script_resource.rb +++ b/spec/support/shared/unit/windows_script_resource.rb @@ -25,7 +25,7 @@ shared_examples_for "a Windows script resource" do before(:each) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s run_context = Chef::RunContext.new(node, nil, nil) diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb index e6b2eec820..f36cbc721d 100644 --- a/spec/unit/api_client_spec.rb +++ b/spec/unit/api_client_spec.rb @@ -41,7 +41,7 @@ describe Chef::ApiClient do end it "only allows string values for the name" do - expect { @client.name Hash.new }.to raise_error(ArgumentError) + expect { @client.name({}) }.to raise_error(ArgumentError) end it "has an admin flag attribute" do @@ -55,7 +55,7 @@ describe Chef::ApiClient do it "allows only boolean values for the admin flag" do expect { @client.admin(false) }.not_to raise_error - expect { @client.admin(Hash.new) }.to raise_error(ArgumentError) + expect { @client.admin({}) }.to raise_error(ArgumentError) end it "has a 'validator' flag attribute" do @@ -69,7 +69,7 @@ describe Chef::ApiClient do it "allows only boolean values for the 'validator' flag" do expect { @client.validator(false) }.not_to raise_error - expect { @client.validator(Hash.new) }.to raise_error(ArgumentError) + expect { @client.validator({}) }.to raise_error(ArgumentError) end it "has a public key attribute" do @@ -79,7 +79,7 @@ describe Chef::ApiClient do it "accepts only String values for the public key" do expect { @client.public_key "" }.not_to raise_error - expect { @client.public_key Hash.new }.to raise_error(ArgumentError) + expect { @client.public_key({}) }.to raise_error(ArgumentError) end it "has a private key attribute" do @@ -89,7 +89,7 @@ describe Chef::ApiClient do it "accepts only String values for the private key" do expect { @client.private_key "" }.not_to raise_error - expect { @client.private_key Hash.new }.to raise_error(ArgumentError) + expect { @client.private_key({}) }.to raise_error(ArgumentError) end describe "when serializing to JSON" do diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb index 6c4e7fe188..3bad466a13 100644 --- a/spec/unit/api_client_v1_spec.rb +++ b/spec/unit/api_client_v1_spec.rb @@ -36,7 +36,7 @@ describe Chef::ApiClientV1 do end it "only allows string values for the name" do - expect { @client.name Hash.new }.to raise_error(ArgumentError) + expect { @client.name({}) }.to raise_error(ArgumentError) end it "has an admin flag attribute" do @@ -50,7 +50,7 @@ describe Chef::ApiClientV1 do it "allows only boolean values for the admin flag" do expect { @client.admin(false) }.not_to raise_error - expect { @client.admin(Hash.new) }.to raise_error(ArgumentError) + expect { @client.admin({}) }.to raise_error(ArgumentError) end it "has an create_key flag attribute" do @@ -64,7 +64,7 @@ describe Chef::ApiClientV1 do it "allows only boolean values for the create_key flag" do expect { @client.create_key(false) }.not_to raise_error - expect { @client.create_key(Hash.new) }.to raise_error(ArgumentError) + expect { @client.create_key({}) }.to raise_error(ArgumentError) end it "has a 'validator' flag attribute" do @@ -78,7 +78,7 @@ describe Chef::ApiClientV1 do it "allows only boolean values for the 'validator' flag" do expect { @client.validator(false) }.not_to raise_error - expect { @client.validator(Hash.new) }.to raise_error(ArgumentError) + expect { @client.validator({}) }.to raise_error(ArgumentError) end it "has a public key attribute" do @@ -88,7 +88,7 @@ describe Chef::ApiClientV1 do it "accepts only String values for the public key" do expect { @client.public_key "" }.not_to raise_error - expect { @client.public_key Hash.new }.to raise_error(ArgumentError) + expect { @client.public_key({}) }.to raise_error(ArgumentError) end it "has a private key attribute" do @@ -98,7 +98,7 @@ describe Chef::ApiClientV1 do it "accepts only String values for the private key" do expect { @client.private_key "" }.not_to raise_error - expect { @client.private_key Hash.new }.to raise_error(ArgumentError) + expect { @client.private_key({}) }.to raise_error(ArgumentError) end describe "when serializing to JSON" do diff --git a/spec/unit/chef_fs/config_spec.rb b/spec/unit/chef_fs/config_spec.rb index f552d454d0..bdb9bc2c72 100644 --- a/spec/unit/chef_fs/config_spec.rb +++ b/spec/unit/chef_fs/config_spec.rb @@ -23,7 +23,7 @@ require "lib/chef/chef_fs/config.rb" describe Chef::ChefFS::Config do describe "initialize" do it "warns when hosted setups use 'everything'" do - base_config = Hash.new + base_config = {} base_config[:repo_mode] = "everything" base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/" @@ -34,7 +34,7 @@ describe Chef::ChefFS::Config do end it "doesn't warn when hosted setups use 'hosted_everything'" do - base_config = Hash.new + base_config = {} base_config[:repo_mode] = "hosted_everything" base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/" @@ -45,7 +45,7 @@ describe Chef::ChefFS::Config do end it "doesn't warn when non-hosted setups use 'everything'" do - base_config = Hash.new + base_config = {} base_config[:repo_mode] = "everything" base_config[:chef_server_url] = "http://foo.com/" diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb index 9180f13f33..ba9f59c97b 100644 --- a/spec/unit/cookbook_loader_spec.rb +++ b/spec/unit/cookbook_loader_spec.rb @@ -88,7 +88,7 @@ describe Chef::CookbookLoader do describe "each" do it "should allow you to iterate over cookbooks with each" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end @@ -97,7 +97,7 @@ describe Chef::CookbookLoader do end it "should iterate in alphabetical order" do - seen = Array.new + seen = [] cookbook_loader.each_key do |cookbook_name| seen << cookbook_name end @@ -173,7 +173,7 @@ describe Chef::CookbookLoader do end it "should have loaded the correct cookbook" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end @@ -203,7 +203,7 @@ describe Chef::CookbookLoader do end it "should not load the other cookbooks" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end @@ -239,7 +239,7 @@ describe Chef::CookbookLoader do end it "should load all cookbooks" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index 3c3420a55a..78953c6b6f 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -43,7 +43,7 @@ describe Chef::DataBagItem do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { data_bag_item.data_bag Hash.new }.to raise_error(ArgumentError) + expect { data_bag_item.data_bag({}) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb index 388c35232f..4b0ba42172 100644 --- a/spec/unit/data_bag_spec.rb +++ b/spec/unit/data_bag_spec.rb @@ -46,7 +46,7 @@ describe Chef::DataBag do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { @data_bag.name Hash.new }.to raise_error(ArgumentError) + expect { @data_bag.name({}) }.to raise_error(ArgumentError) end [ ".", "-", "_", "1"].each do |char| diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb index f93f07bc52..00a1f47fcf 100644 --- a/spec/unit/dsl/data_query_spec.rb +++ b/spec/unit/dsl/data_query_spec.rb @@ -24,7 +24,7 @@ class DataQueryDSLTester end describe Chef::DSL::DataQuery do - let(:node) { Hash.new } + let(:node) { {} } let(:language) do language = DataQueryDSLTester.new diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb index 4da3a9fa0e..42906ef772 100644 --- a/spec/unit/environment_spec.rb +++ b/spec/unit/environment_spec.rb @@ -48,8 +48,8 @@ describe Chef::Environment do end it "should not accept anything but strings" do - expect { @environment.name(Array.new) }.to raise_error(ArgumentError) - expect { @environment.name(Hash.new) }.to raise_error(ArgumentError) + expect { @environment.name([]) }.to raise_error(ArgumentError) + expect { @environment.name({}) }.to raise_error(ArgumentError) expect { @environment.name(2) }.to raise_error(ArgumentError) end end @@ -65,8 +65,8 @@ describe Chef::Environment do end it "should not accept anything but strings" do - expect { @environment.description(Array.new) }.to raise_error(ArgumentError) - expect { @environment.description(Hash.new) }.to raise_error(ArgumentError) + expect { @environment.description([]) }.to raise_error(ArgumentError) + expect { @environment.description({}) }.to raise_error(ArgumentError) expect { @environment.description(42) }.to raise_error(ArgumentError) end end @@ -82,7 +82,7 @@ describe Chef::Environment do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @environment.default_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @environment.default_attributes([]) }.to raise_error(ArgumentError) end end @@ -97,7 +97,7 @@ describe Chef::Environment do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @environment.override_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @environment.override_attributes([]) }.to raise_error(ArgumentError) end end @@ -121,7 +121,7 @@ describe Chef::Environment do it "should not accept anything but a hash" do expect { @environment.cookbook_versions("I am a string!") }.to raise_error(ArgumentError) - expect { @environment.cookbook_versions(Array.new) }.to raise_error(ArgumentError) + expect { @environment.cookbook_versions([]) }.to raise_error(ArgumentError) expect { @environment.cookbook_versions(42) }.to raise_error(ArgumentError) end @@ -257,7 +257,7 @@ describe Chef::Environment do end it "should return false if anything other than a hash is passed as the argument" do - expect(Chef::Environment.validate_cookbook_versions(Array.new)).to eq(false) + expect(Chef::Environment.validate_cookbook_versions([])).to eq(false) expect(Chef::Environment.validate_cookbook_versions(42)).to eq(false) expect(Chef::Environment.validate_cookbook_versions(Chef::CookbookVersion.new("meta"))).to eq(false) expect(Chef::Environment.validate_cookbook_versions("cookbook => 1.2.3")).to eq(false) diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb index b2ca8704b0..6d7f31c6f1 100644 --- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb @@ -22,7 +22,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do let(:node) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s node.automatic[:os] = "windows" node diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb index a2d4cb4815..89fff82f04 100644 --- a/spec/unit/http/authenticator_spec.rb +++ b/spec/unit/http/authenticator_spec.rb @@ -23,7 +23,7 @@ describe Chef::HTTP::Authenticator do let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") } let(:method) { "GET" } let(:url) { URI("https://chef.example.com/organizations/test") } - let(:headers) { Hash.new } + let(:headers) { {} } let(:data) { "" } context "when handle_request is called" do diff --git a/spec/unit/key_spec.rb b/spec/unit/key_spec.rb index e3d9f8e7ad..efae549490 100644 --- a/spec/unit/key_spec.rb +++ b/spec/unit/key_spec.rb @@ -66,7 +66,7 @@ describe Chef::Key do context "when you feed it anything but a string" do it "should raise an ArgumentError" do - expect { key.send(field, Hash.new) }.to raise_error(ArgumentError) + expect { key.send(field, {}) }.to raise_error(ArgumentError) end end end diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb index 21bac9d0c0..770ba8762f 100644 --- a/spec/unit/knife/client_bulk_delete_spec.rb +++ b/spec/unit/knife/client_bulk_delete_spec.rb @@ -42,7 +42,7 @@ describe Chef::Knife::ClientBulkDelete do let(:nonvalidator_client_names) { %w{tim dan stephen} } let(:nonvalidator_clients) do - clients = Hash.new + clients = {} nonvalidator_client_names.each do |client_name| client = Chef::ApiClientV1.new @@ -56,7 +56,7 @@ describe Chef::Knife::ClientBulkDelete do let(:validator_client_names) { %w{myorg-validator} } let(:validator_clients) do - clients = Hash.new + clients = {} validator_client_names.each do |validator_client_name| validator_client = Chef::ApiClientV1.new diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb index c8c1873081..d01213227b 100644 --- a/spec/unit/knife/cookbook_bulk_delete_spec.rb +++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb @@ -31,7 +31,7 @@ describe Chef::Knife::CookbookBulkDelete do allow(@knife.ui).to receive(:stdout).and_return(@stdout) allow(@knife.ui).to receive(:stderr).and_return(@stderr) allow(@knife.ui).to receive(:confirm).and_return(true) - @cookbooks = Hash.new + @cookbooks = {} %w{cheezburger pizza lasagna}.each do |cookbook_name| cookbook = Chef::CookbookVersion.new(cookbook_name) @cookbooks[cookbook_name] = cookbook diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb index fcbfd40381..6437ba2bcd 100644 --- a/spec/unit/knife/key_create_spec.rb +++ b/spec/unit/knife/key_create_spec.rb @@ -84,7 +84,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo 0wIDAQAB -----END PUBLIC KEY-----" end - let(:config) { Hash.new } + let(:config) { {} } let(:actor) { "charmander" } let(:ui) { instance_double("Chef::Knife::UI") } diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb index 7c409f5ea0..1f8067c160 100644 --- a/spec/unit/knife/key_edit_spec.rb +++ b/spec/unit/knife/key_edit_spec.rb @@ -86,7 +86,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo 0wIDAQAB -----END PUBLIC KEY-----" end - let(:config) { Hash.new } + let(:config) { {} } let(:actor) { "charmander" } let(:keyname) { "charmander-key" } let(:ui) { instance_double("Chef::Knife::UI") } diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb index e221a4da72..c65a11b08c 100644 --- a/spec/unit/knife/key_list_spec.rb +++ b/spec/unit/knife/key_list_spec.rb @@ -73,7 +73,7 @@ describe "key list commands that inherit knife" do end describe Chef::Knife::KeyList do - let(:config) { Hash.new } + let(:config) { {} } let(:actor) { "charmander" } let(:ui) { instance_double("Chef::Knife::UI") } diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb index b955b5de6c..b97df004a3 100644 --- a/spec/unit/knife/node_bulk_delete_spec.rb +++ b/spec/unit/knife/node_bulk_delete_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::NodeBulkDelete do @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) allow(@knife.ui).to receive(:confirm).and_return(true) - @nodes = Hash.new + @nodes = {} %w{adam brent jacob}.each do |node_name| @nodes[node_name] = "http://localhost:4000/nodes/#{node_name}" end diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb index c39a8ec652..07a9b484c4 100644 --- a/spec/unit/knife/role_bulk_delete_spec.rb +++ b/spec/unit/knife/role_bulk_delete_spec.rb @@ -29,7 +29,7 @@ describe Chef::Knife::RoleBulkDelete do @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) allow(@knife.ui).to receive(:confirm).and_return(true) - @roles = Hash.new + @roles = {} %w{dev staging production}.each do |role_name| role = Chef::Role.new role.name(role_name) diff --git a/spec/unit/knife/supermarket_install_spec.rb b/spec/unit/knife/supermarket_install_spec.rb index d891de9268..801fb74802 100644 --- a/spec/unit/knife/supermarket_install_spec.rb +++ b/spec/unit/knife/supermarket_install_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::SupermarketInstall do let(:knife) { Chef::Knife::SupermarketInstall.new } let(:stdout) { StringIO.new } let(:stderr) { StringIO.new } - let(:downloader) { Hash.new } + let(:downloader) { {} } let(:archive) { double(Mixlib::Archive, extract: true) } let(:repo) do double(sanity_check: true, reset_to_default_state: true, diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index 5f29095bcb..489742cb7d 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -44,7 +44,7 @@ describe Chef::Mixin::ParamsValidate do it "should require validation map keys to be symbols or strings" do expect { @vo.validate({ one: "two" }, { one: true }) }.not_to raise_error expect { @vo.validate({ one: "two" }, { "one" => true }) }.not_to raise_error - expect { @vo.validate({ one: "two" }, { Hash.new => true }) }.to raise_error(ArgumentError) + expect { @vo.validate({ one: "two" }, { {} => true }) }.to raise_error(ArgumentError) end it "should allow options to be required with true" do @@ -163,7 +163,7 @@ describe Chef::Mixin::ParamsValidate do end it "should let you set a default value with default => value" do - arguments = Hash.new + arguments = {} @vo.validate(arguments, { one: { default: "is the loneliest number", @@ -321,7 +321,7 @@ describe Chef::Mixin::ParamsValidate do end.not_to raise_error expect do @vo.validate( - { one: Hash.new }, + { one: {} }, { one: { kind_of: [ String, Array ], diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb index 06acbe49c9..7d4e18d23c 100644 --- a/spec/unit/mixin/windows_architecture_helper_spec.rb +++ b/spec/unit/mixin/windows_architecture_helper_spec.rb @@ -74,7 +74,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do def with_node_architecture_combinations @valid_architectures.each do |node_architecture| new_node = Chef::Node.new - new_node.default["kernel"] = Hash.new + new_node.default["kernel"] = {} new_node.default["kernel"][:machine] = node_architecture.to_s @valid_architectures.each do |architecture| diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 1b9a9841e5..5055941d06 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -589,7 +589,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key" do - collect = Array.new + collect = [] @attributes.each_key do |k| collect << k end @@ -602,7 +602,7 @@ describe Chef::Node::Attribute do end it "should yield lower if we go deeper" do - collect = Array.new + collect = [] @attributes["one"].each_key do |k| collect << k end @@ -637,7 +637,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key and value, post merge rules" do - collect = Hash.new + collect = {} @attributes.each do |k, v| collect[k] = v end @@ -679,7 +679,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key, post merge rules" do - collect = Array.new + collect = [] @attributes.each_key do |k| collect << k end @@ -715,7 +715,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key and value pair, post merge rules" do - collect = Hash.new + collect = {} @attributes.each_pair do |k, v| collect[k] = v end @@ -751,7 +751,7 @@ describe Chef::Node::Attribute do end it "should yield each value, post merge rules" do - collect = Array.new + collect = [] @attributes.each_value do |v| collect << v end @@ -762,7 +762,7 @@ describe Chef::Node::Attribute do end it "should yield four elements" do - collect = Array.new + collect = [] @attributes.each_value do |v| collect << v end diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index c071e82fae..0fe375a4df 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -103,7 +103,7 @@ describe Chef::Node do end it "should always have a string for name" do - expect { node.name(Hash.new) }.to raise_error(ArgumentError) + expect { node.name({}) }.to raise_error(ArgumentError) end it "cannot be blank" do @@ -126,7 +126,7 @@ describe Chef::Node do end it "should disallow non-strings" do - expect { node.chef_environment(Hash.new) }.to raise_error(ArgumentError) + expect { node.chef_environment({}) }.to raise_error(ArgumentError) expect { node.chef_environment(42) }.to raise_error(ArgumentError) end @@ -162,7 +162,7 @@ describe Chef::Node do end it "disallows non-strings" do - expect { node.policy_name(Hash.new) }.to raise_error(Chef::Exceptions::ValidationFailed) + expect { node.policy_name({}) }.to raise_error(Chef::Exceptions::ValidationFailed) expect { node.policy_name(42) }.to raise_error(Chef::Exceptions::ValidationFailed) end @@ -198,7 +198,7 @@ describe Chef::Node do end it "disallows non-strings" do - expect { node.policy_group(Hash.new) }.to raise_error(Chef::Exceptions::ValidationFailed) + expect { node.policy_group({}) }.to raise_error(Chef::Exceptions::ValidationFailed) expect { node.policy_group(42) }.to raise_error(Chef::Exceptions::ValidationFailed) end @@ -793,7 +793,7 @@ describe Chef::Node do it "should allow you to iterate over attributes with each_attribute" do node.default["sunshine"] = "is bright" node.default["canada"] = "is a nice place" - seen_attributes = Hash.new + seen_attributes = {} node.each_attribute do |a, v| seen_attributes[a] = v end diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb index 79a29b1fff..b291b7cb86 100644 --- a/spec/unit/org_spec.rb +++ b/spec/unit/org_spec.rb @@ -52,7 +52,7 @@ describe Chef::Org do end it "raises an ArgumentError if you feed it anything but a string" do - expect { org.name Hash.new }.to raise_error(ArgumentError) + expect { org.name({}) }.to raise_error(ArgumentError) end end @@ -63,7 +63,7 @@ describe Chef::Org do end it "raises an ArgumentError if you feed it anything but a string" do - expect { org.name Hash.new }.to raise_error(ArgumentError) + expect { org.name({}) }.to raise_error(ArgumentError) end end @@ -74,7 +74,7 @@ describe Chef::Org do end it "raises an ArgumentError if you feed it something lame" do - expect { org.private_key Hash.new }.to raise_error(ArgumentError) + expect { org.private_key({}) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index a247c26651..be4df761d2 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -22,7 +22,7 @@ describe Chef::Provider::PowershellScript, "action_run" do let(:powershell_version) { nil } let(:node) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s if ! powershell_version.nil? node.default[:languages] = { powershell: { version: powershell_version } } diff --git a/spec/unit/resource/batch_spec.rb b/spec/unit/resource/batch_spec.rb index c161428a13..dd3082100e 100644 --- a/spec/unit/resource/batch_spec.rb +++ b/spec/unit/resource/batch_spec.rb @@ -22,7 +22,7 @@ describe Chef::Resource::Batch do let(:node) { Chef::Node.new } before(:each) do - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s node.automatic[:os] = "windows" diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb index 3dd68211db..0c0c0d8287 100644 --- a/spec/unit/resource/directory_spec.rb +++ b/spec/unit/resource/directory_spec.rb @@ -38,7 +38,7 @@ describe Chef::Resource::Directory do it "accepts a string as the path" do expect { resource.path "/tmp" }.not_to raise_error expect(resource.path).to eql("/tmp") - expect { resource.path Hash.new }.to raise_error(ArgumentError) + expect { resource.path({}) }.to raise_error(ArgumentError) end it "allows you to have specify whether the action is recursive with true/false" do diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb index 54dc8ab92b..b49fc4564b 100644 --- a/spec/unit/resource/file_spec.rb +++ b/spec/unit/resource/file_spec.rb @@ -85,7 +85,7 @@ describe Chef::Resource::File do it "accepts a string as the path" do expect { resource.path "/tmp" }.not_to raise_error expect(resource.path).to eql("/tmp") - expect { resource.path Hash.new }.to raise_error(ArgumentError) + expect { resource.path({}) }.to raise_error(ArgumentError) end describe "when it has a path, owner, group, mode, and checksum" do diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb index 05a39835d8..ae32e4aa30 100644 --- a/spec/unit/resource/link_spec.rb +++ b/spec/unit/resource/link_spec.rb @@ -63,7 +63,7 @@ describe Chef::Resource::Link do end it "does not accept a Hash for the link source via 'to'" do - expect { resource.to Hash.new }.to raise_error(ArgumentError) + expect { resource.to({}) }.to raise_error(ArgumentError) end it "allows you to set a link source via 'to'" do diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index a1c5e4c5b0..34d530c1a2 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -23,7 +23,7 @@ describe Chef::Resource::PowershellScript do before(:each) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s node.automatic[:os] = "windows" diff --git a/spec/unit/resource/windows_env_spec.rb b/spec/unit/resource/windows_env_spec.rb index 06b5af630a..3ba5b18881 100644 --- a/spec/unit/resource/windows_env_spec.rb +++ b/spec/unit/resource/windows_env_spec.rb @@ -47,7 +47,7 @@ describe Chef::Resource::WindowsEnv do end it "does not accept a Hash for the env value via 'to'" do - expect { resource.value Hash.new }.to raise_error(ArgumentError) + expect { resource.value({}) }.to raise_error(ArgumentError) end it "allows you to set an env value via 'to'" do diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb index 60053d2b71..30a55cd3e1 100644 --- a/spec/unit/resource_collection/resource_set_spec.rb +++ b/spec/unit/resource_collection/resource_set_spec.rb @@ -172,7 +172,7 @@ describe Chef::ResourceCollection::ResourceSet do end it "should raise an exception if you pass something other than a string or hash to resource" do - expect { collection.find([Array.new]) }.to raise_error(ArgumentError) + expect { collection.find([[]]) }.to raise_error(ArgumentError) end it "raises an error when attempting to find a resource that does not exist" do diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb index a26616d454..60f17b6934 100644 --- a/spec/unit/resource_collection_spec.rb +++ b/spec/unit/resource_collection_spec.rb @@ -97,7 +97,7 @@ describe Chef::ResourceCollection do describe "each" do it "should allow you to iterate over every resource in the collection" do load_up_resources - results = Array.new + results = [] expect do rc.each do |r| results << r.name @@ -119,7 +119,7 @@ describe Chef::ResourceCollection do describe "each_index" do it "should allow you to iterate over every resource by index" do load_up_resources - results = Array.new + results = [] expect do rc.each_index do |i| results << rc[i].name @@ -246,7 +246,7 @@ describe Chef::ResourceCollection do end it "should raise an exception if you pass something other than a string or hash to resource" do - expect { rc.resources([Array.new]) }.to raise_error(ArgumentError) + expect { rc.resources([[]]) }.to raise_error(ArgumentError) end it "raises an error when attempting to find a resource that does not exist" do diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb index 2e3fc63260..a1c59eaaca 100644 --- a/spec/unit/resource_definition_spec.rb +++ b/spec/unit/resource_definition_spec.rb @@ -92,7 +92,7 @@ describe Chef::ResourceDefinition do it "should raise an exception if prototype_params is not a hash" do expect do - defn.define :monkey, Array.new do + defn.define :monkey, [] do end end.to raise_error(ArgumentError) end diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb index 46ee71bb1c..13932ab3ee 100644 --- a/spec/unit/role_spec.rb +++ b/spec/unit/role_spec.rb @@ -113,7 +113,7 @@ describe Chef::Role do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @role.default_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @role.default_attributes([]) }.to raise_error(ArgumentError) end end @@ -128,7 +128,7 @@ describe Chef::Role do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @role.override_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @role.override_attributes([]) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb index ac062c665d..5dc877ad9a 100644 --- a/spec/unit/run_list_spec.rb +++ b/spec/unit/run_list_spec.rb @@ -133,7 +133,7 @@ describe Chef::RunList do it "should yield each member to your block" do @run_list << "foo" @run_list << "bar" - seen = Array.new + seen = [] @run_list.each { |r| seen << r } expect(seen).to be_include("recipe[foo]") expect(seen).to be_include("recipe[bar]") diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb index 151fcb51b3..641e8558ad 100644 --- a/spec/unit/search/query_spec.rb +++ b/spec/unit/search/query_spec.rb @@ -169,7 +169,7 @@ describe Chef::Search::Query do it "accepts a type as the first argument" do expect { query.search("node") }.not_to raise_error expect { query.search(:node) }.not_to raise_error - expect { query.search(Hash.new) }.to raise_error(Chef::Exceptions::InvalidSearchQuery, /(Hash)/) + expect { query.search({}) }.to raise_error(Chef::Exceptions::InvalidSearchQuery, /(Hash)/) end it "queries for every object of a type by default" do diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb index 48dbf010e9..492dc147d9 100644 --- a/spec/unit/user_spec.rb +++ b/spec/unit/user_spec.rb @@ -65,7 +65,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { @user.name Hash.new }.to raise_error(ArgumentError) + expect { @user.name({}) }.to raise_error(ArgumentError) end end @@ -84,7 +84,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it anything but true or false" do - expect { @user.name Hash.new }.to raise_error(ArgumentError) + expect { @user.name({}) }.to raise_error(ArgumentError) end end @@ -99,7 +99,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it something lame" do - expect { @user.public_key Hash.new }.to raise_error(ArgumentError) + expect { @user.public_key({}) }.to raise_error(ArgumentError) end end @@ -114,7 +114,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it something lame" do - expect { @user.private_key Hash.new }.to raise_error(ArgumentError) + expect { @user.private_key({}) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb index 37b2252492..4bde7278fe 100644 --- a/spec/unit/user_v1_spec.rb +++ b/spec/unit/user_v1_spec.rb @@ -37,7 +37,7 @@ describe Chef::UserV1 do end it "should throw an ArgumentError if you feed it something lame" do - expect { @user.send(method, Hash.new) }.to raise_error(ArgumentError) + expect { @user.send(method, {}) }.to raise_error(ArgumentError) end end @@ -57,7 +57,7 @@ describe Chef::UserV1 do end it "should throw an ArgumentError if you feed it anything but true or false" do - expect { @user.send(method, Hash.new) }.to raise_error(ArgumentError) + expect { @user.send(method, {}) }.to raise_error(ArgumentError) end end @@ -95,7 +95,7 @@ describe Chef::UserV1 do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { @user.username Hash.new }.to raise_error(ArgumentError) + expect { @user.username({}) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb index e53bc9662a..ac851a835e 100644 --- a/spec/unit/util/editor_spec.rb +++ b/spec/unit/util/editor_spec.rb @@ -9,7 +9,7 @@ describe Chef::Util::Editor do end it "makes a copy of an Array" do - array = Array.new + array = [] editor = described_class.new(array) expect(editor.lines).to_not be(array) end |