From 271d3e4f91e3d158c9112512ac75d0ca51fc928d Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 23 Feb 2016 10:45:15 -0800 Subject: Autofixing new Perf cops in 0.37.2 6 Performance/Casecmp 18 Performance/Detect 1 Performance/RangeInclude 27 Performance/RedundantBlockCall 6 Performance/RedundantMatch 5 Performance/RedundantMerge 18 Performance/StringReplacement --- Gemfile | 2 +- chef-config/lib/chef-config/package_task.rb | 2 +- lib/chef/application/client.rb | 2 +- lib/chef/chef_fs/data_handler/container_data_handler.rb | 2 +- lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb | 2 +- lib/chef/chef_fs/data_handler/data_handler_base.rb | 2 +- lib/chef/chef_fs/data_handler/organization_data_handler.rb | 2 +- lib/chef/chef_fs/data_handler/policy_data_handler.rb | 4 ++-- lib/chef/chef_fs/data_handler/policy_group_data_handler.rb | 2 +- lib/chef/chef_fs/file_system.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/acl_dir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/acls_dir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb | 4 ++-- lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb | 4 ++-- lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/policies_dir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb | 2 +- lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb | 2 +- lib/chef/chef_fs/file_system/memory/memory_dir.rb | 2 +- lib/chef/chef_fs/parallelizer/flatten_enumerable.rb | 2 +- lib/chef/cookbook_version.rb | 2 +- lib/chef/http/authenticator.rb | 2 +- lib/chef/http/basic_client.rb | 2 +- lib/chef/http/remote_request_id.rb | 2 +- lib/chef/http/socketless_chef_zero_client.rb | 2 +- lib/chef/knife.rb | 4 ++-- lib/chef/knife/cookbook_site_download.rb | 2 +- lib/chef/knife/cookbook_site_show.rb | 2 +- lib/chef/knife/core/bootstrap_context.rb | 5 +++-- lib/chef/knife/core/subcommand_loader.rb | 2 +- lib/chef/knife/search.rb | 2 +- lib/chef/knife/ssh.rb | 2 +- lib/chef/log.rb | 2 +- lib/chef/mixin/command.rb | 2 +- lib/chef/mixin/properties.rb | 3 ++- lib/chef/mixin/why_run.rb | 2 +- lib/chef/provider/link.rb | 2 +- lib/chef/provider/package/portage.rb | 2 +- lib/chef/provider/package/rubygems.rb | 2 +- lib/chef/provider/service/arch.rb | 4 ++-- lib/chef/provider/service/openbsd.rb | 4 ++-- lib/chef/provider/service/upstart.rb | 2 +- lib/chef/resource/mount.rb | 2 +- lib/chef/run_list.rb | 4 ++-- lib/chef/search/query.rb | 2 +- lib/chef/util/windows/net_user.rb | 2 +- lib/chef/win32/api/file.rb | 6 +++--- lib/chef/win32/version.rb | 2 +- spec/functional/resource/link_spec.rb | 2 +- spec/functional/resource/user/useradd_spec.rb | 2 +- spec/functional/run_lock_spec.rb | 2 +- spec/stress/win32/security_spec.rb | 2 +- spec/support/chef_helpers.rb | 2 +- spec/support/mock/constant.rb | 2 +- spec/support/shared/unit/provider/file.rb | 2 +- spec/unit/api_client/registration_spec.rb | 2 +- spec/unit/chef_fs/parallelizer.rb | 4 ++-- spec/unit/knife/cookbook_site_download_spec.rb | 4 ++-- spec/unit/provider/link_spec.rb | 2 +- tasks/external_tests.rb | 2 +- 63 files changed, 77 insertions(+), 75 deletions(-) diff --git a/Gemfile b/Gemfile index 2c37e6c7d4..2d0a7338ea 100644 --- a/Gemfile +++ b/Gemfile @@ -30,7 +30,7 @@ group(:development, :test) do # gem 'chefstyle', github: 'chef/chefstyle' gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master" - gem "ruby-shadow", platforms: :ruby unless RUBY_PLATFORM.downcase.match(/(aix|cygwin)/) + gem "ruby-shadow", platforms: :ruby unless RUBY_PLATFORM.downcase =~ /(aix|cygwin)/ # For external tests # gem 'chef-zero', github: 'chef/chef-zero' diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb index 4f75af9c6c..1860335854 100644 --- a/chef-config/lib/chef-config/package_task.rb +++ b/chef-config/lib/chef-config/package_task.rb @@ -99,7 +99,7 @@ module ChefConfig if defined?(Bundler) Bundler.with_clean_env(&block) else - block.call + yield end end diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index 9ec553fb8a..79cb046919 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -263,7 +263,7 @@ class Chef::Application::Client < Chef::Application option :audit_mode, :long => "--audit-mode MODE", :description => "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`", - :proc => lambda { |mo| mo.gsub("-", "_").to_sym } + :proc => lambda { |mo| mo.tr("-", "_").to_sym } option :minimal_ohai, :long => "--minimal-ohai", diff --git a/lib/chef/chef_fs/data_handler/container_data_handler.rb b/lib/chef/chef_fs/data_handler/container_data_handler.rb index a2e277fc7a..6e578e53d6 100644 --- a/lib/chef/chef_fs/data_handler/container_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/container_data_handler.rb @@ -18,7 +18,7 @@ class Chef def verify_integrity(object, entry, &on_error) base_name = remove_dot_json(entry.name) if object["containername"] != base_name - on_error.call("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['name']}')") + yield("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['name']}')") end end diff --git a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb index 8ac9a520a4..3b609fad4e 100644 --- a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb @@ -45,7 +45,7 @@ class Chef def verify_integrity(object, entry, &on_error) base_name = remove_dot_json(entry.name) if object["raw_data"]["id"] != base_name - on_error.call("ID in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['raw_data']['id']}')") + yield("ID in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['raw_data']['id']}')") end end diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb index 83f56ed16d..93d54e3bee 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -192,7 +192,7 @@ class Chef def verify_integrity(object, entry, &on_error) base_name = remove_dot_json(entry.name) if object["name"] != base_name - on_error.call("Name must be '#{base_name}' (is '#{object['name']}')") + yield("Name must be '#{base_name}' (is '#{object['name']}')") end end diff --git a/lib/chef/chef_fs/data_handler/organization_data_handler.rb b/lib/chef/chef_fs/data_handler/organization_data_handler.rb index 3e5528cc49..d61e4f454a 100644 --- a/lib/chef/chef_fs/data_handler/organization_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/organization_data_handler.rb @@ -21,7 +21,7 @@ class Chef def verify_integrity(object, entry, &on_error) if entry.org != object["name"] - on_error.call("Name must be '#{entry.org}' (is '#{object['name']}')") + yield("Name must be '#{entry.org}' (is '#{object['name']}')") end end end diff --git a/lib/chef/chef_fs/data_handler/policy_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_data_handler.rb index 477d2bf637..47f534bfc9 100644 --- a/lib/chef/chef_fs/data_handler/policy_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_data_handler.rb @@ -29,11 +29,11 @@ class Chef def verify_integrity(object_data, entry, &on_error) name, revision = name_and_revision(entry.name) if object_data["name"] != name - on_error.call("Object name '#{object_data['name']}' doesn't match entry '#{entry.name}'.") + yield("Object name '#{object_data['name']}' doesn't match entry '#{entry.name}'.") end if object_data["revision_id"] != revision - on_error.call("Object revision ID '#{object_data['revision']}' doesn't match entry '#{entry.name}'.") + yield("Object revision ID '#{object_data['revision']}' doesn't match entry '#{entry.name}'.") end end end diff --git a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb index e5c430ab64..d3bdd81e25 100644 --- a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb @@ -17,7 +17,7 @@ class Chef def verify_integrity(object_data, entry, &on_error) if object_data["policies"].empty? - on_error.call("Policy group #{object_data["name"]} does not have any policies in it.") + yield("Policy group #{object_data["name"]} does not have any policies in it.") end end diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb index 415556300c..e6cf735971 100644 --- a/lib/chef/chef_fs/file_system.rb +++ b/lib/chef/chef_fs/file_system.rb @@ -55,7 +55,7 @@ class Chef def list_from(entry, &block) # Include self in results if it matches if pattern.match?(entry.path) - block.call(entry) + yield(entry) end if pattern.could_match_children?(entry.path) diff --git a/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb b/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb index 9943aaeca7..58a32d3860 100644 --- a/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb @@ -30,7 +30,7 @@ class Chef end def make_child_entry(name, exists = nil) - result = @children.select { |child| child.name == name }.first if @children + result = @children.find { |child| child.name == name } if @children result || AclEntry.new(name, self, exists) end diff --git a/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb b/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb index d03164023f..b9af486203 100644 --- a/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb @@ -39,7 +39,7 @@ class Chef end def make_child_entry(name) - children.select { |child| child.name == name }.first + children.find { |child| child.name == name } end def can_have_child?(name, is_dir) diff --git a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb index 6c99d6de73..5030a0733f 100644 --- a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb @@ -119,7 +119,7 @@ class Chef end def can_have_child?(name, is_dir) - result = children.select { |child| child.name == name }.first + result = children.find { |child| child.name == name } result && !!result.dir? == !!is_dir end @@ -136,7 +136,7 @@ class Chef end def make_child_entry(name) - children.select { |child| child.name == name }.first + children.find { |child| child.name == name } end def children diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb index 020f8510b7..0b82a64a0a 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb @@ -35,7 +35,7 @@ class Chef class CookbookArtifactsDir < CookbooksDir def make_child_entry(name) - result = @children.select { |child| child.name == name }.first if @children + result = @children.find { |child| child.name == name } if @children result || CookbookArtifactDir.new(name, self) end 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 3a08768baf..d69126ce6e 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 @@ -74,7 +74,7 @@ class Chef # we need to make sure we don't rethrow the exception. (child(name) # is not supposed to fail.) begin - children.select { |child| child.name == name }.first + children.find { |child| child.name == name } rescue Chef::ChefFS::FileSystem::NotFoundError nil end @@ -101,7 +101,7 @@ class Chef container = self parts[0, parts.length - 1].each do |part| old_container = container - container = old_container.children.select { |child| part == child.name }.first + container = old_container.children.find { |child| part == child.name } if !container container = CookbookSubdir.new(part, old_container, segment_info[:ruby_only], segment_info[:recursive]) old_container.add_child(container) diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb index 913cf1a5e2..01297a39ba 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb @@ -47,7 +47,7 @@ class Chef end def make_child_entry(name) - result = @children.select { |child| child.name == name }.first if @children + result = @children.find { |child| child.name == name } if @children result || NonexistentFSObject.new(name, self) end diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb index 75d7150f8e..72cefe44eb 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb @@ -41,7 +41,7 @@ class Chef include Chef::Mixin::FileClass def make_child_entry(name) - result = @children.select { |child| child.name == name }.first if @children + result = @children.find { |child| child.name == name } if @children result || CookbookDir.new(name, self) end diff --git a/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb b/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb index 9246d8e2b7..ec382e60ef 100644 --- a/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb @@ -25,7 +25,7 @@ class Chef module ChefServer class DataBagsDir < RestListDir def make_child_entry(name, exists = false) - result = @children.select { |child| child.name == name }.first if @children + result = @children.find { |child| child.name == name } if @children result || DataBagDir.new(name, self, exists) end diff --git a/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb b/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb index ebb274a9eb..4a4be19fe4 100644 --- a/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb @@ -47,7 +47,7 @@ class Chef # } def make_child_entry(name, exists = nil) - @children.select { |child| child.name == name }.first if @children + @children.find { |child| child.name == name } if @children PolicyRevisionEntry.new(name, self, exists) end diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb index 488e9c0ed0..b5b602a208 100644 --- a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb @@ -168,7 +168,7 @@ class Chef end def make_child_entry(name, exists = nil) - @children.select { |child| child.name == name }.first if @children + @children.find { |child| child.name == name } if @children RestListEntry.new(name, self, exists) end end diff --git a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb index 9abafed5e7..172405763a 100644 --- a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb @@ -41,7 +41,7 @@ class Chef class VersionedCookbooksDir < CookbooksDir def make_child_entry(name) - result = @children.select { |child| child.name == name }.first if @children + result = @children.find { |child| child.name == name } if @children result || VersionedCookbookDir.new(name, self) end diff --git a/lib/chef/chef_fs/file_system/memory/memory_dir.rb b/lib/chef/chef_fs/file_system/memory/memory_dir.rb index beb661448d..6049f404b1 100644 --- a/lib/chef/chef_fs/file_system/memory/memory_dir.rb +++ b/lib/chef/chef_fs/file_system/memory/memory_dir.rb @@ -14,7 +14,7 @@ class Chef attr_reader :children def make_child_entry(name) - @children.select { |child| child.name == name }.first + @children.find { |child| child.name == name } end def add_child(child) diff --git a/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb b/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb index 6094fab493..84db2c2053 100644 --- a/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb +++ b/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb @@ -26,7 +26,7 @@ class Chef flatten(child, levels.nil? ? levels : levels - 1, &block) end else - block.call(value) + yield(value) end end end diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 9ebf705d79..d9078ac48c 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -493,7 +493,7 @@ class Chef if rendered_manifest.has_key?(segment) rendered_manifest[segment].each do |manifest_record| url_options = { :cookbook_name => name.to_s, :cookbook_version => version, :checksum => manifest_record["checksum"] } - manifest_record["url"] = url_generator.call(url_options) + manifest_record["url"] = yield(url_options) end end end diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb index b5e28cf54d..84065bf816 100644 --- a/lib/chef/http/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -47,7 +47,7 @@ class Chef end def handle_request(method, url, headers = {}, data = false) - headers.merge!({ "X-Ops-Server-API-Version" => @api_version }) + headers["X-Ops-Server-API-Version"] = @api_version headers.merge!(authentication_headers(method, url, data, headers)) if sign_requests? [method, url, headers, data] end diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb index e0a02a05cf..58ae496418 100644 --- a/lib/chef/http/basic_client.rb +++ b/lib/chef/http/basic_client.rb @@ -104,7 +104,7 @@ class Chef # proxy before parsing. The regex /^.*:\/\// matches, for example, http://. Reusing proxy # here since we are really just trying to get the string built correctly. if String === proxy && !proxy.strip.empty? - if proxy.match(/^.*:\/\//) + if proxy =~ /^.*:\/\// proxy = URI.parse(proxy.strip) else proxy = URI.parse("#{url.scheme}://#{proxy.strip}") diff --git a/lib/chef/http/remote_request_id.rb b/lib/chef/http/remote_request_id.rb index ef8a18a1e3..a779df805e 100644 --- a/lib/chef/http/remote_request_id.rb +++ b/lib/chef/http/remote_request_id.rb @@ -25,7 +25,7 @@ class Chef end def handle_request(method, url, headers = {}, data = false) - headers.merge!({ "X-REMOTE-REQUEST-ID" => Chef::RequestID.instance.request_id }) + headers["X-REMOTE-REQUEST-ID"] = Chef::RequestID.instance.request_id [method, url, headers, data] end diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index c8590903f6..e25242c033 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -67,7 +67,7 @@ class Chef end if block_given? - block.call(@body) + yield(@body) else super end diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 657216bcf0..71127b5b57 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -514,7 +514,7 @@ class Chef output = edit_data(object, object_class: object_class) if Kernel.block_given? - output = block.call(output) + output = yield(output) else output.save end @@ -530,7 +530,7 @@ class Chef confirm("Do you really want to delete #{name}") if Kernel.block_given? - object = block.call + object = yield else object = klass.load(name) object.destroy diff --git a/lib/chef/knife/cookbook_site_download.rb b/lib/chef/knife/cookbook_site_download.rb index 2bdeea9781..21a251a011 100644 --- a/lib/chef/knife/cookbook_site_download.rb +++ b/lib/chef/knife/cookbook_site_download.rb @@ -102,7 +102,7 @@ class Chef end def specific_cookbook_version_url - "#{cookbooks_api_url}/#{@name_args[0]}/versions/#{@name_args[1].gsub('.', '_')}" + "#{cookbooks_api_url}/#{@name_args[0]}/versions/#{@name_args[1].tr('.', '_')}" end end end diff --git a/lib/chef/knife/cookbook_site_show.rb b/lib/chef/knife/cookbook_site_show.rb index a6a4c82c85..c0280cb318 100644 --- a/lib/chef/knife/cookbook_site_show.rb +++ b/lib/chef/knife/cookbook_site_show.rb @@ -33,7 +33,7 @@ class Chef when 1 noauth_rest.get("https://supermarket.chef.io/api/v1/cookbooks/#{@name_args[0]}") when 2 - noauth_rest.get("https://supermarket.chef.io/api/v1/cookbooks/#{@name_args[0]}/versions/#{name_args[1].gsub('.', '_')}") + noauth_rest.get("https://supermarket.chef.io/api/v1/cookbooks/#{@name_args[0]}/versions/#{name_args[1].tr('.', '_')}") end end diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index b05cae688c..5379b6504c 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -171,9 +171,10 @@ validation_client_name "#{@chef_config[:validation_client_name]}" def first_boot (@config[:first_boot_attributes] || {}).tap do |attributes| if @config[:policy_name] && @config[:policy_group] - attributes.merge!(:policy_name => @config[:policy_name], :policy_group => @config[:policy_group]) + attributes[:policy_name] = @config[:policy_name] + attributes[:policy_group] = @config[:policy_group] else - attributes.merge!(:run_list => @run_list) + attributes[:run_list] = @run_list end attributes.merge!(:tags => @config[:tags]) if @config[:tags] && !@config[:tags].empty? diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb index 95ab219c80..e636013c70 100644 --- a/lib/chef/knife/core/subcommand_loader.rb +++ b/lib/chef/knife/core/subcommand_loader.rb @@ -118,7 +118,7 @@ class Chef load_command(cmd_words) result = Chef::Knife.subcommands[find_longest_key(Chef::Knife.subcommands, cmd_words, "_")] - result || Chef::Knife.subcommands[args.first.gsub("-", "_")] + result || Chef::Knife.subcommands[args.first.tr("-", "_")] end def guess_category(args) diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb index 30a3db3cf2..520c9273af 100644 --- a/lib/chef/knife/search.rb +++ b/lib/chef/knife/search.rb @@ -177,7 +177,7 @@ class Chef # See lib/chef/search/query.rb for more examples of this. def create_result_filter(filter_string) final_filter = Hash.new - filter_string.gsub!(" ", "") + filter_string.delete!(" ") filters = filter_string.split(",") filters.each do |f| return_id, attr_path = f.split("=") diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index 4184171a4e..9c0f8936f0 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -424,7 +424,7 @@ class Chef end.join(" \\; ") end - tmux_name = "'knife ssh #{@name_args[0].gsub(/:/, '=')}'" + tmux_name = "'knife ssh #{@name_args[0].tr(':', '=')}'" begin server = session.servers_for.first cmd = ["tmux new-session -d -s #{tmux_name}", diff --git a/lib/chef/log.rb b/lib/chef/log.rb index bfb5829be6..ac2baeb9d1 100644 --- a/lib/chef/log.rb +++ b/lib/chef/log.rb @@ -48,7 +48,7 @@ class Chef # Pick the first caller that is *not* part of the Chef gem, that's the # thing the user wrote. chef_gem_path = File.expand_path("../..", __FILE__) - caller(0..20).select { |c| !c.start_with?(chef_gem_path) }.first + caller(0..20).find { |c| !c.start_with?(chef_gem_path) } end def self.deprecation(msg = nil, location = caller(2..2)[0], &block) diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb index 257ed11221..435daeda77 100644 --- a/lib/chef/mixin/command.rb +++ b/lib/chef/mixin/command.rb @@ -183,7 +183,7 @@ class Chef raise Chef::Exceptions::Exec, "#{dir} does not exist or is not a directory" end Dir.chdir(dir) do - block.call + yield end end diff --git a/lib/chef/mixin/properties.rb b/lib/chef/mixin/properties.rb index 2e33d2d0e7..1ee16b8b4a 100644 --- a/lib/chef/mixin/properties.rb +++ b/lib/chef/mixin/properties.rb @@ -98,7 +98,8 @@ class Chef options.each { |k, v| options[k.to_sym] = v if k.is_a?(String) } options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name) - options.merge!(name: name, declared_in: self) + options[:name] = name + options[:declared_in] = self if type == NOT_PASSED # If a type is not passed, the property derives from the diff --git a/lib/chef/mixin/why_run.rb b/lib/chef/mixin/why_run.rb index b2aa5949c0..69fee58e31 100644 --- a/lib/chef/mixin/why_run.rb +++ b/lib/chef/mixin/why_run.rb @@ -49,7 +49,7 @@ class Chef def add_action(descriptions, &block) @actions << [descriptions, block] if (@resource.respond_to?(:is_guard_interpreter) && @resource.is_guard_interpreter) || !Chef::Config[:why_run] - block.call + yield end events.resource_update_applied(@resource, @action, descriptions) end diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index d184094bbb..83b5dd8c00 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -86,7 +86,7 @@ class Chef end def canonicalize(path) - Chef::Platform.windows? ? path.gsub("/", '\\') : path + Chef::Platform.windows? ? path.tr("/", '\\') : path end def action_create diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb index a514dcc66c..7127fa723f 100644 --- a/lib/chef/provider/package/portage.rb +++ b/lib/chef/provider/package/portage.rb @@ -66,7 +66,7 @@ class Chef txt.each_line do |line| if line =~ /\*\s+#{PACKAGE_NAME_PATTERN}/ - found_package_name = $&.gsub(/\*/, "").strip + found_package_name = $&.delete("*").strip if package =~ /\// #the category is specified if found_package_name == package availables[found_package_name] = nil diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index 7a2db6b32b..6afe908180 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -410,7 +410,7 @@ class Chef def find_gem_by_path Chef::Log.debug("#{@new_resource} searching for 'gem' binary in path: #{ENV['PATH']}") separator = ::File::ALT_SEPARATOR ? ::File::ALT_SEPARATOR : ::File::SEPARATOR - path_to_first_gem = ENV["PATH"].split(::File::PATH_SEPARATOR).select { |path| ::File.exists?(path + separator + "gem") }.first + path_to_first_gem = ENV["PATH"].split(::File::PATH_SEPARATOR).find { |path| ::File.exists?(path + separator + "gem") } raise Chef::Exceptions::FileNotFound, "Unable to find 'gem' binary in path: #{ENV['PATH']}" if path_to_first_gem.nil? path_to_first_gem + separator + "gem" end diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb index 9c66fb4098..c0545e9fb3 100644 --- a/lib/chef/provider/service/arch.rb +++ b/lib/chef/provider/service/arch.rb @@ -33,7 +33,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init def load_current_resource raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf") - raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m) + raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf") =~ /DAEMONS=\((.*)\)/m super @current_resource.enabled(daemons.include?(@current_resource.service_name)) @@ -49,7 +49,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init # ) def daemons entries = [] - if ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m) + if ::File.read("/etc/rc.conf") =~ /DAEMONS=\((.*)\)/m entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/, " ").split(" ") if $1.length > 0 end diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb index c31df25e68..c60bbf170c 100644 --- a/lib/chef/provider/service/openbsd.rb +++ b/lib/chef/provider/service/openbsd.rb @@ -92,7 +92,7 @@ class Chef old_services_list = rc_conf_local.match(/^pkg_scripts="(.*)"/) old_services_list = old_services_list ? old_services_list[1].split(" ") : [] new_services_list = old_services_list + [new_resource.service_name] - if rc_conf_local.match(/^pkg_scripts="(.*)"/) + if rc_conf_local =~ /^pkg_scripts="(.*)"/ new_rcl = rc_conf_local.sub(/^pkg_scripts="(.*)"/, "pkg_scripts=\"#{new_services_list.join(' ')}\"") else new_rcl = rc_conf_local + "\n" + "pkg_scripts=\"#{new_services_list.join(' ')}\"\n" @@ -159,7 +159,7 @@ class Chef result = false var_name = builtin_service_enable_variable_name if var_name - if rc_conf.match(/^#{Regexp.escape(var_name)}=(.*)/) + if rc_conf =~ /^#{Regexp.escape(var_name)}=(.*)/ result = true end end diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb index edd41dba7e..3ac5ff51da 100644 --- a/lib/chef/provider/service/upstart.rb +++ b/lib/chef/provider/service/upstart.rb @@ -62,7 +62,7 @@ class Chef end platform, version = Chef::Platform.find_platform_and_version(run_context.node) - if platform == "ubuntu" && (8.04..9.04).include?(version.to_f) + if platform == "ubuntu" && (8.04..9.04).cover?(version.to_f) @upstart_job_dir = "/etc/event.d" @upstart_conf_suffix = "" else diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index 44143d583c..2d85b3897c 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -102,7 +102,7 @@ class Chef ) if ret.is_a? String - ret.gsub(/,/, " ").split(/ /) + ret.tr(",", " ").split(/ /) else ret end diff --git a/lib/chef/run_list.rb b/lib/chef/run_list.rb index b9ec9259ca..9647ef16e6 100644 --- a/lib/chef/run_list.rb +++ b/lib/chef/run_list.rb @@ -106,11 +106,11 @@ class Chef end def each(&block) - @run_list_items.each { |i| block.call(i) } + @run_list_items.each { |i| yield(i) } end def each_index(&block) - @run_list_items.each_index { |i| block.call(i) } + @run_list_items.each_index { |i| yield(i) } end def include?(item) diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb index 487a54f0df..ebf13bec36 100644 --- a/lib/chef/search/query.rb +++ b/lib/chef/search/query.rb @@ -87,7 +87,7 @@ WARNDEP response = call_rest_service(type, query: query, **args_h) if block - response["rows"].each { |row| block.call(row) if row } + response["rows"].each { |row| yield(row) if row } # # args_h[:rows] and args_h[:start] are the page size and # start position requested of the search index backing the diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index b0a779e44a..9bb615aee7 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -123,7 +123,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows user = get_info user[:last_logon] = user[:units_per_week] = 0 #ignored as per USER_INFO_3 doc user[:logon_hours] = nil #PBYTE field; \0 == no changes - proc.call(user) + yield(user) set_info(user) end diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb index 52ac4868c7..09501e66ce 100644 --- a/lib/chef/win32/api/file.rb +++ b/lib/chef/win32/api/file.rb @@ -550,7 +550,7 @@ BOOL WINAPI VerQueryValue( if handle == INVALID_HANDLE_VALUE Chef::ReservedNames::Win32::Error.raise! end - block.call(handle, find_data) + yield(handle, find_data) ensure FindClose(handle) if handle && handle != INVALID_HANDLE_VALUE end @@ -568,7 +568,7 @@ BOOL WINAPI VerQueryValue( if handle == INVALID_HANDLE_VALUE Chef::ReservedNames::Win32::Error.raise! end - block.call(handle) + yield(handle) ensure CloseHandle(handle) if handle && handle != INVALID_HANDLE_VALUE end @@ -583,7 +583,7 @@ BOOL WINAPI VerQueryValue( if handle == INVALID_HANDLE_VALUE Chef::ReservedNames::Win32::Error.raise! end - block.call(handle) + yield(handle) ensure CloseHandle(handle) if handle && handle != INVALID_HANDLE_VALUE end diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb index 85a2744645..303fe1531d 100644 --- a/lib/chef/win32/version.rb +++ b/lib/chef/win32/version.rb @@ -41,7 +41,7 @@ class Chef private_class_method :get_system_metrics def self.method_name_from_marketing_name(marketing_name) - "#{marketing_name.gsub(/\s/, '_').gsub(/\./, '_').downcase}?" + "#{marketing_name.gsub(/\s/, '_').tr('.', '_').downcase}?" # "#{marketing_name.gsub(/\s/, '_').gsub(//, '_').downcase}?" end diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb index f55b9fca1e..7ea3b44a3d 100644 --- a/spec/functional/resource/link_spec.rb +++ b/spec/functional/resource/link_spec.rb @@ -73,7 +73,7 @@ describe Chef::Resource::Link do end def canonicalize(path) - windows? ? path.gsub("/", '\\') : path + windows? ? path.tr("/", '\\') : path end def symlink(a, b) diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb index 6ac855fbfc..f5b228a4df 100644 --- a/spec/functional/resource/user/useradd_spec.rb +++ b/spec/functional/resource/user/useradd_spec.rb @@ -508,7 +508,7 @@ describe Chef::Provider::User::Useradd, metadata do let(:user_locked_context?) { false } def shadow_entry - etc_shadow.lines.select { |l| l.include?(username) }.first + etc_shadow.lines.find { |l| l.include?(username) } end def shadow_password diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb index b0e52471db..f1e480c917 100644 --- a/spec/functional/run_lock_spec.rb +++ b/spec/functional/run_lock_spec.rb @@ -343,7 +343,7 @@ describe Chef::RunLock do write_to_process.print "#{to_event}\n" # Run the background block - background_block.call if background_block + yield if background_block # Wait until it gets there Timeout.timeout(CLIENT_PROCESS_TIMEOUT) do diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb index 4fbd1dac9c..58cf7b3357 100644 --- a/spec/stress/win32/security_spec.rb +++ b/spec/stress/win32/security_spec.rb @@ -27,7 +27,7 @@ end describe "Chef::ReservedNames::Win32::Security", :windows_only do def monkeyfoo - File.join(CHEF_SPEC_DATA, "monkeyfoo").gsub("/", "\\") + File.join(CHEF_SPEC_DATA, "monkeyfoo").tr("/", "\\") end before :all do diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb index aa60737c86..f64c14da4d 100644 --- a/spec/support/chef_helpers.rb +++ b/spec/support/chef_helpers.rb @@ -81,7 +81,7 @@ end # This is a helper to canonicalize paths that we're using in the file # tests. def canonicalize_path(path) - windows? ? path.gsub("/", '\\') : path + windows? ? path.tr("/", '\\') : path end # Check if a cmd exists on the PATH diff --git a/spec/support/mock/constant.rb b/spec/support/mock/constant.rb index a2abc1905e..942905144f 100644 --- a/spec/support/mock/constant.rb +++ b/spec/support/mock/constant.rb @@ -13,7 +13,7 @@ def mock_constants(constants, &block) end begin - block.call + yield ensure constants.each do |constant, val| source_object, const_name = parse_constant(constant) diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index 7ddd51db80..2b2c7255cc 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -37,7 +37,7 @@ end # forwards-vs-reverse slashes on windows sucks def windows_path - windows? ? normalized_path.gsub(/\\/, "/") : normalized_path + windows? ? normalized_path.tr('\\', "/") : normalized_path end # this is all getting a bit stupid, CHEF-4802 cut to remove all this diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb index f086993860..0f036766da 100644 --- a/spec/unit/api_client/registration_spec.rb +++ b/spec/unit/api_client/registration_spec.rb @@ -98,7 +98,7 @@ describe Chef::ApiClient::Registration do it "has an HTTP client configured with validator credentials" do expect(registration.http_api).to be_a_kind_of(Chef::ServerAPI) expect(registration.http_api.options[:client_name]).to eq("test-validator") - auth = registration.http_api.middlewares.select { |klass| klass.kind_of? Chef::HTTP::Authenticator }.first + auth = registration.http_api.middlewares.find { |klass| klass.kind_of? Chef::HTTP::Authenticator } expect(auth.client_name).to eq("test-validator") end diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index 20edbcdcde..96b713b547 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -466,12 +466,12 @@ describe Chef::ChefFS::Parallelizer do def each(&each_block) @values.each do |value| @num_processed += 1 - each_block.call(value) + yield(value) end if @block @block.call do |value| @num_processed += 1 - each_block.call(value) + yield(value) end end end diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb index d7f26f2f2e..d283bd417f 100644 --- a/spec/unit/knife/cookbook_site_download_spec.rb +++ b/spec/unit/knife/cookbook_site_download_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::CookbookSiteDownload do @stderr = StringIO.new @cookbook_api_url = "https://supermarket.chef.io/api/v1/cookbooks" @version = "1.0.2" - @version_us = @version.gsub ".", "_" + @version_us = @version.tr ".", "_" @current_data = { "deprecated" => false, "latest_version" => "#{@cookbook_api_url}/apache2/versions/#{@version_us}", "replacement" => "other_apache2" } @@ -120,7 +120,7 @@ describe Chef::Knife::CookbookSiteDownload do context "downloading a cookbook of a specific version" do before do @version = "1.0.1" - @version_us = @version.gsub ".", "_" + @version_us = @version.tr ".", "_" @cookbook_data = { "version" => @version, "file" => "http://example.com/apache2_#{@version_us}.tgz" } @temp_file = double(:path => "/tmp/apache2_#{@version_us}.tgz") diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index 31065d7bfd..6bb08551a2 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -39,7 +39,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do end def canonicalize(path) - Chef::Platform.windows? ? path.gsub("/", '\\') : path + Chef::Platform.windows? ? path.tr("/", '\\') : path end describe "when the target is a symlink" do diff --git a/tasks/external_tests.rb b/tasks/external_tests.rb index f6fd79c86b..a909ec2178 100644 --- a/tasks/external_tests.rb +++ b/tasks/external_tests.rb @@ -58,7 +58,7 @@ EXTERNAL_PROJECTS = { task :external_specs => EXTERNAL_PROJECTS.keys.map { |g| :"#{g.sub("-", "_")}_spec" } EXTERNAL_PROJECTS.each do |test_gem, commands| - task :"#{test_gem.gsub("-", "_")}_spec" do + task :"#{test_gem.tr("-", "_")}_spec" do bundle_exec_with_chef(test_gem, commands) end end -- cgit v1.2.1 From f17fc92d3b8400cc91bfd384c5bf39fd40bdf5b1 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 23 Feb 2016 11:36:29 -0800 Subject: remove unused block arguments --- lib/chef/chef_fs/data_handler/container_data_handler.rb | 2 +- lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb | 2 +- lib/chef/chef_fs/data_handler/data_handler_base.rb | 2 +- lib/chef/chef_fs/data_handler/organization_data_handler.rb | 2 +- lib/chef/chef_fs/data_handler/policy_data_handler.rb | 2 +- lib/chef/chef_fs/data_handler/policy_group_data_handler.rb | 2 +- lib/chef/cookbook_version.rb | 2 +- lib/chef/guard_interpreter/resource_guard_interpreter.rb | 2 +- lib/chef/http.rb | 2 +- lib/chef/http/socketless_chef_zero_client.rb | 2 +- lib/chef/knife.rb | 4 ++-- lib/chef/mixin/command.rb | 2 +- lib/chef/mixin/provides.rb | 2 +- lib/chef/resource_collection/resource_list.rb | 2 +- lib/chef/run_list.rb | 4 ++-- lib/chef/shell/model_wrapper.rb | 2 +- lib/chef/util/windows/net_user.rb | 2 +- lib/chef/win32/api/file.rb | 6 +++--- spec/functional/win32/versions_spec.rb | 2 +- spec/support/matchers/leak.rb | 2 +- spec/support/mock/constant.rb | 2 +- spec/support/mock/platform.rb | 2 +- spec/support/shared/integration/knife_support.rb | 2 +- spec/unit/chef_fs/parallelizer.rb | 2 +- spec/unit/dsl/resources_spec.rb | 2 +- 25 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/chef/chef_fs/data_handler/container_data_handler.rb b/lib/chef/chef_fs/data_handler/container_data_handler.rb index 6e578e53d6..27bb9dc736 100644 --- a/lib/chef/chef_fs/data_handler/container_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/container_data_handler.rb @@ -15,7 +15,7 @@ class Chef return key == "containername" end - def verify_integrity(object, entry, &on_error) + def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["containername"] != base_name yield("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['name']}')") diff --git a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb index 3b609fad4e..89087e159f 100644 --- a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb @@ -42,7 +42,7 @@ class Chef Chef::DataBagItem end - def verify_integrity(object, entry, &on_error) + def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["raw_data"]["id"] != base_name yield("ID in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['raw_data']['id']}')") diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb index 93d54e3bee..f487218f31 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -189,7 +189,7 @@ class Chef # Verify that the JSON hash for this type has a key that matches its name. # Calls the on_error block with the error, if there is one. # - def verify_integrity(object, entry, &on_error) + def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["name"] != base_name yield("Name must be '#{base_name}' (is '#{object['name']}')") diff --git a/lib/chef/chef_fs/data_handler/organization_data_handler.rb b/lib/chef/chef_fs/data_handler/organization_data_handler.rb index d61e4f454a..4afde75d40 100644 --- a/lib/chef/chef_fs/data_handler/organization_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/organization_data_handler.rb @@ -19,7 +19,7 @@ class Chef return key == "name" end - def verify_integrity(object, entry, &on_error) + def verify_integrity(object, entry) if entry.org != object["name"] yield("Name must be '#{entry.org}' (is '#{object['name']}')") end diff --git a/lib/chef/chef_fs/data_handler/policy_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_data_handler.rb index 47f534bfc9..f88b41401f 100644 --- a/lib/chef/chef_fs/data_handler/policy_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_data_handler.rb @@ -26,7 +26,7 @@ class Chef normalize_hash(policy, defaults) end - def verify_integrity(object_data, entry, &on_error) + def verify_integrity(object_data, entry) name, revision = name_and_revision(entry.name) if object_data["name"] != name yield("Object name '#{object_data['name']}' doesn't match entry '#{entry.name}'.") diff --git a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb index d3bdd81e25..e20676a791 100644 --- a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb @@ -15,7 +15,7 @@ class Chef result end - def verify_integrity(object_data, entry, &on_error) + def verify_integrity(object_data, entry) if object_data["policies"].empty? yield("Policy group #{object_data["name"]} does not have any policies in it.") end diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index d9078ac48c..6c26ae265a 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -485,7 +485,7 @@ class Chef # @deprecated This method was used by the Ruby Chef Server and is no longer # needed. There is no replacement. - def generate_manifest_with_urls(&url_generator) + def generate_manifest_with_urls Chef.log_deprecation("Deprecated method #generate_manifest_with_urls.") rendered_manifest = manifest.dup diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb index c21961479c..6df60aec89 100644 --- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb +++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb @@ -22,7 +22,7 @@ class Chef class GuardInterpreter class ResourceGuardInterpreter < DefaultGuardInterpreter - def initialize(parent_resource, command, opts, &block) + def initialize(parent_resource, command, opts) super(command, opts) @parent_resource = parent_resource @resource = get_interpreter_resource(parent_resource) diff --git a/lib/chef/http.rb b/lib/chef/http.rb index a3673ce281..17024c4bdc 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -159,7 +159,7 @@ class Chef # # If no block is given, the tempfile is returned, which means it's up to # you to unlink the tempfile when you're done with it. - def streaming_request(path, headers = {}, &block) + def streaming_request(path, headers = {}) url = create_url(path) response, rest_request, return_value = nil, nil, nil tempfile = nil diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index e25242c033..482d4ce292 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -148,7 +148,7 @@ class Chef @url.port end - def request(method, url, body, headers, &handler_block) + def request(method, url, body, headers) request = req_to_rack(method, url, body, headers) res = ChefZero::SocketlessServerMap.request(port, request) diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 71127b5b57..1c2c88e540 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -510,7 +510,7 @@ class Chef response.body end - def create_object(object, pretty_name = nil, object_class: nil, &block) + def create_object(object, pretty_name = nil, object_class: nil) output = edit_data(object, object_class: object_class) if Kernel.block_given? @@ -526,7 +526,7 @@ class Chef output(output) if config[:print_after] end - def delete_object(klass, name, delete_name = nil, &block) + def delete_object(klass, name, delete_name = nil) confirm("Do you really want to delete #{name}") if Kernel.block_given? diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb index 435daeda77..387292c8f8 100644 --- a/lib/chef/mixin/command.rb +++ b/lib/chef/mixin/command.rb @@ -177,7 +177,7 @@ class Chef # module_function :popen4 - def chdir_or_tmpdir(dir, &block) + def chdir_or_tmpdir(dir) dir ||= Dir.tmpdir unless File.directory?(dir) raise Chef::Exceptions::Exec, "#{dir} does not exist or is not a directory" diff --git a/lib/chef/mixin/provides.rb b/lib/chef/mixin/provides.rb index 34a078c010..a9dc8bc8f0 100644 --- a/lib/chef/mixin/provides.rb +++ b/lib/chef/mixin/provides.rb @@ -7,7 +7,7 @@ class Chef # TODO no longer needed, remove or deprecate? include Chef::Mixin::DescendantsTracker - def provides(short_name, opts = {}, &block) + def provides(short_name, opts = {}) raise NotImplementedError, :provides end diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb index 20bfc7b5f0..fe96e1a69c 100644 --- a/lib/chef/resource_collection/resource_list.rb +++ b/lib/chef/resource_collection/resource_list.rb @@ -76,7 +76,7 @@ class Chef @resources end - def execute_each_resource(&resource_exec_block) + def execute_each_resource @iterator = ResourceCollection::StepableIterator.for_collection(@resources) @iterator.each_with_index do |resource, idx| @insert_after_idx = idx diff --git a/lib/chef/run_list.rb b/lib/chef/run_list.rb index 9647ef16e6..86c28e6824 100644 --- a/lib/chef/run_list.rb +++ b/lib/chef/run_list.rb @@ -105,11 +105,11 @@ class Chef @run_list_items[pos] = parse_entry(item) end - def each(&block) + def each @run_list_items.each { |i| yield(i) } end - def each_index(&block) + def each_index @run_list_items.each_index { |i| yield(i) } end diff --git a/lib/chef/shell/model_wrapper.rb b/lib/chef/shell/model_wrapper.rb index 403f9479cf..5f2d89d641 100644 --- a/lib/chef/shell/model_wrapper.rb +++ b/lib/chef/shell/model_wrapper.rb @@ -59,7 +59,7 @@ module Shell alias :load :show - def transform(what_to_transform, &block) + def transform(what_to_transform) if what_to_transform == :all objects_to_transform = list_objects else diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index 9bb615aee7..1366700304 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -119,7 +119,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows NetUser.net_local_group_add_member(nil, "Users", args[:name]) end - def user_modify(&proc) + def user_modify user = get_info user[:last_logon] = user[:units_per_week] = 0 #ignored as per USER_INFO_3 doc user[:logon_hours] = nil #PBYTE field; \0 == no changes diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb index 09501e66ce..aeb424bab0 100644 --- a/lib/chef/win32/api/file.rb +++ b/lib/chef/win32/api/file.rb @@ -535,7 +535,7 @@ BOOL WINAPI VerQueryValue( # retrieves a file search handle and passes it # to +&block+ along with the find_data. also # ensures the handle is closed on exit of the block - def file_search_handle(path, &block) + def file_search_handle(path) begin # Workaround for CHEF-4419: # Make sure paths starting with "/" has a drive letter @@ -559,7 +559,7 @@ BOOL WINAPI VerQueryValue( # retrieves a file handle and passes it # to +&block+ along with the find_data. also # ensures the handle is closed on exit of the block - def file_handle(path, &block) + def file_handle(path) begin path = canonical_encode_path(path) handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, @@ -574,7 +574,7 @@ BOOL WINAPI VerQueryValue( end end - def symlink_file_handle(path, &block) + def symlink_file_handle(path) begin path = encode_path(path) handle = CreateFileW(path, FILE_READ_EA, FILE_SHARE_READ, diff --git a/spec/functional/win32/versions_spec.rb b/spec/functional/win32/versions_spec.rb index 53fce39491..d6e840ed7f 100644 --- a/spec/functional/win32/versions_spec.rb +++ b/spec/functional/win32/versions_spec.rb @@ -50,7 +50,7 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on @version = Chef::ReservedNames::Win32::Version.new end - def for_each_windows_version(&block) + def for_each_windows_version @version.methods.each do |method_name| if Chef::ReservedNames::Win32::Version::WIN_VERSIONS.keys.find { |key| method_name.to_s == Chef::ReservedNames::Win32::Version.send(:method_name_from_marketing_name, key) } yield method_name diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb index f50a1bf5f7..5f22c1c151 100644 --- a/spec/support/matchers/leak.rb +++ b/spec/support/matchers/leak.rb @@ -20,7 +20,7 @@ module Matchers module LeakBase include RSpec::Matchers - def initialize(opts = {}, &block) + def initialize(opts = {}) @warmup = opts[:warmup] || 5 @iterations = opts[:iterations] || 100 @variance = opts[:variance] || 5000 diff --git a/spec/support/mock/constant.rb b/spec/support/mock/constant.rb index 942905144f..3a23b4d8d8 100644 --- a/spec/support/mock/constant.rb +++ b/spec/support/mock/constant.rb @@ -4,7 +4,7 @@ # http://missingbit.blogspot.com/2011/07/stubbing-constants-in-rspec_20.html # http://digitaldumptruck.jotabout.com/?p=551 -def mock_constants(constants, &block) +def mock_constants(constants) saved_constants = {} constants.each do |constant, val| source_object, const_name = parse_constant(constant) diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb index ef94678b64..c6670827f9 100644 --- a/spec/support/mock/platform.rb +++ b/spec/support/mock/platform.rb @@ -5,7 +5,7 @@ # 'i386-mingw32' (windows) or 'x86_64-darwin11.2.0' (unix). Usueful for # testing code that mixes in platform specific modules like +Chef::Mixin::Securable+ # or +Chef::FileAccessControl+ -def platform_mock(platform = :unix, &block) +def platform_mock(platform = :unix) allow(ChefConfig).to receive(:windows?).and_return(platform == :windows ? true : false) ENV["SYSTEMDRIVE"] = (platform == :windows ? "C:" : nil) diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb index fe9c6f78a7..1e81cd115c 100644 --- a/spec/support/shared/integration/knife_support.rb +++ b/spec/support/shared/integration/knife_support.rb @@ -23,7 +23,7 @@ require "chef/log" module KnifeSupport DEBUG = ENV["DEBUG"] - def knife(*args, &block) + def knife(*args) # Allow knife('role from file roles/blah.json') rather than requiring the # arguments to be split like knife('role', 'from', 'file', 'roles/blah.json') # If any argument will have actual spaces in it, the long form is required. diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index 96b713b547..9de8077677 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -463,7 +463,7 @@ describe Chef::ChefFS::Parallelizer do attr_reader :num_processed - def each(&each_block) + def each @values.each do |value| @num_processed += 1 yield(value) diff --git a/spec/unit/dsl/resources_spec.rb b/spec/unit/dsl/resources_spec.rb index 53cd6fcdb1..dc05f8bcf4 100644 --- a/spec/unit/dsl/resources_spec.rb +++ b/spec/unit/dsl/resources_spec.rb @@ -25,7 +25,7 @@ describe Chef::DSL::Resources do r = declared_resources Class.new do include Chef::DSL::Resources - define_method(:declare_resource) do |dsl_name, name, _created_at, &_block| + define_method(:declare_resource) do |dsl_name, name, _created_at| r << [dsl_name, name] end end -- cgit v1.2.1 From 4fd88f1f3c7d847712e61abab2bac6cb4a987265 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Fri, 4 Mar 2016 11:11:40 -0800 Subject: add some @yield docs added some FIXMEs because trying to sort out types for random undocumented code was making me completely aggro --- lib/chef/chef_fs/data_handler/container_data_handler.rb | 8 +++++++- lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb | 6 ++++++ lib/chef/chef_fs/data_handler/data_handler_base.rb | 6 ++++-- lib/chef/chef_fs/data_handler/organization_data_handler.rb | 6 ++++++ lib/chef/chef_fs/data_handler/policy_data_handler.rb | 10 ++++++++-- lib/chef/chef_fs/data_handler/policy_group_data_handler.rb | 6 ++++++ lib/chef/http.rb | 3 +++ lib/chef/http/socketless_chef_zero_client.rb | 1 + lib/chef/knife.rb | 2 ++ lib/chef/mixin/command.rb | 1 + lib/chef/mixin/provides.rb | 1 + lib/chef/resource_collection/resource_list.rb | 1 + lib/chef/run_list.rb | 2 ++ lib/chef/shell/model_wrapper.rb | 1 + lib/chef/util/windows/net_user.rb | 1 + lib/chef/win32/api/file.rb | 3 +++ 16 files changed, 53 insertions(+), 5 deletions(-) diff --git a/lib/chef/chef_fs/data_handler/container_data_handler.rb b/lib/chef/chef_fs/data_handler/container_data_handler.rb index 27bb9dc736..04973b5135 100644 --- a/lib/chef/chef_fs/data_handler/container_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/container_data_handler.rb @@ -15,10 +15,16 @@ class Chef return key == "containername" end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s] error message def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["containername"] != base_name - yield("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['name']}')") + yield("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['containername']}')") end end diff --git a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb index 89087e159f..c6b6449d52 100644 --- a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb @@ -42,6 +42,12 @@ class Chef Chef::DataBagItem end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s] error message def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["raw_data"]["id"] != base_name diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb index f487218f31..b30ae9c708 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -185,10 +185,12 @@ class Chef result end - # # Verify that the JSON hash for this type has a key that matches its name. - # Calls the on_error block with the error, if there is one. # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s] error message def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["name"] != base_name diff --git a/lib/chef/chef_fs/data_handler/organization_data_handler.rb b/lib/chef/chef_fs/data_handler/organization_data_handler.rb index 4afde75d40..0facd5d55d 100644 --- a/lib/chef/chef_fs/data_handler/organization_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/organization_data_handler.rb @@ -19,6 +19,12 @@ class Chef return key == "name" end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s] error message def verify_integrity(object, entry) if entry.org != object["name"] yield("Name must be '#{entry.org}' (is '#{object['name']}')") diff --git a/lib/chef/chef_fs/data_handler/policy_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_data_handler.rb index f88b41401f..fa7bbe9101 100644 --- a/lib/chef/chef_fs/data_handler/policy_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_data_handler.rb @@ -26,14 +26,20 @@ class Chef normalize_hash(policy, defaults) end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s] error message def verify_integrity(object_data, entry) name, revision = name_and_revision(entry.name) if object_data["name"] != name - yield("Object name '#{object_data['name']}' doesn't match entry '#{entry.name}'.") + yield("Object name '#{object_data['name']}' doesn't match entry '#{name}'.") end if object_data["revision_id"] != revision - yield("Object revision ID '#{object_data['revision']}' doesn't match entry '#{entry.name}'.") + yield("Object revision ID '#{object_data['revision_id']}' doesn't match entry '#{revision}'.") end end end diff --git a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb index e20676a791..f7aa92373c 100644 --- a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb @@ -15,6 +15,12 @@ class Chef result end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s] error message def verify_integrity(object_data, entry) if object_data["policies"].empty? yield("Policy group #{object_data["name"]} does not have any policies in it.") diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 17024c4bdc..dd02550294 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -159,6 +159,9 @@ class Chef # # If no block is given, the tempfile is returned, which means it's up to # you to unlink the tempfile when you're done with it. + # + # @yield [tempfile] block to process the tempfile + # @yieldparams [tempfile] tempfile def streaming_request(path, headers = {}) url = create_url(path) response, rest_request, return_value = nil, nil, nil diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index 482d4ce292..8c1578b976 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -148,6 +148,7 @@ class Chef @url.port end + # FIXME: yard with @yield def request(method, url, body, headers) request = req_to_rack(method, url, body, headers) res = ChefZero::SocketlessServerMap.request(port, request) diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 1c2c88e540..30825750a8 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -510,6 +510,7 @@ class Chef response.body end + # FIXME: yard with @yield def create_object(object, pretty_name = nil, object_class: nil) output = edit_data(object, object_class: object_class) @@ -526,6 +527,7 @@ class Chef output(output) if config[:print_after] end + # FIXME: yard with @yield def delete_object(klass, name, delete_name = nil) confirm("Do you really want to delete #{name}") diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb index 387292c8f8..0cc3143ec7 100644 --- a/lib/chef/mixin/command.rb +++ b/lib/chef/mixin/command.rb @@ -177,6 +177,7 @@ class Chef # module_function :popen4 + # FIXME: yard with @yield def chdir_or_tmpdir(dir) dir ||= Dir.tmpdir unless File.directory?(dir) diff --git a/lib/chef/mixin/provides.rb b/lib/chef/mixin/provides.rb index a9dc8bc8f0..43a726de8c 100644 --- a/lib/chef/mixin/provides.rb +++ b/lib/chef/mixin/provides.rb @@ -13,6 +13,7 @@ class Chef # Check whether this resource provides the resource_name DSL for the given # node. TODO remove this when we stop checking unregistered things. + # FIXME: yard with @yield def provides?(node, resource) raise NotImplementedError, :provides? end diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb index fe96e1a69c..37eb12a107 100644 --- a/lib/chef/resource_collection/resource_list.rb +++ b/lib/chef/resource_collection/resource_list.rb @@ -76,6 +76,7 @@ class Chef @resources end + # FIXME: yard with @yield def execute_each_resource @iterator = ResourceCollection::StepableIterator.for_collection(@resources) @iterator.each_with_index do |resource, idx| diff --git a/lib/chef/run_list.rb b/lib/chef/run_list.rb index 86c28e6824..4dea938423 100644 --- a/lib/chef/run_list.rb +++ b/lib/chef/run_list.rb @@ -105,10 +105,12 @@ class Chef @run_list_items[pos] = parse_entry(item) end + # FIXME: yard with @yield def each @run_list_items.each { |i| yield(i) } end + # FIXME: yard with @yield def each_index @run_list_items.each_index { |i| yield(i) } end diff --git a/lib/chef/shell/model_wrapper.rb b/lib/chef/shell/model_wrapper.rb index 5f2d89d641..8c3e456a9b 100644 --- a/lib/chef/shell/model_wrapper.rb +++ b/lib/chef/shell/model_wrapper.rb @@ -59,6 +59,7 @@ module Shell alias :load :show + # FIXME: yard with @yield def transform(what_to_transform) if what_to_transform == :all objects_to_transform = list_objects diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index 1366700304..009252c4c1 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -119,6 +119,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows NetUser.net_local_group_add_member(nil, "Users", args[:name]) end + # FIXME: yard with @yield def user_modify user = get_info user[:last_logon] = user[:units_per_week] = 0 #ignored as per USER_INFO_3 doc diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb index aeb424bab0..7489c94fd9 100644 --- a/lib/chef/win32/api/file.rb +++ b/lib/chef/win32/api/file.rb @@ -535,6 +535,7 @@ BOOL WINAPI VerQueryValue( # retrieves a file search handle and passes it # to +&block+ along with the find_data. also # ensures the handle is closed on exit of the block + # FIXME: yard with @yield def file_search_handle(path) begin # Workaround for CHEF-4419: @@ -559,6 +560,7 @@ BOOL WINAPI VerQueryValue( # retrieves a file handle and passes it # to +&block+ along with the find_data. also # ensures the handle is closed on exit of the block + # FIXME: yard with @yield def file_handle(path) begin path = canonical_encode_path(path) @@ -574,6 +576,7 @@ BOOL WINAPI VerQueryValue( end end + # FIXME: yard with @yield def symlink_file_handle(path) begin path = encode_path(path) -- cgit v1.2.1