summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-09 07:53:56 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-09 07:53:56 -0800
commitf073747786abbe6ada55ed24b696a03e39c3c45d (patch)
tree7971d871e89d522a58291713761a6c83f68e8d19 /lib/chef
parentc6e69783705cfd48bfea0c943dc071964dd21311 (diff)
downloadchef-f073747786abbe6ada55ed24b696a03e39c3c45d.tar.gz
auto fixing some rubocops
Style/NegatedWhile Style/ParenthesesAroundCondition Style/WhileUntilDo Style/WordArray Performance/ReverseEach Style/ColonMethodCall
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/application/knife.rb2
-rw-r--r--lib/chef/application/windows_service.rb4
-rw-r--r--lib/chef/audit/audit_event_proxy.rb2
-rw-r--r--lib/chef/chef_fs/chef_fs_data_store.rb6
-rw-r--r--lib/chef/chef_fs/file_pattern.rb24
-rw-r--r--lib/chef/chef_fs/file_system.rb4
-rw-r--r--lib/chef/chef_fs/file_system/base_fs_object.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb2
-rw-r--r--lib/chef/chef_fs/knife.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer/parallel_enumerable.rb6
-rw-r--r--lib/chef/chef_fs/path_utils.rb6
-rw-r--r--lib/chef/cookbook/metadata.rb2
-rw-r--r--lib/chef/environment.rb2
-rw-r--r--lib/chef/event_loggers/windows_eventlog.rb6
-rw-r--r--lib/chef/http/authenticator.rb4
-rw-r--r--lib/chef/http/http_request.rb2
-rw-r--r--lib/chef/http/ssl_policies.rb4
-rw-r--r--lib/chef/knife/bootstrap.rb2
-rw-r--r--lib/chef/knife/cookbook_metadata.rb2
-rw-r--r--lib/chef/knife/cookbook_test.rb2
-rw-r--r--lib/chef/knife/core/generic_presenter.rb2
-rw-r--r--lib/chef/knife/core/ui.rb2
-rw-r--r--lib/chef/knife/edit.rb2
-rw-r--r--lib/chef/knife/status.rb2
-rw-r--r--lib/chef/log.rb2
-rw-r--r--lib/chef/log/winevt.rb2
-rw-r--r--lib/chef/mixin/command/unix.rb2
-rw-r--r--lib/chef/mixin/windows_architecture_helper.rb4
-rw-r--r--lib/chef/mixin/windows_env_helper.rb6
-rw-r--r--lib/chef/monkey_patches/webrick-utils.rb4
-rw-r--r--lib/chef/monologger.rb2
-rw-r--r--lib/chef/node.rb2
-rw-r--r--lib/chef/provider/git.rb2
-rw-r--r--lib/chef/provider/group/groupmod.rb2
-rw-r--r--lib/chef/provider/mount/mount.rb2
-rw-r--r--lib/chef/provider/osx_profile.rb2
-rw-r--r--lib/chef/provider/package/pacman.rb2
-rw-r--r--lib/chef/provider/package/rpm.rb2
-rw-r--r--lib/chef/provider/package/windows.rb2
-rw-r--r--lib/chef/provider/package/windows/registry_uninstall_entry.rb2
-rw-r--r--lib/chef/provider/package/yum.rb2
-rw-r--r--lib/chef/provider/service.rb4
-rw-r--r--lib/chef/provider/service/aixinit.rb2
-rw-r--r--lib/chef/provider/service/freebsd.rb2
-rw-r--r--lib/chef/provider/template.rb2
-rw-r--r--lib/chef/provider/user/dscl.rb10
-rw-r--r--lib/chef/provider/user/useradd.rb2
-rw-r--r--lib/chef/resource/rpm_package.rb2
-rw-r--r--lib/chef/resource/yum_package.rb2
-rw-r--r--lib/chef/role.rb6
-rw-r--r--lib/chef/run_context.rb4
-rw-r--r--lib/chef/run_list/run_list_item.rb2
-rw-r--r--lib/chef/run_lock.rb2
-rw-r--r--lib/chef/util/dsc/local_configuration_manager.rb10
-rw-r--r--lib/chef/util/windows/net_group.rb12
-rw-r--r--lib/chef/util/windows/net_user.rb12
-rw-r--r--lib/chef/win32/eventlog.rb2
-rw-r--r--lib/chef/win32/file.rb2
-rw-r--r--lib/chef/win32/security/sid.rb6
-rw-r--r--lib/chef/win32/security/token.rb2
-rw-r--r--lib/chef/win32/unicode.rb2
-rw-r--r--lib/chef/win32/version.rb2
63 files changed, 115 insertions, 115 deletions
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index 849a011ab3..4a39ba5ba1 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -167,7 +167,7 @@ class Chef::Application::Knife < Chef::Application
if no_command_given?
print_help_and_exit(1, NO_COMMAND_GIVEN)
elsif no_subcommand_given?
- if (want_help? || want_version?)
+ if want_help? || want_version?
print_help_and_exit(0)
else
print_help_and_exit(2, NO_COMMAND_GIVEN)
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index b955dd31b8..a9f7664e4f 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -74,7 +74,7 @@ class Chef
# Set the initial timeout to splay sleep time
timeout = rand Chef::Config[:splay]
- while running? do
+ while running?
# Grab the service_action_mutex to make a chef-client run
@service_action_mutex.synchronize do
begin
@@ -310,7 +310,7 @@ class Chef
when /^(http|https):\/\//
Chef::HTTP.new("").streaming_request(config[:config_file]) { |f| apply_config(f.path) }
else
- ::File::open(config[:config_file]) { |f| apply_config(f.path) }
+ ::File.open(config[:config_file]) { |f| apply_config(f.path) }
end
rescue Errno::ENOENT => error
Chef::Log.warn("*****************************************")
diff --git a/lib/chef/audit/audit_event_proxy.rb b/lib/chef/audit/audit_event_proxy.rb
index 667e1db592..c4d67fa8f4 100644
--- a/lib/chef/audit/audit_event_proxy.rb
+++ b/lib/chef/audit/audit_event_proxy.rb
@@ -70,7 +70,7 @@ class Chef
# If the innermost block has a resource instead of a string, don't include it in context
describe_groups.unshift(group[:description]) if described_class.nil?
group = group[:parent_example_group]
- while !group.nil?
+ until group.nil?
describe_groups.unshift(group[:description])
group = group[:parent_example_group]
end
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb
index 7cf7d5f8d9..f1a114e7f1 100644
--- a/lib/chef/chef_fs/chef_fs_data_store.rb
+++ b/lib/chef/chef_fs/chef_fs_data_store.rb
@@ -327,7 +327,7 @@ class Chef
relative << path[1]
end
relative = relative + file[:path].split("/")
- file["url"] = ChefZero::RestBase::build_uri(request.base_uri, relative)
+ file["url"] = ChefZero::RestBase.build_uri(request.base_uri, relative)
end
end
end
@@ -610,7 +610,7 @@ class Chef
private
def use_memory_store?(path)
- return path[0] == "sandboxes" || path[0] == "file_store" && path[1] == "checksums" || path == [ "environments", "_default" ]
+ return path[0] == "sandboxes" || path[0] == "file_store" && path[1] == "checksums" || path == %w(environments _default)
end
def write_cookbook(path, data, *options)
@@ -704,7 +704,7 @@ class Chef
# /acls/containers|nodes|.../x.json
# /acls/organization.json
- if path.length == 3 || path == [ "acls", "organization" ]
+ if path.length == 3 || path == %w(acls organization)
path = path.dup
path[-1] = "#{path[-1]}.json"
end
diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb
index 5beec6dfdd..a308a0fe2c 100644
--- a/lib/chef/chef_fs/file_pattern.rb
+++ b/lib/chef/chef_fs/file_pattern.rb
@@ -72,11 +72,11 @@ class Chef
def could_match_children?(path)
return false if path == "" # Empty string is not a path
- argument_is_absolute = Chef::ChefFS::PathUtils::is_absolute?(path)
+ argument_is_absolute = Chef::ChefFS::PathUtils.is_absolute?(path)
return false if is_absolute != argument_is_absolute
path = path[1, path.length - 1] if argument_is_absolute
- path_parts = Chef::ChefFS::PathUtils::split(path)
+ path_parts = Chef::ChefFS::PathUtils.split(path)
# If the pattern is shorter than the path (or same size), children will be larger than the pattern, and will not match.
return false if regexp_parts.length <= path_parts.length && !has_double_star
# If the path doesn't match up to this point, children won't match either.
@@ -111,8 +111,8 @@ class Chef
#
# This method assumes +could_match_children?(path)+ is +true+.
def exact_child_name_under(path)
- path = path[1, path.length - 1] if Chef::ChefFS::PathUtils::is_absolute?(path)
- dirs_in_path = Chef::ChefFS::PathUtils::split(path).length
+ path = path[1, path.length - 1] if Chef::ChefFS::PathUtils.is_absolute?(path)
+ dirs_in_path = Chef::ChefFS::PathUtils.split(path).length
return nil if exact_parts.length <= dirs_in_path
return exact_parts[dirs_in_path]
end
@@ -124,8 +124,8 @@ class Chef
# abc/x\\yz.exact_path == 'abc/xyz'
def exact_path
return nil if has_double_star || exact_parts.any? { |part| part.nil? }
- result = Chef::ChefFS::PathUtils::join(*exact_parts)
- is_absolute ? Chef::ChefFS::PathUtils::join("", result) : result
+ result = Chef::ChefFS::PathUtils.join(*exact_parts)
+ is_absolute ? Chef::ChefFS::PathUtils.join("", result) : result
end
# Returns the normalized version of the pattern, with / as the directory
@@ -149,7 +149,7 @@ class Chef
# abc/*/def.match?('abc/foo/def') == true
# abc/*/def.match?('abc/foo') == false
def match?(path)
- argument_is_absolute = Chef::ChefFS::PathUtils::is_absolute?(path)
+ argument_is_absolute = Chef::ChefFS::PathUtils.is_absolute?(path)
return false if is_absolute != argument_is_absolute
path = path[1, path.length - 1] if argument_is_absolute
!!regexp.match(path)
@@ -184,7 +184,7 @@ class Chef
def calculate
if !@regexp
- @is_absolute = Chef::ChefFS::PathUtils::is_absolute?(@pattern)
+ @is_absolute = Chef::ChefFS::PathUtils.is_absolute?(@pattern)
full_regexp_parts = []
normalized_parts = []
@@ -192,8 +192,8 @@ class Chef
@exact_parts = []
@has_double_star = false
- Chef::ChefFS::PathUtils::split(pattern).each do |part|
- regexp, exact, has_double_star = FilePattern::pattern_to_regexp(part)
+ Chef::ChefFS::PathUtils.split(pattern).each do |part|
+ regexp, exact, has_double_star = FilePattern.pattern_to_regexp(part)
if has_double_star
@has_double_star = true
end
@@ -232,14 +232,14 @@ class Chef
end
end
- @regexp = Regexp.new("^#{full_regexp_parts.join(Chef::ChefFS::PathUtils::regexp_path_separator)}$")
+ @regexp = Regexp.new("^#{full_regexp_parts.join(Chef::ChefFS::PathUtils.regexp_path_separator)}$")
@normalized_pattern = Chef::ChefFS::PathUtils.join(*normalized_parts)
@normalized_pattern = Chef::ChefFS::PathUtils.join("", @normalized_pattern) if @is_absolute
end
end
def self.pattern_special_characters
- if Chef::ChefFS::windows?
+ if Chef::ChefFS.windows?
@pattern_special_characters ||= /(\*\*|\*|\?|[\*\?\.\|\(\)\[\]\{\}\+\\\\\^\$])/
else
# Unix also supports character regexes and backslashes
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb
index 5865dd4b7c..415556300c 100644
--- a/lib/chef/chef_fs/file_system.rb
+++ b/lib/chef/chef_fs/file_system.rb
@@ -72,7 +72,7 @@ class Chef
# Otherwise, go through all children and find any matches
elsif entry.dir?
- results = Parallelizer::parallelize(entry.children) { |child| Chef::ChefFS::FileSystem.list(child, pattern) }
+ results = Parallelizer.parallelize(entry.children) { |child| Chef::ChefFS::FileSystem.list(child, pattern) }
results.flatten(1).each(&block)
end
end
@@ -101,7 +101,7 @@ class Chef
end
result = entry
- Chef::ChefFS::PathUtils::split(path).each do |part|
+ Chef::ChefFS::PathUtils.split(path).each do |part|
result = result.child(part)
end
result
diff --git a/lib/chef/chef_fs/file_system/base_fs_object.rb b/lib/chef/chef_fs/file_system/base_fs_object.rb
index 19f98f2bdd..cf1aed552f 100644
--- a/lib/chef/chef_fs/file_system/base_fs_object.rb
+++ b/lib/chef/chef_fs/file_system/base_fs_object.rb
@@ -27,7 +27,7 @@ class Chef
@parent = parent
@name = name
if parent
- @path = Chef::ChefFS::PathUtils::join(parent.path, name)
+ @path = Chef::ChefFS::PathUtils.join(parent.path, name)
else
if name != ""
raise ArgumentError, "Name of root object must be empty string: was '#{name}' instead"
@@ -149,7 +149,7 @@ class Chef
if parent_path == "."
name
else
- Chef::ChefFS::PathUtils::join(parent.path_for_printing, name)
+ Chef::ChefFS::PathUtils.join(parent.path_for_printing, name)
end
else
name
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 a6a062ab3c..3a08768baf 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
@@ -153,7 +153,7 @@ class Chef
return [ !exists?, nil, nil ]
end
are_same = true
- Chef::ChefFS::CommandLine::diff_entries(self, other, nil, :name_only).each do |type, old_entry, new_entry|
+ Chef::ChefFS::CommandLine.diff_entries(self, other, nil, :name_only).each do |type, old_entry, new_entry|
if [ :directory_to_file, :file_to_directory, :deleted, :added, :modified ].include?(type)
are_same = false
end
diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb
index 399bf1c434..1731e19ce1 100644
--- a/lib/chef/chef_fs/knife.rb
+++ b/lib/chef/chef_fs/knife.rb
@@ -131,7 +131,7 @@ class Chef
ui.error("Current working directory is '#{@chef_fs_config.cwd}'.")
exit(1)
else
- inferred_path = Chef::ChefFS::PathUtils::join(@chef_fs_config.base_path, arg)
+ inferred_path = Chef::ChefFS::PathUtils.join(@chef_fs_config.base_path, arg)
end
Chef::ChefFS::FilePattern.new(inferred_path)
end
diff --git a/lib/chef/chef_fs/parallelizer.rb b/lib/chef/chef_fs/parallelizer.rb
index 5d05f41e94..ccbf7ad96e 100644
--- a/lib/chef/chef_fs/parallelizer.rb
+++ b/lib/chef/chef_fs/parallelizer.rb
@@ -87,7 +87,7 @@ class Chef
def worker_loop
begin
- while !@stop_thread[Thread.current]
+ until @stop_thread[Thread.current]
begin
task = @tasks.pop
task.call
diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
index 8df6a76e13..9d02bbab78 100644
--- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
@@ -157,7 +157,7 @@ class Chef
@parent_task_queue.push(method(:process_one))
stop_processing_input = false
- while !@unconsumed_output.empty?
+ until @unconsumed_output.empty?
output, index, input, type = @unconsumed_output.pop
yield output, index, input, type
if type == :exception && @options[:stop_on_exception]
@@ -178,13 +178,13 @@ class Chef
end
end
- while !finished?
+ until finished?
# yield thread to others (for 1.8.7)
if @unconsumed_output.empty?
sleep(0.01)
end
- while !@unconsumed_output.empty?
+ until @unconsumed_output.empty?
yield @unconsumed_output.pop
end
diff --git a/lib/chef/chef_fs/path_utils.rb b/lib/chef/chef_fs/path_utils.rb
index 8ec5c3df78..7b2de5e3e0 100644
--- a/lib/chef/chef_fs/path_utils.rb
+++ b/lib/chef/chef_fs/path_utils.rb
@@ -57,7 +57,7 @@ class Chef
end
def self.regexp_path_separator
- Chef::ChefFS::windows? ? '[\/\\\\]' : "/"
+ Chef::ChefFS.windows? ? '[\/\\\\]' : "/"
end
# Given a server path, determines if it is absolute.
@@ -83,7 +83,7 @@ class Chef
# File.dirname happens to return the path as its own dirname if you're
# at the root (such as at \\foo\bar, C:\ or /)
- until parent_path == path do
+ until parent_path == path
# This can occur if a path such as "C:" is given. Ruby gives the parent as "C:."
# for reasons only it knows.
raise ArgumentError "Invalid path segment #{path}" if parent_path.length > path.length
@@ -101,7 +101,7 @@ class Chef
# Compares two path fragments according to the case-sentitivity of the host platform.
def self.os_path_eq?(left, right)
- Chef::ChefFS::windows? ? left.casecmp(right) == 0 : left == right
+ Chef::ChefFS.windows? ? left.casecmp(right) == 0 : left == right
end
# Given two general OS-dependent file paths, determines the relative path of the
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index 7cc4be9f89..73d1cf8379 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -485,7 +485,7 @@ class Chef
:description => { :kind_of => String },
:choice => { :kind_of => [ Array ], :default => [] },
:calculated => { :equal_to => [ true, false ], :default => false },
- :type => { :equal_to => [ "string", "array", "hash", "symbol", "boolean", "numeric" ], :default => "string" },
+ :type => { :equal_to => %w(string array hash symbol boolean numeric), :default => "string" },
:required => { :equal_to => [ "required", "recommended", "optional", true, false ], :default => "optional" },
:recipes => { :kind_of => [ Array ], :default => [] },
:default => { :kind_of => [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] },
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index aa6d756737..b286dad4e2 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -170,7 +170,7 @@ class Chef
unless params[:cookbook_version].nil?
params[:cookbook_version].each do |index, cookbook_constraint_spec|
- unless (cookbook_constraint_spec.nil? || cookbook_constraint_spec.size == 0)
+ unless cookbook_constraint_spec.nil? || cookbook_constraint_spec.size == 0
valid = valid && update_cookbook_constraint_from_param(index, cookbook_constraint_spec)
end
end
diff --git a/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb
index 1d16b66087..514fc7b087 100644
--- a/lib/chef/event_loggers/windows_eventlog.rb
+++ b/lib/chef/event_loggers/windows_eventlog.rb
@@ -38,11 +38,11 @@ class Chef
SOURCE = "Chef"
def self.available?
- return Chef::Platform::windows?
+ return Chef::Platform.windows?
end
def initialize
- @eventlog = ::Win32::EventLog::open("Application")
+ @eventlog = ::Win32::EventLog.open("Application")
end
def run_start(version)
@@ -83,7 +83,7 @@ class Chef
[@run_status.run_id,
@run_status.elapsed_time.to_s]
else
- ["UNKNOWN", "UNKNOWN"]
+ %w(UNKNOWN UNKNOWN)
end
@eventlog.report_event(
diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb
index 970c19cd62..b5e28cf54d 100644
--- a/lib/chef/http/authenticator.rb
+++ b/lib/chef/http/authenticator.rb
@@ -73,9 +73,9 @@ class Chef
end
def load_signing_key(key_file, raw_key = nil)
- if (!!key_file)
+ if !!key_file
@raw_key = IO.read(key_file).strip
- elsif (!!raw_key)
+ elsif !!raw_key
@raw_key = raw_key.strip
else
return nil
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index a1ef9b9ee2..6cd7dda251 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -169,7 +169,7 @@ class Chef
raise ArgumentError, "You must provide :GET, :PUT, :POST, :DELETE or :HEAD as the method"
end
- @http_request.body = request_body if (request_body && @http_request.request_body_permitted?)
+ @http_request.body = request_body if request_body && @http_request.request_body_permitted?
# Optionally handle HTTP Basic Authentication
if url.user
user = URI.unescape(url.user)
diff --git a/lib/chef/http/ssl_policies.rb b/lib/chef/http/ssl_policies.rb
index f49fca02f6..51db01c232 100644
--- a/lib/chef/http/ssl_policies.rb
+++ b/lib/chef/http/ssl_policies.rb
@@ -86,8 +86,8 @@ class Chef
end
def set_client_credentials
- if (config[:ssl_client_cert] || config[:ssl_client_key])
- unless (config[:ssl_client_cert] && config[:ssl_client_key])
+ if config[:ssl_client_cert] || config[:ssl_client_key]
+ unless config[:ssl_client_cert] && config[:ssl_client_key]
raise Chef::Exceptions::ConfigurationError, "You must configure ssl_client_cert and ssl_client_key together"
end
unless ::File.exists?(config[:ssl_client_cert])
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 7982c0f927..27f7a4ddc3 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -220,7 +220,7 @@ class Chef
:long => "--node-ssl-verify-mode [peer|none]",
:description => "Whether or not to verify the SSL cert for all HTTPS requests.",
:proc => Proc.new { |v|
- valid_values = ["none", "peer"]
+ valid_values = %w(none peer)
unless valid_values.include?(v)
raise "Invalid value '#{v}' for --node-ssl-verify-mode. Valid values are: #{valid_values.join(", ")}"
end
diff --git a/lib/chef/knife/cookbook_metadata.rb b/lib/chef/knife/cookbook_metadata.rb
index b13ab18a57..bfae9d8814 100644
--- a/lib/chef/knife/cookbook_metadata.rb
+++ b/lib/chef/knife/cookbook_metadata.rb
@@ -61,7 +61,7 @@ class Chef
end
def generate_metadata(cookbook)
- Array(config[:cookbook_path]).reverse.each do |path|
+ Array(config[:cookbook_path]).reverse_each do |path|
file = File.expand_path(File.join(path, cookbook, "metadata.rb"))
if File.exists?(file)
generate_metadata_from_file(cookbook, file)
diff --git a/lib/chef/knife/cookbook_test.rb b/lib/chef/knife/cookbook_test.rb
index ee42facf5e..1a5c9df74e 100644
--- a/lib/chef/knife/cookbook_test.rb
+++ b/lib/chef/knife/cookbook_test.rb
@@ -69,7 +69,7 @@ class Chef
def test_cookbook(cookbook)
ui.info("Running syntax check on #{cookbook}")
- Array(config[:cookbook_path]).reverse.each do |path|
+ Array(config[:cookbook_path]).reverse_each do |path|
syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cookbook, path)
test_ruby(syntax_checker)
test_templates(syntax_checker)
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index bbe0249b3d..61069cff48 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -81,7 +81,7 @@ class Chef
Chef::JSONCompat.to_json_pretty(data)
when :yaml
require "yaml"
- YAML::dump(data)
+ YAML.dump(data)
when :pp
require "stringio"
# If you were looking for some attribute and there is only one match
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb
index ee92127898..d6c21ee411 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -173,7 +173,7 @@ class Chef
def edit_data(data, parse_output = true)
output = Chef::JSONCompat.to_json_pretty(data)
- if (!config[:disable_editing])
+ if !config[:disable_editing]
Tempfile.open([ "knife-edit-", ".json" ]) do |tf|
tf.sync = true
tf.puts output
diff --git a/lib/chef/knife/edit.rb b/lib/chef/knife/edit.rb
index 00358b2d09..cd2c1c741b 100644
--- a/lib/chef/knife/edit.rb
+++ b/lib/chef/knife/edit.rb
@@ -50,7 +50,7 @@ class Chef
end
def edit_text(text, extension)
- if (!config[:disable_editing])
+ if !config[:disable_editing]
Tempfile.open([ "knife-edit-", extension ]) do |file|
# Write the text to a temporary file
file.write(text)
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 7bf9abbd1b..e7a7165faa 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -97,7 +97,7 @@ class Chef
end
output(all_nodes.sort { |n1, n2|
- if (config[:sort_reverse] || Chef::Config[:knife][:sort_status_reverse])
+ if config[:sort_reverse] || Chef::Config[:knife][:sort_status_reverse]
(n2["ohai_time"] or 0) <=> (n1["ohai_time"] or 0)
else
(n1["ohai_time"] or 0) <=> (n2["ohai_time"] or 0)
diff --git a/lib/chef/log.rb b/lib/chef/log.rb
index 8d4fed56aa..bfb5829be6 100644
--- a/lib/chef/log.rb
+++ b/lib/chef/log.rb
@@ -21,7 +21,7 @@ require "logger"
require "chef/monologger"
require "chef/exceptions"
require "mixlib/log"
-require "chef/log/syslog" unless (RUBY_PLATFORM =~ /mswin|mingw|windows/)
+require "chef/log/syslog" unless RUBY_PLATFORM =~ /mswin|mingw|windows/
require "chef/log/winevt"
class Chef
diff --git a/lib/chef/log/winevt.rb b/lib/chef/log/winevt.rb
index 04e24e3913..8411ad8af0 100644
--- a/lib/chef/log/winevt.rb
+++ b/lib/chef/log/winevt.rb
@@ -43,7 +43,7 @@ class Chef
attr_accessor :sync, :formatter, :level
def initialize(eventlog = nil)
- @eventlog = eventlog || ::Win32::EventLog::open("Application")
+ @eventlog = eventlog || ::Win32::EventLog.open("Application")
end
def close
diff --git a/lib/chef/mixin/command/unix.rb b/lib/chef/mixin/command/unix.rb
index d930ee33e6..bfd507979f 100644
--- a/lib/chef/mixin/command/unix.rb
+++ b/lib/chef/mixin/command/unix.rb
@@ -109,7 +109,7 @@ class Chef
Marshal.dump(e, ps.last)
ps.last.flush
end
- ps.last.close unless (ps.last.closed?)
+ ps.last.close unless ps.last.closed?
exit!
}
ensure
diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb
index 5f8d3e3729..ea058537ea 100644
--- a/lib/chef/mixin/windows_architecture_helper.rb
+++ b/lib/chef/mixin/windows_architecture_helper.rb
@@ -98,13 +98,13 @@ class Chef
end
def disable_wow64_file_redirection( node )
- if ( ( node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?)
+ if ( node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?
Chef::ReservedNames::Win32::System.wow64_disable_wow64_fs_redirection
end
end
def restore_wow64_file_redirection( node, original_redirection_state )
- if ( (node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?)
+ if (node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?
Chef::ReservedNames::Win32::System.wow64_revert_wow64_fs_redirection(original_redirection_state)
end
end
diff --git a/lib/chef/mixin/windows_env_helper.rb b/lib/chef/mixin/windows_env_helper.rb
index b2e08edc08..51806da31d 100644
--- a/lib/chef/mixin/windows_env_helper.rb
+++ b/lib/chef/mixin/windows_env_helper.rb
@@ -43,12 +43,12 @@ class Chef
flags = SMTO_BLOCK | SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG
# for why two calls, see:
# http://stackoverflow.com/questions/4968373/why-doesnt-sendmessagetimeout-update-the-environment-variables
- if ( SendMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string("Environment").address, flags, 5000, nil) == 0 )
+ if SendMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string("Environment").address, flags, 5000, nil) == 0
Chef::ReservedNames::Win32::Error.raise!
end
- if ( SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string(
+ if SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string(
utf8_to_wide("Environment")
- ).address, flags, 5000, nil) == 0 )
+ ).address, flags, 5000, nil) == 0
Chef::ReservedNames::Win32::Error.raise!
end
end
diff --git a/lib/chef/monkey_patches/webrick-utils.rb b/lib/chef/monkey_patches/webrick-utils.rb
index 71bed2bb74..7880adb202 100644
--- a/lib/chef/monkey_patches/webrick-utils.rb
+++ b/lib/chef/monkey_patches/webrick-utils.rb
@@ -24,7 +24,7 @@ module WEBrick
unless port
raise ArgumentError, "must specify port"
end
- res = Socket::getaddrinfo(address, port,
+ res = Socket.getaddrinfo(address, port,
Socket::AF_UNSPEC, # address family
Socket::SOCK_STREAM, # socket type
0, # protocol
@@ -36,7 +36,7 @@ module WEBrick
logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger
sock = TCPServer.new(ai[3], port)
port = sock.addr[1] if port == 0
- Utils::set_close_on_exec(sock)
+ Utils.set_close_on_exec(sock)
sockets << sock
rescue => ex
logger.warn("TCPServer Error: #{ex}") if logger
diff --git a/lib/chef/monologger.rb b/lib/chef/monologger.rb
index 77ca54d7eb..49f744e314 100644
--- a/lib/chef/monologger.rb
+++ b/lib/chef/monologger.rb
@@ -64,7 +64,7 @@ class MonoLogger < Logger
private
def open_logfile(filename)
- if (FileTest.exist?(filename))
+ if FileTest.exist?(filename)
open(filename, (File::WRONLY | File::APPEND))
else
create_logfile(filename)
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index 1f72c86a8b..4afba1aeb8 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -685,7 +685,7 @@ class Chef
def data_for_save
data = for_json
- ["automatic", "default", "normal", "override"].each do |level|
+ %w(automatic default normal override).each do |level|
whitelist_config_option = "#{level}_attribute_whitelist".to_sym
whitelist = Chef::Config[whitelist_config_option]
unless whitelist.nil? # nil => save everything
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index f8a8dabb46..600da540e5 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -126,7 +126,7 @@ class Chef
end
def add_remotes
- if (@new_resource.additional_remotes.length > 0)
+ if @new_resource.additional_remotes.length > 0
@new_resource.additional_remotes.each_pair do |remote_name, remote_url|
converge_by("add remote #{remote_name} from #{remote_url}") do
Chef::Log.info "#{@new_resource} adding git remote #{remote_name} = #{remote_url}"
diff --git a/lib/chef/provider/group/groupmod.rb b/lib/chef/provider/group/groupmod.rb
index 379d00e286..98846aa418 100644
--- a/lib/chef/provider/group/groupmod.rb
+++ b/lib/chef/provider/group/groupmod.rb
@@ -25,7 +25,7 @@ class Chef
def load_current_resource
super
- [ "group", "user" ].each do |binary|
+ %w(group user).each do |binary|
raise Chef::Exceptions::Group, "Could not find binary /usr/sbin/#{binary} for #{@new_resource}" unless ::File.exists?("/usr/sbin/#{binary}")
end
end
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index f8b8684a1b..8f9f8b05d4 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -42,7 +42,7 @@ class Chef
def mountable?
# only check for existence of non-remote devices
- if (device_should_exist? && !::File.exists?(device_real) )
+ if device_should_exist? && !::File.exists?(device_real)
raise Chef::Exceptions::Mount, "Device #{@new_resource.device} does not exist"
elsif( @new_resource.mount_point != "none" && !::File.exists?(@new_resource.mount_point) )
raise Chef::Exceptions::Mount, "Mount point #{@new_resource.mount_point} does not exist"
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index e93d29bd1f..1bef30d53b 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -234,7 +234,7 @@ class Chef
end
def read_plist(xml_file)
- Plist::parse_xml(xml_file)
+ Plist.parse_xml(xml_file)
end
def profile_installed?
diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb
index 22fa9c2307..460f4c4ea2 100644
--- a/lib/chef/provider/package/pacman.rb
+++ b/lib/chef/provider/package/pacman.rb
@@ -52,7 +52,7 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
- repos = ["extra", "core", "community"]
+ repos = %w(extra core community)
if(::File.exists?("/etc/pacman.conf"))
pacman = ::File.read("/etc/pacman.conf")
diff --git a/lib/chef/provider/package/rpm.rb b/lib/chef/provider/package/rpm.rb
index c72c9559c8..c00f0ebbd4 100644
--- a/lib/chef/provider/package/rpm.rb
+++ b/lib/chef/provider/package/rpm.rb
@@ -25,7 +25,7 @@ class Chef
class Package
class Rpm < Chef::Provider::Package
- provides :rpm_package, os: [ "linux", "aix" ]
+ provides :rpm_package, os: %w(linux aix)
include Chef::Mixin::GetSourceFromPackage
diff --git a/lib/chef/provider/package/windows.rb b/lib/chef/provider/package/windows.rb
index dc22de7ad5..f0c60db29e 100644
--- a/lib/chef/provider/package/windows.rb
+++ b/lib/chef/provider/package/windows.rb
@@ -105,7 +105,7 @@ class Chef
return :nsis
end
- if (io.tell() < filesize)
+ if io.tell() < filesize
io.seek(io.tell() - overlap)
end
end
diff --git a/lib/chef/provider/package/windows/registry_uninstall_entry.rb b/lib/chef/provider/package/windows/registry_uninstall_entry.rb
index 952a0f76b9..3fa00b6081 100644
--- a/lib/chef/provider/package/windows/registry_uninstall_entry.rb
+++ b/lib/chef/provider/package/windows/registry_uninstall_entry.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "win32/registry" if (RUBY_PLATFORM =~ /mswin|mingw32|windows/)
+require "win32/registry" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
class Chef
class Provider
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index aeecf3869e..858b430abe 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -128,7 +128,7 @@ class Chef
y_pos_max = y.length - 1
y_comp = nil
- while (x_pos <= x_pos_max and y_pos <= y_pos_max)
+ while x_pos <= x_pos_max and y_pos <= y_pos_max
# first we skip over anything non alphanumeric
while (x_pos <= x_pos_max) and (isalnum(x[x_pos]) == false)
x_pos += 1 # +1 over pos_max if end of string
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index 390330aed2..3b78cb4afc 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -50,10 +50,10 @@ class Chef
# XXX?: the #nil? check below will likely fail if this is a cloned resource or if
# we just run multiple actions.
def load_new_resource_state
- if ( @new_resource.enabled.nil? )
+ if @new_resource.enabled.nil?
@new_resource.enabled(@current_resource.enabled)
end
- if ( @new_resource.running.nil? )
+ if @new_resource.running.nil?
@new_resource.running(@current_resource.running)
end
end
diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb
index 6b451d649a..0234673474 100644
--- a/lib/chef/provider/service/aixinit.rb
+++ b/lib/chef/provider/service/aixinit.rb
@@ -97,7 +97,7 @@ class Chef
priority = {}
files.each do |file|
- if (RC_D_SCRIPT_NAME =~ file)
+ if RC_D_SCRIPT_NAME =~ file
priority[2] = [($1 == "S" ? :start : :stop), ($2.empty? ? "" : $2.to_i)]
if $1 == "S"
is_enabled = true
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb
index 7e475fc878..e556eccf22 100644
--- a/lib/chef/provider/service/freebsd.rb
+++ b/lib/chef/provider/service/freebsd.rb
@@ -27,7 +27,7 @@ class Chef
attr_reader :enabled_state_found
- provides :service, os: [ "freebsd", "netbsd" ]
+ provides :service, os: %w(freebsd netbsd)
include Chef::Mixin::ShellOut
diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb
index e12d465353..3c46a6eb7d 100644
--- a/lib/chef/provider/template.rb
+++ b/lib/chef/provider/template.rb
@@ -45,7 +45,7 @@ class Chef
super
requirements.assert(:create, :create_if_missing) do |a|
- a.assertion { ::File::exists?(content.template_location) }
+ a.assertion { ::File.exists?(content.template_location) }
a.failure_message "Template source #{content.template_location} could not be found."
a.whyrun "Template source #{content.template_location} does not exist. Assuming it would have been created."
a.block_action!
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index e81a01c764..8c282b0d7e 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -130,7 +130,7 @@ user password using shadow hash.")
# Calling shell_out directly since we want to give an input stream
shadow_hash_xml = convert_binary_plist_to_xml(shadow_hash_binary.string)
- shadow_hash = Plist::parse_xml(shadow_hash_xml)
+ shadow_hash = Plist.parse_xml(shadow_hash_xml)
if shadow_hash["SALTED-SHA512"]
# Convert the shadow value from Base64 encoding to hex before consuming them
@@ -212,7 +212,7 @@ user password using shadow hash.")
#
def dscl_set_uid
# XXX: mutates the new resource
- new_resource.uid(get_free_uid) if (new_resource.uid.nil? || new_resource.uid == "")
+ new_resource.uid(get_free_uid) if new_resource.uid.nil? || new_resource.uid == ""
if uid_used?(new_resource.uid)
raise(Chef::Exceptions::RequestedUIDUnavailable, "uid #{new_resource.uid} is already in use")
@@ -410,7 +410,7 @@ user password using shadow hash.")
salt = OpenSSL::Random.random_bytes(32)
iterations = new_resource.iterations # Use the default if not specified by the user
- entropy = OpenSSL::PKCS5::pbkdf2_hmac(
+ entropy = OpenSSL::PKCS5.pbkdf2_hmac(
new_resource.password,
salt,
iterations,
@@ -589,7 +589,7 @@ user password using shadow hash.")
begin
user_plist_file = "#{USER_PLIST_DIRECTORY}/#{new_resource.username}.plist"
user_plist_info = run_plutil("convert xml1 -o - #{user_plist_file}")
- user_info = Plist::parse_xml(user_plist_info)
+ user_info = Plist.parse_xml(user_plist_info)
rescue Chef::Exceptions::PlistUtilCommandFailed
end
@@ -695,7 +695,7 @@ user password using shadow hash.")
def salted_sha512_pbkdf2_password_match?
salt = convert_to_binary(current_resource.salt)
- OpenSSL::PKCS5::pbkdf2_hmac(
+ OpenSSL::PKCS5.pbkdf2_hmac(
new_resource.password,
salt,
current_resource.iterations,
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
index aabd4b5f68..708631e4ab 100644
--- a/lib/chef/provider/user/useradd.rb
+++ b/lib/chef/provider/user/useradd.rb
@@ -75,7 +75,7 @@ class Chef
unless passwd_s.exitstatus == 0
raise_lock_error = false
- if ["redhat", "centos"].include?(node[:platform])
+ if %w(redhat centos).include?(node[:platform])
passwd_version_check = shell_out!("rpm -q passwd")
passwd_version = passwd_version_check.stdout.chomp
diff --git a/lib/chef/resource/rpm_package.rb b/lib/chef/resource/rpm_package.rb
index fdb5913db5..72598b6a83 100644
--- a/lib/chef/resource/rpm_package.rb
+++ b/lib/chef/resource/rpm_package.rb
@@ -23,7 +23,7 @@ class Chef
class Resource
class RpmPackage < Chef::Resource::Package
resource_name :rpm_package
- provides :rpm_package, os: [ "linux", "aix" ]
+ provides :rpm_package, os: %w(linux aix)
property :allow_downgrade, [ true, false ], default: false, desired_state: false
diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb
index f2dd772d82..c7d18f0dc2 100644
--- a/lib/chef/resource/yum_package.rb
+++ b/lib/chef/resource/yum_package.rb
@@ -23,7 +23,7 @@ class Chef
class Resource
class YumPackage < Chef::Resource::Package
resource_name :yum_package
- provides :package, os: "linux", platform_family: [ "rhel", "fedora" ]
+ provides :package, os: "linux", platform_family: %w(rhel fedora)
# Install a specific arch
property :arch, [ String, Array ]
diff --git a/lib/chef/role.rb b/lib/chef/role.rb
index a5a33c28cf..bac054143e 100644
--- a/lib/chef/role.rb
+++ b/lib/chef/role.rb
@@ -70,7 +70,7 @@ class Chef
end
def run_list(*args)
- if (args.length > 0)
+ if args.length > 0
@env_run_lists["_default"].reset!(args)
end
@env_run_lists["_default"]
@@ -93,7 +93,7 @@ class Chef
# Per environment run lists
def env_run_lists(env_run_lists = nil)
- if (!env_run_lists.nil?)
+ if !env_run_lists.nil?
unless env_run_lists.key?("_default")
msg = "_default key is required in env_run_lists.\n"
msg << "(env_run_lists: #{env_run_lists.inspect})"
@@ -108,7 +108,7 @@ class Chef
alias :env_run_list :env_run_lists
def env_run_lists_add(env_run_lists = nil)
- if (!env_run_lists.nil?)
+ if !env_run_lists.nil?
env_run_lists.each { |k, v| @env_run_lists[k] = Chef::RunList.new(*Array(v)) }
end
@env_run_lists
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index ecb16c190d..cb3338d3de 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -541,12 +541,12 @@ ERROR_MESSAGE
# 5. raise an exception on any second call.
# 6. ?
def request_reboot(reboot_info)
- Chef::Log::info "Changing reboot status from #{self.reboot_info.inspect} to #{reboot_info.inspect}"
+ Chef::Log.info "Changing reboot status from #{self.reboot_info.inspect} to #{reboot_info.inspect}"
@reboot_info = reboot_info
end
def cancel_reboot
- Chef::Log::info "Changing reboot status from #{reboot_info.inspect} to {}"
+ Chef::Log.info "Changing reboot status from #{reboot_info.inspect} to {}"
@reboot_info = {}
end
diff --git a/lib/chef/run_list/run_list_item.rb b/lib/chef/run_list/run_list_item.rb
index 15e11b206e..0abfb106ff 100644
--- a/lib/chef/run_list/run_list_item.rb
+++ b/lib/chef/run_list/run_list_item.rb
@@ -32,7 +32,7 @@ class Chef
assert_hash_is_valid_run_list_item!(item)
@type = (item["type"] || item[:type]).to_sym
@name = item["name"] || item[:name]
- if (item.has_key?("version") || item.has_key?(:version))
+ if item.has_key?("version") || item.has_key?(:version)
@version = item["version"] || item[:version]
end
when String
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index be83494048..08d58fd164 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -63,7 +63,7 @@ class Chef
def acquire
if timeout_given?
begin
- Timeout::timeout(time_to_wait) do
+ Timeout.timeout(time_to_wait) do
unless test
if time_to_wait > 0.0
wait
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb
index 3b4eaa92a9..741c6a5898 100644
--- a/lib/chef/util/dsc/local_configuration_manager.rb
+++ b/lib/chef/util/dsc/local_configuration_manager.rb
@@ -81,11 +81,11 @@ EOH
def log_what_if_exception(what_if_exception_output)
if whatif_not_supported?(what_if_exception_output)
# LCM returns an error if any of the resources do not support the opptional What-If
- Chef::Log::warn("Received error while testing configuration due to resource not supporting 'WhatIf'")
+ Chef::Log.warn("Received error while testing configuration due to resource not supporting 'WhatIf'")
elsif dsc_module_import_failure?(what_if_exception_output)
- Chef::Log::warn("Received error while testing configuration due to a module for an imported resource possibly not being fully installed:\n#{what_if_exception_output.gsub(/\s+/, ' ')}")
+ Chef::Log.warn("Received error while testing configuration due to a module for an imported resource possibly not being fully installed:\n#{what_if_exception_output.gsub(/\s+/, ' ')}")
else
- Chef::Log::warn("Received error while testing configuration:\n#{what_if_exception_output.gsub(/\s+/, ' ')}")
+ Chef::Log.warn("Received error while testing configuration:\n#{what_if_exception_output.gsub(/\s+/, ' ')}")
end
end
@@ -102,9 +102,9 @@ EOH
def configuration_update_required?(what_if_output)
Chef::Log.debug("DSC: DSC returned the following '-whatif' output from test operation:\n#{what_if_output}")
begin
- Parser::parse(what_if_output)
+ Parser.parse(what_if_output)
rescue Chef::Exceptions::LCMParser => e
- Chef::Log::warn("Could not parse LCM output: #{e}")
+ Chef::Log.warn("Could not parse LCM output: #{e}")
[Chef::Util::DSC::ResourceInfo.new("Unknown DSC Resources", true, ["Unknown changes because LCM output was not parsable."])]
end
end
diff --git a/lib/chef/util/windows/net_group.rb b/lib/chef/util/windows/net_group.rb
index 6dd6e39f2b..0a351fbc6f 100644
--- a/lib/chef/util/windows/net_group.rb
+++ b/lib/chef/util/windows/net_group.rb
@@ -36,7 +36,7 @@ class Chef::Util::Windows::NetGroup
def local_get_members
begin
- Chef::ReservedNames::Win32::NetUser::net_local_group_get_members(nil, groupname)
+ Chef::ReservedNames::Win32::NetUser.net_local_group_get_members(nil, groupname)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
@@ -44,7 +44,7 @@ class Chef::Util::Windows::NetGroup
def local_add
begin
- Chef::ReservedNames::Win32::NetUser::net_local_group_add(nil, groupname)
+ Chef::ReservedNames::Win32::NetUser.net_local_group_add(nil, groupname)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
@@ -52,7 +52,7 @@ class Chef::Util::Windows::NetGroup
def local_set_members(members)
begin
- Chef::ReservedNames::Win32::NetUser::net_local_group_set_members(nil, groupname, members)
+ Chef::ReservedNames::Win32::NetUser.net_local_group_set_members(nil, groupname, members)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
@@ -60,7 +60,7 @@ class Chef::Util::Windows::NetGroup
def local_add_members(members)
begin
- Chef::ReservedNames::Win32::NetUser::net_local_group_add_members(nil, groupname, members)
+ Chef::ReservedNames::Win32::NetUser.net_local_group_add_members(nil, groupname, members)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
@@ -68,7 +68,7 @@ class Chef::Util::Windows::NetGroup
def local_delete_members(members)
begin
- Chef::ReservedNames::Win32::NetUser::net_local_group_del_members(nil, groupname, members)
+ Chef::ReservedNames::Win32::NetUser.net_local_group_del_members(nil, groupname, members)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
@@ -76,7 +76,7 @@ class Chef::Util::Windows::NetGroup
def local_delete
begin
- Chef::ReservedNames::Win32::NetUser::net_local_group_del(nil, groupname)
+ Chef::ReservedNames::Win32::NetUser.net_local_group_del(nil, groupname)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb
index f2edeacf17..b0a779e44a 100644
--- a/lib/chef/util/windows/net_user.rb
+++ b/lib/chef/util/windows/net_user.rb
@@ -79,7 +79,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def set_info(args)
begin
- rc = NetUser::net_user_set_info_l3(nil, @username, transform_usri3(args))
+ rc = NetUser.net_user_set_info_l3(nil, @username, transform_usri3(args))
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
@@ -96,7 +96,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
#XXX for an extra painful alternative, see: http://support.microsoft.com/kb/180548
def validate_credentials(passwd)
begin
- token = Security::logon_user(@username, nil, passwd,
+ token = Security.logon_user(@username, nil, passwd,
LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT)
return true
rescue Chef::Exceptions::Win32APIError
@@ -106,7 +106,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def get_info
begin
- ui3 = NetUser::net_user_get_info_l3(nil, @username)
+ ui3 = NetUser.net_user_get_info_l3(nil, @username)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
@@ -115,8 +115,8 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def add(args)
transformed_args = transform_usri3(args)
- NetUser::net_user_add_l3(nil, transformed_args)
- NetUser::net_local_group_add_member(nil, "Users", args[:name])
+ NetUser.net_user_add_l3(nil, transformed_args)
+ NetUser.net_local_group_add_member(nil, "Users", args[:name])
end
def user_modify(&proc)
@@ -137,7 +137,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def delete
begin
- NetUser::net_user_del(nil, @username)
+ NetUser.net_user_del(nil, @username)
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb
index 0562f0c10e..723b43fc44 100644
--- a/lib/chef/win32/eventlog.rb
+++ b/lib/chef/win32/eventlog.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-if Chef::Platform::windows? and not Chef::Platform::windows_server_2003?
+if Chef::Platform.windows? and not Chef::Platform.windows_server_2003?
if !defined? Chef::Win32EventLogLoaded
if defined? Windows::Constants
[:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c|
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb
index 19b17b7d7c..94a771c3ba 100644
--- a/lib/chef/win32/file.rb
+++ b/lib/chef/win32/file.rb
@@ -76,7 +76,7 @@ class Chef
is_symlink = false
path = encode_path(file_name)
if ::File.exists?(file_name)
- if ((GetFileAttributesW(path) & FILE_ATTRIBUTE_REPARSE_POINT) > 0)
+ if (GetFileAttributesW(path) & FILE_ATTRIBUTE_REPARSE_POINT) > 0
file_search_handle(file_name) do |handle, find_data|
if find_data[:dw_reserved_0] == IO_REPARSE_TAG_SYMLINK
is_symlink = true
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index 4d2d252dd3..665cba8880 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -46,7 +46,7 @@ class Chef
end
def self.from_string_sid(string_sid)
- Chef::ReservedNames::Win32::Security::convert_string_sid_to_sid(string_sid)
+ Chef::ReservedNames::Win32::Security.convert_string_sid_to_sid(string_sid)
end
def ==(other)
@@ -275,10 +275,10 @@ class Chef
status = ERROR_MORE_DATA
- while(status == ERROR_MORE_DATA) do
+ while(status == ERROR_MORE_DATA)
status = NetUserEnum(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle)
- if (status == NERR_Success || status == ERROR_MORE_DATA)
+ if status == NERR_Success || status == ERROR_MORE_DATA
entriesread.read_long.times.collect do |i|
user_info = USER_INFO_3.new(bufptr.read_pointer + i * USER_INFO_3.size)
# Check if the account is the Administrator account
diff --git a/lib/chef/win32/security/token.rb b/lib/chef/win32/security/token.rb
index f8b6790d44..38ef03b33c 100644
--- a/lib/chef/win32/security/token.rb
+++ b/lib/chef/win32/security/token.rb
@@ -55,7 +55,7 @@ class Chef
def adjust_privileges(privileges_struct)
if privileges_struct[:PrivilegeCount] > 0
- Chef::ReservedNames::Win32::Security::adjust_token_privileges(self, privileges_struct)
+ Chef::ReservedNames::Win32::Security.adjust_token_privileges(self, privileges_struct)
end
end
diff --git a/lib/chef/win32/unicode.rb b/lib/chef/win32/unicode.rb
index b0fcf6492d..d531463be0 100644
--- a/lib/chef/win32/unicode.rb
+++ b/lib/chef/win32/unicode.rb
@@ -38,7 +38,7 @@ module FFI
# Find the length of the string
length = 0
last_char = nil
- while last_char != "\000\000" do
+ while last_char != "\000\000"
length += 1
last_char = self.get_bytes(0, length * 2)[-2..-1]
end
diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb
index a18211b8c6..85a2744645 100644
--- a/lib/chef/win32/version.rb
+++ b/lib/chef/win32/version.rb
@@ -76,7 +76,7 @@ class Chef
# Obtain sku information for the purpose of identifying
# datacenter, cluster, and core skus, the latter 2 only
# exist in releases after Windows Server 2003
- if ! Chef::Platform::windows_server_2003?
+ if ! Chef::Platform.windows_server_2003?
@sku = get_product_info(@major_version, @minor_version, @sp_major_version, @sp_minor_version)
else
# The get_product_info API is not supported on Win2k3,