summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-01-17 13:34:18 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2018-01-17 13:34:18 -0800
commit746562d6358c27b838c95ea27b2a2bd82c03cefe (patch)
treebaa587f091d06c1385543bbde818970e5fee7b75 /lib/chef
parentfcd8d778baeeb990a64fe9042164bbd3e1dd5269 (diff)
downloadchef-746562d6358c27b838c95ea27b2a2bd82c03cefe.tar.gz
prepping for rubocop 0.52.1lcg/rubocop-0.52.1
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/audit/audit_reporter.rb6
-rw-r--r--lib/chef/audit/runner.rb4
-rw-r--r--lib/chef/chef_fs/data_handler/acl_data_handler.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/policies_dir.rb4
-rw-r--r--lib/chef/client.rb16
-rw-r--r--lib/chef/cookbook/cookbook_collection.rb4
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb1
-rw-r--r--lib/chef/cookbook/gem_installer.rb4
-rw-r--r--lib/chef/cookbook/metadata.rb3
-rw-r--r--lib/chef/cookbook_loader.rb12
-rw-r--r--lib/chef/cookbook_uploader.rb1
-rw-r--r--lib/chef/cookbook_version.rb8
-rw-r--r--lib/chef/data_bag.rb4
-rw-r--r--lib/chef/data_bag_item.rb8
-rw-r--r--lib/chef/environment.rb6
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb4
-rw-r--r--lib/chef/handler/json_file.rb3
-rw-r--r--lib/chef/http/basic_client.rb3
-rw-r--r--lib/chef/http/http_request.rb4
-rw-r--r--lib/chef/http/socketless_chef_zero_client.rb4
-rw-r--r--lib/chef/knife/cookbook_metadata.rb4
-rw-r--r--lib/chef/knife/cookbook_site_install.rb4
-rw-r--r--lib/chef/knife/cookbook_test.rb4
-rw-r--r--lib/chef/knife/cookbook_upload.rb4
-rw-r--r--lib/chef/knife/environment_compare.rb6
-rw-r--r--lib/chef/knife/ssh.rb4
-rw-r--r--lib/chef/knife/xargs.rb2
-rw-r--r--lib/chef/node.rb7
-rw-r--r--lib/chef/node/attribute_collections.rb4
-rw-r--r--lib/chef/node/immutable_collections.rb6
-rw-r--r--lib/chef/provider.rb5
-rw-r--r--lib/chef/provider/remote_directory.rb4
-rw-r--r--lib/chef/provider/route.rb2
-rw-r--r--lib/chef/provider/windows_task.rb4
-rw-r--r--lib/chef/resource.rb2
-rw-r--r--lib/chef/resource/action_class.rb4
-rw-r--r--lib/chef/resource/lwrp_base.rb5
-rw-r--r--lib/chef/resource_reporter.rb3
-rw-r--r--lib/chef/role.rb4
-rw-r--r--lib/chef/search/query.rb3
-rw-r--r--lib/chef/shell.rb1
-rw-r--r--lib/chef/shell/shell_session.rb5
-rw-r--r--lib/chef/util/windows/volume.rb4
-rw-r--r--lib/chef/win32/registry.rb4
45 files changed, 83 insertions, 117 deletions
diff --git a/lib/chef/audit/audit_reporter.rb b/lib/chef/audit/audit_reporter.rb
index 8546a21bb4..80ae3a8dd4 100644
--- a/lib/chef/audit/audit_reporter.rb
+++ b/lib/chef/audit/audit_reporter.rb
@@ -1,7 +1,7 @@
#
# Author:: Tyler Ball (<tball@chef.io>)
#
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,7 +49,7 @@ class Chef
def audit_phase_complete(audit_output)
Chef::Log.debug("Audit Reporter completed successfully without errors.")
- ordered_control_groups.each do |name, control_group|
+ ordered_control_groups.each_value do |control_group|
audit_data.add_control_group(control_group)
end
end
@@ -62,7 +62,7 @@ class Chef
# The stacktrace information has already been logged elsewhere
@audit_phase_error = error
Chef::Log.debug("Audit Reporter failed.")
- ordered_control_groups.each do |name, control_group|
+ ordered_control_groups.each_value do |control_group|
audit_data.add_control_group(control_group)
end
end
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index 837346381c..f6fed3fc64 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -1,6 +1,6 @@
#
# Author:: Claire McQuin (<claire@chef.io>)
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -163,7 +163,7 @@ class Chef
# or use example group filters.
def register_control_groups
add_example_group_methods
- run_context.audits.each do |name, group|
+ run_context.audits.each do |name, group| # rubocop:disable Performance/HashEachMethods
ctl_grp = RSpec::Core::ExampleGroup.__control_group__(*group.args, &group.block)
RSpec.world.record(ctl_grp)
end
diff --git a/lib/chef/chef_fs/data_handler/acl_data_handler.rb b/lib/chef/chef_fs/data_handler/acl_data_handler.rb
index 6c8833004a..834fc5ca0b 100644
--- a/lib/chef/chef_fs/data_handler/acl_data_handler.rb
+++ b/lib/chef/chef_fs/data_handler/acl_data_handler.rb
@@ -13,7 +13,7 @@ class Chef
"delete" => {},
"grant" => {},
})
- result.keys.each do |key|
+ result.each_key do |key|
result[key] = normalize_hash(result[key], { "actors" => [], "groups" => [] })
result[key]["actors"] = result[key]["actors"].sort
result[key]["groups"] = result[key]["groups"].sort
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
index 64488ed705..9b0ea18cd8 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -76,7 +76,7 @@ class Chef
if @children.nil?
@children = []
manifest = chef_object.cookbook_manifest
- manifest.by_parent_directory.each do |segment, files|
+ manifest.by_parent_directory.each_value do |files|
files.each do |file|
parts = file[:path].split("/")
# Get or create the path to the file
diff --git a/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb b/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb
index a4add1378d..8259db473d 100644
--- a/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -71,7 +71,7 @@ class Chef
result = []
data = root.get_json(api_path)
data.keys.sort.each do |policy_name|
- data[policy_name]["revisions"].keys.each do |policy_revision|
+ data[policy_name]["revisions"].each_key do |policy_revision|
filename = "#{policy_name}-#{policy_revision}.json"
result << make_child_entry(filename, true)
end
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 786ed2c4fc..6ff2d78ee6 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -3,7 +3,7 @@
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Christopher Brown (<cb@chef.io>)
# Author:: Tim Hinderliter (<tim@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -100,14 +100,6 @@ class Chef
attr_reader :rest
#
- # A rest object with validate_utf8 set to false. This will not throw exceptions
- # on non-UTF8 strings in JSON but will sanitize them so that e.g. POSTs will
- # never fail. Cannot be configured on a request-by-request basis, so we carry
- # around another rest object for it.
- #
- attr_reader :rest_clean
-
- #
# The runner used to converge.
#
# @return [Chef::Runner]
@@ -398,8 +390,10 @@ class Chef
end
end
- # Rest client for use by API reporters. This rest client will not fail with an exception if
- # it is fed non-UTF8 data.
+ # A rest object with validate_utf8 set to false. This will not throw exceptions
+ # on non-UTF8 strings in JSON but will sanitize them so that e.g. POSTs will
+ # never fail. Cannot be configured on a request-by-request basis, so we carry
+ # around another rest object for it.
#
# @api private
def rest_clean(client_name = node_name, config = Chef::Config)
diff --git a/lib/chef/cookbook/cookbook_collection.rb b/lib/chef/cookbook/cookbook_collection.rb
index 997eb6de12..b2a4d5884a 100644
--- a/lib/chef/cookbook/cookbook_collection.rb
+++ b/lib/chef/cookbook/cookbook_collection.rb
@@ -1,7 +1,7 @@
#--
# Author:: Tim Hinderliter (<tim@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2010-2016 Chef Software, Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -50,7 +50,7 @@ class Chef
# @raise [Chef::Exceptions::CookbookChefVersionMismatch] if the Chef::VERSION fails validation
# @raise [Chef::Exceptions::CookbookOhaiVersionMismatch] if the Ohai::VERSION fails validation
def validate!
- each do |cookbook_name, cookbook_version|
+ each_value do |cookbook_version|
cookbook_version.metadata.validate_chef_version!
cookbook_version.metadata.validate_ohai_version!
end
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index 35dac27fa5..b139a8d489 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -13,7 +13,6 @@ class Chef
attr_reader :cookbook_settings
attr_reader :cookbook_paths
- attr_reader :metadata_filenames
attr_reader :frozen
attr_reader :uploaded_cookbook_version_file
diff --git a/lib/chef/cookbook/gem_installer.rb b/lib/chef/cookbook/gem_installer.rb
index 5b1426e4e8..0b64d3354f 100644
--- a/lib/chef/cookbook/gem_installer.rb
+++ b/lib/chef/cookbook/gem_installer.rb
@@ -1,5 +1,5 @@
#--
-# Copyright:: Copyright (c) 2010-2017, Chef Software Inc.
+# Copyright:: Copyright (c) 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,7 +38,7 @@ class Chef
def install
cookbook_gems = Hash.new { |h, k| h[k] = [] }
- cookbook_collection.each do |cookbook_name, cookbook_version|
+ cookbook_collection.each_value do |cookbook_version|
cookbook_version.metadata.gems.each do |args|
cookbook_gems[args.first] += args[1..-1]
end
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index a6bb3d079d..22f006640d 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: AJ Christensen (<aj@chef.io>)
# Author:: Seth Falcon (<seth@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -74,7 +74,6 @@ class Chef
attr_reader :providing
attr_reader :attributes
attr_reader :recipes
- attr_reader :version
# @return [Array<Gem::Dependency>] Array of supported Chef versions
attr_reader :chef_versions
diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb
index a965b43c61..1cd498496a 100644
--- a/lib/chef/cookbook_loader.rb
+++ b/lib/chef/cookbook_loader.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Daniel DeLeo (<dan@kallistec.com>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# Copyright:: Copyright 2009-2016, Daniel DeLeo
# License:: Apache License, Version 2.0
#
@@ -78,7 +78,7 @@ class Chef
# @api private
def load_cookbooks_without_shadow_warning
preload_cookbooks
- @loaders_by_name.each do |cookbook_name, _loaders|
+ @loaders_by_name.each_key do |cookbook_name|
load_cookbook(cookbook_name)
end
@cookbooks_by_name
@@ -142,6 +142,14 @@ class Chef
end
end
+ def each_key(&block)
+ cookbook_names.each(&block)
+ end
+
+ def each_value(&block)
+ values.each(&block)
+ end
+
def cookbook_names
@cookbooks_by_name.keys.sort
end
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index 5e11314190..470d7be5b6 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -145,7 +145,6 @@ class Chef
Chef::Log.info("Validating templates")
exit(1) unless syntax_checker.validate_templates
Chef::Log.info("Syntax OK")
- true
end
end
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index dcb8c97548..99438ade82 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -4,7 +4,7 @@
# Author:: Tim Hinderliter (<tim@chef.io>)
# Author:: Seth Falcon (<seth@chef.io>)
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,11 +54,6 @@ class Chef
# CookbookVersion.
attr_reader :metadata
- attr_reader :recipe_filenames_by_name
- attr_reader :attribute_filenames_by_short_filename
-
- attr_accessor :chef_server_rest
-
# The `identifier` field is used for cookbook_artifacts, which are
# organized on the chef server according to their content. If the
# policy_mode option to CookbookManifest is set to true it will include
@@ -157,7 +152,6 @@ class Chef
def metadata=(metadata)
@metadata = metadata
@metadata.recipes_from_cookbook_version(self)
- @metadata
end
def manifest
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index cd10b7c704..c5e2b38c94 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Nuo Yan (<nuo@chef.io>)
# Author:: Christopher Brown (<cb@chef.io>)
-# Copyright:: Copyright 2009-2016, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,8 +35,6 @@ class Chef
VALID_NAME = /^[\.\-[:alnum:]_]+$/
RESERVED_NAMES = /^(node|role|environment|client)$/
- attr_accessor :chef_server_rest
-
def self.validate_name!(name)
unless name =~ VALID_NAME
raise Exceptions::InvalidDataBagName, "DataBags must have a name matching #{VALID_NAME.inspect}, you gave #{name.inspect}"
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index d0fca26125..388da78dad 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Nuo Yan (<nuo@chef.io>)
# Author:: Christopher Brown (<cb@chef.io>)
-# Copyright:: Copyright 2009-2016, Chef Software, Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,8 +38,6 @@ class Chef
VALID_ID = /^[\.\-[:alnum:]_]+$/
- attr_accessor :chef_server_rest
-
def self.validate_id!(id_str)
if id_str.nil? || ( id_str !~ VALID_ID )
raise Exceptions::InvalidDataBagItemID, "Data Bag items must have an id matching #{VALID_ID.inspect}, you gave: #{id_str.inspect}"
@@ -66,10 +64,6 @@ class Chef
Chef::ServerAPI.new(Chef::Config[:chef_server_url])
end
- def raw_data
- @raw_data
- end
-
def validate_id!(id_str)
self.class.validate_id!(id_str)
end
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index 621a122440..be05b58989 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -3,7 +3,7 @@
# Author:: Seth Falcon (<seth@chef.io>)
# Author:: John Keiser (<jkeiser@ospcode.com>)
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,8 +34,6 @@ class Chef
include Chef::Mixin::ParamsValidate
include Chef::Mixin::FromFile
- attr_accessor :chef_server_rest
-
COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:[\s]+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:[\s]+).+)$/
def initialize(chef_server_rest: nil)
@@ -297,7 +295,7 @@ class Chef
def self.validate_cookbook_versions(cv)
return false unless cv.kind_of?(Hash)
- cv.each do |cookbook, version|
+ cv.each_value do |version|
return false unless Chef::Environment.validate_cookbook_version(version)
end
true
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index 6df60aec89..e245eab2c7 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Edwards (<adamed@chef.io>)
-# Copyright:: Copyright 2014-2016, Chef Software Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -108,7 +108,7 @@ class Chef
def block_from_attributes(attributes)
Proc.new do
- attributes.keys.each do |attribute_name|
+ attributes.each_key do |attribute_name|
send(attribute_name, attributes[attribute_name]) if respond_to?(attribute_name)
end
end
diff --git a/lib/chef/handler/json_file.rb b/lib/chef/handler/json_file.rb
index 9ba3d70383..7f29b91449 100644
--- a/lib/chef/handler/json_file.rb
+++ b/lib/chef/handler/json_file.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +28,6 @@ class Chef
def initialize(config = {})
@config = config
@config[:path] ||= "/var/chef/reports"
- @config
end
def report
diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb
index 9a000136e6..1539770aa8 100644
--- a/lib/chef/http/basic_client.rb
+++ b/lib/chef/http/basic_client.rb
@@ -5,7 +5,7 @@
# Author:: Christopher Brown (<cb@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2009-2016, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,7 +32,6 @@ class Chef
HTTPS = "https".freeze
attr_reader :url
- attr_reader :http_client
attr_reader :ssl_policy
attr_reader :keepalives
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index 7fc1acb889..bd999d8f86 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -5,7 +5,7 @@
# Author:: Christopher Brown (<cb@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2009-2016, 2010-2016 Chef Software, Inc.
+# Copyright:: Copyright 2009-2016, 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -71,7 +71,7 @@ class Chef
@user_agent ||= DEFAULT_UA
end
- attr_reader :method, :url, :headers, :http_client, :http_request
+ attr_reader :method, :url, :headers, :http_request
def initialize(method, url, req_body, base_headers = {})
@method, @url = method, url
diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb
index 296330815a..34a5dbb083 100644
--- a/lib/chef/http/socketless_chef_zero_client.rb
+++ b/lib/chef/http/socketless_chef_zero_client.rb
@@ -1,6 +1,6 @@
#--
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2015-2016, Chef Software, Inc.
+# Copyright:: Copyright 2015-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -133,7 +133,7 @@ class Chef
511 => "Network Authentication Required",
}
- STATUS_MESSAGE.values.each { |v| v.freeze }
+ STATUS_MESSAGE.each_value { |v| v.freeze }
STATUS_MESSAGE.freeze
def initialize(base_url)
diff --git a/lib/chef/knife/cookbook_metadata.rb b/lib/chef/knife/cookbook_metadata.rb
index 29eba6a36a..e089c4b777 100644
--- a/lib/chef/knife/cookbook_metadata.rb
+++ b/lib/chef/knife/cookbook_metadata.rb
@@ -1,7 +1,7 @@
#
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2009-2016, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,7 +47,7 @@ class Chef
if config[:all]
cl = Chef::CookbookLoader.new(config[:cookbook_path])
cl.load_cookbooks
- cl.each do |cname, cookbook|
+ cl.each_key do |cname|
generate_metadata(cname.to_s)
end
else
diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb
index 72fb426554..f4d692e13c 100644
--- a/lib/chef/knife/cookbook_site_install.rb
+++ b/lib/chef/knife/cookbook_site_install.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -116,7 +116,7 @@ class Chef
end
unless config[:no_deps]
- preferred_metadata.dependencies.each do |cookbook, version_list|
+ preferred_metadata.dependencies.each_key do |cookbook|
# Doesn't do versions.. yet
nv = self.class.new
nv.config = config
diff --git a/lib/chef/knife/cookbook_test.rb b/lib/chef/knife/cookbook_test.rb
index 5c6dd32f37..f3a4981c95 100644
--- a/lib/chef/knife/cookbook_test.rb
+++ b/lib/chef/knife/cookbook_test.rb
@@ -2,7 +2,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Matthew Kent (<mkent@magoazul.com>)
-# Copyright:: Copyright 2009-2016, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# Copyright:: Copyright 2010-2016, Matthew Kent
# License:: Apache License, Version 2.0
#
@@ -50,7 +50,7 @@ class Chef
if config[:all]
cl = cookbook_loader
cl.load_cookbooks
- cl.each do |key, cookbook|
+ cl.each_key do |key|
checked_a_cookbook = true
test_cookbook(key)
end
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index 92084e7906..f67a26dc9a 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Nuo Yan (<yan.nuo@gmail.com>)
-# Copyright:: Copyright 2009-2016, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -172,7 +172,7 @@ class Chef
if ! upload_set.has_key?(cookbook_name)
upload_set[cookbook_name] = cookbook_repo[cookbook_name]
if config[:depends]
- upload_set[cookbook_name].metadata.dependencies.each { |dep, ver| @name_args << dep }
+ upload_set[cookbook_name].metadata.dependencies.each_key { |dep| @name_args << dep }
end
end
rescue Exceptions::CookbookNotFoundInRepo => e
diff --git a/lib/chef/knife/environment_compare.rb b/lib/chef/knife/environment_compare.rb
index 8a2ef853d3..2e70783d3f 100644
--- a/lib/chef/knife/environment_compare.rb
+++ b/lib/chef/knife/environment_compare.rb
@@ -94,17 +94,17 @@ class Chef
def cookbook_list(constraints)
result = {}
- constraints.each { |env, cb| result.merge!(cb) }
+ constraints.each_value { |cb| result.merge!(cb) }
result
end
def matrix_output(cookbooks, constraints)
rows = [ "" ]
environments = []
- constraints.each { |e, v| environments << e.to_s }
+ constraints.each_key { |e| environments << e.to_s }
columns = environments.count + 1
environments.each { |env| rows << ui.color(env, :bold) }
- cookbooks.each do |c, v|
+ cookbooks.each_key do |c|
total = []
environments.each { |n| total << constraints[n][c] }
if total.uniq.count == 1
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index b6abd67719..b3d84e42d1 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2009-2017, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -315,7 +315,7 @@ class Chef
end
def fixup_sudo(command)
- command.sub(/^sudo/, 'sudo -p \'knife sudo password: \'')
+ command.sub(/^sudo/, "sudo -p 'knife sudo password: '")
end
def print_data(host, data)
diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb
index 7f436d7936..a316fb8cf7 100644
--- a/lib/chef/knife/xargs.rb
+++ b/lib/chef/knife/xargs.rb
@@ -181,7 +181,7 @@ class Chef
def destroy_tempfiles(tempfiles)
# Unlink the files now that we're done with them
- tempfiles.keys.each { |tempfile| tempfile.close! }
+ tempfiles.each_key { |tempfile| tempfile.close! }
end
def xargs_files(command, tempfiles)
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index 549bde0dbb..20134ca11b 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -2,7 +2,7 @@
# Author:: Christopher Brown (<cb@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Tim Hinderliter (<tim@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,9 +47,7 @@ class Chef
def_delegators :attributes, :default_unless, :normal_unless, :override_unless, :set_unless
def_delegators :attributes, :read, :read!, :write, :write!, :unlink, :unlink!
- attr_accessor :recipe_list, :run_state, :override_runlist
-
- attr_accessor :chef_server_rest
+ attr_accessor :recipe_list, :run_state
# RunContext will set itself as run_context via this setter when
# initialized. This is needed so DSL::IncludeAttribute (in particular,
@@ -300,6 +298,7 @@ class Chef
@primary_runlist
end
+ attr_writer :override_runlist
def override_runlist(*args)
args.length > 0 ? @override_runlist.reset!(args) : @override_runlist
end
diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb
index bb32ae3b54..6922bcf200 100644
--- a/lib/chef/node/attribute_collections.rb
+++ b/lib/chef/node/attribute_collections.rb
@@ -1,6 +1,6 @@
#--
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2012-2017, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -175,7 +175,7 @@ class Chef
def []=(key, value)
ret = super
send_reset_cache(__path__)
- ret
+ ret # rubocop:disable Lint/Void
end
alias :attribute? :has_key?
diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb
index 6458db94e9..dc8ead9176 100644
--- a/lib/chef/node/immutable_collections.rb
+++ b/lib/chef/node/immutable_collections.rb
@@ -1,5 +1,5 @@
#--
-# Copyright:: Copyright 2012-2017, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -286,8 +286,6 @@ class Chef
super
end
- alias_method :to_hash, :to_h
-
def reset
@generated_cache = false
@short_circuit_attr_level = nil
@@ -315,7 +313,7 @@ class Chef
unless subhash.nil? # FIXME: nil is used for not present
tracked_components << component
if subhash.kind_of?(Hash)
- subhash.keys.each do |key|
+ subhash.each_key do |key|
next if internal_key?(key)
internal_set(key, subhash[key])
end
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 874735e048..7385a608fc 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2008-2016, 2009-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2016, 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,7 +38,6 @@ class Chef
attr_accessor :run_context
attr_reader :recipe_name
- attr_reader :cookbook_name
include Chef::Mixin::WhyRun
extend Chef::Mixin::Provides
@@ -337,7 +336,7 @@ class Chef
define_singleton_method(:inspect) { to_s }
# Add a delegator for each explicit property that will get the *current* value
# of the property by default instead of the *actual* value.
- resource.class.properties.each do |name, property|
+ resource.class.properties.each_key do |name|
class_eval(<<-EOM, __FILE__, __LINE__)
def #{name}(*args, &block)
# If no arguments were passed, we process "get" by defaulting
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index a9edf5fa58..94de68c557 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,8 +47,6 @@ class Chef
!!@overwrite
end
- attr_accessor :managed_files
-
# Hash containing keys of the paths for all the files that we sync, plus all their
# parent directories.
#
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index be695dd83a..2784ae43bc 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -181,7 +181,7 @@ class Chef
conf[dev] << config_file_contents(:delete)
end
end
- conf.each do |k, v|
+ conf.each_key do |k|
if new_resource.target == "default"
network_file_name = "/etc/sysconfig/network"
converge_by("write route default route to #{network_file_name}") do
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index d8f9094fd1..8420210a57 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -1,6 +1,6 @@
#
# Author:: Nimisha Sharad (<nimisha.sharad@msystechnologies.com>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -204,7 +204,7 @@ class Chef
# rubocop:disable Style/StringLiteralsInInterpolation
def run_schtasks(task_action, options = {})
cmd = "schtasks /#{task_action} /TN \"#{new_resource.task_name}\" "
- options.keys.each do |option|
+ options.each_key do |option|
unless option == "TR"
cmd += "/#{option} "
cmd += "\"#{options[option].to_s.gsub('"', "\\\"")}\" " unless options[option] == ""
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 5436e3ceb3..5ee4be6e25 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -861,7 +861,7 @@ class Chef
# @return [Array<Symbol>] The list of actions this Resource is allowed to
# have.
#
- attr_accessor :allowed_actions
+ attr_writer :allowed_actions
def allowed_actions(value = NOT_PASSED)
if value != NOT_PASSED
self.allowed_actions = value
diff --git a/lib/chef/resource/action_class.rb b/lib/chef/resource/action_class.rb
index dce3be3244..1bb3decb75 100644
--- a/lib/chef/resource/action_class.rb
+++ b/lib/chef/resource/action_class.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@chef.io)
-# Copyright:: Copyright 2015-2017, Chef Software Inc.
+# Copyright:: Copyright 2015-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,7 +40,7 @@ class Chef
# We clear desired state in the copy, because it is supposed to be actual state.
# We keep identity properties and non-desired-state, which are assumed to be
# "control" values like `recurse: true`
- current_resource.class.properties.each do |name, property|
+ current_resource.class.properties.each_value do |property|
if property.desired_state? && !property.identity? && !property.name_property?
property.reset(current_resource)
end
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index b12ac98673..0e4c3f826c 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,8 +41,6 @@ class Chef
include Chef::Mixin::ConvertToClassName
include Chef::Mixin::FromFile
- attr_accessor :loaded_lwrps
-
def build_from_file(cookbook_name, filename, run_context)
if LWRPBase.loaded_lwrps[filename]
Chef::Log.debug("Custom resource #{filename} from cookbook #{cookbook_name} has already been loaded! Skipping the reload.")
@@ -102,6 +100,7 @@ class Chef
protected
+ attr_writer :loaded_lwrps
def loaded_lwrps
@loaded_lwrps ||= {}
end
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index afc8500a2a..53e7ea9e30 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -3,7 +3,7 @@
# Author:: Prajakta Purohit (prajakta@chef.io>)
# Auther:: Tyler Cloke (<tyler@opscode.com>)
#
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -94,7 +94,6 @@ class Chef
attr_reader :updated_resources
attr_reader :status
attr_reader :exception
- attr_reader :run_id
attr_reader :error_descriptions
PROTOCOL_VERSION = "0.1.0"
diff --git a/lib/chef/role.rb b/lib/chef/role.rb
index c22c77b70d..ad01e9fa26 100644
--- a/lib/chef/role.rb
+++ b/lib/chef/role.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Nuo Yan (<nuo@chef.io>)
# Author:: Christopher Brown (<cb@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,8 +33,6 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
- attr_accessor :chef_server_rest
-
# Create a new Chef::Role object.
def initialize(chef_server_rest: nil)
@name = ""
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index a2663d111d..b7b15765bb 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,7 +27,6 @@ class Chef
class Search
class Query
- attr_accessor :rest
attr_reader :config
def initialize(url = nil, config: Chef::Config)
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index 40bdf01762..88d26e78fc 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -41,7 +41,6 @@ module Shell
LEADERS[Chef::Node] = ":attributes"
class << self
- attr_accessor :client_type
attr_accessor :options
attr_accessor :env
attr_writer :editor
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index dfed5372c1..ce2e457461 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -2,7 +2,7 @@
# Author:: Daniel DeLeo (<dan@kallistec.com>)
# Author:: Tim Hinderliter (<tim@chef.io>)
# Copyright:: Copyright 2009-2016, Daniel DeLeo
-# Copyright:: Copyright 2011-2016, Chef Software Inc.
+# Copyright:: Copyright 2011-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,7 +38,7 @@ module Shell
@session_type
end
- attr_accessor :node, :compile, :recipe, :run_context, :json_configuration
+ attr_accessor :node, :compile, :recipe, :json_configuration
attr_reader :node_attributes, :client
def initialize
@node_built = false
@@ -73,6 +73,7 @@ module Shell
run_context.resource_collection
end
+ attr_writer :run_context
def run_context
@run_context ||= rebuild_context
end
diff --git a/lib/chef/util/windows/volume.rb b/lib/chef/util/windows/volume.rb
index dc9c0ca1d0..358a3f4bb8 100644
--- a/lib/chef/util/windows/volume.rb
+++ b/lib/chef/util/windows/volume.rb
@@ -46,8 +46,4 @@ class Chef::Util::Windows::Volume < Chef::Util::Windows
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
-
- def mount_point
- @mount_point
- end
end
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index 6f1eb9ff12..4a1dbe3eac 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -2,7 +2,7 @@
# Author:: Prajakta Purohit (<prajakta@chef.io>)
# Author:: Lamont Granquist (<lamont@chef.io>)
#
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ class Chef
extend Chef::Mixin::WideString
attr_accessor :run_context
- attr_accessor :architecture
+ attr_reader :architecture
def initialize(run_context = nil, user_architecture = :machine)
@run_context = run_context