summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-03 12:26:05 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-05 12:40:44 -0700
commit4978a9a8a402477f3b35f43404701d6a5cf26fa1 (patch)
tree7f336c1fa29d7bdb50f8a6e0a2e5943fbb32ba51 /lib
parent2833651dcf54db5ba8e92746b479ebafa897b275 (diff)
downloadchef-4978a9a8a402477f3b35f43404701d6a5cf26fa1.tar.gz
Style/EmptyLiteral
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/api_client.rb2
-rw-r--r--lib/chef/api_client_v1.rb2
-rw-r--r--lib/chef/cookbook_manifest.rb2
-rw-r--r--lib/chef/cookbook_version.rb10
-rw-r--r--lib/chef/dsl/data_query.rb2
-rw-r--r--lib/chef/environment.rb6
-rw-r--r--lib/chef/file_cache.rb2
-rw-r--r--lib/chef/knife/bootstrap.rb4
-rw-r--r--lib/chef/knife/cookbook_show.rb2
-rw-r--r--lib/chef/knife/core/generic_presenter.rb2
-rw-r--r--lib/chef/knife/core/status_presenter.rb2
-rw-r--r--lib/chef/knife/data_bag_from_file.rb2
-rw-r--r--lib/chef/knife/search.rb8
-rw-r--r--lib/chef/knife/ssh.rb4
-rw-r--r--lib/chef/knife/supermarket_list.rb2
-rw-r--r--lib/chef/knife/tag_delete.rb2
-rw-r--r--lib/chef/mixin/api_version_request_handling.rb2
-rw-r--r--lib/chef/mixin/windows_architecture_helper.rb4
-rw-r--r--lib/chef/node.rb4
-rw-r--r--lib/chef/node/immutable_collections.rb2
-rw-r--r--lib/chef/provider/ifconfig.rb4
-rw-r--r--lib/chef/recipe.rb2
-rw-r--r--lib/chef/resource.rb4
-rw-r--r--lib/chef/resource/apt_package.rb2
-rw-r--r--lib/chef/resource/cron.rb2
-rw-r--r--lib/chef/resource/cron_d.rb2
-rw-r--r--lib/chef/resource/dpkg_package.rb2
-rw-r--r--lib/chef/resource/git.rb2
-rw-r--r--lib/chef/resource/http_request.rb2
-rw-r--r--lib/chef/resource/openssl_x509_certificate.rb2
-rw-r--r--lib/chef/resource/remote_file.rb2
-rw-r--r--lib/chef/resource/template.rb2
-rw-r--r--lib/chef/resource_collection/resource_collection_serialization.rb2
-rw-r--r--lib/chef/resource_collection/resource_list.rb2
-rw-r--r--lib/chef/resource_collection/resource_set.rb8
-rw-r--r--lib/chef/resource_definition.rb2
-rw-r--r--lib/chef/resource_definition_list.rb2
-rw-r--r--lib/chef/role.rb2
-rw-r--r--lib/chef/run_context.rb4
-rw-r--r--lib/chef/run_list/run_list_expansion.rb2
-rw-r--r--lib/chef/run_list/versioned_recipe_list.rb2
-rw-r--r--lib/chef/search/query.rb4
-rw-r--r--lib/chef/train_transport.rb2
-rw-r--r--lib/chef/user.rb2
-rw-r--r--lib/chef/user_v1.rb2
-rw-r--r--lib/chef/util/dsc/lcm_output_parser.rb4
-rw-r--r--lib/chef/util/windows/net_use.rb2
-rw-r--r--lib/chef/win32/version.rb2
48 files changed, 69 insertions, 69 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|