From 03eadde04eb219bfa8abe52d312261a5142e7266 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Fri, 12 Feb 2016 09:32:14 -0800 Subject: pull rubocop 0.37.2 into chefstyle this is from the same ruleset that we had, but the new code catches more conditions. --- lib/chef/application/knife.rb | 4 ++-- lib/chef/cookbook/cookbook_collection.rb | 2 +- lib/chef/encrypted_data_bag_item/assertions.rb | 2 +- lib/chef/environment.rb | 4 ++-- lib/chef/http.rb | 2 +- lib/chef/http/http_request.rb | 2 +- lib/chef/knife/client_create.rb | 2 +- lib/chef/knife/cookbook_site_install.rb | 4 ++-- lib/chef/knife/cookbook_upload.rb | 2 +- lib/chef/knife/core/bootstrap_context.rb | 2 +- lib/chef/knife/core/gem_glob_loader.rb | 4 ++-- lib/chef/knife/user_create.rb | 2 +- lib/chef/mixin/template.rb | 2 +- lib/chef/mixin/xml_escape.rb | 10 +++++----- lib/chef/policy_builder/policyfile.rb | 2 +- lib/chef/provider/git.rb | 10 +++++----- lib/chef/provider/package/yum.rb | 10 +++++----- lib/chef/provider/user.rb | 2 +- lib/chef/resource/template.rb | 4 ++-- lib/chef/resource_collection/resource_set.rb | 2 +- lib/chef/util/dsc/configuration_generator.rb | 2 +- lib/chef/win32/api.rb | 2 +- 22 files changed, 39 insertions(+), 39 deletions(-) (limited to 'lib/chef') diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb index 4a39ba5ba1..2a3e35bea7 100644 --- a/lib/chef/application/knife.rb +++ b/lib/chef/application/knife.rb @@ -38,7 +38,7 @@ class Chef::Application::Knife < Chef::Application :short => "-V", :long => "--verbose", :description => "More verbose output. Use twice for max verbosity", - :proc => Proc.new { verbosity_level += 1 }, + :proc => Proc.new { verbosity_level += 1 }, :default => 0 option :color, @@ -63,7 +63,7 @@ class Chef::Application::Knife < Chef::Application :long => "--disable-editing", :description => "Do not open EDITOR, just accept the data as is", :boolean => true, - :default => false + :default => false option :help, :short => "-h", diff --git a/lib/chef/cookbook/cookbook_collection.rb b/lib/chef/cookbook/cookbook_collection.rb index 81e7bb92b4..853657fb38 100644 --- a/lib/chef/cookbook/cookbook_collection.rb +++ b/lib/chef/cookbook/cookbook_collection.rb @@ -36,7 +36,7 @@ class Chef def initialize(cookbook_versions = {}) super() do |hash, key| raise Chef::Exceptions::CookbookNotFound, "Cookbook #{key} not found. " << - "If you're loading #{key} from another cookbook, make sure you configure the dependency in your metadata" + "If you're loading #{key} from another cookbook, make sure you configure the dependency in your metadata" end cookbook_versions.each { |cookbook_name, cookbook_version| self[cookbook_name] = cookbook_version } end diff --git a/lib/chef/encrypted_data_bag_item/assertions.rb b/lib/chef/encrypted_data_bag_item/assertions.rb index 8162a9aa54..bbdcf7a721 100644 --- a/lib/chef/encrypted_data_bag_item/assertions.rb +++ b/lib/chef/encrypted_data_bag_item/assertions.rb @@ -30,7 +30,7 @@ class Chef::EncryptedDataBagItem unless format_version.kind_of?(Integer) and 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]}'" + "but the config setting 'data_bag_decrypt_minimum_version' requires version `#{Chef::Config[:data_bag_decrypt_minimum_version]}'" end end diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index b286dad4e2..9cdb8a8522 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -36,7 +36,7 @@ class Chef attr_accessor :chef_server_rest - COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:[\s]+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:[\s]+).+)$/.freeze + COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:[\s]+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:[\s]+).+)$/ def initialize(chef_server_rest: nil) @name = "" @@ -123,7 +123,7 @@ class Chef result = { "name" => @name, "description" => @description, - "cookbook_versions" => @cookbook_versions, + "cookbook_versions" => @cookbook_versions, "json_class" => self.class.name, "chef_type" => "environment", "default_attributes" => @default_attributes, diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 0060fb08c7..9cd55f18dd 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -383,7 +383,7 @@ class Chef end def build_headers(method, url, headers = {}, json_body = false) - headers = @default_headers.merge(headers) + headers = @default_headers.merge(headers) headers["Content-Length"] = json_body.bytesize.to_s if json_body headers.merge!(Chef::Config[:custom_http_headers]) if Chef::Config[:custom_http_headers] headers diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb index 6cd7dda251..20c46aaa8d 100644 --- a/lib/chef/http/http_request.rb +++ b/lib/chef/http/http_request.rb @@ -60,7 +60,7 @@ class Chef HOST_LOWER = "host".freeze - URI_SCHEME_DEFAULT_PORT = { "http" => 80, "https" => 443 }.freeze + URI_SCHEME_DEFAULT_PORT = { "http" => 80, "https" => 443 }.freeze def self.user_agent=(ua) @user_agent = ua diff --git a/lib/chef/knife/client_create.rb b/lib/chef/knife/client_create.rb index ecacb36833..22c7ce907d 100644 --- a/lib/chef/knife/client_create.rb +++ b/lib/chef/knife/client_create.rb @@ -39,7 +39,7 @@ class Chef :boolean => true option :validator, - :long => "--validator", + :long => "--validator", :description => "Create the client as a validator.", :boolean => true diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb index 9a79cd076a..01374b9b36 100644 --- a/lib/chef/knife/cookbook_site_install.rb +++ b/lib/chef/knife/cookbook_site_install.rb @@ -53,7 +53,7 @@ class Chef :default => "master" option :use_current_branch, - :short => "-b", + :short => "-b", :long => "--use-current-branch", :description => "Use the current branch", :boolean => true, @@ -172,7 +172,7 @@ class Chef def preferred_metadata md = Chef::Cookbook::Metadata.new - rb = File.join(@install_path, @cookbook_name, "metadata.rb") + rb = File.join(@install_path, @cookbook_name, "metadata.rb") if File.exist?(rb) md.from_file(rb) return md diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index e16e21ae64..a2d7bd4bc1 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -151,7 +151,7 @@ class Chef ui.info "Uploaded #{upload_ok} cookbook#{upload_ok > 1 ? "s" : ""}." elsif upload_failures > 0 && upload_ok > 0 ui.warn "Uploaded #{upload_ok} cookbook#{upload_ok > 1 ? "s" : ""} ok but #{upload_failures} " + - "cookbook#{upload_failures > 1 ? "s" : ""} upload failed." + "cookbook#{upload_failures > 1 ? "s" : ""} upload failed." elsif upload_failures > 0 && upload_ok == 0 ui.error "Failed to upload #{upload_failures} cookbook#{upload_failures > 1 ? "s" : ""}." exit 1 diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index a863e0cdb7..62e23cdcc1 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -188,7 +188,7 @@ validation_client_name "#{@chef_config[:validation_client_name]}" if @chef_config[:trusted_certs_dir] Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(@chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert| content << "cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\n" + - IO.read(File.expand_path(cert)) + "\nEOP\n" + IO.read(File.expand_path(cert)) + "\nEOP\n" end end content diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb index 6802be29ef..78726feee7 100644 --- a/lib/chef/knife/core/gem_glob_loader.rb +++ b/lib/chef/knife/core/gem_glob_loader.rb @@ -22,8 +22,8 @@ class Chef class Knife class SubcommandLoader class GemGlobLoader < Chef::Knife::SubcommandLoader - MATCHES_CHEF_GEM = %r{/chef-[\d]+\.[\d]+\.[\d]+}.freeze - MATCHES_THIS_CHEF_GEM = %r{/chef-#{Chef::VERSION}(-\w+)?(-\w+)?/}.freeze + MATCHES_CHEF_GEM = %r{/chef-[\d]+\.[\d]+\.[\d]+} + MATCHES_THIS_CHEF_GEM = %r{/chef-#{Chef::VERSION}(-\w+)?(-\w+)?/} def subcommand_files @subcommand_files ||= (gem_and_builtin_subcommands.values + site_subcommands).flatten.uniq diff --git a/lib/chef/knife/user_create.rb b/lib/chef/knife/user_create.rb index 5a9589aad8..b1782a893b 100644 --- a/lib/chef/knife/user_create.rb +++ b/lib/chef/knife/user_create.rb @@ -38,7 +38,7 @@ class Chef option :user_key, :long => "--user-key FILENAME", - :description => "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)." + :description => "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)." option :prevent_keygen, :short => "-k", diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb index c423ccaa42..f749d34c51 100644 --- a/lib/chef/mixin/template.rb +++ b/lib/chef/mixin/template.rb @@ -105,7 +105,7 @@ class Chef def node return @node if @node raise "Could not find a value for node. If you are explicitly setting variables in a template, " + - "include a node variable if you plan to use it." + "include a node variable if you plan to use it." end # diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb index afb0d09c2d..f9a41b9fd0 100644 --- a/lib/chef/mixin/xml_escape.rb +++ b/lib/chef/mixin/xml_escape.rb @@ -64,14 +64,14 @@ class Chef CP1252 = { 128 => 8364, # euro sign 130 => 8218, # single low-9 quotation mark - 131 => 402, # latin small letter f with hook + 131 => 402, # latin small letter f with hook 132 => 8222, # double low-9 quotation mark 133 => 8230, # horizontal ellipsis 134 => 8224, # dagger 135 => 8225, # double dagger - 136 => 710, # modifier letter circumflex accent + 136 => 710, # modifier letter circumflex accent 137 => 8240, # per mille sign - 138 => 352, # latin capital letter s with caron + 138 => 352, # latin capital letter s with caron 139 => 8249, # single left-pointing angle quotation mark 140 => 338, # latin capital ligature oe 142 => 381, # latin capital letter z with caron @@ -82,9 +82,9 @@ class Chef 149 => 8226, # bullet 150 => 8211, # en dash 151 => 8212, # em dash - 152 => 732, # small tilde + 152 => 732, # small tilde 153 => 8482, # trade mark sign - 154 => 353, # latin small letter s with caron + 154 => 353, # latin small letter s with caron 155 => 8250, # single right-pointing angle quotation mark 156 => 339, # latin small ligature oe 158 => 382, # latin small letter z with caron diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index 9a6e62bc5d..1c0145348a 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -257,7 +257,7 @@ class Chef named_run_list or 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 diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index 600da540e5..854b5c01d9 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -53,9 +53,9 @@ class Chef a.assertion { !(@new_resource.revision =~ /^origin\//) } a.failure_message Chef::Exceptions::InvalidRemoteGitReference, "Deploying remote branches is not supported. " + - "Specify the remote branch as a local branch for " + - "the git repository you're deploying from " + - "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')." + "Specify the remote branch as a local branch for " + + "the git repository you're deploying from " + + "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')." end requirements.assert(:all_actions) do |a| @@ -65,8 +65,8 @@ class Chef a.assertion { target_revision != nil } a.failure_message Chef::Exceptions::UnresolvableGitReference, "Unable to parse SHA reference for '#{@new_resource.revision}' in repository '#{@new_resource.repository}'. " + - "Verify your (case-sensitive) repository URL and revision.\n" + - "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}" + "Verify your (case-sensitive) repository URL and revision.\n" + + "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}" end end diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 858b430abe..1ab06a36f8 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -240,7 +240,7 @@ class Chef @r = args[2] else raise ArgumentError, "Expecting either 'epoch-version-release' or 'epoch, " + - "version, release'" + "version, release'" end end attr_reader :e, :v, :r @@ -349,7 +349,7 @@ class Chef @provides = args[5] else raise ArgumentError, "Expecting either 'name, epoch-version-release, arch, provides' " + - "or 'name, epoch, version, release, arch, provides'" + "or 'name, epoch, version, release, arch, provides'" end # We always have one, ourselves! @@ -433,7 +433,7 @@ class Chef @flag = args[4] || :== else raise ArgumentError, "Expecting either 'name, epoch-version-release, flag' or " + - "'name, epoch, version, release, flag'" + "'name, epoch, version, release, flag'" end end attr_reader :name, :version, :flag @@ -1224,7 +1224,7 @@ class Chef else # we bail like yum when the package is older raise Chef::Exceptions::Package, "Installed package #{n}-#{current_version_array[idx]} is newer " + - "than candidate package #{n}-#{v}" + "than candidate package #{n}-#{v}" end end end @@ -1257,7 +1257,7 @@ class Chef yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} #{method} #{pkg_string}") else raise Chef::Exceptions::Package, "Version #{version} of #{name} not found. Did you specify both version " + - "and release? (version-release, e.g. 1.84-10.fc6)" + "and release? (version-release, e.g. 1.84-10.fc6)" end end diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index 85bd674d8d..795a5950fb 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -98,7 +98,7 @@ class Chef a.assertion { @shadow_lib_ok } a.failure_message Chef::Exceptions::MissingLibrary, "You must have ruby-shadow installed for password support!" a.whyrun "ruby-shadow is not installed. Attempts to set user password will cause failure. Assuming that this gem will have been previously installed." + - "Note that user update converge may report false-positive on the basis of mismatched password. " + "Note that user update converge may report false-positive on the basis of mismatched password. " end requirements.assert(:modify, :lock, :unlock) do |a| a.assertion { @user_exists } diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index 1570af2812..0b9d86f242 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -171,8 +171,8 @@ class Chef elsif module_name.nil? raise Exceptions::ValidationFailed, "#helpers requires either a module name or inline module code as a block.\n" + - "e.g.: helpers do; helper_code; end;\n" + - "OR: helpers(MyHelpersModule)" + "e.g.: helpers do; helper_code; end;\n" + + "OR: helpers(MyHelpersModule)" else raise Exceptions::ValidationFailed, "Argument to #helpers must be a module. You gave #{module_name.inspect} (#{module_name.class})" diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb index 2a653356dc..be24dc6ad8 100644 --- a/lib/chef/resource_collection/resource_set.rb +++ b/lib/chef/resource_collection/resource_set.rb @@ -124,7 +124,7 @@ class Chef else raise Chef::Exceptions::InvalidResourceSpecification, "The object `#{query_object.inspect}' is not valid for resource collection lookup. " + - "Use a String like `resource_type[resource_name]' or a Chef::Resource object" + "Use a String like `resource_type[resource_name]' or a Chef::Resource object" end end diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb index af9a71b246..739a463ad5 100644 --- a/lib/chef/util/dsc/configuration_generator.rb +++ b/lib/chef/util/dsc/configuration_generator.rb @@ -68,7 +68,7 @@ class Chef::Util::DSC end def get_merged_configuration_flags!(configuration_flags, configuration_name) - merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) } + merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) } if configuration_flags configuration_flags.map do |switch, value| if merged_configuration_flags.key?(switch.to_s.downcase.to_sym) diff --git a/lib/chef/win32/api.rb b/lib/chef/win32/api.rb index ad65b087cc..64db9d2b63 100644 --- a/lib/chef/win32/api.rb +++ b/lib/chef/win32/api.rb @@ -67,7 +67,7 @@ class Chef # BaseTsd.h: #ifdef (_WIN64) host.typedef int HALF_PTR; #else host.typedef short HALF_PTR; host.typedef :ulong, :HACCEL # (L) Handle to an accelerator table. WinDef.h: #host.typedef HANDLE HACCEL; # See http://msdn.microsoft.com/en-us/library/ms645526%28VS.85%29.aspx - host.typedef :size_t, :HANDLE # (L) Handle to an object. WinNT.h: #host.typedef PVOID HANDLE; + host.typedef :size_t, :HANDLE # (L) Handle to an object. WinNT.h: #host.typedef PVOID HANDLE; # todo: Platform-dependent! Need to change to :uint64 for Win64 host.typedef :ulong, :HBITMAP # (L) Handle to a bitmap: http://msdn.microsoft.com/en-us/library/dd183377%28VS.85%29.aspx host.typedef :ulong, :HBRUSH # (L) Handle to a brush. http://msdn.microsoft.com/en-us/library/dd183394%28VS.85%29.aspx -- cgit v1.2.1