diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-14 10:34:33 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-14 10:34:33 -0700 |
commit | 6705acbd7f301d1b04388043a3dfa0308655f120 (patch) | |
tree | 1e8a43b35ef1684a4b90578f1a6374758aa7e3c7 /lib/chef | |
parent | 365064280c93d519fdacbf032c0c21057e5549c9 (diff) | |
download | chef-6705acbd7f301d1b04388043a3dfa0308655f120.tar.gz |
chefstyle Style/AndOr fixes
this is part of our informal style guide, lets make it formal since
clearly its not getting followed very well.
Diffstat (limited to 'lib/chef')
62 files changed, 128 insertions, 128 deletions
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb index b05bdcac31..e8ab0149e8 100644 --- a/lib/chef/api_client/registration.rb +++ b/lib/chef/api_client/registration.rb @@ -69,7 +69,7 @@ class Chef end def assert_destination_writable! - if (File.exists?(destination) && !File.writable?(destination)) or !File.writable?(File.dirname(destination)) + if (File.exists?(destination) && !File.writable?(destination)) || !File.writable?(File.dirname(destination)) abs_path = File.expand_path(destination) raise Chef::Exceptions::CannotWritePrivateKey, "I can't write your private key to #{abs_path} - check permissions?" end diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index e779a270aa..89c6927a4d 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -480,7 +480,7 @@ class Chef::Application::Client < Chef::Application end def client_sleep(sec) - IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return + IO.select([ SELF_PIPE[0] ], nil, nil, sec) || (return) @signal = SELF_PIPE[0].getc.chr end diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb index 1dbbe1a508..53964c8b85 100644 --- a/lib/chef/chef_fs/config.rb +++ b/lib/chef/chef_fs/config.rb @@ -270,7 +270,7 @@ class Chef end object_names.each do |object_name| # cookbooks -> cookbook_path - singular_name = INFLECTIONS[object_name] or raise "Unknown object name #{object_name}" + (singular_name = INFLECTIONS[object_name]) || raise("Unknown object name #{object_name}") variable_name = "#{singular_name}_path" paths = Array(@chef_config[variable_name]).flatten result[object_name] = paths.map { |path| File.expand_path(path) } diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb index 72c878618e..920a4f95f6 100644 --- a/lib/chef/cookbook_loader.rb +++ b/lib/chef/cookbook_loader.rb @@ -121,7 +121,7 @@ class Chef end def [](cookbook) - if @cookbooks_by_name.has_key?(cookbook.to_sym) or load_cookbook(cookbook.to_sym) + if @cookbooks_by_name.has_key?(cookbook.to_sym) || load_cookbook(cookbook.to_sym) @cookbooks_by_name[cookbook.to_sym] else raise Exceptions::CookbookNotFoundInRepo, "Cannot find a cookbook named #{cookbook}; did you forget to add metadata to a cookbook? (https://docs.chef.io/config_rb_metadata.html)" diff --git a/lib/chef/daemon.rb b/lib/chef/daemon.rb index 242419890c..70bdddf457 100644 --- a/lib/chef/daemon.rb +++ b/lib/chef/daemon.rb @@ -61,7 +61,7 @@ class Chef # String:: # Location of the pid file for @name def pid_file - Chef::Config[:pid_file] or "/tmp/#{@name}.pid" + Chef::Config[:pid_file] || "/tmp/#{@name}.pid" end # Suck the pid out of pid_file @@ -82,7 +82,7 @@ class Chef def change_privilege Dir.chdir("/") - if Chef::Config[:user] and Chef::Config[:group] + if Chef::Config[:user] && Chef::Config[:group] Chef::Log.info("About to change privilege to #{Chef::Config[:user]}:#{Chef::Config[:group]}") _change_privilege(Chef::Config[:user], Chef::Config[:group]) elsif Chef::Config[:user] @@ -117,7 +117,7 @@ class Chef return false end - if (uid != target_uid) or (gid != target_gid) + if (uid != target_uid) || (gid != target_gid) Process.initgroups(user, target_gid) Process::GID.change_privilege(target_gid) Process::UID.change_privilege(target_uid) diff --git a/lib/chef/deprecation/provider/remote_file.rb b/lib/chef/deprecation/provider/remote_file.rb index 9f115a2565..b469609ffe 100644 --- a/lib/chef/deprecation/provider/remote_file.rb +++ b/lib/chef/deprecation/provider/remote_file.rb @@ -73,7 +73,7 @@ class Chef # which tricks Chef::REST into decompressing the response body. In this # case you'd end up with a tar archive (no gzip) named, e.g., foo.tgz, # which is not what you wanted. - if @new_resource.path =~ /gz$/ or source =~ /gz$/ + if @new_resource.path =~ /gz$/ || source =~ /gz$/ opts[:disable_gzip] = true end opts diff --git a/lib/chef/encrypted_data_bag_item/assertions.rb b/lib/chef/encrypted_data_bag_item/assertions.rb index bbdcf7a721..e8f8bfcbf2 100644 --- a/lib/chef/encrypted_data_bag_item/assertions.rb +++ b/lib/chef/encrypted_data_bag_item/assertions.rb @@ -27,7 +27,7 @@ class Chef::EncryptedDataBagItem module Assertions def assert_format_version_acceptable!(format_version) - unless format_version.kind_of?(Integer) and format_version >= Chef::Config[:data_bag_decrypt_minimum_version] + unless format_version.kind_of?(Integer) && format_version >= Chef::Config[:data_bag_decrypt_minimum_version] raise UnacceptableEncryptedDataBagItemFormat, "The encrypted data bag item has format version `#{format_version}', " + "but the config setting 'data_bag_decrypt_minimum_version' requires version `#{Chef::Config[:data_bag_decrypt_minimum_version]}'" diff --git a/lib/chef/event_loggers/base.rb b/lib/chef/event_loggers/base.rb index c34ed2267d..17fd6198ff 100644 --- a/lib/chef/event_loggers/base.rb +++ b/lib/chef/event_loggers/base.rb @@ -42,8 +42,8 @@ class Chef end def self.new(name) - event_logger_class = by_name(name.to_s) or - raise UnknownEventLogger, "No event logger found for #{name} (available: #{available_event_loggers.join(', ')})" + (event_logger_class = by_name(name.to_s)) || + raise(UnknownEventLogger, "No event logger found for #{name} (available: #{available_event_loggers.join(', ')})") raise UnavailableEventLogger unless available_event_loggers.include? name.to_s event_logger_class.new end diff --git a/lib/chef/file_access_control/unix.rb b/lib/chef/file_access_control/unix.rb index eec9c62701..1746db44d3 100644 --- a/lib/chef/file_access_control/unix.rb +++ b/lib/chef/file_access_control/unix.rb @@ -117,7 +117,7 @@ class Chef end def gid_from_resource(resource) - return nil if resource == nil or resource.group.nil? + return nil if resource == nil || resource.group.nil? if resource.group.kind_of?(String) diminished_radix_complement( Etc.getgrnam(resource.group).gid ) elsif resource.group.kind_of?(Integer) @@ -168,7 +168,7 @@ class Chef end def mode_from_resource(res) - return nil if res == nil or res.mode.nil? + return nil if res == nil || res.mode.nil? (res.mode.respond_to?(:oct) ? res.mode.oct : res.mode.to_i) & 007777 end @@ -197,7 +197,7 @@ class Chef # the user has specified a permission, and it does not match the file, so fix the permission Chef::Log.debug("Found target_mode != current_mode, updating mode") return true - elsif suid_bit_set? and (should_update_group? or should_update_owner?) + elsif suid_bit_set? && (should_update_group? || should_update_owner?) return true else Chef::Log.debug("Found target_mode == current_mode, not updating mode") @@ -264,7 +264,7 @@ class Chef end def uid_from_resource(resource) - return nil if resource == nil or resource.owner.nil? + return nil if resource == nil || resource.owner.nil? if resource.owner.kind_of?(String) diminished_radix_complement( Etc.getpwnam(resource.owner).uid ) elsif resource.owner.kind_of?(Integer) diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb index b2a8c8099b..2ac1274c37 100644 --- a/lib/chef/formatters/base.rb +++ b/lib/chef/formatters/base.rb @@ -51,8 +51,8 @@ class Chef #-- # TODO: is it too clever to be defining new() on a module like this? def self.new(name, out, err) - formatter_class = by_name(name.to_s) or - raise UnknownFormatter, "No output formatter found for #{name} (available: #{available_formatters.join(', ')})" + (formatter_class = by_name(name.to_s)) || + raise(UnknownFormatter, "No output formatter found for #{name} (available: #{available_formatters.join(', ')})") formatter_class.new(out, err) end diff --git a/lib/chef/formatters/error_descriptor.rb b/lib/chef/formatters/error_descriptor.rb index 0f14e6e783..1a40f785cb 100644 --- a/lib/chef/formatters/error_descriptor.rb +++ b/lib/chef/formatters/error_descriptor.rb @@ -31,7 +31,7 @@ class Chef end def section(heading, text) - @sections << { heading => (text or "") } + @sections << { heading => (text || "") } end def display(out) diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb index f5936285be..94ecce88de 100644 --- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb @@ -63,7 +63,7 @@ class Chef def recipe_snippet return nil if dynamic_resource? @snippet ||= begin - if file = parse_source and line = parse_line(file) + if (file = parse_source) && (line = parse_line(file)) return nil unless ::File.exists?(file) lines = IO.readlines(file) diff --git a/lib/chef/http.rb b/lib/chef/http.rb index dd02550294..15fb20d588 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -221,7 +221,7 @@ class Chef return path if path.is_a?(URI) if path =~ /^(http|https|chefzero):\/\//i URI.parse(path) - elsif path.nil? or path.empty? + elsif path.nil? || path.empty? URI.parse(@url) else # The regular expressions used here are to make sure '@url' does not have diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index 8c1578b976..9d5be78a57 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -177,7 +177,7 @@ class Chef def to_net_http(code, headers, chunked_body) body = chunked_body.join("") - msg = STATUS_MESSAGE[code] or raise "Cannot determine HTTP status message for code #{code}" + (msg = STATUS_MESSAGE[code]) || raise("Cannot determine HTTP status message for code #{code}") response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg) response.instance_variable_set(:@body, body) headers.each do |name, value| diff --git a/lib/chef/http/ssl_policies.rb b/lib/chef/http/ssl_policies.rb index 74c8093f98..a3692b81b6 100644 --- a/lib/chef/http/ssl_policies.rb +++ b/lib/chef/http/ssl_policies.rb @@ -118,7 +118,7 @@ class Chef class APISSLPolicy < DefaultSSLPolicy def set_verify_mode - if config[:ssl_verify_mode] == :verify_peer or config[:verify_api_cert] + if config[:ssl_verify_mode] == :verify_peer || config[:verify_api_cert] http_client.verify_mode = OpenSSL::SSL::VERIFY_PEER elsif config[:ssl_verify_mode] == :verify_none http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb index 26d3751897..f8f05a0074 100644 --- a/lib/chef/json_compat.rb +++ b/lib/chef/json_compat.rb @@ -61,7 +61,7 @@ class Chef # JSON gem requires top level object to be a Hash or Array (otherwise # you get the "must contain two octets" error). Yajl doesn't impose the # same limitation. For compatibility, we re-impose this condition. - unless obj.kind_of?(Hash) or obj.kind_of?(Array) + unless obj.kind_of?(Hash) || obj.kind_of?(Array) raise Chef::Exceptions::JSON::ParseError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})" end diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 636be0dbc7..a27a3b332b 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -145,7 +145,7 @@ class Chef end def self.subcommand_class_from(args) - if args.size == 1 and args[0].strip.downcase == "rehash" + if args.size == 1 && args[0].strip.downcase == "rehash" # To prevent issues with the rehash file not pointing to the correct plugins, # we always use the glob loader when regenerating the rehash file @subcommand_loader = Chef::Knife::SubcommandLoader.gem_glob_loader(chef_config_dir) diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb index 01374b9b36..802fdd792b 100644 --- a/lib/chef/knife/cookbook_site_install.rb +++ b/lib/chef/knife/cookbook_site_install.rb @@ -123,7 +123,7 @@ class Chef ui.error("Please specify a cookbook to download and install.") exit 1 elsif name_args.size >= 2 - unless name_args.last.match(/^(\d+)(\.\d+){1,2}$/) and name_args.size == 2 + unless name_args.last.match(/^(\d+)(\.\d+){1,2}$/) && name_args.size == 2 ui.error("Installing multiple cookbooks at once is not supported.") exit 1 end diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index 72f7d9d2d9..6938ac280d 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -86,7 +86,7 @@ class Chef config[:cookbook_path] ||= Chef::Config[:cookbook_path] - if @name_args.empty? and ! config[:all] + if @name_args.empty? && ! config[:all] show_usage ui.fatal("You must specify the --all flag or at least one cookbook name") exit 1 diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 18cbe46232..48d2cb9e77 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -143,7 +143,7 @@ CONFIG # If the user doesn't have a client path configure, let bash use the PATH for what it was designed for client_path = @chef_config[:chef_client_path] || "chef-client" s = "#{client_path} -j /etc/chef/first-boot.json" - s << " -l debug" if @config[:verbosity] and @config[:verbosity] >= 2 + s << " -l debug" if @config[:verbosity] && @config[:verbosity] >= 2 s << " -E #{bootstrap_environment}" unless bootstrap_environment.nil? s << " --no-color" unless @config[:color] s diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index 61069cff48..f273cb5bca 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -86,7 +86,7 @@ class Chef require "stringio" # If you were looking for some attribute and there is only one match # just dump the attribute value - if config[:attribute] and data.length == 1 + if config[:attribute] && data.length == 1 data.values[0] else out = StringIO.new diff --git a/lib/chef/knife/core/node_editor.rb b/lib/chef/knife/core/node_editor.rb index 0f7e51cdf3..b009bf8652 100644 --- a/lib/chef/knife/core/node_editor.rb +++ b/lib/chef/knife/core/node_editor.rb @@ -96,7 +96,7 @@ class Chef # @api private def apply_updates(updated_data) - if node.name and node.name != updated_data["name"] + if node.name && node.name != updated_data["name"] ui.warn "Changing the name of a node results in a new node being created, #{node.name} will not be modified or removed." ui.confirm "Proceed with creation of new node" end diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb index 938942c173..67e431f1a7 100644 --- a/lib/chef/knife/core/ui.rb +++ b/lib/chef/knife/core/ui.rb @@ -140,7 +140,7 @@ class Chef def ask_question(question, opts = {}) question = question + "[#{opts[:default]}] " if opts[:default] - if opts[:default] and config[:defaults] + if opts[:default] && config[:defaults] opts[:default] else stdout.print question diff --git a/lib/chef/knife/ssl_check.rb b/lib/chef/knife/ssl_check.rb index 6dac06b27b..0995fc8a54 100644 --- a/lib/chef/knife/ssl_check.rb +++ b/lib/chef/knife/ssl_check.rb @@ -50,7 +50,7 @@ class Chef end def given_uri - (name_args[0] or Chef::Config.chef_server_url) + (name_args[0] || Chef::Config.chef_server_url) end def host diff --git a/lib/chef/knife/ssl_fetch.rb b/lib/chef/knife/ssl_fetch.rb index f694a46ac6..5af1a905d5 100644 --- a/lib/chef/knife/ssl_fetch.rb +++ b/lib/chef/knife/ssl_fetch.rb @@ -47,7 +47,7 @@ class Chef end def given_uri - (name_args[0] or Chef::Config.chef_server_url) + (name_args[0] || Chef::Config.chef_server_url) end def host diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb index e7a7165faa..551d5addfc 100644 --- a/lib/chef/knife/status.rb +++ b/lib/chef/knife/status.rb @@ -98,9 +98,9 @@ class Chef output(all_nodes.sort { |n1, n2| if config[:sort_reverse] || Chef::Config[:knife][:sort_status_reverse] - (n2["ohai_time"] or 0) <=> (n1["ohai_time"] or 0) + (n2["ohai_time"] || 0) <=> (n1["ohai_time"] || 0) else - (n1["ohai_time"] or 0) <=> (n2["ohai_time"] or 0) + (n1["ohai_time"] || 0) <=> (n2["ohai_time"] || 0) end }) end diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb index c423ccaa42..b10e036c4e 100644 --- a/lib/chef/mixin/template.rb +++ b/lib/chef/mixin/template.rb @@ -186,7 +186,7 @@ class Chef module_names.each do |mod| context_methods = [:node, :render, :render_template, :render_template_from_string] context_methods.each do |core_method| - if mod.method_defined?(core_method) or mod.private_method_defined?(core_method) + if mod.method_defined?(core_method) || mod.private_method_defined?(core_method) Chef::Log.warn("Core template method `#{core_method}' overridden by extension module #{mod}") end end diff --git a/lib/chef/mixin/why_run.rb b/lib/chef/mixin/why_run.rb index 69fee58e31..ea62527bdd 100644 --- a/lib/chef/mixin/why_run.rb +++ b/lib/chef/mixin/why_run.rb @@ -319,7 +319,7 @@ class Chef def run(action) @assertions[action.to_sym].each do |a| a.run(action, events, @resource) - if a.assertion_failed? and a.block_action? + if a.assertion_failed? && a.block_action? @blocked_actions << action break end diff --git a/lib/chef/mixin/wide_string.rb b/lib/chef/mixin/wide_string.rb index 4566bdd382..4342ef1650 100644 --- a/lib/chef/mixin/wide_string.rb +++ b/lib/chef/mixin/wide_string.rb @@ -34,7 +34,7 @@ class Chef ustring = (ustring + "").force_encoding("UTF-8") if ustring.respond_to?(:force_encoding) && ustring.encoding.name != "UTF-8" # ensure we have the double-null termination Windows Wide likes - ustring = ustring + "\000\000" if ustring.length == 0 or ustring[-1].chr != "\000" + ustring = ustring + "\000\000" if ustring.length == 0 || ustring[-1].chr != "\000" # encode it all as UTF-16LE AKA Windows Wide Character AKA Windows Unicode ustring = begin diff --git a/lib/chef/monkey_patches/net-ssh-multi.rb b/lib/chef/monkey_patches/net-ssh-multi.rb index b0d05a0b27..cb1bc3b2bc 100644 --- a/lib/chef/monkey_patches/net-ssh-multi.rb +++ b/lib/chef/monkey_patches/net-ssh-multi.rb @@ -119,7 +119,7 @@ if Net::SSH::Multi::Version::STRING == "1.1.0" || Net::SSH::Multi::Version::STRI count = concurrent_connections ? (concurrent_connections - open_connections) : @pending_sessions.length count.times do - session = @pending_sessions.pop or break + (session = @pending_sessions.pop) || break # ===== PATCH START # Increment the open_connections count here to prevent # creation of connection thread again before that is diff --git a/lib/chef/monologger.rb b/lib/chef/monologger.rb index 49f744e314..8bcdae1293 100644 --- a/lib/chef/monologger.rb +++ b/lib/chef/monologger.rb @@ -42,7 +42,7 @@ class MonoLogger < Logger def initialize(log = nil) @dev = @filename = @shift_age = @shift_size = nil - if log.respond_to?(:write) and log.respond_to?(:close) + if log.respond_to?(:write) && log.respond_to?(:close) @dev = log else @dev = open_logfile(log) diff --git a/lib/chef/policy_builder/dynamic.rb b/lib/chef/policy_builder/dynamic.rb index c6c7deeee6..389f124f84 100644 --- a/lib/chef/policy_builder/dynamic.rb +++ b/lib/chef/policy_builder/dynamic.rb @@ -139,7 +139,7 @@ class Chef # # @return [PolicyBuilder::Policyfile, PolicyBuilder::ExpandNodeObject] def implementation - @implementation or raise Exceptions::InvalidPolicybuilderCall, "#load_node must be called before other policy builder methods" + @implementation || raise(Exceptions::InvalidPolicybuilderCall, "#load_node must be called before other policy builder methods") end # @api private diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index 8f35c66cab..e2238d4a73 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -256,10 +256,10 @@ class Chef # @api private def run_list if named_run_list_requested? - named_run_list or - raise ConfigurationError, + named_run_list || + raise(ConfigurationError, "Policy '#{retrieved_policy_name}' revision '#{revision_id}' does not have named_run_list '#{named_run_list_name}'" + - "(available named_run_lists: [#{available_named_run_lists.join(', ')}])" + "(available named_run_lists: [#{available_named_run_lists.join(', ')}])") else policy["run_list"] end @@ -321,17 +321,17 @@ class Chef # @api private def deployment_group - Chef::Config[:deployment_group] or - raise ConfigurationError, "Setting `deployment_group` is not configured." + Chef::Config[:deployment_group] || + raise(ConfigurationError, "Setting `deployment_group` is not configured.") end # @api private def validate_policy_config! - policy_group or - raise ConfigurationError, "Setting `policy_group` is not configured." + policy_group || + raise(ConfigurationError, "Setting `policy_group` is not configured.") - policy_name or - raise ConfigurationError, "Setting `policy_name` is not configured." + policy_name || + raise(ConfigurationError, "Setting `policy_name` is not configured.") end # @api private diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index 4f17da0288..82f5ca2ba5 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -143,7 +143,7 @@ class Chef args = [] args << "-o #{remote}" unless remote == "origin" args << "--depth #{@new_resource.depth}" if @new_resource.depth - args << "--no-single-branch" if @new_resource.depth and git_minor_version >= Gem::Version.new("1.7.10") + args << "--no-single-branch" if @new_resource.depth && git_minor_version >= Gem::Version.new("1.7.10") Chef::Log.info "#{@new_resource} cloning repo #{@new_resource.repository} to #{@new_resource.destination}" diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index e73869d829..4cfb257bb9 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -168,7 +168,7 @@ class Chef end def can_generate_config? - ! @config_template.nil? and ! @config_path.nil? + ! @config_template.nil? && ! @config_path.nil? end def resource_for_config(path) diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index 83b5dd8c00..5fce97e5b3 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -74,8 +74,8 @@ class Chef requirements.assert(:delete) do |a| a.assertion do if @current_resource.to - @current_resource.link_type == @new_resource.link_type and - (@current_resource.link_type == :symbolic or @current_resource.to != "") + @current_resource.link_type == @new_resource.link_type && + (@current_resource.link_type == :symbolic || @current_resource.to != "") else true end diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index c815c9ccb8..07da6ac361 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -133,7 +133,7 @@ class Chef end def remount_fs - if @current_resource.mounted and @new_resource.supports[:remount] + if @current_resource.mounted && @new_resource.supports[:remount] shell_out!(remount_command) @new_resource.updated_by_last_action(true) Chef::Log.debug("#{@new_resource} is remounted at #{@new_resource.mount_point}") @@ -258,9 +258,9 @@ class Chef end def mount_options_unchanged? - @current_resource.fstype == @new_resource.fstype and - @current_resource.options == @new_resource.options and - @current_resource.dump == @new_resource.dump and + @current_resource.fstype == @new_resource.fstype && + @current_resource.options == @new_resource.options && + @current_resource.dump == @new_resource.dump && @current_resource.pass == @new_resource.pass end diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb index 3e37cbc9a5..6ac67e0560 100644 --- a/lib/chef/provider/osx_profile.rb +++ b/lib/chef/provider/osx_profile.rb @@ -68,15 +68,15 @@ class Chef requirements.assert(:remove) do |a| if @new_profile_identifier a.assertion { - !@new_profile_identifier.nil? and - !@new_profile_identifier.end_with?(".mobileconfig") and + !@new_profile_identifier.nil? && + !@new_profile_identifier.end_with?(".mobileconfig") && /^\w+(?:\.\w+)+$/.match(@new_profile_identifier) } a.failure_message RuntimeError, "when removing using the identifier attribute, it must match the profile identifier" else new_profile_name = @new_resource.profile_name a.assertion { - !new_profile_name.end_with?(".mobileconfig") and + !new_profile_name.end_with?(".mobileconfig") && /^\w+(?:\.\w+)+$/.match(new_profile_name) } a.failure_message RuntimeError, "When removing by resource name, it must match the profile identifier " @@ -239,7 +239,7 @@ class Chef def profile_installed? # Profile Identifier and UUID must match a currently installed profile - if @current_resource.profile.nil? or @current_resource.profile.empty? + if @current_resource.profile.nil? || @current_resource.profile.empty? false else if @new_resource.action.include?(:remove) diff --git a/lib/chef/provider/package/homebrew.rb b/lib/chef/provider/package/homebrew.rb index c032881e70..853a354b28 100644 --- a/lib/chef/provider/package/homebrew.rb +++ b/lib/chef/provider/package/homebrew.rb @@ -53,7 +53,7 @@ class Chef def upgrade_package(name, version) current_version = current_resource.version - if current_version.nil? or current_version.empty? + if current_version.nil? || current_version.empty? install_package(name, version) elsif current_version != version brew("upgrade", new_resource.options, name) diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb index dc83e4aa08..85053d47f2 100644 --- a/lib/chef/provider/package/ips.rb +++ b/lib/chef/provider/package/ips.rb @@ -69,7 +69,7 @@ class Chef package_name = "#{name}@#{version}" normal_command = "pkg#{expand_options(@new_resource.options)} install -q #{package_name}" command = - if @new_resource.respond_to?(:accept_license) and @new_resource.accept_license + if @new_resource.respond_to?(:accept_license) && @new_resource.accept_license normal_command.gsub("-q", "-q --accept") else normal_command diff --git a/lib/chef/provider/package/macports.rb b/lib/chef/provider/package/macports.rb index b110207d8a..7bbc68aba8 100644 --- a/lib/chef/provider/package/macports.rb +++ b/lib/chef/provider/package/macports.rb @@ -15,7 +15,7 @@ class Chef @candidate_version = macports_candidate_version - if !@new_resource.version and !@candidate_version + if !@new_resource.version && !@candidate_version raise Chef::Exceptions::Package, "Could not get a candidate version for this package -- #{@new_resource.name} does not seem to be a valid package!" end @@ -48,20 +48,20 @@ class Chef def install_package(name, version) unless @current_resource.version == version command = "port#{expand_options(@new_resource.options)} install #{name}" - command << " @#{version}" if version and !version.empty? + command << " @#{version}" if version && !version.empty? shell_out_with_timeout!(command) end end def purge_package(name, version) command = "port#{expand_options(@new_resource.options)} uninstall #{name}" - command << " @#{version}" if version and !version.empty? + command << " @#{version}" if version && !version.empty? shell_out_with_timeout!(command) end def remove_package(name, version) command = "port#{expand_options(@new_resource.options)} deactivate #{name}" - command << " @#{version}" if version and !version.empty? + command << " @#{version}" if version && !version.empty? shell_out_with_timeout!(command) end @@ -71,7 +71,7 @@ class Chef # happens otherwise... current_version = @current_resource.version - if current_version.nil? or current_version.empty? + if current_version.nil? || current_version.empty? # Macports doesn't like when you upgrade a package # that hasn't been installed. install_package(name, version) diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index 60abbed7c8..39eff19bd0 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -115,7 +115,7 @@ class Chef # Compatibility note: Rubygems 1.x uses Gem::Format, 2.0 moved this # code into Gem::Package. def spec_from_file(file) - if defined?(Gem::Format) and Gem::Package.respond_to?(:open) + if defined?(Gem::Format) && Gem::Package.respond_to?(:open) Gem::Format.from_file_by_path(file).spec else Gem::Package.new(file).spec diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 858b430abe..73507ec5ab 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -73,17 +73,17 @@ class Chef # verify def isalnum(x) - isalpha(x) or isdigit(x) + isalpha(x) || isdigit(x) end def isalpha(x) v = x.ord - (v >= 65 and v <= 90) or (v >= 97 and v <= 122) + (v >= 65 && v <= 90) || (v >= 97 && v <= 122) end def isdigit(x) v = x.ord - v >= 48 and v <= 57 + v >= 48 && v <= 57 end # based on the reference spec in lib/rpmvercmp.c in rpm 4.9.0 @@ -128,17 +128,17 @@ 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 && y_pos <= y_pos_max # first we skip over anything non alphanumeric - while (x_pos <= x_pos_max) and (isalnum(x[x_pos]) == false) + while (x_pos <= x_pos_max) && (isalnum(x[x_pos]) == false) x_pos += 1 # +1 over pos_max if end of string end - while (y_pos <= y_pos_max) and (isalnum(y[y_pos]) == false) + while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false) y_pos += 1 end # if we hit the end of either we are done matching segments - if (x_pos == x_pos_max + 1) or (y_pos == y_pos_max + 1) + if (x_pos == x_pos_max + 1) || (y_pos == y_pos_max + 1) break end @@ -154,14 +154,14 @@ class Chef x_seg_pos += 1 # gather up our digits - while (x_seg_pos <= x_pos_max) and isdigit(x[x_seg_pos]) + while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos]) x_seg_pos += 1 end # copy the segment but not the unmatched character that x_seg_pos will # refer to x_comp = x[x_pos, x_seg_pos - x_pos] - while (y_seg_pos <= y_pos_max) and isdigit(y[y_seg_pos]) + while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos]) y_seg_pos += 1 end y_comp = y[y_pos, y_seg_pos - y_pos] @@ -169,12 +169,12 @@ class Chef # we are comparing strings x_seg_is_num = false - while (x_seg_pos <= x_pos_max) and isalpha(x[x_seg_pos]) + while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos]) x_seg_pos += 1 end x_comp = x[x_pos, x_seg_pos - x_pos] - while (y_seg_pos <= y_pos_max) and isalpha(y[y_seg_pos]) + while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos]) y_seg_pos += 1 end y_comp = y[y_pos, y_seg_pos - y_pos] @@ -213,7 +213,7 @@ class Chef # segments matched completely but the segment separators were different - # rpm reference code treats these as equal. - if (x_pos == x_pos_max + 1) and (y_pos == y_pos_max + 1) + if (x_pos == x_pos_max + 1) && (y_pos == y_pos_max + 1) return 0 end @@ -290,11 +290,11 @@ class Chef x = self # compare epoch - if (x.e.nil? == false and x.e > 0) and y.e.nil? + if (x.e.nil? == false && x.e > 0) && y.e.nil? return 1 - elsif x.e.nil? and (y.e.nil? == false and y.e > 0) + elsif x.e.nil? && (y.e.nil? == false && y.e > 0) return -1 - elsif x.e.nil? == false and y.e.nil? == false + elsif x.e.nil? == false && y.e.nil? == false if x.e < y.e return -1 elsif x.e > y.e @@ -303,25 +303,25 @@ class Chef end # compare version - if partial and (x.v.nil? or y.v.nil?) + if partial && (x.v.nil? || y.v.nil?) return 0 - elsif x.v.nil? == false and y.v.nil? + elsif x.v.nil? == false && y.v.nil? return 1 - elsif x.v.nil? and y.v.nil? == false + elsif x.v.nil? && y.v.nil? == false return -1 - elsif x.v.nil? == false and y.v.nil? == false + elsif x.v.nil? == false && y.v.nil? == false cmp = RPMUtils.rpmvercmp(x.v, y.v) return cmp if cmp != 0 end # compare release - if partial and (x.r.nil? or y.r.nil?) + if partial && (x.r.nil? || y.r.nil?) return 0 - elsif x.r.nil? == false and y.r.nil? + elsif x.r.nil? == false && y.r.nil? return 1 - elsif x.r.nil? and y.r.nil? == false + elsif x.r.nil? && y.r.nil? == false return -1 - elsif x.r.nil? == false and y.r.nil? == false + elsif x.r.nil? == false && y.r.nil? == false cmp = RPMUtils.rpmvercmp(x.r, y.r) return cmp end @@ -372,11 +372,11 @@ class Chef return 0 if x.nevra == y.nevra # compare name - if x.n.nil? == false and y.n.nil? + if x.n.nil? == false && y.n.nil? return 1 - elsif x.n.nil? and y.n.nil? == false + elsif x.n.nil? && y.n.nil? == false return -1 - elsif x.n.nil? == false and y.n.nil? == false + elsif x.n.nil? == false && y.n.nil? == false if x.n < y.n return -1 elsif x.n > y.n @@ -392,11 +392,11 @@ class Chef end # compare arch - if x.a.nil? == false and y.a.nil? + if x.a.nil? == false && y.a.nil? return 1 - elsif x.a.nil? and y.a.nil? == false + elsif x.a.nil? && y.a.nil? == false return -1 - elsif x.a.nil? == false and y.a.nil? == false + elsif x.a.nil? == false && y.a.nil? == false if x.a < y.a return -1 elsif x.a > y.a @@ -482,10 +482,10 @@ class Chef return true elsif sense > 0 and (x.flag == :< || x.flag == :<=) || (y.flag == :>= || y.flag == :>) return true - elsif sense == 0 and ( - ((x.flag == :== or x.flag == :<= or x.flag == :>=) and (y.flag == :== or y.flag == :<= or y.flag == :>=)) or - (x.flag == :< and y.flag == :<) or - (x.flag == :> and y.flag == :>) + elsif sense == 0 && ( + ((x.flag == :== || x.flag == :<= || x.flag == :>=) && (y.flag == :== || y.flag == :<= || y.flag == :>=)) || + (x.flag == :< && y.flag == :<) || + (x.flag == :> && y.flag == :>) ) return true end @@ -1340,7 +1340,7 @@ class Chef old_candidate = @yum.candidate_version(package_name) new_installed = @yum.installed_version(new_package_name, new_arch) new_candidate = @yum.candidate_version(new_package_name, new_arch) - if (old_installed.nil? and old_candidate.nil?) and (new_installed or new_candidate) + if (old_installed.nil? && old_candidate.nil?) && (new_installed || new_candidate) Chef::Log.debug("Parsed out arch #{new_arch}, new package name is #{new_package_name}") return new_package_name, new_arch end @@ -1378,7 +1378,7 @@ class Chef if packages.empty? # Don't bother if we are just ensuring a package is removed - we don't need Provides data actions = Array(@new_resource.action) - unless actions.size == 1 and (actions[0] == :remove || actions[0] == :purge) + unless actions.size == 1 && (actions[0] == :remove || actions[0] == :purge) Chef::Log.debug("#{@new_resource} couldn't match #{@new_resource.package_name} in " + "installed Provides, loading available Provides - this may take a moment") @yum.reload_provides diff --git a/lib/chef/provider/remote_file/cache_control_data.rb b/lib/chef/provider/remote_file/cache_control_data.rb index 7aa059f4cb..8d7de5c370 100644 --- a/lib/chef/provider/remote_file/cache_control_data.rb +++ b/lib/chef/provider/remote_file/cache_control_data.rb @@ -96,7 +96,7 @@ class Chef end def validate!(current_copy_checksum) - if current_copy_checksum.nil? or checksum != current_copy_checksum + if current_copy_checksum.nil? || checksum != current_copy_checksum reset! false else diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb index 448acdb018..b49e84fa69 100644 --- a/lib/chef/provider/remote_file/ftp.rb +++ b/lib/chef/provider/remote_file/ftp.rb @@ -112,7 +112,7 @@ class Chef def validate_typecode! # Only support ascii and binary types - if typecode and /\A[ai]\z/ !~ typecode + if typecode && /\A[ai]\z/ !~ typecode raise ArgumentError, "invalid typecode: #{typecode.inspect}" end end diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb index 6fa574e777..6a9738c02b 100644 --- a/lib/chef/provider/remote_file/http.rb +++ b/lib/chef/provider/remote_file/http.rb @@ -45,10 +45,10 @@ class Chef def conditional_get_headers cache_control_headers = {} - if last_modified = cache_control_data.mtime and want_mtime_cache_control? + if (last_modified = cache_control_data.mtime) && want_mtime_cache_control? cache_control_headers["if-modified-since"] = last_modified end - if etag = cache_control_data.etag and want_etag_cache_control? + if (etag = cache_control_data.etag) && want_etag_cache_control? cache_control_headers["if-none-match"] = etag end Chef::Log.debug("Cache control headers: #{cache_control_headers.inspect}") diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb index 0234673474..73c5e07715 100644 --- a/lib/chef/provider/service/aixinit.rb +++ b/lib/chef/provider/service/aixinit.rb @@ -44,7 +44,7 @@ class Chef else priority_ok = @current_resource.priority == @new_resource.priority end - if @current_resource.enabled and priority_ok + if @current_resource.enabled && priority_ok Chef::Log.debug("#{@new_resource} already enabled - nothing to do") else converge_by("enable service #{@new_resource}") do diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb index c0545e9fb3..2fd32e37aa 100644 --- a/lib/chef/provider/service/arch.rb +++ b/lib/chef/provider/service/arch.rb @@ -70,7 +70,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init new_daemons = [] entries = daemons - if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}") + if entries.include?(new_resource.service_name) || entries.include?("@#{new_resource.service_name}") # exists and already enabled (or already enabled as a background service) # new_daemons += entries else @@ -100,7 +100,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init # exists and disabled # new_daemons += entries else - if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}") + if entries.include?(new_resource.service_name) || entries.include?("@#{new_resource.service_name}") # exists but enabled (or enabled as a back-ground service) # FIXME: Does arch support !@foobar ? entries.each do |daemon| diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb index 6550c85b2a..67b71953f7 100644 --- a/lib/chef/provider/service/debian.rb +++ b/lib/chef/provider/service/debian.rb @@ -124,7 +124,7 @@ class Chef else priority_ok = @current_resource.priority == new_resource.priority end - if current_resource.enabled and priority_ok + if current_resource.enabled && priority_ok Chef::Log.debug("#{new_resource} already enabled - nothing to do") else converge_by("enable service #{new_resource}") do diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb index 56064bc03a..8fb6d1f9af 100644 --- a/lib/chef/provider/service/gentoo.rb +++ b/lib/chef/provider/service/gentoo.rb @@ -38,7 +38,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init exists = ::File.exists? file readable = ::File.readable? file Chef::Log.debug "#{@new_resource} exists: #{exists}, readable: #{readable}" - exists and readable + exists && readable end ) Chef::Log.debug "#{@new_resource} enabled: #{@current_resource.enabled}" diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index e6e57e4695..648cd9748b 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -181,7 +181,7 @@ class Chef end def set_service_status - return if @plist == nil or @service_label.to_s.empty? + return if @plist == nil || @service_label.to_s.empty? cmd = "launchctl list #{@service_label}" res = shell_out_as_user(cmd) diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb index a76622ee8f..08f8e108d5 100644 --- a/lib/chef/provider/service/redhat.rb +++ b/lib/chef/provider/service/redhat.rb @@ -76,7 +76,7 @@ class Chef if ::File.exists?("/sbin/chkconfig") chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0, 1]) - unless run_levels.nil? or run_levels.empty? + unless run_levels.nil? || run_levels.empty? all_levels_match = true chkconfig.stdout.split(/\s+/)[1..-1].each do |level| index = level.split(":").first @@ -100,11 +100,11 @@ class Chef # @api private def levels - (run_levels.nil? or run_levels.empty?) ? "" : "--level #{run_levels.join('')} " + (run_levels.nil? || run_levels.empty?) ? "" : "--level #{run_levels.join('')} " end def enable_service() - unless run_levels.nil? or run_levels.empty? + unless run_levels.nil? || run_levels.empty? disable_levels = current_run_levels - run_levels shell_out! "/sbin/chkconfig --level #{disable_levels.join('')} #{new_resource.service_name} off" unless disable_levels.empty? end diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index d76779a74b..fe4768b2e8 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -76,8 +76,8 @@ class Chef end requirements.assert(:all_actions) do |a| - a.assertion { @new_resource.status_command or supports[:status] or - (!ps_cmd.nil? and !ps_cmd.empty?) } + a.assertion { @new_resource.status_command || supports[:status] || + (!ps_cmd.nil? && !ps_cmd.empty?) } a.failure_message Chef::Exceptions::Service, "#{@new_resource} could not determine how to inspect the process table, please set this node's 'command.ps' attribute" end requirements.assert(:all_actions) do |a| diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb index 42798a5f62..3f168b8da3 100644 --- a/lib/chef/provider/user/aix.rb +++ b/lib/chef/provider/user/aix.rb @@ -79,7 +79,7 @@ class Chef # Aix specific handling to update users home directory. def manage_home # -m option does not work on aix, so move dir. - if updating_home? and managing_home_dir? + if updating_home? && managing_home_dir? universal_options.delete("-m") if ::File.directory?(@current_resource.home) Chef::Log.debug("Changing users home directory from #{@current_resource.home} to #{new_resource.home}") diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb index e2f5b5897a..3fef8d3642 100644 --- a/lib/chef/provider/user/useradd.rb +++ b/lib/chef/provider/user/useradd.rb @@ -150,7 +150,7 @@ class Chef # ::File.expand_path("///tmp") == ::File.expand_path("/tmp") => false # ::File.expand_path("\\tmp") => "C:/tmp" return true if @current_resource.home.nil? && new_resource.home - new_resource.home and Pathname.new(@current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath + new_resource.home && Pathname.new(@current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath end def managing_home_dir? diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index b42cf4ba5f..595280a583 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -139,7 +139,7 @@ class Chef end def absolute_uri?(source) - Chef::Provider::RemoteFile::Fetcher.network_share?(source) or (source.kind_of?(String) and as_uri(source).absolute?) + Chef::Provider::RemoteFile::Fetcher.network_share?(source) || (source.kind_of?(String) && as_uri(source).absolute?) rescue URI::InvalidURIError false end diff --git a/lib/chef/resource/ruby_block.rb b/lib/chef/resource/ruby_block.rb index 0e3a980b11..87a4cfb7c5 100644 --- a/lib/chef/resource/ruby_block.rb +++ b/lib/chef/resource/ruby_block.rb @@ -34,7 +34,7 @@ class Chef end def block(&block) - if block_given? and block + if block_given? && block @block = block else @block diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index e33af3174b..896aa71340 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -161,7 +161,7 @@ class Chef # helpers(MyTemplateHelper) # The template code in the above example will work unmodified. def helpers(module_name = nil, &block) - if block_given? and !module_name.nil? + if block_given? && !module_name.nil? raise Exceptions::ValidationFailed, "Passing both a module and block to #helpers is not supported. Call #helpers multiple times instead" elsif block_given? diff --git a/lib/chef/role.rb b/lib/chef/role.rb index 9b6fa1c59d..331fa614f1 100644 --- a/lib/chef/role.rb +++ b/lib/chef/role.rb @@ -256,7 +256,7 @@ class Chef roles_files = Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path), "**", "**")) js_files = roles_files.select { |file| file.match(/\/#{name}\.json$/) } rb_files = roles_files.select { |file| file.match(/\/#{name}\.rb$/) } - if js_files.count > 1 or rb_files.count > 1 + if js_files.count > 1 || rb_files.count > 1 raise Chef::Exceptions::DuplicateRole, "Multiple roles of same type found named #{name}" end js_path, rb_path = js_files.first, rb_files.first diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb index 2e81b363e0..bdcedff7f8 100644 --- a/lib/chef/util/dsc/lcm_output_parser.rb +++ b/lib/chef/util/dsc/lcm_output_parser.rb @@ -79,7 +79,7 @@ class Chef end when :end # Make sure we log the last line - if current_resource[:context] == :logging and info.include? current_resource[:name] + if current_resource[:context] == :logging && info.include?(current_resource[:name]) current_resource[:logs].push(info) end current_resource[:context] = nil diff --git a/lib/chef/util/dsc/resource_store.rb b/lib/chef/util/dsc/resource_store.rb index bb3480d105..be8d0b301b 100644 --- a/lib/chef/util/dsc/resource_store.rb +++ b/lib/chef/util/dsc/resource_store.rb @@ -74,7 +74,7 @@ class Chef found = rs.find_all do |r| name_matches = r["Name"].casecmp(name) == 0 if name_matches - module_name == nil || (r["Module"] and r["Module"]["Name"].casecmp(module_name) == 0) + module_name == nil || (r["Module"] && r["Module"]["Name"].casecmp(module_name) == 0) else false end diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb index 723b43fc44..4254b8ead3 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? && (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| |