diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
commit | 686113531d23f30e9973d659c456ae33eb9cff1f (patch) | |
tree | f225de7251a8b49b8d183dd168bab0a0addbe23f /lib/chef/dsl | |
parent | d1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff) | |
download | chef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz |
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces
1860 Style/SpaceAroundOperators
1336 Style/SpaceInsideBlockBraces
1292 Style/AlignHash
997 Style/SpaceAfterComma
860 Style/SpaceAroundEqualsInParameterDefault
310 Style/EmptyLines
294 Style/IndentationConsistency
267 Style/TrailingWhitespace
238 Style/ExtraSpacing
212 Style/SpaceBeforeBlockBraces
166 Style/MultilineOperationIndentation
144 Style/TrailingBlankLines
120 Style/EmptyLineBetweenDefs
101 Style/IndentationWidth
82 Style/SpaceAroundBlockParameters
40 Style/EmptyLinesAroundMethodBody
29 Style/EmptyLinesAroundAccessModifier
1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib/chef/dsl')
-rw-r--r-- | lib/chef/dsl/chef_provisioning.rb | 2 | ||||
-rw-r--r-- | lib/chef/dsl/cheffish.rb | 2 | ||||
-rw-r--r-- | lib/chef/dsl/data_query.rb | 4 | ||||
-rw-r--r-- | lib/chef/dsl/declare_resource.rb | 6 | ||||
-rw-r--r-- | lib/chef/dsl/definitions.rb | 3 | ||||
-rw-r--r-- | lib/chef/dsl/include_attribute.rb | 2 | ||||
-rw-r--r-- | lib/chef/dsl/platform_introspection.rb | 12 | ||||
-rw-r--r-- | lib/chef/dsl/powershell.rb | 2 | ||||
-rw-r--r-- | lib/chef/dsl/reboot_pending.rb | 13 | ||||
-rw-r--r-- | lib/chef/dsl/registry_helper.rb | 6 | ||||
-rw-r--r-- | lib/chef/dsl/resources.rb | 5 |
11 files changed, 26 insertions, 31 deletions
diff --git a/lib/chef/dsl/chef_provisioning.rb b/lib/chef/dsl/chef_provisioning.rb index d2b6aabb17..a91d297d02 100644 --- a/lib/chef/dsl/chef_provisioning.rb +++ b/lib/chef/dsl/chef_provisioning.rb @@ -37,7 +37,7 @@ class Chef with_image_options with_machine_options }.each do |method_name| - eval(<<-EOM, binding, __FILE__, __LINE__+1) + eval(<<-EOM, binding, __FILE__, __LINE__ + 1) def #{method_name}(*args, &block) Chef::DSL::ChefProvisioning.load_chef_provisioning self.#{method_name}(*args, &block) diff --git a/lib/chef/dsl/cheffish.rb b/lib/chef/dsl/cheffish.rb index 3314ffd4d5..de052bbe5c 100644 --- a/lib/chef/dsl/cheffish.rb +++ b/lib/chef/dsl/cheffish.rb @@ -44,7 +44,7 @@ class Chef with_chef_local_server get_private_key }.each do |method_name| - eval(<<-EOM, binding, __FILE__, __LINE__+1) + eval(<<-EOM, binding, __FILE__, __LINE__ + 1) def #{method_name}(*args, &block) Chef::DSL::Cheffish.load_cheffish self.#{method_name}(*args, &block) diff --git a/lib/chef/dsl/data_query.rb b/lib/chef/dsl/data_query.rb index 865d914d13..b966885724 100644 --- a/lib/chef/dsl/data_query.rb +++ b/lib/chef/dsl/data_query.rb @@ -55,7 +55,7 @@ class Chef raise end - def data_bag_item(bag, item, secret=nil) + def data_bag_item(bag, item, secret = nil) DataBag.validate_name!(bag.to_s) DataBagItem.validate_id!(item) @@ -73,7 +73,7 @@ class Chef raise end end - + item rescue Exception Log.error("Failed to load data bag item: #{bag.inspect} #{item.inspect}") diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb index 91fe62c263..2e7dc934dc 100644 --- a/lib/chef/dsl/declare_resource.rb +++ b/lib/chef/dsl/declare_resource.rb @@ -48,7 +48,7 @@ class Chef # action :delete # end # - def declare_resource(type, name, created_at=nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block) + def declare_resource(type, name, created_at = nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block) created_at ||= caller[0] if create_if_missing @@ -86,7 +86,7 @@ class Chef # action :delete # end # - def build_resource(type, name, created_at=nil, run_context: self.run_context, &resource_attrs_block) + def build_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block) created_at ||= caller[0] Thread.exclusive do require "chef/resource_builder" unless defined?(Chef::ResourceBuilder) @@ -100,7 +100,7 @@ class Chef run_context: run_context, cookbook_name: cookbook_name, recipe_name: recipe_name, - enclosing_provider: self.is_a?(Chef::Provider) ? self : nil, + enclosing_provider: self.is_a?(Chef::Provider) ? self : nil, ).build(&resource_attrs_block) end end diff --git a/lib/chef/dsl/definitions.rb b/lib/chef/dsl/definitions.rb index 1358f67720..60b1cf6f61 100644 --- a/lib/chef/dsl/definitions.rb +++ b/lib/chef/dsl/definitions.rb @@ -9,7 +9,7 @@ class Chef # module Definitions def self.add_definition(dsl_name) - module_eval <<-EOM, __FILE__, __LINE__+1 + module_eval <<-EOM, __FILE__, __LINE__ + 1 def #{dsl_name}(*args, &block) evaluate_resource_definition(#{dsl_name.inspect}, *args, &block) end @@ -25,7 +25,6 @@ class Chef # # @api private def evaluate_resource_definition(definition_name, *args, &block) - # This dupes the high level object, but we still need to dup the params new_def = run_context.definitions[definition_name].dup diff --git a/lib/chef/dsl/include_attribute.rb b/lib/chef/dsl/include_attribute.rb index b1b9dc4dac..6d27fefc25 100644 --- a/lib/chef/dsl/include_attribute.rb +++ b/lib/chef/dsl/include_attribute.rb @@ -59,5 +59,3 @@ end # **DEPRECATED** # This used to be part of chef/mixin/language_include_attribute. Load the file to activate the deprecation code. require "chef/mixin/language_include_attribute" - - diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb index a3a978d418..276a03af63 100644 --- a/lib/chef/dsl/platform_introspection.rb +++ b/lib/chef/dsl/platform_introspection.rb @@ -45,7 +45,7 @@ class Chef # :default => default_value def initialize(platform_hash) @values = {} - platform_hash.each { |platforms, value| set(platforms, value)} + platform_hash.each { |platforms, value| set(platforms, value) } end def value_for_node(node) @@ -110,7 +110,7 @@ class Chef @values["default"] = value else assert_valid_platform_values!(platforms, value) - Array(platforms).each { |platform| @values[platform.to_s] = normalize_keys(value)} + Array(platforms).each { |platform| @values[platform.to_s] = normalize_keys(value) } value end end @@ -134,8 +134,6 @@ class Chef end end - - # Given a hash similar to the one we use for Platforms, select a value from the hash. Supports # per platform defaults, along with a single base default. Arrays may be passed as hash keys and # will be expanded. @@ -168,8 +166,6 @@ class Chef has_platform end - - # Implementation class for determining platform family dependent values class PlatformFamilyDependentValue @@ -193,7 +189,7 @@ class Chef def initialize(platform_family_hash) @values = {} @values["default"] = nil - platform_family_hash.each { |platform_families, value| set(platform_families, value)} + platform_family_hash.each { |platform_families, value| set(platform_families, value) } end def value_for_node(node) @@ -221,7 +217,6 @@ class Chef end end - # Given a hash mapping platform families to values, select a value from the hash. Supports a single # base default if platform family is not in the map. Arrays may be passed as hash keys and will be # expanded @@ -257,4 +252,3 @@ end # **DEPRECATED** # This used to be part of chef/mixin/language. Load the file to activate the deprecation code. require "chef/mixin/language" - diff --git a/lib/chef/dsl/powershell.rb b/lib/chef/dsl/powershell.rb index ff5fee93a5..1a900af6f6 100644 --- a/lib/chef/dsl/powershell.rb +++ b/lib/chef/dsl/powershell.rb @@ -21,7 +21,7 @@ require "chef/util/powershell/ps_credential" class Chef module DSL module Powershell - def ps_credential(username="placeholder", password) + def ps_credential(username = "placeholder", password) Chef::Util::Powershell::PSCredential.new(username, password) end end diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb index c3cf9a9a51..e8982d290e 100644 --- a/lib/chef/dsl/reboot_pending.rb +++ b/lib/chef/dsl/reboot_pending.rb @@ -29,7 +29,6 @@ class Chef # Returns true if the system needs a reboot or is expected to reboot # Note that we will silently miss any other platform-specific reboot notices besides Windows+Ubuntu. def reboot_pending? - # don't break when used as a mixin in contexts without #node (e.g. specs). if self.respond_to?(:node, true) && node.run_context.reboot_requested? true @@ -42,17 +41,17 @@ class Chef # RebootRequired key contains Update IDs with a value of 1 if they require a reboot. # The existence of RebootRequired alone is sufficient on my Windows 8.1 workstation in Windows Update - registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') || + registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') || # Vista + Server 2008 and newer may have reboots pending from CBS - registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') || + registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') || # The mere existence of the UpdateExeVolatile key should indicate a pending restart for certain updates # http://support.microsoft.com/kb/832475 - Chef::Platform.windows_server_2003? && - (registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') && - !registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0].nil? && - [1,2,3].include?(registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0][:data])) + Chef::Platform.windows_server_2003? && + (registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') && + !registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0].nil? && + [1, 2, 3].include?(registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0][:data])) elsif platform?("ubuntu") # This should work for Debian as well if update-notifier-common happens to be installed. We need an API for that. File.exists?("/var/run/reboot-required") diff --git a/lib/chef/dsl/registry_helper.rb b/lib/chef/dsl/registry_helper.rb index 256b4eca1e..63da635ef1 100644 --- a/lib/chef/dsl/registry_helper.rb +++ b/lib/chef/dsl/registry_helper.rb @@ -33,22 +33,27 @@ class Chef registry = Chef::Win32::Registry.new(run_context, architecture) registry.key_exists?(key_path) end + def registry_get_values(key_path, architecture = :machine) registry = Chef::Win32::Registry.new(run_context, architecture) registry.get_values(key_path) end + def registry_has_subkeys?(key_path, architecture = :machine) registry = Chef::Win32::Registry.new(run_context, architecture) registry.has_subkeys?(key_path) end + def registry_get_subkeys(key_path, architecture = :machine) registry = Chef::Win32::Registry.new(run_context, architecture) registry.get_subkeys(key_path) end + def registry_value_exists?(key_path, value, architecture = :machine) registry = Chef::Win32::Registry.new(run_context, architecture) registry.value_exists?(key_path, value) end + def registry_data_exists?(key_path, value, architecture = :machine) registry = Chef::Win32::Registry.new(run_context, architecture) registry.data_exists?(key_path, value) @@ -56,4 +61,3 @@ class Chef end end end - diff --git a/lib/chef/dsl/resources.rb b/lib/chef/dsl/resources.rb index aba602da7e..7bbfeb2914 100644 --- a/lib/chef/dsl/resources.rb +++ b/lib/chef/dsl/resources.rb @@ -34,7 +34,7 @@ class Chef def self.add_resource_dsl(dsl_name) begin - module_eval(<<-EOM, __FILE__, __LINE__+1) + module_eval(<<-EOM, __FILE__, __LINE__ + 1) def #{dsl_name}(*args, &block) Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1 declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block) @@ -48,8 +48,9 @@ class Chef end end end + def self.remove_resource_dsl(dsl_name) - remove_method(dsl_name) + remove_method(dsl_name) rescue NameError end end |