From d06220ce1979fb381b240b3a42bc5d2db407f270 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 10:01:45 -0800 Subject: [PATCH 01/17] Layout/ClosingParenthesisIndentation This commit enables the Rubocop Layout/ClosingParenthesisIndentation cop. --- .rubocop_todo.yml | 4 ---- lib/puppet/application.rb | 2 +- lib/puppet/defaults.rb | 8 ++++---- lib/puppet/ffi/windows/constants.rb | 2 +- lib/puppet/functions/dig.rb | 4 ++-- lib/puppet/module_tool/applications/installer.rb | 2 +- lib/puppet/pal/pal_impl.rb | 6 +++--- lib/puppet/parser/ast/resource.rb | 2 +- lib/puppet/parser/functions/create_resources.rb | 2 +- lib/puppet/parser/functions/fail.rb | 2 +- lib/puppet/parser/functions/hiera_array.rb | 2 +- lib/puppet/pops/loader/module_loaders.rb | 8 ++++---- lib/puppet/pops/lookup.rb | 2 +- lib/puppet/pops/parser/lexer_support.rb | 2 +- lib/puppet/pops/types/tree_iterators.rb | 2 +- lib/puppet/pops/types/type_calculator.rb | 2 +- lib/puppet/type/file/content.rb | 2 +- lib/puppet/util/windows/process.rb | 2 +- 18 files changed, 26 insertions(+), 30 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 873128789ad..9f09c4e3b61 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,10 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent: I18n/RailsI18n/DecorateString: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/ClosingParenthesisIndentation: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowForAlignment. Layout/CommentIndentation: diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 9b165dc4792..4e301d7ebbe 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -364,7 +364,7 @@ def initialize(command_line = Puppet::Util::CommandLine.new) def app_defaults Puppet::Settings.app_defaults_for_run_mode(self.class.run_mode).merge( :name => name - ) + ) end # Initialize application defaults. It's usually not necessary to override this method. diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index cd275d430db..e0049f6d636 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -117,7 +117,7 @@ def self.initialize_default_settings!(settings) :desc => "The name of the application, if we are running as one. The default is essentially $0 without the path or `.rb`.", } - ) + ) settings.define_settings(:main, :logdir => { @@ -1298,7 +1298,7 @@ def self.initialize_default_settings!(settings) :default => nil, :desc => "The address the agent should use to initiate requests.", }, - ) + ) settings.define_settings(:environment, :manifest => { @@ -2135,7 +2135,7 @@ def self.initialize_default_settings!(settings) For more info, see [the ENC documentation](https://puppet.com/docs/puppet/latest/nodes_external.html).", } - ) + ) settings.define_settings( :ldap, @@ -2205,7 +2205,7 @@ def self.initialize_default_settings!(settings) have one already set. Generally, it should be the 'ou=Hosts' branch under your main directory.", } - ) + ) settings.define_settings(:server, :storeconfigs => { diff --git a/lib/puppet/ffi/windows/constants.rb b/lib/puppet/ffi/windows/constants.rb index b054e6ea607..6d12503691a 100644 --- a/lib/puppet/ffi/windows/constants.rb +++ b/lib/puppet/ffi/windows/constants.rb @@ -203,7 +203,7 @@ module Constants :TokenSecurityAttributes, :TokenIsRestricted, :MaxTokenInfoClass - ) + ) # Service error codes # https://docs.microsoft.com/en-us/windows/desktop/debug/system-error-codes--1000-1299- diff --git a/lib/puppet/functions/dig.rb b/lib/puppet/functions/dig.rb index a95ddfb1f58..aa1dacc03d7 100644 --- a/lib/puppet/functions/dig.rb +++ b/lib/puppet/functions/dig.rb @@ -46,7 +46,7 @@ def dig(data, *args) 'SLICE_ERROR', {'walked_path' => walked_path, 'value_type' => t}, 'EXPECTED_COLLECTION' - ) + ) raise Puppet::ErrorWithData.new(error_data, msg) end @@ -59,7 +59,7 @@ def dig(data, *args) 'SLICE_ERROR', {'walked_path' => walked_path, 'index_type' => t}, 'EXPECTED_INTEGER_INDEX' - ) + ) raise Puppet::ErrorWithData.new(error_data, msg) end d[k] diff --git a/lib/puppet/module_tool/applications/installer.rb b/lib/puppet/module_tool/applications/installer.rb index f307b39fade..fc064cb9f8e 100644 --- a/lib/puppet/module_tool/applications/installer.rb +++ b/lib/puppet/module_tool/applications/installer.rb @@ -187,7 +187,7 @@ def run :requested_name => name, :requested_version => options[:version] || graph.dependencies[name].max.version.to_s, :unsatisfied => unsatisfied - ) + ) end unless forced? diff --git a/lib/puppet/pal/pal_impl.rb b/lib/puppet/pal/pal_impl.rb index 74547bc473d..79fcca6a9bc 100644 --- a/lib/puppet/pal/pal_impl.rb +++ b/lib/puppet/pal/pal_impl.rb @@ -235,7 +235,7 @@ def self.in_tmp_environment(env_name, facts: nil, variables: {}, &block - ) + ) assert_non_empty_string(env_name, _("temporary environment name")) # TRANSLATORS: do not translate variable name string in these assertions assert_optionally_empty_array(modulepath, 'modulepath') @@ -249,7 +249,7 @@ def self.in_tmp_environment(env_name, in_environment_context( Puppet::Environments::Static.new(env), # The tmp env is the only known env env, facts, variables, &block - ) + ) end # Defines the context in which to perform puppet operations (evaluation, etc) @@ -287,7 +287,7 @@ def self.in_environment(env_name, facts: nil, variables: {}, &block - ) + ) # TRANSLATORS terms in the assertions below are names of terms in code assert_non_empty_string(env_name, 'env_name') assert_optionally_empty_array(modulepath, 'modulepath', true) diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index 0db8a8abe65..c2baa42e591 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -52,7 +52,7 @@ def evaluate(scope) :source => scope.source, :scope => scope, :strict => true - ) + ) # rubocop:disable Layout/ClosingParenthesisIndentation if resource.resource_type.is_a? Puppet::Resource::Type resource.resource_type.instantiate_resource(scope, resource) diff --git a/lib/puppet/parser/functions/create_resources.rb b/lib/puppet/parser/functions/create_resources.rb index 08d14c4668d..60dedcf03a3 100644 --- a/lib/puppet/parser/functions/create_resources.rb +++ b/lib/puppet/parser/functions/create_resources.rb @@ -106,6 +106,6 @@ :add => false ) end.compact - ) + ) end.flatten.compact end diff --git a/lib/puppet/parser/functions/fail.rb b/lib/puppet/parser/functions/fail.rb index cd1657e622e..0ff4444fa05 100644 --- a/lib/puppet/parser/functions/fail.rb +++ b/lib/puppet/parser/functions/fail.rb @@ -6,7 +6,7 @@ Fail with a parse error. Any parameters will be stringified, concatenated, and passed to the exception-handler. DOC -) do |vals| + ) do |vals| vals = vals.collect { |s| s.to_s }.join(" ") if vals.is_a? Array raise Puppet::ParseError, vals.to_s end diff --git a/lib/puppet/parser/functions/hiera_array.rb b/lib/puppet/parser/functions/hiera_array.rb index 707cb573f36..da3127d6cec 100644 --- a/lib/puppet/parser/functions/hiera_array.rb +++ b/lib/puppet/parser/functions/hiera_array.rb @@ -86,7 +86,7 @@ module Puppet::Parser::Functions - Since 4.0.0 DOC -) do |*_args| + ) do |*_args| Error.is4x('hiera_array') end end diff --git a/lib/puppet/pops/loader/module_loaders.rb b/lib/puppet/pops/loader/module_loaders.rb index 15fc2921b5f..bfca2694e06 100644 --- a/lib/puppet/pops/loader/module_loaders.rb +++ b/lib/puppet/pops/loader/module_loaders.rb @@ -35,7 +35,7 @@ def self.cached_loader_from(parent_loader, loaders) Puppet[:libdir], 'cached_puppet_lib', [:func_4x, :func_3x, :datatype] - ) + ) end def self.system_loader_from(parent_loader, loaders) @@ -63,7 +63,7 @@ def self.environment_loader_from(parent_loader, loaders, env_path) ENVIRONMENT, env_path, ENVIRONMENT - ) + ) end end @@ -73,7 +73,7 @@ def self.module_loader_from(parent_loader, loaders, module_name, module_path) module_name, module_path, module_name - ) + ) end def self.pcore_resource_type_loader_from(parent_loader, loaders, environment_path) @@ -82,7 +82,7 @@ def self.pcore_resource_type_loader_from(parent_loader, loaders, environment_pat nil, environment_path, 'pcore_resource_types' - ) + ) end class EmptyLoader < BaseLoader diff --git a/lib/puppet/pops/lookup.rb b/lib/puppet/pops/lookup.rb index e9149c7994a..06e23585ad2 100644 --- a/lib/puppet/pops/lookup.rb +++ b/lib/puppet/pops/lookup.rb @@ -92,7 +92,7 @@ def self.fail_lookup(names) raise Puppet::DataBinding::LookupError, n_("Function lookup() did not find a value for the name '%{name}'", "Function lookup() did not find a value for any of the names [%{name_list}]", names.size - ) % { name: names[0], name_list: names.map { |n| "'#{n}'" }.join(', ') } + ) % { name: names[0], name_list: names.map { |n| "'#{n}'" }.join(', ') } end private_class_method :fail_lookup end diff --git a/lib/puppet/pops/parser/lexer_support.rb b/lib/puppet/pops/parser/lexer_support.rb index 0a2a89275f1..e12d8018699 100644 --- a/lib/puppet/pops/parser/lexer_support.rb +++ b/lib/puppet/pops/parser/lexer_support.rb @@ -214,7 +214,7 @@ def get_bom(content) (content.getbyte(1) || ' '), (content.getbyte(2) || ' '), (content.getbyte(3) || ' ') - ) + ) end end diff --git a/lib/puppet/pops/types/tree_iterators.rb b/lib/puppet/pops/types/tree_iterators.rb index 5be0550abac..ec2ee545f32 100644 --- a/lib/puppet/pops/types/tree_iterators.rb +++ b/lib/puppet/pops/types/tree_iterators.rb @@ -9,7 +9,7 @@ class TreeIterator PArrayType::DEFAULT, PHashType::DEFAULT, PObjectType::DEFAULT - ) + ) # Creates a TreeIterator that by default treats all Array, Hash and Object instances as # containers - the 'containers' option can be set to a type that denotes which types of values diff --git a/lib/puppet/pops/types/type_calculator.rb b/lib/puppet/pops/types/type_calculator.rb index 42b6a1c2b6a..1b170fa581c 100644 --- a/lib/puppet/pops/types/type_calculator.rb +++ b/lib/puppet/pops/types/type_calculator.rb @@ -139,7 +139,7 @@ def self.infer_callable_methods_t(o) o.instance_of?(Array) || o.instance_of?(Hash) || Types::PUndefType::DEFAULT.instance?(o) - ) + ) return nil end # For other objects (e.g. PObjectType instances, and runtime types) full inference needed, since that will diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index f48c1de5b4d..aa4ab27082c 100644 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -61,7 +61,7 @@ module Puppet _('See https://puppet.com/docs/puppet/latest/static_catalogs.html for more information.')].join(" "), :file => @resource.file, :line => @resource.line - ) if !@actual_content && !resource.parameter(:source) + ) if !@actual_content && !resource.parameter(:source) value else @actual_content = value.is_a?(Puppet::Pops::Types::PBinaryType::Binary) ? value.binary_buffer : value diff --git a/lib/puppet/util/windows/process.rb b/lib/puppet/util/windows/process.rb index 1979acbe245..09ffc7144d9 100644 --- a/lib/puppet/util/windows/process.rb +++ b/lib/puppet/util/windows/process.rb @@ -153,7 +153,7 @@ def lookup_privilege_value(name, system_name = '', &block) wide_string(system_name), wide_string(name.to_s), luid_ptr - ) + ) if result == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new( From cca38069f348e3b55f3f61c482695e038267c17b Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 10:04:39 -0800 Subject: [PATCH 02/17] Layout/CommentIndentation This commit enables the Rubocop Layout/CommentIndentation cop. --- .rubocop_todo.yml | 5 ---- lib/puppet/application/script.rb | 2 +- lib/puppet/defaults.rb | 4 ++-- lib/puppet/metatype/manager.rb | 4 ++-- lib/puppet/parameter/value_collection.rb | 2 +- lib/puppet/parser/ast.rb | 6 ++--- lib/puppet/parser/ast/pops_bridge.rb | 2 +- lib/puppet/parser/functions/require.rb | 4 ++-- lib/puppet/pops/loader/loader_paths.rb | 16 ++++++------- lib/puppet/pops/loader/static_loader.rb | 6 ++--- lib/puppet/pops/lookup/explainer.rb | 12 +++++----- lib/puppet/pops/model/model_tree_dumper.rb | 2 +- .../pops/resource/resource_type_impl.rb | 14 +++++------ lib/puppet/pops/types/p_object_type.rb | 2 +- lib/puppet/pops/types/string_converter.rb | 18 +++++++------- lib/puppet/pops/types/type_parser.rb | 2 +- lib/puppet/pops/validation.rb | 2 +- .../provider/nameservice/directoryservice.rb | 2 +- lib/puppet/provider/service/debian.rb | 6 ++--- lib/puppet/provider/user/directoryservice.rb | 24 +++++++++---------- lib/puppet/settings.rb | 2 +- lib/puppet/type/resources.rb | 4 ++-- lib/puppet/util/command_line/trollop.rb | 2 +- lib/puppet/util/tagging.rb | 2 +- lib/puppet/util/windows/daemon.rb | 2 +- 25 files changed, 71 insertions(+), 76 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9f09c4e3b61..1153787ddee 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,11 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent: I18n/RailsI18n/DecorateString: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowForAlignment. -Layout/CommentIndentation: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: leading, trailing diff --git a/lib/puppet/application/script.rb b/lib/puppet/application/script.rb index 02b8eb63d29..5ee6898192a 100644 --- a/lib/puppet/application/script.rb +++ b/lib/puppet/application/script.rb @@ -248,7 +248,7 @@ def setup # installed where a settings catalog have already been applied... # This saves 1/5th of the startup time -# Puppet.settings.use :main, :agent, :ssl + # Puppet.settings.use :main, :agent, :ssl # When running a script, the catalog is not relevant, and neither is caching of it Puppet::Resource::Catalog.indirection.cache_class = nil diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index e0049f6d636..8674ae36efc 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -1273,7 +1273,7 @@ def self.initialize_default_settings!(settings) } ) - # Define the config default. + # Define the config default. settings.define_settings(:application, :config_file_name => { @@ -2054,7 +2054,7 @@ def self.initialize_default_settings!(settings) } ) - # Central fact information. + # Central fact information. settings.define_settings( :main, diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb index 9fd1a9807cf..176b12eb459 100644 --- a/lib/puppet/metatype/manager.rb +++ b/lib/puppet/metatype/manager.rb @@ -38,8 +38,8 @@ def clear_misses # @return [Object] the last returned value from the block. def eachtype @types.each do |_name, type| - # Only consider types that have names - #if ! type.parameters.empty? or ! type.validproperties.empty? + # Only consider types that have names + #if ! type.parameters.empty? or ! type.validproperties.empty? yield type #end end diff --git a/lib/puppet/parameter/value_collection.rb b/lib/puppet/parameter/value_collection.rb index 981c09d7066..a2fcbde2eda 100644 --- a/lib/puppet/parameter/value_collection.rb +++ b/lib/puppet/parameter/value_collection.rb @@ -121,7 +121,7 @@ def munge(value) # @option options [Symbol] :event The event that should be emitted when this value is set. # @todo Option :event original comment says "event should be returned...", is "returned" the correct word # to use? - # @option options [Symbol] :invalidate_refreshes True if a change on this property should invalidate and + # @option options [Symbol] :invalidate_refreshes True if a change on this property should invalidate and # remove any scheduled refreshes (from notify or subscribe) targeted at the same resource. For example, if # a change in this property takes into account any changes that a scheduled refresh would have performed, # then the scheduled refresh would be deleted. diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb index 0dcb1683513..2bd231a33f1 100644 --- a/lib/puppet/parser/ast.rb +++ b/lib/puppet/parser/ast.rb @@ -31,9 +31,9 @@ def safeevaluate(scope) return self.evaluate(scope) rescue Puppet::Pops::Evaluator::PuppetStopIteration => detail raise detail -# # Only deals with StopIteration from the break() function as a general -# # StopIteration is a general runtime problem -# raise Puppet::ParseError.new(detail.message, detail.file, detail.line, detail) + # # Only deals with StopIteration from the break() function as a general + # # StopIteration is a general runtime problem + # raise Puppet::ParseError.new(detail.message, detail.file, detail.line, detail) rescue Puppet::Error => detail raise adderrorcontext(detail) rescue => detail diff --git a/lib/puppet/parser/ast/pops_bridge.rb b/lib/puppet/parser/ast/pops_bridge.rb index 1a5122b4962..405e49cfa5d 100644 --- a/lib/puppet/parser/ast/pops_bridge.rb +++ b/lib/puppet/parser/ast/pops_bridge.rb @@ -103,7 +103,7 @@ def instantiate(modname) nil end end.flatten().compact() # flatten since node definition may have returned an array - # Compact since 4x definitions are not understood by compiler + # Compact since 4x definitions are not understood by compiler end def evaluate(scope) diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb index 8cc1cfb2a4b..4c4a7405a34 100644 --- a/lib/puppet/parser/functions/require.rb +++ b/lib/puppet/parser/functions/require.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true -# Requires the specified classes + # frozen_string_literal: true + # Requires the specified classes Puppet::Parser::Functions::newfunction( :require, diff --git a/lib/puppet/pops/loader/loader_paths.rb b/lib/puppet/pops/loader/loader_paths.rb index cdf4a28e47e..a5872850a27 100644 --- a/lib/puppet/pops/loader/loader_paths.rb +++ b/lib/puppet/pops/loader/loader_paths.rb @@ -45,14 +45,14 @@ def self.relative_paths_for_type(type, loader) result end -# # DO NOT REMOVE YET. needed later? when there is the need to decamel a classname -# def de_camel(fq_name) -# fq_name.to_s.gsub(/::/, '/'). -# gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). -# gsub(/([a-z\d])([A-Z])/,'\1_\2'). -# tr("-", "_"). -# downcase -# end + # # DO NOT REMOVE YET. needed later? when there is the need to decamel a classname + # def de_camel(fq_name) + # fq_name.to_s.gsub(/::/, '/'). + # gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + # gsub(/([a-z\d])([A-Z])/,'\1_\2'). + # tr("-", "_"). + # downcase + # end class SmartPath # Creates SmartPath for the given loader (loader knows how to check for existence etc.) diff --git a/lib/puppet/pops/loader/static_loader.rb b/lib/puppet/pops/loader/static_loader.rb index 0fcc547ec43..603ab5712a7 100644 --- a/lib/puppet/pops/loader/static_loader.rb +++ b/lib/puppet/pops/loader/static_loader.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true - # Static Loader contains constants, basic data types and other types required for the system - # to boot. - # +# Static Loader contains constants, basic data types and other types required for the system +# to boot. +# module Puppet::Pops module Loader class StaticLoader < Loader diff --git a/lib/puppet/pops/lookup/explainer.rb b/lib/puppet/pops/lookup/explainer.rb index bacbb2b5e04..0fa11390332 100644 --- a/lib/puppet/pops/lookup/explainer.rb +++ b/lib/puppet/pops/lookup/explainer.rb @@ -2,12 +2,12 @@ module Puppet::Pops module Lookup -# The ExplainNode contains information of a specific node in a tree traversed during -# lookup. The tree can be traversed using the `parent` and `branches` attributes of -# each node. -# -# Each leaf node contains information about what happened when the leaf of the branch -# was traversed. + # The ExplainNode contains information of a specific node in a tree traversed during + # lookup. The tree can be traversed using the `parent` and `branches` attributes of + # each node. + # + # Each leaf node contains information about what happened when the leaf of the branch + # was traversed. class ExplainNode def branches @branches ||= [] diff --git a/lib/puppet/pops/model/model_tree_dumper.rb b/lib/puppet/pops/model/model_tree_dumper.rb index cdb2dd54b3d..d5d979990fd 100644 --- a/lib/puppet/pops/model/model_tree_dumper.rb +++ b/lib/puppet/pops/model/model_tree_dumper.rb @@ -66,7 +66,7 @@ def dump_CollectExpression o def dump_EppExpression o result = ["epp"] -# result << ["parameters"] + o.parameters.collect {|p| do_dump(p) } if o.parameters.size() > 0 + # result << ["parameters"] + o.parameters.collect {|p| do_dump(p) } if o.parameters.size() > 0 if o.body result << do_dump(o.body) else diff --git a/lib/puppet/pops/resource/resource_type_impl.rb b/lib/puppet/pops/resource/resource_type_impl.rb index 1b8bf3d34cd..7c028aaeb71 100644 --- a/lib/puppet/pops/resource/resource_type_impl.rb +++ b/lib/puppet/pops/resource/resource_type_impl.rb @@ -202,16 +202,16 @@ def instantiate_resource(scope, resource) # This is what the Puppet::Type implementation does # None of this should be needed - # # Make sure our parent class has been evaluated, if we have one. - # if parent && !scope.catalog.resource(resource.type, parent) - # parent_type(scope).ensure_in_catalog(scope) - # end + # # Make sure our parent class has been evaluated, if we have one. + # if parent && !scope.catalog.resource(resource.type, parent) + # parent_type(scope).ensure_in_catalog(scope) + # end # This will never happen - # if ['Class', 'Node'].include? resource.type - # scope.catalog.tag(*resource.tags) - # end + # if ['Class', 'Node'].include? resource.type + # scope.catalog.tag(*resource.tags) + # end end # Being isomorphic in puppet means that the resource is managing a state diff --git a/lib/puppet/pops/types/p_object_type.rb b/lib/puppet/pops/types/p_object_type.rb index 67d1cdf202e..5e9a05be410 100644 --- a/lib/puppet/pops/types/p_object_type.rb +++ b/lib/puppet/pops/types/p_object_type.rb @@ -485,7 +485,7 @@ def write(value, serializer) writer.write(self, value, serializer) end - # @api private + # @api private def create_new_function impl_class = implementation_class return impl_class.create_new_function(self) if impl_class.respond_to?(:create_new_function) diff --git a/lib/puppet/pops/types/string_converter.rb b/lib/puppet/pops/types/string_converter.rb index efd510b2f62..a596c7c7f13 100644 --- a/lib/puppet/pops/types/string_converter.rb +++ b/lib/puppet/pops/types/string_converter.rb @@ -497,7 +497,7 @@ def convert(value, string_formats = :default) case string_formats when :default - # do nothing, use default formats + # do nothing, use default formats when Hash # Convert and validate user input @@ -511,14 +511,14 @@ def convert(value, string_formats = :default) _convert(value_type, value, options, DEFAULT_INDENTATION) end -# # A method only used for manual debugging as the default output of the formatting rules is -# # very hard to read otherwise. -# # -# # @api private -# def dump_string_formats(f, indent = 1) -# return f.to_s unless f.is_a?(Hash) -# "{#{f.map {|k,v| "#{k.to_s} => #{dump_string_formats(v,indent+1)}"}.join(",\n#{' '*indent} ")}}" -# end + # # A method only used for manual debugging as the default output of the formatting rules is + # # very hard to read otherwise. + # # + # # @api private + # def dump_string_formats(f, indent = 1) + # return f.to_s unless f.is_a?(Hash) + # "{#{f.map {|k,v| "#{k.to_s} => #{dump_string_formats(v,indent+1)}"}.join(",\n#{' '*indent} ")}}" + # end def _convert(val_type, value, format_map, indentation) @string_visitor.visit_this_3(self, val_type, value, format_map, indentation) diff --git a/lib/puppet/pops/types/type_parser.rb b/lib/puppet/pops/types/type_parser.rb index 0eead75b528..d2ce73c586e 100644 --- a/lib/puppet/pops/types/type_parser.rb +++ b/lib/puppet/pops/types/type_parser.rb @@ -197,7 +197,7 @@ def self.type_map 'typealias' => TypeFactory.type_alias, 'typereference' => TypeFactory.type_reference, 'typeset' => TypeFactory.type_set, - # A generic callable as opposed to one that does not accept arguments + # A generic callable as opposed to one that does not accept arguments 'callable' => TypeFactory.all_callables, 'semver' => TypeFactory.sem_ver, 'semverrange' => TypeFactory.sem_ver_range, diff --git a/lib/puppet/pops/validation.rb b/lib/puppet/pops/validation.rb index 3d68e3a453d..8cd2d8e2a03 100644 --- a/lib/puppet/pops/validation.rb +++ b/lib/puppet/pops/validation.rb @@ -438,7 +438,7 @@ def prune(&block) @error_count -= 1 when :warning @warning_count -= 1 - # there is not ignore_count + # there is not ignore_count end end removed.empty? ? nil : removed diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index da24f3aa049..9ca6bb0d163 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -96,7 +96,7 @@ def self.get_ds_path def self.list_all_present # rubocop:disable Naming/MemoizedInstanceVariableName @all_present ||= begin - # rubocop:enable Naming/MemoizedInstanceVariableName + # rubocop:enable Naming/MemoizedInstanceVariableName # JJM: List all objects of this Puppet::Type already present on the system. begin dscl_output = execute(get_exec_preamble("-list")) diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb index b1c79dca96e..a1e305582f7 100644 --- a/lib/puppet/provider/service/debian.rb +++ b/lib/puppet/provider/service/debian.rb @@ -68,9 +68,9 @@ def enable end def statuscmd - # /usr/sbin/service provides an abstraction layer which is able to query services - # independent of the init system used. - # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=775795 + # /usr/sbin/service provides an abstraction layer which is able to query services + # independent of the init system used. + # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=775795 (@resource[:hasstatus] == :true) && [command(:service), @resource[:name], "status"] end end diff --git a/lib/puppet/provider/user/directoryservice.rb b/lib/puppet/provider/user/directoryservice.rb index 6ac6947e8fc..18fcc0e36d4 100644 --- a/lib/puppet/provider/user/directoryservice.rb +++ b/lib/puppet/provider/user/directoryservice.rb @@ -6,9 +6,9 @@ Puppet::Type.type(:user).provide :directoryservice do desc "User management on OS X." -## ## -## Provider Settings ## -## ## + ## ## + ## Provider Settings ## + ## ## # Provider command declarations commands :uuidgen => '/usr/bin/uuidgen' @@ -34,9 +34,9 @@ #provider can set the user's shell has_feature :manages_shell -## ## -## Class Methods ## -## ## + ## ## + ## Class Methods ## + ## ## # This method exists to map the dscl values to the correct Puppet # properties. This stays relatively consistent, but who knows what @@ -240,9 +240,9 @@ def self.get_sha1(guid) end -## ## -## Ensurable Methods ## -## ## + ## ## + ## Ensurable Methods ## + ## ## def exists? begin @@ -322,9 +322,9 @@ def delete dscl '.', '-delete', "/Users/#{@resource.name}" end -## ## -## Getter/Setter Methods ## -## ## + ## ## + ## Getter/Setter Methods ## + ## ## # In the setter method we're only going to take action on groups for which # the user is not currently a member. diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index d0bf0da678f..93582884971 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -1094,7 +1094,7 @@ def to_config }.gsub(/^/, "# ") -# Add a section heading that matches our name. + # Add a section heading that matches our name. str += "[#{preferred_run_mode}]\n" eachsection do |section| persection(section) do |obj| diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index dacb538dc9a..8eb55633f71 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -90,8 +90,8 @@ end WINDOWS_SYSTEM_SID_REGEXES = - # Administrator, Guest, Domain Admins, Schema Admins, Enterprise Admins. - # https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems + # Administrator, Guest, Domain Admins, Schema Admins, Enterprise Admins. + # https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems [/S-1-5-21.+-500/, /S-1-5-21.+-501/, /S-1-5-21.+-512/, /S-1-5-21.+-518/, /S-1-5-21.+-519/] diff --git a/lib/puppet/util/command_line/trollop.rb b/lib/puppet/util/command_line/trollop.rb index ad64a200d7c..694c72aa916 100644 --- a/lib/puppet/util/command_line/trollop.rb +++ b/lib/puppet/util/command_line/trollop.rb @@ -463,7 +463,7 @@ def parse_date_parameter param, arg #:nodoc: ## Print the help message to +stream+. def educate stream=$stdout width # just calculate it now; otherwise we have to be careful not to - # call this unless the cursor's at the beginning of a line. + # call this unless the cursor's at the beginning of a line. left = {} @specs.each do |name, spec| diff --git a/lib/puppet/util/tagging.rb b/lib/puppet/util/tagging.rb index 184cc0a3a67..8dbab6f7d57 100644 --- a/lib/puppet/util/tagging.rb +++ b/lib/puppet/util/tagging.rb @@ -20,7 +20,7 @@ def tag(*ary) # not seen before, so now we test if it is valid if valid_tag?(name) if split_qualified_tags? - # avoid adding twice by first testing if the string contains '::' + # avoid adding twice by first testing if the string contains '::' @tags.merge(name.split('::')) if name.include?('::') end else diff --git a/lib/puppet/util/windows/daemon.rb b/lib/puppet/util/windows/daemon.rb index cdbbb69b412..957fc1c3dd1 100644 --- a/lib/puppet/util/windows/daemon.rb +++ b/lib/puppet/util/windows/daemon.rb @@ -121,7 +121,7 @@ class Daemon dwState = SERVICE_PAUSED when SERVICE_CONTROL_CONTINUE dwState = SERVICE_RUNNING - #else + #else # TODO: Handle other control codes? Retain the current state? end From 4e59f24383dcfe2b9771ab1c607685705b86309b Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 10:06:51 -0800 Subject: [PATCH 03/17] Layout/DotPosition This commit enables the Rubocop Layout/DotPosition cop. --- .rubocop_todo.yml | 6 ----- lib/puppet/file_serving/fileset.rb | 6 ++--- lib/puppet/interface/documentation.rb | 4 ++-- lib/puppet/network/formats.rb | 4 ++-- lib/puppet/network/http/api.rb | 20 ++++++++-------- lib/puppet/network/http/api/server/v3.rb | 24 +++++++++---------- .../collectors/exported_collector.rb | 4 ++-- lib/puppet/pops/types/class_loader.rb | 10 ++++---- .../pops/types/type_mismatch_describer.rb | 4 ++-- lib/puppet/provider/package/gem.rb | 6 ++--- lib/puppet/provider/user/user_role_add.rb | 8 +++---- lib/puppet/settings.rb | 10 ++++---- lib/puppet/ssl/certificate_request.rb | 12 +++++----- lib/puppet/type/file.rb | 8 +++---- lib/puppet/type/resources.rb | 12 +++++----- lib/puppet/type/user.rb | 8 +++---- lib/puppet/util/execution.rb | 4 ++-- lib/puppet/util/windows/file.rb | 4 ++-- 18 files changed, 74 insertions(+), 80 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1153787ddee..67a3e26ee9a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,12 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent: I18n/RailsI18n/DecorateString: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/ElseAlignment: Enabled: false diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index 54c0e6d4dfc..e9bffc08cbb 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -135,9 +135,9 @@ def basename def children return [] unless directory? - Dir.entries(path, encoding: Encoding::UTF_8). - reject { |child| ignore?(child) }. - collect { |child| down_level(child) } + Dir.entries(path, encoding: Encoding::UTF_8) + .reject { |child| ignore?(child) } + .collect { |child| down_level(child) } end def ignore?(child) diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index d6265755f61..433a3a8a5b4 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -285,8 +285,8 @@ def copyright_owner=(value) attr_reader :copyright_years def copyright_years=(value) years = munge_copyright_year value - years = (years.is_a?(Array) ? years : [years]). - sort_by do |x| x.is_a?(Range) ? x.first : x end + years = (years.is_a?(Array) ? years : [years]) + .sort_by do |x| x.is_a?(Range) ? x.first : x end @copyright_years = years.map do |year| if year.is_a? Range then diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index c81fc70c12f..3c9d8e9e996 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -160,8 +160,8 @@ def render(datum) column_a = datum.empty? ? 2 : datum.map{ |k,_v| k.to_s.length }.max + 2 datum.sort_by { |k,_v| k.to_s } .each do |key, value| output << key.to_s.ljust(column_a) - output << json.render(value). - chomp.gsub(/\n */) { |x| x + (' ' * column_a) } + output << json.render(value) + .chomp.gsub(/\n */) { |x| x + (' ' * column_a) } output << "\n" end return output diff --git a/lib/puppet/network/http/api.rb b/lib/puppet/network/http/api.rb index 68339498986..116c1c0822c 100644 --- a/lib/puppet/network/http/api.rb +++ b/lib/puppet/network/http/api.rb @@ -3,17 +3,17 @@ class Puppet::Network::HTTP::API require_relative '../../../puppet/version' def self.not_found - Puppet::Network::HTTP::Route. - path(/.*/). - any(lambda do |req, _res| + Puppet::Network::HTTP::Route + .path(/.*/) + .any(lambda do |req, _res| raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new("No route for #{req.method} #{req.path}", Puppet::Network::HTTP::Issues::HANDLER_NOT_FOUND) end) end def self.not_found_upgrade - Puppet::Network::HTTP::Route. - path(/.*/). - any(lambda do |_req, _res| + Puppet::Network::HTTP::Route + .path(/.*/) + .any(lambda do |_req, _res| raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new("Error: Invalid URL - Puppet expects requests that conform to the " + "/puppet and /puppet-ca APIs.\n\n" + "Note that Puppet 3 agents aren't compatible with this version; if you're " + @@ -28,10 +28,10 @@ def self.not_found_upgrade def self.server_routes server_prefix = Regexp.new("^#{Puppet::Network::HTTP::SERVER_URL_PREFIX}/") - Puppet::Network::HTTP::Route.path(server_prefix). - any. - chain(Puppet::Network::HTTP::API::Server::V3.routes, - Puppet::Network::HTTP::API.not_found) + Puppet::Network::HTTP::Route.path(server_prefix) + .any + .chain(Puppet::Network::HTTP::API::Server::V3.routes, + Puppet::Network::HTTP::API.not_found) end def self.master_routes diff --git a/lib/puppet/network/http/api/server/v3.rb b/lib/puppet/network/http/api/server/v3.rb index 5f38117cb8e..33c0688d095 100644 --- a/lib/puppet/network/http/api/server/v3.rb +++ b/lib/puppet/network/http/api/server/v3.rb @@ -11,26 +11,26 @@ class V3 def self.wrap(&block) lambda do |request, response| - Puppet::Network::Authorization. - check_external_authorization(request.method, - request.path) + Puppet::Network::Authorization + .check_external_authorization(request.method, + request.path) block.call.call(request, response) end end - INDIRECTED = Puppet::Network::HTTP::Route. - path(/.*/). - any(wrap { Puppet::Network::HTTP::API::IndirectedRoutes.new } ) + INDIRECTED = Puppet::Network::HTTP::Route + .path(/.*/) + .any(wrap { Puppet::Network::HTTP::API::IndirectedRoutes.new } ) - ENVIRONMENTS = Puppet::Network::HTTP::Route. - path(%r{^/environments$}). - get(wrap { Environments.new(Puppet.lookup(:environments)) } ) + ENVIRONMENTS = Puppet::Network::HTTP::Route + .path(%r{^/environments$}) + .get(wrap { Environments.new(Puppet.lookup(:environments)) } ) def self.routes - Puppet::Network::HTTP::Route.path(%r{v3}). - any. - chain(ENVIRONMENTS, INDIRECTED) + Puppet::Network::HTTP::Route.path(%r{v3}) + .any + .chain(ENVIRONMENTS, INDIRECTED) end end end diff --git a/lib/puppet/pops/evaluator/collectors/exported_collector.rb b/lib/puppet/pops/evaluator/collectors/exported_collector.rb index 43953fa3c80..a331ee53f59 100644 --- a/lib/puppet/pops/evaluator/collectors/exported_collector.rb +++ b/lib/puppet/pops/evaluator/collectors/exported_collector.rb @@ -39,8 +39,8 @@ def collect resource.type == t && resource.exported? && (q.nil? || q.call(resource)) end - found = Puppet::Resource.indirection. - search(@type, :host => @scope.compiler.node.name, :filter => @equery, :scope => @scope) + found = Puppet::Resource.indirection + .search(@type, :host => @scope.compiler.node.name, :filter => @equery, :scope => @scope) found_resources = found.map {|x| x.is_a?(Puppet::Parser::Resource) ? x : x.to_resource(@scope)} diff --git a/lib/puppet/pops/types/class_loader.rb b/lib/puppet/pops/types/class_loader.rb index eed4aa33b69..6f9a3fcf08a 100644 --- a/lib/puppet/pops/types/class_loader.rb +++ b/lib/puppet/pops/types/class_loader.rb @@ -120,11 +120,11 @@ def self.paths_for_name(fq_named_parts) private_class_method :paths_for_name def self.de_camel(fq_name) - fq_name.to_s.gsub(/::/, '/'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). - tr("-", "_"). - downcase + fq_name.to_s.gsub(/::/, '/') + .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') + .gsub(/([a-z\d])([A-Z])/,'\1_\2') + .tr("-", "_") + .downcase end private_class_method :de_camel diff --git a/lib/puppet/pops/types/type_mismatch_describer.rb b/lib/puppet/pops/types/type_mismatch_describer.rb index c138a82ced1..88ef956cd5c 100644 --- a/lib/puppet/pops/types/type_mismatch_describer.rb +++ b/lib/puppet/pops/types/type_mismatch_describer.rb @@ -581,8 +581,8 @@ def validate_default_parameter(subject, param_name, param_type, value, tense = : end def get_deferred_function_return_type(value) - func = Puppet.lookup(:loaders).private_environment_loader. - load(:function, value.name) + func = Puppet.lookup(:loaders).private_environment_loader + .load(:function, value.name) dispatcher = func.class.dispatcher.find_matching_dispatcher(value.arguments) raise ArgumentError, "No matching arity found for #{func.class.name} with arguments #{value.arguments}" unless dispatcher dispatcher.type.return_type diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index 1dbf653a9b0..fc90df71b76 100644 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -118,9 +118,9 @@ def self.gemlist(options) end begin - list = execute_gem_command(options[:command], command_options).lines. - map {|set| gemsplit(set) }. - reject {|x| x.nil? } + list = execute_gem_command(options[:command], command_options).lines + .map {|set| gemsplit(set) } + .reject {|x| x.nil? } rescue Puppet::ExecutionFailure => detail raise Puppet::Error, _("Could not list gems: %{detail}") % { detail: detail }, detail.backtrace end diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index b512ef90539..9db98ee83bf 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -178,11 +178,11 @@ def target_file_path #No abstraction, all esoteric knowledge of file formats, yay def shadow_entry return @shadow_entry if defined? @shadow_entry - @shadow_entry = File.readlines(target_file_path). - reject { |r| r =~ /^[^\w]/ }. + @shadow_entry = File.readlines(target_file_path) + .reject { |r| r =~ /^[^\w]/ }. # PUP-229: don't suppress the empty fields - collect { |l| l.chomp.split(':', -1) }. - find { |user, _| user == @resource[:name] } + collect { |l| l.chomp.split(':', -1) } + .find { |user, _| user == @resource[:name] } end def password diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index 93582884971..c2f486b52c8 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -1143,11 +1143,11 @@ def use(*sections) if transaction.any_failed? report = transaction.report status_failures = report.resource_statuses.values.select { |r| r.failed? } - status_fail_msg = status_failures. - collect(&:events). - flatten. - select { |event| event.status == 'failure' }. - collect { |event| "#{event.resource}: #{event.message}" }.join("; ") + status_fail_msg = status_failures + .collect(&:events) + .flatten + .select { |event| event.status == 'failure' } + .collect { |event| "#{event.resource}: #{event.message}" }.join("; ") raise "Got #{status_failures.length} failure(s) while initializing: #{status_fail_msg}" end diff --git a/lib/puppet/ssl/certificate_request.rb b/lib/puppet/ssl/certificate_request.rb index 710bd0afb4c..e2e015e7573 100644 --- a/lib/puppet/ssl/certificate_request.rb +++ b/lib/puppet/ssl/certificate_request.rb @@ -170,12 +170,12 @@ def request_extensions end def subject_alt_names - @subject_alt_names ||= request_extensions. - select {|x| x["oid"] == "subjectAltName" }. - map {|x| x["value"].split(/\s*,\s*/) }. - flatten. - sort. - uniq + @subject_alt_names ||= request_extensions + .select {|x| x["oid"] == "subjectAltName" } + .map {|x| x["value"].split(/\s*,\s*/) } + .flatten + .sort + .uniq end # Return all user specified attributes attached to this CSR as a hash. IF an diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 569c0ab3cfa..44b8b491139 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -655,10 +655,10 @@ def remove_less_specific_files(files) def self.remove_less_specific_files(files, parent_path, existing_files, &block) # REVISIT: is this Windows safe? AltSeparator? mypath = parent_path.split(::File::Separator) - other_paths = existing_files. - select { |r| (yield r) != parent_path}. - collect { |r| (yield r).split(::File::Separator) }. - select { |p| p[0,mypath.length] == mypath } + other_paths = existing_files + .select { |r| (yield r) != parent_path} + .collect { |r| (yield r).split(::File::Separator) } + .select { |p| p[0,mypath.length] == mypath } return files if other_paths.empty? diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 8eb55633f71..ada21422a4b 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -116,12 +116,12 @@ def able_to_ensure_absent?(resource) # right now, because it only supports purging. def generate return [] unless self.purge? - resource_type.instances. - reject { |r| catalog.resource_refs.include? r.ref }. - select { |r| check(r) }. - select { |r| r.class.validproperty?(:ensure) }. - select { |r| able_to_ensure_absent?(r) }. - each { |resource| + resource_type.instances + .reject { |r| catalog.resource_refs.include? r.ref } + .select { |r| check(r) } + .select { |r| r.class.validproperty?(:ensure) } + .select { |r| able_to_ensure_absent?(r) } + .each { |resource| resource.copy_metaparams(@parameters) resource.purging } diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index 55bbf1ab217..9df5e7dac9b 100644 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -806,10 +806,10 @@ def authorized_keys_path(entry) # @see generate # @api private def find_unmanaged_keys - self[:purge_ssh_keys]. - select { |f| File.readable?(f) }. - map { |f| unknown_keys_in_file(f) }. - flatten.each do |res| + self[:purge_ssh_keys] + .select { |f| File.readable?(f) } + .map { |f| unknown_keys_in_file(f) } + .flatten.each do |res| res[:ensure] = :absent res[:user] = self[:name] res.copy_metaparams(@parameters) diff --git a/lib/puppet/util/execution.rb b/lib/puppet/util/execution.rb index aad07a333bf..5f4921c7c21 100644 --- a/lib/puppet/util/execution.rb +++ b/lib/puppet/util/execution.rb @@ -312,8 +312,8 @@ def self.execute(command, options = NoOptionsSpecified) # def self.ruby_path() File.join(RbConfig::CONFIG['bindir'], - RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']). - sub(/.*\s.*/m, '"\&"') + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']) + .sub(/.*\s.*/m, '"\&"') end # Because some modules provide their own version of this method. diff --git a/lib/puppet/util/windows/file.rb b/lib/puppet/util/windows/file.rb index d49257f4d6a..dc17fae7e87 100644 --- a/lib/puppet/util/windows/file.rb +++ b/lib/puppet/util/windows/file.rb @@ -38,8 +38,8 @@ def move_file_ex(source, target, flags = 0) flags) return true if result != FFI::WIN32_FALSE - raise Puppet::Util::Windows::Error. - new("MoveFileEx(#{source}, #{target}, #{flags.to_s(8)})") + raise Puppet::Util::Windows::Error + .new("MoveFileEx(#{source}, #{target}, #{flags.to_s(8)})") end module_function :move_file_ex From 62f677efbef64e01ff44613d87e61347b8d85473 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 10:40:20 -0800 Subject: [PATCH 04/17] Layout/ElseAlignment This commit enables the Rubocop Layout/ElseAlignment cop. In some instances (like Puppet::Pal::TaskSignature.runable_with? and Puppet::Transaction::Report.initialize_from_hash), the new alignment pushed code past the 80 character line length recommended by the Ruby style guide and was reformatted to accomodate that. --- .rubocop.yml | 5 +++ .rubocop_todo.yml | 4 --- lib/puppet/graph/simple_graph.rb | 40 ++++++++++----------- lib/puppet/pal/task_signature.rb | 21 ++++++----- lib/puppet/parser/scope.rb | 2 +- lib/puppet/pops/evaluator/evaluator_impl.rb | 14 ++++---- lib/puppet/pops/loaders.rb | 32 ++++++++--------- lib/puppet/pops/lookup/function_provider.rb | 10 +++--- lib/puppet/pops/lookup/hiera_config.rb | 12 +++---- lib/puppet/pops/lookup/lookup_adapter.rb | 12 +++---- lib/puppet/transaction/report.rb | 18 ++++++---- lib/puppet/type.rb | 36 +++++++++---------- lib/puppet/type/resources.rb | 11 +++--- lib/puppet/util/command_line/trollop.rb | 24 ++++++------- lib/puppet/util/ldap/connection.rb | 12 +++---- 15 files changed, 131 insertions(+), 122 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index be8d072e377..13a40c7f504 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -28,6 +28,11 @@ Layout/BeginEndAlignment: Exclude: - 'lib/puppet/provider/package/*.rb' +Layout/ElseAlignment: + Enabled: true + Exclude: + - 'lib/puppet/provider/package/*.rb' + # puppet uses symbol booleans in types and providers to work around long standing # bugs when trying to manage falsey pararameters and properties Lint/BooleanSymbol: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 67a3e26ee9a..9a097ebf5df 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,10 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent: I18n/RailsI18n/DecorateString: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/ElseAlignment: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLineAfterGuardClause: Enabled: false diff --git a/lib/puppet/graph/simple_graph.rb b/lib/puppet/graph/simple_graph.rb index 6cb8d3bcd15..e07ccf4420d 100644 --- a/lib/puppet/graph/simple_graph.rb +++ b/lib/puppet/graph/simple_graph.rb @@ -507,26 +507,26 @@ def initialize_from_hash(hash) def to_data_hash hash = { 'edges' => edges.map(&:to_data_hash) } hash['vertices'] = if self.class.use_new_yaml_format - vertices - else - # Represented in YAML using the old (version 2.6) format. - result = {} - vertices.each do |vertex| - adjacencies = {} - [:in, :out].each do |direction| - direction_hash = {} - adjacencies[direction.to_s] = direction_hash - adjacent(vertex, :direction => direction, :type => :edges).each do |edge| - other_vertex = direction == :in ? edge.source : edge.target - (direction_hash[other_vertex.to_s] ||= []) << edge - end - direction_hash.each_pair { |key, edges| direction_hash[key] = edges.uniq.map(&:to_data_hash) } - end - vname = vertex.to_s - result[vname] = { 'adjacencies' => adjacencies, 'vertex' => vname } - end - result - end + vertices + else + # Represented in YAML using the old (version 2.6) format. + result = {} + vertices.each do |vertex| + adjacencies = {} + [:in, :out].each do |direction| + direction_hash = {} + adjacencies[direction.to_s] = direction_hash + adjacent(vertex, :direction => direction, :type => :edges).each do |edge| + other_vertex = direction == :in ? edge.source : edge.target + (direction_hash[other_vertex.to_s] ||= []) << edge + end + direction_hash.each_pair { |key, edges| direction_hash[key] = edges.uniq.map(&:to_data_hash) } + end + vname = vertex.to_s + result[vname] = { 'adjacencies' => adjacencies, 'vertex' => vname } + end + result + end hash end diff --git a/lib/puppet/pal/task_signature.rb b/lib/puppet/pal/task_signature.rb index a126bd4150e..889cddf24f3 100644 --- a/lib/puppet/pal/task_signature.rb +++ b/lib/puppet/pal/task_signature.rb @@ -21,19 +21,24 @@ def initialize(task) def runnable_with?(args_hash) params = @task.parameters params_type = if params.nil? - T_GENERIC_TASK_HASH - else - Puppet::Pops::Types::TypeFactory.struct(params) - end + T_GENERIC_TASK_HASH + else + Puppet::Pops::Types::TypeFactory.struct(params) + end return true if params_type.instance?(args_hash) if block_given? tm = Puppet::Pops::Types::TypeMismatchDescriber.singleton error = if params.nil? - tm.describe_mismatch('', params_type, Puppet::Pops::Types::TypeCalculator.infer_set(args_hash)) - else - tm.describe_struct_signature(params_type, args_hash).flatten.map {|e| e.format }.join("\n") - end + tm.describe_mismatch('', params_type, + Puppet::Pops::Types::TypeCalculator + .infer_set(args_hash)) + else + tm.describe_struct_signature(params_type, args_hash) + .flatten + .map {|e| e.format } + .join("\n") + end yield "Task #{@task.name}:\n#{error}" end false diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 5fb13187a12..eb0b5d169c1 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -298,7 +298,7 @@ def exist?(name) else other_scope.exist?(variable_name) end - else + else # rubocop:disable Layout/ElseAlignment next_scope = inherited_scope || enclosing_scope effective_symtable(true).include?(name) || next_scope && next_scope.exist?(name) || BUILT_IN_VARS.include?(name) end diff --git a/lib/puppet/pops/evaluator/evaluator_impl.rb b/lib/puppet/pops/evaluator/evaluator_impl.rb index ff563c16597..78ec6fd9d27 100644 --- a/lib/puppet/pops/evaluator/evaluator_impl.rb +++ b/lib/puppet/pops/evaluator/evaluator_impl.rb @@ -1256,18 +1256,16 @@ def delete(x, y) when Array y = case y when Array then y - when Hash then y.to_a - else - [y] - end + when Hash then y.to_a + else [y] + end y.each {|e| result.delete(e) } when Hash y = case y when Array then y - when Hash then y.keys - else - [y] - end + when Hash then y.keys + else [y] + end y.each {|e| result.delete(e) } else raise ArgumentError.new(_("Can only delete from an Array or Hash.")) diff --git a/lib/puppet/pops/loaders.rb b/lib/puppet/pops/loaders.rb index 389895b16d1..23103ea6531 100644 --- a/lib/puppet/pops/loaders.rb +++ b/lib/puppet/pops/loaders.rb @@ -281,22 +281,22 @@ def load_main_manifest parser = Parser::EvaluatingParser.singleton parsed_code = Puppet[:code] program = if parsed_code != "" - parser.parse_string(parsed_code, 'unknown-source-location') - else - file = @environment.manifest - - # if the manifest file is a reference to a directory, parse and combine - # all .pp files in that directory - if file == Puppet::Node::Environment::NO_MANIFEST - nil - elsif File.directory?(file) - raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints directory '#{file}'. It must be a file" - elsif File.exist?(file) - parser.parse_file(file) - else - raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints '#{file}'. It does not exist" - end - end + parser.parse_string(parsed_code, 'unknown-source-location') + else + file = @environment.manifest + + # if the manifest file is a reference to a directory, parse and + # combine all .pp files in that directory + if file == Puppet::Node::Environment::NO_MANIFEST + nil + elsif File.directory?(file) + raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints directory '#{file}'. It must be a file" + elsif File.exist?(file) + parser.parse_file(file) + else + raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints '#{file}'. It does not exist" + end + end instantiate_definitions(program, public_environment_loader) unless program.nil? program rescue Puppet::ParseErrorWithIssue => detail diff --git a/lib/puppet/pops/lookup/function_provider.rb b/lib/puppet/pops/lookup/function_provider.rb index 81cc5bb5194..8e710af72ae 100644 --- a/lib/puppet/pops/lookup/function_provider.rb +++ b/lib/puppet/pops/lookup/function_provider.rb @@ -84,11 +84,11 @@ def load_function(lookup_invocation) loaders = lookup_invocation.scope.compiler.loaders typed_name = Loader::TypedName.new(:function, @function_name) loader = if typed_name.qualified? - qualifier = typed_name.name_parts[0] - qualifier == 'environment' ? loaders.private_environment_loader : loaders.private_loader_for_module(qualifier) - else - loaders.private_environment_loader - end + qualifier = typed_name.name_parts[0] + qualifier == 'environment' ? loaders.private_environment_loader : loaders.private_loader_for_module(qualifier) + else + loaders.private_environment_loader + end te = loader.load_typed(typed_name) if te.nil? || te.value.nil? @parent_data_provider.config(lookup_invocation).fail(Issues::HIERA_DATA_PROVIDER_FUNCTION_NOT_FOUND, diff --git a/lib/puppet/pops/lookup/hiera_config.rb b/lib/puppet/pops/lookup/hiera_config.rb index dfe92b09633..f8356be94ef 100644 --- a/lib/puppet/pops/lookup/hiera_config.rb +++ b/lib/puppet/pops/lookup/hiera_config.rb @@ -626,12 +626,12 @@ def create_configured_data_providers(lookup_invocation, parent_data_provider, us compiler = Puppet.lookup(:pal_compiler) { nil } config_key = if compiler.is_a?(Puppet::Pal::ScriptCompiler) && !@config[KEY_PLAN_HIERARCHY].nil? - KEY_PLAN_HIERARCHY - elsif use_default_hierarchy - KEY_DEFAULT_HIERARCHY - else - KEY_HIERARCHY - end + KEY_PLAN_HIERARCHY + elsif use_default_hierarchy + KEY_DEFAULT_HIERARCHY + else + KEY_HIERARCHY + end @config[config_key].each do |he| name = he[KEY_NAME] if data_providers.include?(name) diff --git a/lib/puppet/pops/lookup/lookup_adapter.rb b/lib/puppet/pops/lookup/lookup_adapter.rb index 40dff6f969c..cef441b9eef 100644 --- a/lib/puppet/pops/lookup/lookup_adapter.rb +++ b/lib/puppet/pops/lookup/lookup_adapter.rb @@ -353,12 +353,12 @@ def retrieve_lookup_options(module_name, lookup_invocation, merge_strategy) catch(:no_such_key) do module_opts = validate_lookup_options(lookup_in_module(LookupKey::LOOKUP_OPTIONS, meta_invocation, merge_strategy), module_name) opts = if opts.nil? - module_opts - elsif module_opts - merge_strategy.lookup([GLOBAL_ENV_MERGE, "Module #{lookup_invocation.module_name}"], meta_invocation) do |n| - meta_invocation.with(:scope, n) { meta_invocation.report_found(LOOKUP_OPTIONS, n == GLOBAL_ENV_MERGE ? opts : module_opts) } - end - end + module_opts + elsif module_opts + merge_strategy.lookup([GLOBAL_ENV_MERGE, "Module #{lookup_invocation.module_name}"], meta_invocation) do |n| + meta_invocation.with(:scope, n) { meta_invocation.report_found(LOOKUP_OPTIONS, n == GLOBAL_ENV_MERGE ? opts : module_opts) } + end + end end end compile_patterns(opts) diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index 25205eb4cf7..bb78124ca8b 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -301,12 +301,18 @@ def initialize_from_hash(data) @resource_statuses = {} data['resource_statuses'].map do |key, rs| - @resource_statuses[key] = if rs == Puppet::Resource::EMPTY_HASH - nil - else - # Older versions contain tags that causes Psych to create instances directly - rs.is_a?(Puppet::Resource::Status) ? rs : Puppet::Resource::Status.from_data_hash(rs) - end + @resource_statuses[key] = + if rs == Puppet::Resource::EMPTY_HASH + nil + else + # Older versions contain tags that causes Psych to create instances + # directly + if rs.is_a?(Puppet::Resource::Status) + rs + else + Puppet::Resource::Status.from_data_hash(rs) + end + end end end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 367227ebda3..989f126b5d6 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1795,20 +1795,20 @@ def self.provide(name, options = {}, &block) pname = options[:parent] parent = if pname - options.delete(:parent) - if pname.is_a? Class - pname - else - provider = self.provider(pname) - if provider - provider - else - raise Puppet::DevError, _("Could not find parent provider %{parent} of %{name}") % { parent: pname, name: name } - end - end - else - Puppet::Provider - end + options.delete(:parent) + if pname.is_a? Class + pname + else + provider = self.provider(pname) + if provider + provider + else + raise Puppet::DevError, _("Could not find parent provider %{parent} of %{name}") % { parent: pname, name: name } + end + end + else + Puppet::Provider + end options[:resource_type] ||= self @@ -2520,10 +2520,10 @@ def parent return @parent if @parent parents = catalog.adjacent(self, :direction => :in) @parent = if parents - parents.shift - else - nil - end + parents.shift + else + nil + end end # Returns a reference to this as a string in "Type[name]" format. diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index ada21422a4b..94d2cee1867 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -172,12 +172,11 @@ def self.system_users_max_uid end # Otherwise, use a sensible default based on the OS family - @system_users_max_uid ||= case Puppet.runtime[:facter].value('os.family') - when 'OpenBSD', 'FreeBSD' - 999 - else - 499 - end + @system_users_max_uid ||= + case Puppet.runtime[:facter].value('os.family') + when 'OpenBSD', 'FreeBSD' then 999 + else 499 + end @system_users_max_uid end diff --git a/lib/puppet/util/command_line/trollop.rb b/lib/puppet/util/command_line/trollop.rb index 694c72aa916..8ac29808627 100644 --- a/lib/puppet/util/command_line/trollop.rb +++ b/lib/puppet/util/command_line/trollop.rb @@ -527,18 +527,18 @@ def educate stream=$stdout def width #:nodoc: @width ||= if $stdout.tty? - begin - require 'curses' - Curses::init_screen - x = Curses::cols - Curses::close_screen - x - rescue Exception - 80 - end - else - 80 - end + begin + require 'curses' + Curses::init_screen + x = Curses::cols + Curses::close_screen + x + rescue Exception + 80 + end + else + 80 + end end def wrap str, opts={} # :nodoc: diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb index e72d779ffb1..4fd7df0c7c1 100644 --- a/lib/puppet/util/ldap/connection.rb +++ b/lib/puppet/util/ldap/connection.rb @@ -9,12 +9,12 @@ class Puppet::Util::Ldap::Connection # Return a default connection, using our default settings. def self.instance ssl = if Puppet[:ldaptls] - :tls - elsif Puppet[:ldapssl] - true - else - false - end + :tls + elsif Puppet[:ldapssl] + true + else + false + end options = {} options[:ssl] = ssl From 00592c4ac04705e056994d9e005e10acfd782ac7 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 15:43:57 -0800 Subject: [PATCH 05/17] Layout/EmptyLineBetweenDefs This commit enables the Rubocop Layout/EmptyLineBetweenDefs cop. --- .rubocop_todo.yml | 5 ----- lib/puppet/agent/disabler.rb | 1 - lib/puppet/application/device.rb | 1 - lib/puppet/application/face_base.rb | 1 - lib/puppet/application/filebucket.rb | 1 - lib/puppet/face/module/list.rb | 1 - lib/puppet/functions.rb | 3 --- lib/puppet/generate/type.rb | 1 + lib/puppet/http/pool.rb | 1 - lib/puppet/interface/option.rb | 3 ++- lib/puppet/module/plan.rb | 2 ++ lib/puppet/module/task.rb | 2 ++ lib/puppet/network/formats.rb | 1 + lib/puppet/network/http_pool.rb | 1 + lib/puppet/pal/catalog_compiler.rb | 1 - lib/puppet/parameter.rb | 1 - lib/puppet/parameter/path.rb | 1 + lib/puppet/parser/ast/pops_bridge.rb | 1 + lib/puppet/parser/scope.rb | 2 -- lib/puppet/pops.rb | 1 + lib/puppet/pops/evaluator/access_operator.rb | 1 - lib/puppet/pops/evaluator/compare_operator.rb | 1 - lib/puppet/pops/evaluator/evaluator_impl.rb | 2 -- lib/puppet/pops/loader/loader.rb | 1 - lib/puppet/pops/model/ast.rb | 1 + lib/puppet/pops/model/ast_transformer.rb | 1 - lib/puppet/pops/model/model_label_provider.rb | 1 - lib/puppet/pops/types/string_converter.rb | 1 + lib/puppet/pops/types/type_formatter.rb | 2 -- lib/puppet/pops/types/types.rb | 2 +- lib/puppet/provider/nameservice/directoryservice.rb | 3 ++- lib/puppet/provider/service/launchd.rb | 1 - lib/puppet/provider/service/upstart.rb | 1 - lib/puppet/provider/user/user_role_add.rb | 1 - lib/puppet/resource.rb | 1 - lib/puppet/settings.rb | 1 - lib/puppet/settings/errors.rb | 1 + lib/puppet/type.rb | 1 - lib/puppet/type/file/target.rb | 1 - lib/puppet/util.rb | 1 - lib/puppet/util/package/version/range/eq.rb | 1 + lib/puppet/util/package/version/range/gt.rb | 1 + lib/puppet/util/package/version/range/gt_eq.rb | 1 + lib/puppet/util/package/version/range/lt.rb | 1 + lib/puppet/util/package/version/range/lt_eq.rb | 1 + lib/puppet/util/package/version/range/min_max.rb | 3 +++ lib/puppet/util/windows.rb | 5 +++++ lib/puppet/util/windows/adsi.rb | 1 - util/rspec_runner | 1 + 49 files changed, 32 insertions(+), 39 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9a097ebf5df..c56dbf0af88 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,11 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLines: Enabled: false diff --git a/lib/puppet/agent/disabler.rb b/lib/puppet/agent/disabler.rb index 8fa8ba9a036..7608f465e33 100644 --- a/lib/puppet/agent/disabler.rb +++ b/lib/puppet/agent/disabler.rb @@ -44,7 +44,6 @@ def disable_message nil end - def disable_lockfile @disable_lockfile ||= Puppet::Util::JsonLockfile.new(Puppet[:agent_disabled_lockfile]) diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb index d8d9e5f4c4d..86f774cfc0c 100644 --- a/lib/puppet/application/device.rb +++ b/lib/puppet/application/device.rb @@ -227,7 +227,6 @@ def help HELP end - def main if options[:resource] and !options[:target] raise _("resource command requires target") diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index 07ae18e6366..94dd220ba72 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -205,7 +205,6 @@ def setup self.render_as ||= (@action.render_as || :console) end - def main status = false diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb index 9529568f105..788768223b9 100644 --- a/lib/puppet/application/filebucket.rb +++ b/lib/puppet/application/filebucket.rb @@ -209,7 +209,6 @@ def help HELP end - def run_command @args = command_line.args command = args.shift diff --git a/lib/puppet/face/module/list.rb b/lib/puppet/face/module/list.rb index bf813d5c545..842d557566c 100644 --- a/lib/puppet/face/module/list.rb +++ b/lib/puppet/face/module/list.rb @@ -147,7 +147,6 @@ def unmet_dependencies(environment) unmet_deps end - def warn_unmet_dependencies(environment) @unmet_deps = unmet_dependencies(environment) diff --git a/lib/puppet/functions.rb b/lib/puppet/functions.rb index e1c85f3eb14..33ccb3dbc60 100644 --- a/lib/puppet/functions.rb +++ b/lib/puppet/functions.rb @@ -386,7 +386,6 @@ def self.init_dispatch(a_closure) end end - # Public api methods of the DispatcherBuilder are available within dispatch() # blocks declared in a Puppet::Function.create_function() call. # @@ -599,7 +598,6 @@ def internal_type_parse(type_string, loader) private :internal_type_parse end - # The LocalTypeAliasBuilder is used by the 'local_types' method to collect the individual # type aliases given by the function's author. # @@ -801,7 +799,6 @@ def self.from_to_names(func_info) end end - # Injection and Weaving of parameters # --- # It is possible to inject and weave a set of well known parameters into a call. diff --git a/lib/puppet/generate/type.rb b/lib/puppet/generate/type.rb index 86f91e8f527..59a5e1408d4 100644 --- a/lib/puppet/generate/type.rb +++ b/lib/puppet/generate/type.rb @@ -138,6 +138,7 @@ def self.find_inputs(format = :pcore, environment = Puppet.lookup(:current_envir def self.bad_input? @bad_input end + # Generates files for the given inputs. # If a file is up to date (newer than input) it is kept. # If a file is out of date it is regenerated. diff --git a/lib/puppet/http/pool.rb b/lib/puppet/http/pool.rb index f5081078557..5b5fa27902a 100644 --- a/lib/puppet/http/pool.rb +++ b/lib/puppet/http/pool.rb @@ -71,7 +71,6 @@ def start(site, verifier, http) end end - # Safely close a persistent connection. # Don't try to close a connection that's already closed. # diff --git a/lib/puppet/interface/option.rb b/lib/puppet/interface/option.rb index 43a5e7c95af..02e26a5207d 100644 --- a/lib/puppet/interface/option.rb +++ b/lib/puppet/interface/option.rb @@ -102,13 +102,14 @@ def optparse_to_name(declaration) name.to_sym end - def takes_argument? !!@argument end + def optional_argument? !!@optional_argument end + def required? !!@required end diff --git a/lib/puppet/module/plan.rb b/lib/puppet/module/plan.rb index 871ef554f49..843242ec4c9 100644 --- a/lib/puppet/module/plan.rb +++ b/lib/puppet/module/plan.rb @@ -34,8 +34,10 @@ def initialize(msg) class InvalidPlan < Error end + class InvalidMetadata < Error end + class PlanNotFound < Error def initialize(plan_name, module_name) msg = _("Plan %{plan_name} not found in module %{module_name}.") % diff --git a/lib/puppet/module/task.rb b/lib/puppet/module/task.rb index 396d4781b30..a551e109cd8 100644 --- a/lib/puppet/module/task.rb +++ b/lib/puppet/module/task.rb @@ -35,8 +35,10 @@ def initialize(msg) class InvalidTask < Error end + class InvalidMetadata < Error end + class TaskNotFound < Error def initialize(task_name, module_name) msg = _("Task %{task_name} not found in module %{module_name}.") % diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index 3c9d8e9e996..bdbe8d24854 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -247,6 +247,7 @@ def render(datum) end Puppet::Util::Json.dump(datum, :pretty => true, :quirks_mode => true) end + def render_multiple(data) data.collect(&:render).join("\n") end diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb index 0b1549a58ac..663fab1f9af 100644 --- a/lib/puppet/network/http_pool.rb +++ b/lib/puppet/network/http_pool.rb @@ -15,6 +15,7 @@ module Puppet::Network::HttpPool def self.http_client_class @http_client_class end + def self.http_client_class=(klass) @http_client_class = klass end diff --git a/lib/puppet/pal/catalog_compiler.rb b/lib/puppet/pal/catalog_compiler.rb index 1cdce5347fc..a9bec724487 100644 --- a/lib/puppet/pal/catalog_compiler.rb +++ b/lib/puppet/pal/catalog_compiler.rb @@ -63,7 +63,6 @@ def evaluate(ast) end end - # Compiles the result of additional evaluation taking place in a PAL catalog compilation. # This will evaluate all lazy constructs until all have been evaluated, and will the validate # the result. diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index dc01eb0bd9c..d5b4faee7e2 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -332,7 +332,6 @@ def version resource.version end - # Initializes the parameter with a required resource reference and optional attribute settings. # The option `:resource` must be specified or an exception is raised. Any additional options passed # are used to initialize the attributes of this parameter by treating each key in the `options` hash as diff --git a/lib/puppet/parameter/path.rb b/lib/puppet/parameter/path.rb index 4a62247d199..3bfcae10b5a 100644 --- a/lib/puppet/parameter/path.rb +++ b/lib/puppet/parameter/path.rb @@ -12,6 +12,7 @@ class Puppet::Parameter::Path < Puppet::Parameter def self.accept_arrays(bool = true) @accept_arrays = !!bool end + def self.arrays? @accept_arrays end diff --git a/lib/puppet/parser/ast/pops_bridge.rb b/lib/puppet/parser/ast/pops_bridge.rb index 405e49cfa5d..80e4f6acce0 100644 --- a/lib/puppet/parser/ast/pops_bridge.rb +++ b/lib/puppet/parser/ast/pops_bridge.rb @@ -66,6 +66,7 @@ def evaluate(scope) end end end + # Bridges the top level "Program" produced by the pops parser. # Its main purpose is to give one point where all definitions are instantiated (actually defined since the # Puppet 3x terminology is somewhat misleading - the definitions are instantiated, but instances of the created types diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index eb0b5d169c1..e37a3890f66 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -264,7 +264,6 @@ def to_hash end end - # Returns true if the variable of the given name has a non nil value. # TODO: This has vague semantics - does the variable exist or not? # use ['name'] to get nil or value, and if nil check with exist?('name') @@ -1036,7 +1035,6 @@ def find_defined_resource_type(type) raise Puppet::DevError, _("Scope#find_defined_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead") end - def method_missing(method, *args, &block) method.to_s =~ /^function_(.*)$/ name = $1 diff --git a/lib/puppet/pops.rb b/lib/puppet/pops.rb index bdaa843a2e9..35068af2332 100644 --- a/lib/puppet/pops.rb +++ b/lib/puppet/pops.rb @@ -61,6 +61,7 @@ module Model module Resource require_relative 'pops/resource/resource_type_impl' end + module Evaluator require_relative 'pops/evaluator/literal_evaluator' require_relative 'pops/evaluator/callable_signature' diff --git a/lib/puppet/pops/evaluator/access_operator.rb b/lib/puppet/pops/evaluator/access_operator.rb index 711d32f7f5e..0790de83b16 100644 --- a/lib/puppet/pops/evaluator/access_operator.rb +++ b/lib/puppet/pops/evaluator/access_operator.rb @@ -126,7 +126,6 @@ def access_Array(o, scope, keys) end end - # Evaluates [] with support for one or more arguments. If more than one argument is used, the result # is an array with each lookup. # @note diff --git a/lib/puppet/pops/evaluator/compare_operator.rb b/lib/puppet/pops/evaluator/compare_operator.rb index e0d3fda891f..5989dddba2c 100644 --- a/lib/puppet/pops/evaluator/compare_operator.rb +++ b/lib/puppet/pops/evaluator/compare_operator.rb @@ -114,7 +114,6 @@ def cmp_Object(a, b) raise ArgumentError.new(_('Only Strings, Numbers, Timespans, Timestamps, and Versions are comparable')) end - def equals_Object(a, b) a == b end diff --git a/lib/puppet/pops/evaluator/evaluator_impl.rb b/lib/puppet/pops/evaluator/evaluator_impl.rb index 78ec6fd9d27..21970558d0c 100644 --- a/lib/puppet/pops/evaluator/evaluator_impl.rb +++ b/lib/puppet/pops/evaluator/evaluator_impl.rb @@ -390,7 +390,6 @@ def eval_ArithmeticExpression(o, scope) result end - # Handles binary expression where lhs and rhs are array/hash or numeric and operator is +, - , *, % / << >> # def calculate(left, right, bin_expr, scope) @@ -1098,7 +1097,6 @@ def eval_ConcatenatedString o, scope o.segments.collect {|expr| string(evaluate(expr, scope), scope)}.join end - # If the wrapped expression is a QualifiedName, it is taken as the name of a variable in scope. # Note that this is different from the 3.x implementation, where an initial qualified name # is accepted. (e.g. `"---${var + 1}---"` is legal. This implementation requires such concrete diff --git a/lib/puppet/pops/loader/loader.rb b/lib/puppet/pops/loader/loader.rb index 8b2517df5f1..08ab051eadb 100644 --- a/lib/puppet/pops/loader/loader.rb +++ b/lib/puppet/pops/loader/loader.rb @@ -202,7 +202,6 @@ def inspect self.to_s end - # An entry for one entity loaded by the loader. # class NamedEntry diff --git a/lib/puppet/pops/model/ast.rb b/lib/puppet/pops/model/ast.rb index 800ccb3f5d9..64f9be79747 100644 --- a/lib/puppet/pops/model/ast.rb +++ b/lib/puppet/pops/model/ast.rb @@ -28,6 +28,7 @@ def self.create def initialize @hash = 2270595461303489901 end + def _pcore_init_hash {} end diff --git a/lib/puppet/pops/model/ast_transformer.rb b/lib/puppet/pops/model/ast_transformer.rb index c95403cfd42..e09576f19cd 100644 --- a/lib/puppet/pops/model/ast_transformer.rb +++ b/lib/puppet/pops/model/ast_transformer.rb @@ -79,7 +79,6 @@ def hostname(o) @@hostname_transform_visitor.visit_this_0(self, o) end - # Ensures transformation fails if a 3.1 non supported object is encountered in a query expression # def query_Object(o) diff --git a/lib/puppet/pops/model/model_label_provider.rb b/lib/puppet/pops/model/model_label_provider.rb index b7ed7e5080a..33a383c8504 100644 --- a/lib/puppet/pops/model/model_label_provider.rb +++ b/lib/puppet/pops/model/model_label_provider.rb @@ -117,7 +117,6 @@ def label_Resource o 'Resource Statement' end - def label_Class o if o <= Types::PAnyType simple_name = o.name.split('::').last diff --git a/lib/puppet/pops/types/string_converter.rb b/lib/puppet/pops/types/string_converter.rb index a596c7c7f13..3d1c875c625 100644 --- a/lib/puppet/pops/types/string_converter.rb +++ b/lib/puppet/pops/types/string_converter.rb @@ -226,6 +226,7 @@ def self.type_rank(t) 0 end end + # Returns an array with a delimiter pair derived from the format. # If format does not contain a delimiter specification the given default is returned # diff --git a/lib/puppet/pops/types/type_formatter.rb b/lib/puppet/pops/types/type_formatter.rb index 4f28a40bc7a..8575fd94ac4 100644 --- a/lib/puppet/pops/types/type_formatter.rb +++ b/lib/puppet/pops/types/type_formatter.rb @@ -97,7 +97,6 @@ def ruby_string(ref_ctor, indent, t) end end - def append_default @bld << 'default' end @@ -332,7 +331,6 @@ def string_PPatternType(t) append_array('Pattern', t.patterns.empty?) { append_strings(t.patterns.map(&:regexp)) } end - # @api private def string_PCollectionType(t) range = range_array_part(t.size_type) diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index 780775c4e2e..d7d4517f360 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -1680,7 +1680,6 @@ def self.register_ptype(loader, ir) }) end - # Returns a new function that produces a Regexp instance # def self.new_function(type) @@ -3172,6 +3171,7 @@ def initialize(class_name) def hash 11 ^ @class_name.hash end + def eql?(o) self.class == o.class && @class_name == o.class_name end diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index 9ca6bb0d163..25310527c58 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -37,6 +37,7 @@ def self.post_resource_eval # be actively maintained. There may also be collisions with different # types (Users, Groups, Mounts, Hosts, etc...) def ds_to_ns_attribute_map; self.class.ds_to_ns_attribute_map; end + def self.ds_to_ns_attribute_map { 'RecordName' => :name, @@ -55,6 +56,7 @@ def self.ds_to_ns_attribute_map # JJM The same table as above, inverted. def ns_to_ds_attribute_map; self.class.ns_to_ds_attribute_map end + def self.ns_to_ds_attribute_map @ns_to_ds_attribute_map ||= ds_to_ns_attribute_map.invert end @@ -301,7 +303,6 @@ def self.next_system_id(id_type, min_id=20) end end - def ensure=(ensure_value) super # We need to loop over all valid properties for the type we're diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index 515586b74c4..efdaa9a3e60 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -289,7 +289,6 @@ def start self.disable if did_enable_job and resource[:enable] == :false end - def stop if resource[:stop] service_command(:stop) diff --git a/lib/puppet/provider/service/upstart.rb b/lib/puppet/provider/service/upstart.rb index 4cc88d276f1..36861f66bf8 100644 --- a/lib/puppet/provider/service/upstart.rb +++ b/lib/puppet/provider/service/upstart.rb @@ -67,7 +67,6 @@ def self.excludes excludes end - def self.get_services(exclude=[]) instances = [] execpipe("#{command(:initctl)} list") { |process| diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index 9db98ee83bf..271e7a6ddde 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -166,7 +166,6 @@ def keys=(keys_hash) run([command(:modify)] + build_keys_cmd(keys_hash) << @resource[:name], "modify attribute key pairs") end - # This helper makes it possible to test this on stub data without having to # do too many crazy things! def target_file_path diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index 31fd5fff50a..03711c261df 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -574,7 +574,6 @@ def self.type_and_title(type, title) [type, title] end - def self.extract_type_and_title(argtype, argtitle) if (argtype.nil? || argtype == :component || argtype == :whit) && argtitle =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ] diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index c2f486b52c8..dd17b1d3524 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -382,7 +382,6 @@ def self.clean_opt(opt, val) [opt, val] end - def app_defaults_initialized? @app_defaults_initialized end diff --git a/lib/puppet/settings/errors.rb b/lib/puppet/settings/errors.rb index 1f0b52c8fb6..653ea77da2a 100644 --- a/lib/puppet/settings/errors.rb +++ b/lib/puppet/settings/errors.rb @@ -6,6 +6,7 @@ class Puppet::Settings class SettingsError < Puppet::Error ; end class ValidationError < SettingsError ; end class InterpolationError < SettingsError ; end + class ParseError < SettingsError include Puppet::ExternalFileError end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 989f126b5d6..2358b469caa 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1218,7 +1218,6 @@ def self.hash2resource(hash) resource end - # Returns an array of strings representing the containment hierarchy # (types/classes) that make up the path to the resource from the root # of the catalog. This is mostly used for logging purposes. diff --git a/lib/puppet/type/file/target.rb b/lib/puppet/type/file/target.rb index 6b426d4de9c..302fd730aa4 100644 --- a/lib/puppet/type/file/target.rb +++ b/lib/puppet/type/file/target.rb @@ -71,7 +71,6 @@ def insync?(currentvalue) end end - def retrieve stat = @resource.stat if stat diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 26fee160b2e..bc2136047ac 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -102,7 +102,6 @@ def self.withumask(mask) end end - # Change the process to a different user def self.chuser group = Puppet[:group] diff --git a/lib/puppet/util/package/version/range/eq.rb b/lib/puppet/util/package/version/range/eq.rb index f47b5a4152b..65db90359a2 100644 --- a/lib/puppet/util/package/version/range/eq.rb +++ b/lib/puppet/util/package/version/range/eq.rb @@ -7,6 +7,7 @@ class Eq < Simple def to_s "#{@version}" end + def include?(version) version == @version end diff --git a/lib/puppet/util/package/version/range/gt.rb b/lib/puppet/util/package/version/range/gt.rb index 45abec7e42a..b52ff7acc33 100644 --- a/lib/puppet/util/package/version/range/gt.rb +++ b/lib/puppet/util/package/version/range/gt.rb @@ -7,6 +7,7 @@ class Gt < Simple def to_s ">#{@version}" end + def include?(version) version > @version end diff --git a/lib/puppet/util/package/version/range/gt_eq.rb b/lib/puppet/util/package/version/range/gt_eq.rb index 4b7316e3d6d..8ebfa83bfb9 100644 --- a/lib/puppet/util/package/version/range/gt_eq.rb +++ b/lib/puppet/util/package/version/range/gt_eq.rb @@ -7,6 +7,7 @@ class GtEq < Simple def to_s ">=#{@version}" end + def include?(version) version >= @version end diff --git a/lib/puppet/util/package/version/range/lt.rb b/lib/puppet/util/package/version/range/lt.rb index a4fbea97a20..fc8e4453ea8 100644 --- a/lib/puppet/util/package/version/range/lt.rb +++ b/lib/puppet/util/package/version/range/lt.rb @@ -7,6 +7,7 @@ class Lt< Simple def to_s "<#{@version}" end + def include?(version) version < @version end diff --git a/lib/puppet/util/package/version/range/lt_eq.rb b/lib/puppet/util/package/version/range/lt_eq.rb index 5db385cb30f..64301500d49 100644 --- a/lib/puppet/util/package/version/range/lt_eq.rb +++ b/lib/puppet/util/package/version/range/lt_eq.rb @@ -7,6 +7,7 @@ class LtEq < Simple def to_s "<=#{@version}" end + def include?(version) version <= @version end diff --git a/lib/puppet/util/package/version/range/min_max.rb b/lib/puppet/util/package/version/range/min_max.rb index 9888a922954..0fdd4b09847 100644 --- a/lib/puppet/util/package/version/range/min_max.rb +++ b/lib/puppet/util/package/version/range/min_max.rb @@ -8,12 +8,15 @@ def initialize(min, max) @min = min @max = max end + def to_s "#{@min} #{@max}" end + def to_gem_version "#{@min}, #{@max}" end + def include?(version) @min.include?(version) && @max.include?(version) end diff --git a/lib/puppet/util/windows.rb b/lib/puppet/util/windows.rb index 60d655aad5f..4e3505d8ca9 100644 --- a/lib/puppet/util/windows.rb +++ b/lib/puppet/util/windows.rb @@ -8,15 +8,20 @@ class User < ADSIObject; end class UserProfile; end class Group < ADSIObject; end end + module File; end + module Registry end + module Service DEFAULT_TIMEOUT = 30 end + module SID class Principal; end end + class EventLog; end if Puppet::Util::Platform.windows? diff --git a/lib/puppet/util/windows/adsi.rb b/lib/puppet/util/windows/adsi.rb index 5ed5f714044..360e83184d2 100644 --- a/lib/puppet/util/windows/adsi.rb +++ b/lib/puppet/util/windows/adsi.rb @@ -200,7 +200,6 @@ def name_sid_hash(names, allow_unresolved = false) Hash[ sids ] end - def delete(name) Puppet::Util::Windows::ADSI.delete(name, @object_class) end diff --git a/util/rspec_runner b/util/rspec_runner index c0fc11769b1..03f47d8a355 100755 --- a/util/rspec_runner +++ b/util/rspec_runner @@ -23,6 +23,7 @@ module Parallel dump_failure_info(example) end end + # # Responsible for running spec files given a spec file. # Can supply an optional list of additional options (used when running in CI). From 101b11789d16b0e95a3f02007955370c348df676 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 15:48:26 -0800 Subject: [PATCH 06/17] Layout/EmptyLines This commit enables the Rubocop Layout/EmptyLines cop. --- .rubocop_todo.yml | 4 ---- lib/puppet/agent/locker.rb | 1 - lib/puppet/application/apply.rb | 1 - lib/puppet/external/dot.rb | 1 - lib/puppet/face/epp.rb | 1 - lib/puppet/face/module/list.rb | 1 - lib/puppet/face/parser.rb | 1 - lib/puppet/file_system/uniquefile.rb | 1 - lib/puppet/file_system/windows.rb | 1 - lib/puppet/functions/index.rb | 1 - lib/puppet/functions/max.rb | 1 - lib/puppet/functions/min.rb | 1 - lib/puppet/functions/size.rb | 1 - lib/puppet/indirector/catalog/compiler.rb | 2 -- lib/puppet/interface.rb | 3 --- lib/puppet/interface/action.rb | 4 ---- lib/puppet/network/formats.rb | 2 -- lib/puppet/node/facts.rb | 1 - lib/puppet/pops/evaluator/access_operator.rb | 1 - lib/puppet/pops/evaluator/evaluator_impl.rb | 1 - lib/puppet/pops/loader/module_loaders.rb | 1 - lib/puppet/pops/model/pn_transformer.rb | 1 - lib/puppet/pops/parser/heredoc_support.rb | 2 -- lib/puppet/pops/parser/lexer2.rb | 1 - lib/puppet/pops/parser/lexer_support.rb | 1 - lib/puppet/pops/types/types.rb | 2 -- lib/puppet/provider/package/dnfmodule.rb | 1 - lib/puppet/provider/package/dpkg.rb | 1 - lib/puppet/provider/package/macports.rb | 1 - lib/puppet/provider/package/nim.rb | 5 ----- lib/puppet/provider/package/zypper.rb | 1 - lib/puppet/provider/user/directoryservice.rb | 2 -- lib/puppet/provider/user/pw.rb | 1 - lib/puppet/ssl/certificate.rb | 1 - lib/puppet/ssl/oids.rb | 1 - lib/puppet/test/test_helper.rb | 1 - lib/puppet/type.rb | 3 --- lib/puppet/type/exec.rb | 1 - lib/puppet/type/file/ensure.rb | 1 - lib/puppet/type/file/mode.rb | 1 - lib/puppet/type/file/selcontext.rb | 1 - lib/puppet/type/notify.rb | 1 - lib/puppet/type/package.rb | 1 - lib/puppet/type/service.rb | 1 - lib/puppet/type/whit.rb | 1 - lib/puppet/util.rb | 3 --- lib/puppet/util/constant_inflector.rb | 1 - lib/puppet/util/execution.rb | 3 --- lib/puppet/util/log.rb | 1 - .../util/rdoc/generators/template/puppet/puppet.rb | 14 -------------- lib/puppet/util/windows/adsi.rb | 1 - 51 files changed, 87 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c56dbf0af88..10742d2a35a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,10 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLines: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: around, only_before diff --git a/lib/puppet/agent/locker.rb b/lib/puppet/agent/locker.rb index cfbeae79c02..b0ac4162412 100644 --- a/lib/puppet/agent/locker.rb +++ b/lib/puppet/agent/locker.rb @@ -43,5 +43,4 @@ def lockfile end private :lockfile - end diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 1a7db86d2b1..f5bd0544c03 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -310,7 +310,6 @@ def setup Puppet.settings.use :main, :agent, :ssl - if Puppet[:catalog_cache_terminus] Puppet::Resource::Catalog.indirection.cache_class = Puppet[:catalog_cache_terminus] end diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb index 3e75baa90ec..eabf2a54c25 100644 --- a/lib/puppet/external/dot.rb +++ b/lib/puppet/external/dot.rb @@ -161,7 +161,6 @@ def each_option_pair end - # This is used when we build nodes that have shape=record # ports don't have options :) diff --git a/lib/puppet/face/epp.rb b/lib/puppet/face/epp.rb index d0dd2136571..7a69ff6c44a 100644 --- a/lib/puppet/face/epp.rb +++ b/lib/puppet/face/epp.rb @@ -102,7 +102,6 @@ end end - action(:dump) do summary _("Outputs a dump of the internal template parse tree for debugging") arguments "[--format ] [--pretty] { -e | [ ...] } " diff --git a/lib/puppet/face/module/list.rb b/lib/puppet/face/module/list.rb index 842d557566c..001c2b66279 100644 --- a/lib/puppet/face/module/list.rb +++ b/lib/puppet/face/module/list.rb @@ -106,7 +106,6 @@ end end - def unmet_dependencies(environment) error_types = [:non_semantic_version, :version_mismatch, :missing] diff --git a/lib/puppet/face/parser.rb b/lib/puppet/face/parser.rb index 746dce0064e..76458df462f 100644 --- a/lib/puppet/face/parser.rb +++ b/lib/puppet/face/parser.rb @@ -100,7 +100,6 @@ end end - action(:dump) do summary _("Outputs a dump of the internal parse tree for debugging") arguments "[--format ] [--pretty] { -e | [ ...] } " diff --git a/lib/puppet/file_system/uniquefile.rb b/lib/puppet/file_system/uniquefile.rb index e009f23906d..f430532dba2 100644 --- a/lib/puppet/file_system/uniquefile.rb +++ b/lib/puppet/file_system/uniquefile.rb @@ -161,7 +161,6 @@ def tmpdir File.expand_path(tmp) end - class << self # yields with locking for +tmpname+ and returns the result of the # block. diff --git a/lib/puppet/file_system/windows.rb b/lib/puppet/file_system/windows.rb index c69e209b4d5..1839a0d4b66 100644 --- a/lib/puppet/file_system/windows.rb +++ b/lib/puppet/file_system/windows.rb @@ -144,7 +144,6 @@ def replace_file(path, mode = nil) raise ArgumentError, "#{mode} is invalid: Only modes 0644, 0640, 0660, and 0440 are allowed" end - tempfile = Puppet::FileSystem::Uniquefile.new(Puppet::FileSystem.basename_string(path), Puppet::FileSystem.dir_string(path)) begin tempdacl = Puppet::Util::Windows::AccessControlList.new diff --git a/lib/puppet/functions/index.rb b/lib/puppet/functions/index.rb index 0ad17eb3a2f..fbac8754867 100644 --- a/lib/puppet/functions/index.rb +++ b/lib/puppet/functions/index.rb @@ -121,7 +121,6 @@ param 'Any', :match end - def index_Hash_1(hash) hash.each_pair { |x, y| return x if yield(y) } nil diff --git a/lib/puppet/functions/max.rb b/lib/puppet/functions/max.rb index ade7e1110cd..f025100e9a4 100644 --- a/lib/puppet/functions/max.rb +++ b/lib/puppet/functions/max.rb @@ -134,7 +134,6 @@ repeated_param 'Any', :values end - # All are Numeric - ok now, will be ok later def on_numeric(*args) assert_arg_count(args) diff --git a/lib/puppet/functions/min.rb b/lib/puppet/functions/min.rb index 2952ab21e84..4dcc0a2b881 100644 --- a/lib/puppet/functions/min.rb +++ b/lib/puppet/functions/min.rb @@ -133,7 +133,6 @@ repeated_param 'Any', :values end - # All are Numeric - ok now, will be ok later def on_numeric(*args) assert_arg_count(args) diff --git a/lib/puppet/functions/size.rb b/lib/puppet/functions/size.rb index 9afa1444281..f706cec7433 100644 --- a/lib/puppet/functions/size.rb +++ b/lib/puppet/functions/size.rb @@ -8,7 +8,6 @@ param 'Variant[Collection, String, Binary]', :arg end - def generic_size(arg) call_function('length', arg) end diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 9790b1158da..8b11cfea7f4 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -365,7 +365,6 @@ def compile(node, options) end end - config end @@ -384,7 +383,6 @@ def find_node(name, environment, transaction_uuid, configured_environment, facts raise Puppet::Error, message, detail.backtrace end - # Add any external data to the node. if node add_node_data(node) diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb index 16c5224445a..a3dab5e9a50 100644 --- a/lib/puppet/interface.rb +++ b/lib/puppet/interface.rb @@ -16,7 +16,6 @@ class Puppet::Interface require_relative 'interface/option_builder' require_relative 'interface/option_manager' - include FullDocs include Puppet::Interface::ActionManager @@ -121,7 +120,6 @@ def find_action(name, action, version = :current) # splits out this should merge into a module that both the action and face # include. --daniel 2011-04-17 - # Returns the synopsis for the face. This shows basic usage and global # options. # @return [String] usage synopsis @@ -130,7 +128,6 @@ def synopsis build_synopsis self.name, '' end - ######################################################################## # The name of the face diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index a30fcf78b76..6f856f41171 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -72,7 +72,6 @@ def synopsis ######################################################################## # Support for rendering formats and all. - # @api private def when_rendering(type) unless type.is_a? Symbol @@ -139,7 +138,6 @@ def __render_method_name_for(type) end private :__render_method_name_for - # @api private # @return [Symbol] attr_reader :render_as @@ -194,7 +192,6 @@ def deprecated? # @face.send(name, *args, &block) # end - # We need to build an instance method as a wrapper, using normal code, to be # able to expose argument defaulting between the caller and definer in the # Ruby API. An extra method is, sadly, required for Ruby 1.8 to work since @@ -214,7 +211,6 @@ def deprecated? # idea how motivated we were to make this cleaner. Sorry. # --daniel 2011-03-31 - # The arity of the action # @return [Integer] attr_reader :positional_arg_count diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index bdbe8d24854..4bec9c55aef 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -143,7 +143,6 @@ def data_to_instance(klass, data) # This is really only ever going to be used for Catalogs. Puppet::Network::FormatHandler.create_serialized_formats(:dot, :required_methods => [:render_method]) - Puppet::Network::FormatHandler.create(:console, :mime => 'text/x-console-text', :weight => 0) do @@ -253,7 +252,6 @@ def render_multiple(data) end end - Puppet::Network::FormatHandler.create(:rich_data_json, mime: 'application/vnd.puppet.rich+json', charset: Encoding::UTF_8, weight: 30) do def intern(klass, text) Puppet.override({:rich_data => true}) do diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb index 150a1d4dfbd..c0619b4120d 100644 --- a/lib/puppet/node/facts.rb +++ b/lib/puppet/node/facts.rb @@ -5,7 +5,6 @@ require_relative '../../puppet/indirector' require_relative '../../puppet/util/psych_support' - # Manage a given node's facts. This either accepts facts and stores them, or # returns facts for a given node. class Puppet::Node::Facts diff --git a/lib/puppet/pops/evaluator/access_operator.rb b/lib/puppet/pops/evaluator/access_operator.rb index 0790de83b16..6c45b3683c9 100644 --- a/lib/puppet/pops/evaluator/access_operator.rb +++ b/lib/puppet/pops/evaluator/access_operator.rb @@ -640,7 +640,6 @@ def access_PResourceType(o, scope, keys) return result_type_array ? result : result.pop end - keys = [:no_title] if keys.size < 1 # if there was only a type_name and it was consumed result = keys.each_with_index.map do |t, i| unless t.is_a?(String) || t == :no_title diff --git a/lib/puppet/pops/evaluator/evaluator_impl.rb b/lib/puppet/pops/evaluator/evaluator_impl.rb index 21970558d0c..20226b824f5 100644 --- a/lib/puppet/pops/evaluator/evaluator_impl.rb +++ b/lib/puppet/pops/evaluator/evaluator_impl.rb @@ -106,7 +106,6 @@ def evaluate(target, scope) fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e) end - rescue Puppet::Error => e # PuppetError has the ability to wrap an exception, if so, use the wrapped exception's # call stack instead diff --git a/lib/puppet/pops/loader/module_loaders.rb b/lib/puppet/pops/loader/module_loaders.rb index bfca2694e06..8381cbd8d07 100644 --- a/lib/puppet/pops/loader/module_loaders.rb +++ b/lib/puppet/pops/loader/module_loaders.rb @@ -104,7 +104,6 @@ class AbstractPathBasedModuleLoader < BaseLoader # The name of the module, or nil, if this is a global "component", or "any module" if set to the `NAMESPACE_WILDCARD` (*) attr_reader :module_name - # The path to the location of the module/component - semantics determined by subclass attr_reader :path diff --git a/lib/puppet/pops/model/pn_transformer.rb b/lib/puppet/pops/model/pn_transformer.rb index 63e8aada9d5..416de658d7d 100644 --- a/lib/puppet/pops/model/pn_transformer.rb +++ b/lib/puppet/pops/model/pn_transformer.rb @@ -4,7 +4,6 @@ module Puppet::Pops module Model - class PNTransformer extend Puppet::Concurrent::ThreadLocalSingleton diff --git a/lib/puppet/pops/parser/heredoc_support.rb b/lib/puppet/pops/parser/heredoc_support.rb index ac93e2cbbeb..6aff4ccd2da 100644 --- a/lib/puppet/pops/parser/heredoc_support.rb +++ b/lib/puppet/pops/parser/heredoc_support.rb @@ -9,7 +9,6 @@ module HeredocSupport # PATTERN_HEREDOC = %r{@\(([^:/\r\n\)]+)(?::[[:blank:]]*([a-z][a-zA-Z0-9_+]+)[[:blank:]]*)?(?:/((?:\w|[$])*)[[:blank:]]*)?\)} - def heredoc scn = @scanner ctx = @lexing_context @@ -94,7 +93,6 @@ def heredoc # Record position where next heredoc (from same line as current @()) should start scanning for content ctx[:newline_jump] = scn.pos - # Process captured lines - remove leading, and trailing newline # get processed string and index of removed margin/leading size per line str, margin_per_line = heredoc_text(lines, leading, has_margin, remove_break) diff --git a/lib/puppet/pops/parser/lexer2.rb b/lib/puppet/pops/parser/lexer2.rb index a48d1bdea65..d59cefb8e19 100644 --- a/lib/puppet/pops/parser/lexer2.rb +++ b/lib/puppet/pops/parser/lexer2.rb @@ -245,7 +245,6 @@ def initialize() emit(TOKEN_RBRACE, @scanner.pos) end, - # TOKENS @, @@, @( '@' => lambda do scn = @scanner diff --git a/lib/puppet/pops/parser/lexer_support.rb b/lib/puppet/pops/parser/lexer_support.rb index e12d8018699..23dc3447442 100644 --- a/lib/puppet/pops/parser/lexer_support.rb +++ b/lib/puppet/pops/parser/lexer_support.rb @@ -147,7 +147,6 @@ def to_s # end - MM = Puppet::Util::MultiMatch MM_ANY = MM::NOT_NIL diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index d7d4517f360..4ddf9d98cad 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -1367,7 +1367,6 @@ def eql?(o) self.class == o.class && @size_type == o.size_type end - DEFAULT_SIZE = PIntegerType.new(0) ZERO_SIZE = PIntegerType.new(0, 0) NOT_EMPTY_SIZE = PIntegerType.new(1) @@ -3193,7 +3192,6 @@ def _assignable?(o, guard) # For backward compatibility PHostClassType = PClassType - # Represents a Resource Type in the Puppet Language # @api public # diff --git a/lib/puppet/provider/package/dnfmodule.rb b/lib/puppet/provider/package/dnfmodule.rb index 8647293c11f..048c1404227 100644 --- a/lib/puppet/provider/package/dnfmodule.rb +++ b/lib/puppet/provider/package/dnfmodule.rb @@ -8,7 +8,6 @@ # flavor => 'client', # install a specific profile # } - require_relative '../../../puppet/provider/package' Puppet::Type.type(:package).provide :dnfmodule, :parent => :dnf do diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index 5d0db55045f..cec45f07354 100644 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -92,7 +92,6 @@ def install end args = [] - if @resource[:configfiles] == :keep args << '--force-confold' else diff --git a/lib/puppet/provider/package/macports.rb b/lib/puppet/provider/package/macports.rb index db72b2059a4..909a317b086 100644 --- a/lib/puppet/provider/package/macports.rb +++ b/lib/puppet/provider/package/macports.rb @@ -24,7 +24,6 @@ has_feature :upgradeable has_feature :versionable - def self.parse_installed_query_line(line) regex = /(\S+)\s+@(\S+)_(\d+).*\(active\)/ fields = [:name, :ensure, :revision] diff --git a/lib/puppet/provider/package/nim.rb b/lib/puppet/provider/package/nim.rb index b4f0965233a..4f412a0f9ca 100644 --- a/lib/puppet/provider/package/nim.rb +++ b/lib/puppet/provider/package/nim.rb @@ -27,8 +27,6 @@ attr_accessor :latest_info - - def self.srclistcmd(source) [ command(:nimclient), "-o", "showres", "-a", "installp_flags=L", "-a", "resource=#{source}" ] end @@ -91,7 +89,6 @@ def install(useversion = true) end output = Puppet::Util::Execution.execute(showres_command) - if (version_specified) package_type = determine_package_type(output, pkg, version) else @@ -146,7 +143,6 @@ def install(useversion = true) end end - private ## UTILITY METHODS FOR PARSING `nimclient -o showres` output @@ -181,7 +177,6 @@ def install(useversion = true) # @@R:mypackage.foo-1.2.3-4 1.2.3-4 # @@R:mypackage.foo-1.2.3-8 1.2.3-8 - # Parse the output of a `nimclient -o showres` command. Returns a two-dimensional # hash, where the first-level keys are package names, the second-level keys are # version number strings for all of the available version numbers for a package, diff --git a/lib/puppet/provider/package/zypper.rb b/lib/puppet/provider/package/zypper.rb index bd23120fe5a..44a56497cee 100644 --- a/lib/puppet/provider/package/zypper.rb +++ b/lib/puppet/provider/package/zypper.rb @@ -122,7 +122,6 @@ def install inst_opts = [] inst_opts = install_options if resource[:install_options] - options = [] options << quiet options << '--no-gpg-check' unless inst_opts.delete('--no-gpg-check').nil? diff --git a/lib/puppet/provider/user/directoryservice.rb b/lib/puppet/provider/user/directoryservice.rb index 18fcc0e36d4..5cf710bcc64 100644 --- a/lib/puppet/provider/user/directoryservice.rb +++ b/lib/puppet/provider/user/directoryservice.rb @@ -239,7 +239,6 @@ def self.get_sha1(guid) password_hash end - ## ## ## Ensurable Methods ## ## ## @@ -467,7 +466,6 @@ def salt=(value) end end - ## ## ## Helper Methods ## ## ## diff --git a/lib/puppet/provider/user/pw.rb b/lib/puppet/provider/user/pw.rb index 8f26bb02fdf..3db82ab644a 100644 --- a/lib/puppet/provider/user/pw.rb +++ b/lib/puppet/provider/user/pw.rb @@ -19,7 +19,6 @@ value.split("-").reverse.join("-") } - verify :gid, "GID must be an integer" do |value| value.is_a? Integer end diff --git a/lib/puppet/ssl/certificate.rb b/lib/puppet/ssl/certificate.rb index fd44f445159..cc3742e9325 100644 --- a/lib/puppet/ssl/certificate.rb +++ b/lib/puppet/ssl/certificate.rb @@ -62,7 +62,6 @@ def custom_extensions private - # Extract the extensions sequence from the wrapped certificate's raw ASN.1 form def exts_seq # See RFC-2459 section 4.1 (https://tools.ietf.org/html/rfc2459#section-4.1) diff --git a/lib/puppet/ssl/oids.rb b/lib/puppet/ssl/oids.rb index f9897724304..d2587e595dd 100644 --- a/lib/puppet/ssl/oids.rb +++ b/lib/puppet/ssl/oids.rb @@ -187,7 +187,6 @@ def self.subtree_of?(first, second, exclusive = false) first_oid = OpenSSL::ASN1::ObjectId.new(first).oid second_oid = OpenSSL::ASN1::ObjectId.new(second).oid - if exclusive and first_oid == second_oid false else diff --git a/lib/puppet/test/test_helper.rb b/lib/puppet/test/test_helper.rb index 134775fe363..bed71c9172b 100644 --- a/lib/puppet/test/test_helper.rb +++ b/lib/puppet/test/test_helper.rb @@ -196,7 +196,6 @@ def self.after_each_test() Puppet.rollback_context(ROLLBACK_MARK) end - ######################################################################################### # PRIVATE METHODS (not part of the public TestHelper API--do not call these from outside # of this class!) diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 2358b469caa..b95963c8713 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -15,7 +15,6 @@ # see the bottom of the file for the rest of the inclusions - module Puppet # The base class for all Puppet types. # @@ -1569,7 +1568,6 @@ def self.relationship_params RelationshipMetaparam.subclasses end - # Note that the order in which the relationships params is defined # matters. The labeled params (notify and subscribe) must be later, # so that if both params are used, those ones win. It's a hackish @@ -2291,7 +2289,6 @@ def log(msg) ) end - # instance methods related to instance intrinsics # e.g., initialize and name diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index c6295f62403..7066f0b480d 100644 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -379,7 +379,6 @@ def value=(*values) defaultto 0 end - newcheck(:refreshonly) do desc <<-'EOT' The command should only be run as a diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index dbf6a8e74d6..3fca1b01690 100644 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -97,7 +97,6 @@ module Puppet return :directory_created end - newvalue(:link, :event => :link_created, :required_features => :manages_symlinks) do property = resource.property(:target) fail "Cannot create a symlink without a target" unless property diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb index 8a837e02f52..aedd065bcbc 100644 --- a/lib/puppet/type/file/mode.rb +++ b/lib/puppet/type/file/mode.rb @@ -3,7 +3,6 @@ # for specification (e.g., u+rwx, or -0011), but for now only supports # specifying the full mode. - module Puppet Puppet::Type.type(:file).newproperty(:mode) do require_relative '../../../puppet/util/symbolic_file_mode' diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb index 4c51404fced..e3b961be86e 100644 --- a/lib/puppet/type/file/selcontext.rb +++ b/lib/puppet/type/file/selcontext.rb @@ -20,7 +20,6 @@ # # See https://www.nsa.gov/selinux/ for complete docs on SELinux. - module Puppet require_relative '../../../puppet/util/selinux' diff --git a/lib/puppet/type/notify.rb b/lib/puppet/type/notify.rb index 7be28669264..cb61e5d81b1 100644 --- a/lib/puppet/type/notify.rb +++ b/lib/puppet/type/notify.rb @@ -2,7 +2,6 @@ # # Simple module for logging messages on the client-side - module Puppet Type.newtype(:notify) do @doc = "Sends an arbitrary message, specified as a string, to the agent run-time log. It's important to note that the notify resource type is not idempotent. As a result, notifications are shown as a change on every Puppet run." diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 710ba396930..f9501edbd70 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -190,7 +190,6 @@ def insync?(is) self.debug "#{@resource.name} #{is.inspect} is installed, latest is #{@latest.inspect}" end - when :absent return true if is == :absent || is == :purged when :purged diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index c896803c250..c1a6c646808 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -5,7 +5,6 @@ # can only be managed through the interface of an init script # which is why they have a search path for initscripts and such - module Puppet Type.newtype(:service) do diff --git a/lib/puppet/type/whit.rb b/lib/puppet/type/whit.rb index 27efbf20703..9b4a6b76aa7 100644 --- a/lib/puppet/type/whit.rb +++ b/lib/puppet/type/whit.rb @@ -10,7 +10,6 @@ desc "The name of the whit, because it must have one." end - # Hide the fact that we're a whit from logs. # # I hate you, milkman whit. You are so painful, so often. diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index bc2136047ac..a756b226de1 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -608,7 +608,6 @@ def replace_file(file, default_mode, staging_location: nil, validate_callback: n tempfile = Puppet::FileSystem::Uniquefile.new(Puppet::FileSystem.basename_string(file), Puppet::FileSystem.dir_string(file)) end - effective_mode = if !Puppet::Util::Platform.windows? # Grab the current file mode, and fall back to the defaults. @@ -679,7 +678,6 @@ def replace_file(file, default_mode, staging_location: nil, validate_callback: n end end - # Ideally, we would now fsync the directory as well, but Ruby doesn't # have support for that, and it doesn't matter /that/ much... @@ -740,7 +738,6 @@ def skip_external_facts end end - require_relative 'util/errors' require_relative 'util/metaid' require_relative 'util/classgen' diff --git a/lib/puppet/util/constant_inflector.rb b/lib/puppet/util/constant_inflector.rb index b58bf980835..0feed2f3ba1 100644 --- a/lib/puppet/util/constant_inflector.rb +++ b/lib/puppet/util/constant_inflector.rb @@ -7,7 +7,6 @@ # A common module for converting between constants and # file names. - module Puppet module Util module ConstantInflector diff --git a/lib/puppet/util/execution.rb b/lib/puppet/util/execution.rb index 5f4921c7c21..78b160136ba 100644 --- a/lib/puppet/util/execution.rb +++ b/lib/puppet/util/execution.rb @@ -321,7 +321,6 @@ class << self alias util_execute execute end - # This is private method. # @comment see call to private_class_method after method definition # @api private @@ -375,7 +374,6 @@ def self.execute_posix(command, options, stdin, stdout, stderr) end private_class_method :execute_posix - # This is private method. # @comment see call to private_class_method after method definition # @api private @@ -392,7 +390,6 @@ def self.execute_windows(command, options, stdin, stdout, stderr) end private_class_method :execute_windows - # This is private method. # @comment see call to private_class_method after method definition # @api private diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index ca3259fdfa8..81091fd5823 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -294,7 +294,6 @@ def self.log_func(scope, level, vals) nil end - attr_accessor :time, :remote, :file, :line, :pos, :issue_code, :environment, :node, :backtrace attr_reader :level, :message, :source diff --git a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb index 54d5f025856..34e82ca12e7 100644 --- a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +++ b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb @@ -246,7 +246,6 @@ module Page .ruby-value { color: #7fffd4; background: transparent; } } - ##################################################################### ### H E A D E R T E M P L A T E ##################################################################### @@ -300,7 +299,6 @@ module Page } - ##################################################################### ### C O N T E X T C O N T E N T T E M P L A T E ##################################################################### @@ -308,7 +306,6 @@ module Page CONTEXT_CONTENT = %{ } - ##################################################################### ### F O O T E R T E M P L A T E ##################################################################### @@ -321,7 +318,6 @@ module Page } - ##################################################################### ### F I L E P A G E H E A D E R T E M P L A T E ##################################################################### @@ -346,7 +342,6 @@ module Page } - ##################################################################### ### C L A S S P A G E H E A D E R T E M P L A T E ##################################################################### @@ -468,7 +463,6 @@ module Page } - ##################################################################### ### M E T H O D L I S T T E M P L A T E ##################################################################### @@ -531,7 +525,6 @@ module Page END:sections } - METHOD_LIST = %{
@@ -847,7 +840,6 @@ module Page END:sections } - ##################################################################### ### B O D Y T E M P L A T E ##################################################################### @@ -876,8 +868,6 @@ module Page } + FOOTER - - ##################################################################### ### S O U R C E C O D E T E M P L A T E ##################################################################### @@ -895,7 +885,6 @@ module Page } - ##################################################################### ### I N D E X F I L E T E M P L A T E S ##################################################################### @@ -963,7 +952,6 @@ module Page } - CLASS_INDEX = FILE_INDEX METHOD_INDEX = FILE_INDEX @@ -1078,8 +1066,6 @@ module Page } - - end # module Page end # class RDoc diff --git a/lib/puppet/util/windows/adsi.rb b/lib/puppet/util/windows/adsi.rb index 360e83184d2..b0079ba1f33 100644 --- a/lib/puppet/util/windows/adsi.rb +++ b/lib/puppet/util/windows/adsi.rb @@ -367,7 +367,6 @@ def remove_from_groups(*group_names) end alias remove_from_group remove_from_groups - def add_group_sids(*sids) group_names = sids.map { |s| s.domain_account } add_to_groups(*group_names) From 0ef9c771fdf3a21e997fdf2547f16b1613c8fcd7 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 15:58:09 -0800 Subject: [PATCH 07/17] Layout/EmptyLinesAroundAccessModifier This commit enables the Rubocop Layout/EmptyLinesAroundAccessModifier cop. --- .rubocop_todo.yml | 6 ------ lib/puppet/file_bucket/dipper.rb | 1 + lib/puppet/file_system/posix.rb | 1 + lib/puppet/interface.rb | 2 ++ lib/puppet/interface/action.rb | 1 + lib/puppet/interface/action_builder.rb | 1 + lib/puppet/module_tool/applications/upgrader.rb | 1 + lib/puppet/pops/types/types.rb | 3 +++ lib/puppet/provider/file/windows.rb | 2 ++ lib/puppet/provider/package/portage.rb | 2 ++ lib/puppet/provider/package/rpm.rb | 1 + lib/puppet/provider/service/upstart.rb | 1 + lib/puppet/settings/file_setting.rb | 1 + lib/puppet/type/exec.rb | 1 + lib/puppet/util/inifile.rb | 1 + lib/puppet/util/posix.rb | 1 + lib/puppet/util/windows/eventlog.rb | 1 + util/rspec_grouper | 1 + 18 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 10742d2a35a..0fad8a09621 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,12 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: around, only_before -Layout/EmptyLinesAroundAccessModifier: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLinesAroundArguments: Exclude: diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index b258da6b1f5..6f3fa9cd2f0 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -168,6 +168,7 @@ def list(fromdate, todate) end private + def absolutize_path( path ) Pathname.new(path).realpath end diff --git a/lib/puppet/file_system/posix.rb b/lib/puppet/file_system/posix.rb index 7f690df6154..6b96248c67a 100644 --- a/lib/puppet/file_system/posix.rb +++ b/lib/puppet/file_system/posix.rb @@ -26,6 +26,7 @@ def compare_stream(path, stream) end private + def stream_blksize(*streams) streams.each do |s| next unless s.respond_to?(:stat) diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb index a3dab5e9a50..ab2c0b9fb15 100644 --- a/lib/puppet/interface.rb +++ b/lib/puppet/interface.rb @@ -198,7 +198,9 @@ def deprecated? # to be unrecognizable in the final outcome. At which point we will throw # all this away, replace it with something nice, and work out if we should # be making this visible to the outside world... --daniel 2011-04-14 + private + # @return [void] # @api private def __invoke_decorations(type, action, passed_args = [], passed_options = {}) diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 6f856f41171..18d7b0b35f2 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -395,6 +395,7 @@ def validate_and_clean(original) # Support code for action decoration; see puppet/interface.rb for the gory # details of why this is hidden away behind private. --daniel 2011-04-15 private + # @return [void] # @api private def __add_method(name, proc) diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb index 68ac69173a4..1c0b2e2d20f 100644 --- a/lib/puppet/interface/action_builder.rb +++ b/lib/puppet/interface/action_builder.rb @@ -150,6 +150,7 @@ def render_as(value = nil) end private + def initialize(face, name, &block) @face = face @action = Puppet::Interface::Action.new(face, name) diff --git a/lib/puppet/module_tool/applications/upgrader.rb b/lib/puppet/module_tool/applications/upgrader.rb index 97fddc21f6f..dd38132016f 100644 --- a/lib/puppet/module_tool/applications/upgrader.rb +++ b/lib/puppet/module_tool/applications/upgrader.rb @@ -220,6 +220,7 @@ def installed_release.priority end private + # rubocop:disable Naming/MemoizedInstanceVariableName def module_repository @repo ||= Puppet::Forge.new(Puppet[:module_repository]) diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index 4ddf9d98cad..4aae311c3e9 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -619,6 +619,7 @@ def callable_args?(callable_t, guard) DEFAULT = PUndefType.new protected + # @api private def _assignable?(o, guard) o.is_a?(PUndefType) @@ -680,6 +681,7 @@ def instance?(o, guard = nil) DEFAULT = PDefaultType.new protected + # @api private def _assignable?(o, guard) o.is_a?(PDefaultType) @@ -3142,6 +3144,7 @@ def instance?(o, guard = nil) end protected + # @api private def _assignable?(o, guard) o.is_a?(PCatalogEntryType) diff --git a/lib/puppet/provider/file/windows.rb b/lib/puppet/provider/file/windows.rb index 0eeb0ec0437..e0c46940555 100644 --- a/lib/puppet/provider/file/windows.rb +++ b/lib/puppet/provider/file/windows.rb @@ -135,7 +135,9 @@ def munge_windows_system_group(current, should) end attr_reader :file + private + def file @file ||= Puppet::FileSystem.pathname(resource[:path]) end diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb index 024811514de..1bdf6fcd785 100644 --- a/lib/puppet/provider/package/portage.rb +++ b/lib/puppet/provider/package/portage.rb @@ -239,6 +239,7 @@ def latest end private + def eix_get_version_for_versions(versions, target) # [2.7.10-r1,2.7.12,3.4.3-r1,3.4.5,3.5.2] 3.5.2 return nil if versions.nil? @@ -249,6 +250,7 @@ def eix_get_version_for_versions(versions, target) end private + def eix_get_version_for_slot(versions_and_slots, slot) # [2.7.12:2.7 3.4.5:3.4 3.5.2:3.5] 3.5 return nil if versions_and_slots.nil? diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb index 5a3633ac935..bfad001df37 100644 --- a/lib/puppet/provider/package/rpm.rb +++ b/lib/puppet/provider/package/rpm.rb @@ -195,6 +195,7 @@ def insync?(is) end private + # @param line [String] one line of rpm package query information # @return [Hash] of NEVRA_FIELDS strings parsed from package info # or an empty hash if we failed to parse diff --git a/lib/puppet/provider/service/upstart.rb b/lib/puppet/provider/service/upstart.rb index 36861f66bf8..da2eecdf603 100644 --- a/lib/puppet/provider/service/upstart.rb +++ b/lib/puppet/provider/service/upstart.rb @@ -192,6 +192,7 @@ def status end private + def is_upstart?(script = initscript) Puppet::FileSystem.exist?(script) && script.match(/\/etc\/init\/\S+\.conf/) end diff --git a/lib/puppet/settings/file_setting.rb b/lib/puppet/settings/file_setting.rb index 6fbba80add0..571be1d1f6b 100644 --- a/lib/puppet/settings/file_setting.rb +++ b/lib/puppet/settings/file_setting.rb @@ -49,6 +49,7 @@ def value end private + def safe_to_use_settings_value? @settings[:mkusers] or @settings.send(@available_method) end diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 7066f0b480d..62f81fb96df 100644 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -694,6 +694,7 @@ def current_username end private + def set_sensitive_parameters(sensitive_parameters) # If any are sensitive, mark all as sensitive sensitive = false diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb index ba9e2bab3ac..e140d77e1ce 100644 --- a/lib/puppet/util/inifile.rb +++ b/lib/puppet/util/inifile.rb @@ -95,6 +95,7 @@ def format end private + def find_entry(key) @entries.each do |entry| return entry if entry.is_a?(Array) && entry[0] == key diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index 1b45cd92daf..a9e216096ae 100644 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -34,6 +34,7 @@ def groups_of(user) end private + def get_groups_list(user) raise LoadError, "The 'getgrouplist' method is not available" unless Puppet::FFI::POSIX::Functions.respond_to?(:getgrouplist) diff --git a/lib/puppet/util/windows/eventlog.rb b/lib/puppet/util/windows/eventlog.rb index 94fb600b547..883774b9b49 100644 --- a/lib/puppet/util/windows/eventlog.rb +++ b/lib/puppet/util/windows/eventlog.rb @@ -103,6 +103,7 @@ def to_native(level) end private + # For the purposes of allowing this class to be standalone, the following are # duplicate definitions from elsewhere in Puppet: diff --git a/util/rspec_grouper b/util/rspec_grouper index 3b5c1fbd2de..b7eab2aa109 100755 --- a/util/rspec_grouper +++ b/util/rspec_grouper @@ -54,6 +54,7 @@ module Parallel end private + def count_examples(group) return 0 unless group # Each group can have examples as well as child groups, so recursively traverse From 1902d9da88cd4ab8695ea6397469791435cf06da Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:03:02 -0800 Subject: [PATCH 08/17] Layout/EmptyLinesAroundArguments This commit enables the Rubocop Layout/EmptyLinesAroundArguments cop. --- .rubocop_todo.yml | 13 ------------- lib/puppet/defaults.rb | 1 - lib/puppet/parser/functions/sprintf.rb | 1 - lib/puppet/settings.rb | 1 - lib/puppet/type.rb | 1 - lib/puppet/type/schedule.rb | 1 - lib/puppet/util/diff.rb | 1 - lib/puppet/util/rdoc/generators/puppet_generator.rb | 3 --- .../util/rdoc/generators/template/puppet/puppet.rb | 3 --- lib/puppet/util/windows/com.rb | 1 - 10 files changed, 26 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0fad8a09621..10ab8a47cf3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,19 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLinesAroundArguments: - Exclude: - - 'lib/puppet/defaults.rb' - - 'lib/puppet/parser/functions/sprintf.rb' - - 'lib/puppet/settings.rb' - - 'lib/puppet/type.rb' - - 'lib/puppet/type/schedule.rb' - - 'lib/puppet/util/diff.rb' - - 'lib/puppet/util/rdoc/generators/puppet_generator.rb' - - 'lib/puppet/util/rdoc/generators/template/puppet/puppet.rb' - - 'lib/puppet/util/windows/com.rb' - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowAliasSyntax, AllowedMethods. # AllowedMethods: alias_method, public, protected, private diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 8674ae36efc..10340ab921c 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -813,7 +813,6 @@ def self.initialize_default_settings!(settings) settings.define_settings( :main, - # We have to downcase the fqdn, because the current ssl stuff (as opposed to in master) doesn't have good facilities for # manipulating naming. :certname => { diff --git a/lib/puppet/parser/functions/sprintf.rb b/lib/puppet/parser/functions/sprintf.rb index cca836a7e86..0a46ebecbb0 100644 --- a/lib/puppet/parser/functions/sprintf.rb +++ b/lib/puppet/parser/functions/sprintf.rb @@ -42,7 +42,6 @@ ``` This statement produces a notice of `value is : 42`." - ) do |args| fmt = args[0] args = args[1..-1] diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index dd17b1d3524..0afd32b2525 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -1090,7 +1090,6 @@ def to_config The file format supports octothorpe-commented lines, but not partial-line comments. Generated on #{Time.now}. - }.gsub(/^/, "# ") # Add a section heading that matches our name. diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index b95963c8713..ebbab2650fe 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -2281,7 +2281,6 @@ def self.validate(&block) def log(msg) Puppet::Util::Log.create( - :level => @parameters[:loglevel].value, :message => msg, diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index be27da934e6..88e69111b19 100644 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -400,7 +400,6 @@ def self.mkdefaultschedules Puppet.debug "Creating default schedules" result << self.new( - :name => "puppet", :period => :hourly, diff --git a/lib/puppet/util/diff.rb b/lib/puppet/util/diff.rb index 4f48472cbe1..7841b6f8fcd 100644 --- a/lib/puppet/util/diff.rb +++ b/lib/puppet/util/diff.rb @@ -48,7 +48,6 @@ def lcs_diff(data_old, data_new, format=:unified, context_lines=3) hunk = ::Diff::LCS::Hunk.new( data_old, data_new, piece, context_lines, - file_length_difference) file_length_difference = hunk.file_length_difference next unless oldhunk diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index e530f9cefff..df19cfb4c53 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -242,7 +242,6 @@ def gen_class_index gen_composite_index( file, RDoc::Page::COMBO_INDEX, - "#{MODULE_DIR}/fr_#{file["file"].context.module_name}.html") end end @@ -502,7 +501,6 @@ def write_on(f) template = TemplatePage.new( RDoc::Page::BODYINC, RDoc::Page::NODE_PAGE, - RDoc::Page::METHOD_LIST) template.write_html_on(f, @values) end @@ -746,7 +744,6 @@ def write_on(f) template = TemplatePage.new( RDoc::Page::BODYINC, RDoc::Page::PLUGIN_PAGE, - RDoc::Page::PLUGIN_LIST) template.write_html_on(f, @values) end diff --git a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb index 34e82ca12e7..2e2e61bc856 100644 --- a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +++ b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb @@ -849,11 +849,9 @@ module Page !INCLUDE!
- } + METHOD_LIST + %{
- } + FOOTER BODYINC = HEADER + %{ @@ -865,7 +863,6 @@ module Page !INCLUDE!
- } + FOOTER ##################################################################### diff --git a/lib/puppet/util/windows/com.rb b/lib/puppet/util/windows/com.rb index 365dbc12622..f8aa36af62c 100644 --- a/lib/puppet/util/windows/com.rb +++ b/lib/puppet/util/windows/com.rb @@ -196,7 +196,6 @@ def initialize(opts = {}) IUnknown = Interface[ FFI::WIN32::GUID['00000000-0000-0000-C000-000000000046'], - QueryInterface: [[:pointer, :pointer], :hresult], AddRef: [[], :win32_ulong], Release: [[], :win32_ulong] From ab6facdc74700f1c297ad8fdb58ed87f71a38137 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:05:40 -0800 Subject: [PATCH 09/17] Layout/EmptyLinesAroundAttributeAccessor This commit enables the Rubocop Layout/EmptyLinesAroundAttributeAccessor cop and fixes all offenses. --- .rubocop_todo.yml | 6 ------ lib/puppet/confine.rb | 1 + lib/puppet/confine_collection.rb | 1 + lib/puppet/error.rb | 1 + lib/puppet/file_serving/base.rb | 3 +++ lib/puppet/file_serving/configuration.rb | 1 + lib/puppet/graph/rb_tree_map.rb | 1 + lib/puppet/interface/action.rb | 3 +++ lib/puppet/interface/documentation.rb | 2 ++ lib/puppet/interface/option.rb | 3 +++ lib/puppet/module/plan.rb | 1 + lib/puppet/module/task.rb | 1 + lib/puppet/module_tool/install_directory.rb | 1 + lib/puppet/parser/ast/leaf.rb | 1 + lib/puppet/parser/ast/resource_instance.rb | 1 + lib/puppet/pops/evaluator/closure.rb | 1 + lib/puppet/pops/evaluator/relationship_operator.rb | 2 ++ lib/puppet/pops/issues.rb | 1 + lib/puppet/pops/loader/static_loader.rb | 1 + lib/puppet/pops/model/ast_transformer.rb | 1 + lib/puppet/pops/model/factory.rb | 1 + lib/puppet/pops/model/tree_dumper.rb | 1 + lib/puppet/pops/pn.rb | 2 ++ lib/puppet/pops/serialization/extension.rb | 6 ++++++ lib/puppet/pops/validation.rb | 3 +++ lib/puppet/pops/visitor.rb | 1 + lib/puppet/provider/package/windows.rb | 1 + lib/puppet/ssl/error.rb | 1 + lib/puppet/type.rb | 1 + lib/puppet/type/exec.rb | 1 + lib/puppet/type/file/source.rb | 1 + lib/puppet/util/docs.rb | 1 + lib/puppet/util/filetype.rb | 1 + lib/puppet/util/windows/adsi.rb | 1 + 34 files changed, 49 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 10ab8a47cf3..f9bedf43fcb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,12 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowAliasSyntax, AllowedMethods. -# AllowedMethods: alias_method, public, protected, private -Layout/EmptyLinesAroundAttributeAccessor: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLinesAroundBeginBody: Exclude: diff --git a/lib/puppet/confine.rb b/lib/puppet/confine.rb index bffb2c573b3..a7b1515be4c 100644 --- a/lib/puppet/confine.rb +++ b/lib/puppet/confine.rb @@ -42,6 +42,7 @@ def self.test(name) # Mark that this confine is used for testing binary existence. attr_accessor :for_binary + def for_binary? for_binary end diff --git a/lib/puppet/confine_collection.rb b/lib/puppet/confine_collection.rb index f7b77f940fc..0abbd48aea6 100644 --- a/lib/puppet/confine_collection.rb +++ b/lib/puppet/confine_collection.rb @@ -26,6 +26,7 @@ def confine(hash) end attr_reader :label + def initialize(label) @label = label @confines = [] diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb index 6e7ee775c05..3625dedf09f 100644 --- a/lib/puppet/error.rb +++ b/lib/puppet/error.rb @@ -3,6 +3,7 @@ module Puppet # The base class for all Puppet errors. It can wrap another exception class Error < RuntimeError attr_accessor :original + def initialize(message, original=nil) super(message.scrub) @original = original diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 081494cb4ef..5b2b95c1c60 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -44,6 +44,7 @@ def initialize(path, links: nil, relative_path: nil, source: nil) # Determine how we deal with links. attr_reader :links + def links=(value) value = value.to_sym value = :manage if value == :ignore @@ -54,6 +55,7 @@ def links=(value) # Set our base path. attr_reader :path + def path=(path) raise ArgumentError.new(_("Paths must be fully qualified")) unless Puppet::FileServing::Base.absolute?(path) @path = path @@ -62,6 +64,7 @@ def path=(path) # Set a relative path; this is used for recursion, and sets # the file's path relative to the initial recursion point. attr_reader :relative_path + def relative_path=(path) raise ArgumentError.new(_("Relative paths must not be fully qualified")) if Puppet::FileServing::Base.absolute?(path) @relative_path = path diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index c29e56e300b..8329a7d76e2 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -22,6 +22,7 @@ def self.configuration private_class_method :new attr_reader :mounts + #private :mounts # Find the right mount. Does some shenanigans to support old-style module diff --git a/lib/puppet/graph/rb_tree_map.rb b/lib/puppet/graph/rb_tree_map.rb index 7fc69c6ef87..63a2e154d0d 100644 --- a/lib/puppet/graph/rb_tree_map.rb +++ b/lib/puppet/graph/rb_tree_map.rb @@ -198,6 +198,7 @@ def to_hash class Node # :nodoc: all attr_accessor :color, :key, :value, :left, :right + def initialize(key, value) @key = key @value = value diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 18d7b0b35f2..730a47e2113 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -57,6 +57,7 @@ def to_s() "#{@face}##{@name}" end # @return [Boolean] # @api private attr_accessor :default + def default? !!@default end @@ -141,6 +142,7 @@ def __render_method_name_for(type) # @api private # @return [Symbol] attr_reader :render_as + def render_as=(value) @render_as = value.to_sym end @@ -218,6 +220,7 @@ def deprecated? # The block that is executed when the action is invoked # @return [block] attr_reader :when_invoked + def when_invoked=(block) internal_name = "#{@name} implementation, required on Ruby 1.8".to_sym diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index 433a3a8a5b4..c50ffa9b0a6 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -267,6 +267,7 @@ def copyright(owner = nil, years = nil) # @return [String] Comma-separated list of copyright owners # @api private attr_reader :copyright_owner + def copyright_owner=(value) case value when String then @copyright_owner = value @@ -283,6 +284,7 @@ def copyright_owner=(value) # @return [String] # @api private attr_reader :copyright_years + def copyright_years=(value) years = munge_copyright_year value years = (years.is_a?(Array) ? years : [years]) diff --git a/lib/puppet/interface/option.rb b/lib/puppet/interface/option.rb index 02e26a5207d..4cf143636a0 100644 --- a/lib/puppet/interface/option.rb +++ b/lib/puppet/interface/option.rb @@ -135,6 +135,7 @@ def default end attr_reader :parent, :name, :aliases, :optparse, :required + def required=(value) if has_default? raise ArgumentError, _("%{name} can't be optional and have a default value") % { name: self } @@ -143,6 +144,7 @@ def required=(value) end attr_reader :before_action + def before_action=(proc) unless proc.is_a? Proc #TRANSLATORS 'proc' is a Ruby block of code @@ -154,6 +156,7 @@ def before_action=(proc) end attr_reader :after_action + def after_action=(proc) unless proc.is_a? Proc #TRANSLATORS 'proc' is a Ruby block of code diff --git a/lib/puppet/module/plan.rb b/lib/puppet/module/plan.rb index 843242ec4c9..e9792dc0192 100644 --- a/lib/puppet/module/plan.rb +++ b/lib/puppet/module/plan.rb @@ -5,6 +5,7 @@ class Puppet::Module class Plan class Error < Puppet::Error attr_accessor :kind, :details + def initialize(message, kind, details = nil) super(message) @details = details || {} diff --git a/lib/puppet/module/task.rb b/lib/puppet/module/task.rb index a551e109cd8..47a419f4eda 100644 --- a/lib/puppet/module/task.rb +++ b/lib/puppet/module/task.rb @@ -5,6 +5,7 @@ class Puppet::Module class Task class Error < Puppet::Error attr_accessor :kind, :details + def initialize(message, kind, details = nil) super(message) @details = details || {} diff --git a/lib/puppet/module_tool/install_directory.rb b/lib/puppet/module_tool/install_directory.rb index 47570ae9208..3b76bb97246 100644 --- a/lib/puppet/module_tool/install_directory.rb +++ b/lib/puppet/module_tool/install_directory.rb @@ -9,6 +9,7 @@ class InstallDirectory include Puppet::ModuleTool::Errors attr_reader :target + def initialize(target) @target = target end diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index 1973239c6ce..c97c9c77afe 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -5,6 +5,7 @@ # class Puppet::Parser::AST::Leaf < Puppet::Parser::AST attr_accessor :value, :type + # Return our value. def evaluate(scope) @value diff --git a/lib/puppet/parser/ast/resource_instance.rb b/lib/puppet/parser/ast/resource_instance.rb index fc71321982d..13f43516916 100644 --- a/lib/puppet/parser/ast/resource_instance.rb +++ b/lib/puppet/parser/ast/resource_instance.rb @@ -4,6 +4,7 @@ # class Puppet::Parser::AST::ResourceInstance < Puppet::Parser::AST::Branch attr_accessor :title, :parameters + def initialize(argshash) Puppet.warn_once('deprecations', 'AST::ResourceInstance', _('Use of Puppet::Parser::AST::ResourceInstance is deprecated')) super(argshash) diff --git a/lib/puppet/pops/evaluator/closure.rb b/lib/puppet/pops/evaluator/closure.rb index a44cff09fe3..3a0e7dd55d0 100644 --- a/lib/puppet/pops/evaluator/closure.rb +++ b/lib/puppet/pops/evaluator/closure.rb @@ -5,6 +5,7 @@ class Jumper < Exception # rubocop:disable Lint/InheritException attr_reader :value attr_reader :file attr_reader :line + def initialize(value, file, line) @value = value @file = file diff --git a/lib/puppet/pops/evaluator/relationship_operator.rb b/lib/puppet/pops/evaluator/relationship_operator.rb index ca69ecaa3f1..65c70666f5f 100644 --- a/lib/puppet/pops/evaluator/relationship_operator.rb +++ b/lib/puppet/pops/evaluator/relationship_operator.rb @@ -18,6 +18,7 @@ class RelationshipOperator class IllegalRelationshipOperandError < RuntimeError attr_reader :operand + def initialize operand @operand = operand end @@ -25,6 +26,7 @@ def initialize operand class NotCatalogTypeError < RuntimeError attr_reader :type + def initialize type @type = type end diff --git a/lib/puppet/pops/issues.rb b/lib/puppet/pops/issues.rb index b6196365681..48b0f20bfe4 100644 --- a/lib/puppet/pops/issues.rb +++ b/lib/puppet/pops/issues.rb @@ -23,6 +23,7 @@ class Issue # If this issue can have its severity lowered to :warning, :deprecation, or :ignored attr_writer :demotable + # Configures the Issue with required arguments (bound by occurrence), and a block producing a message. def initialize issue_code, *args, &block @issue_code = issue_code diff --git a/lib/puppet/pops/loader/static_loader.rb b/lib/puppet/pops/loader/static_loader.rb index 603ab5712a7..10f269bf48e 100644 --- a/lib/puppet/pops/loader/static_loader.rb +++ b/lib/puppet/pops/loader/static_loader.rb @@ -37,6 +37,7 @@ class StaticLoader < Loader }.freeze attr_reader :loaded + def initialize @loaded = {} @runtime_3_initialized = false diff --git a/lib/puppet/pops/model/ast_transformer.rb b/lib/puppet/pops/model/ast_transformer.rb index e09576f19cd..76e9bf89b1c 100644 --- a/lib/puppet/pops/model/ast_transformer.rb +++ b/lib/puppet/pops/model/ast_transformer.rb @@ -11,6 +11,7 @@ class Puppet::Pops::Model::AstTransformer Model = Puppet::Pops::Model attr_reader :importer + def initialize(source_file = "unknown-file", importer=nil) @@transform_visitor ||= Puppet::Pops::Visitor.new(nil,"transform",0,0) @@query_transform_visitor ||= Puppet::Pops::Visitor.new(nil,"query",0,0) diff --git a/lib/puppet/pops/model/factory.rb b/lib/puppet/pops/model/factory.rb index 3bddf4d426f..e04ef5399d9 100644 --- a/lib/puppet/pops/model/factory.rb +++ b/lib/puppet/pops/model/factory.rb @@ -994,6 +994,7 @@ def self.name_is_statement?(name) class ArgsToNonCallError < RuntimeError attr_reader :args, :name_expr + def initialize(args, name_expr) @args = args @name_expr = name_expr diff --git a/lib/puppet/pops/model/tree_dumper.rb b/lib/puppet/pops/model/tree_dumper.rb index 0103886fa60..3ddf3cc97fc 100644 --- a/lib/puppet/pops/model/tree_dumper.rb +++ b/lib/puppet/pops/model/tree_dumper.rb @@ -3,6 +3,7 @@ # class Puppet::Pops::Model::TreeDumper attr_accessor :indent_count + def initialize initial_indentation = 0 @@dump_visitor ||= Puppet::Pops::Visitor.new(nil,"dump",0,0) @indent_count = initial_indentation diff --git a/lib/puppet/pops/pn.rb b/lib/puppet/pops/pn.rb index be46c522e50..0ab1e48c3ab 100644 --- a/lib/puppet/pops/pn.rb +++ b/lib/puppet/pops/pn.rb @@ -69,6 +69,7 @@ def format_elements(elements, indent, b) class Indent attr_reader :current + def initialize(indent = ' ', current = '') @indent = indent @current = current @@ -120,6 +121,7 @@ def to_data class Entry attr_reader :key, :value + def initialize(key, value) @key = key @value = value diff --git a/lib/puppet/pops/serialization/extension.rb b/lib/puppet/pops/serialization/extension.rb index 04839481755..8cc817492e4 100644 --- a/lib/puppet/pops/serialization/extension.rb +++ b/lib/puppet/pops/serialization/extension.rb @@ -49,6 +49,7 @@ class Default class Tabulation include NotTabulated attr_reader :index + def initialize(index) @index = index end @@ -63,6 +64,7 @@ class MapStart include NotTabulated include SequenceStart attr_reader :size + def initialize(size) @size = size end @@ -78,6 +80,7 @@ class ArrayStart include NotTabulated include SequenceStart attr_reader :size + def initialize(size) @size = size end @@ -98,6 +101,7 @@ class SensitiveStart class PcoreObjectStart include SequenceStart attr_reader :type_name, :attribute_count + def initialize(type_name, attribute_count) @type_name = type_name @attribute_count = attribute_count @@ -120,6 +124,7 @@ def sequence_size class ObjectStart include SequenceStart attr_reader :attribute_count + def initialize(attribute_count) @attribute_count = attribute_count end @@ -141,6 +146,7 @@ def sequence_size # The class that triggers the use of the COMMENT extension. The payload is comment text class Comment attr_reader :comment + def initialize(comment) @comment = comment end diff --git a/lib/puppet/pops/validation.rb b/lib/puppet/pops/validation.rb index 8cd2d8e2a03..fa1d77995e3 100644 --- a/lib/puppet/pops/validation.rb +++ b/lib/puppet/pops/validation.rb @@ -179,6 +179,7 @@ class DiagnosticProducer # @return [LabelProvider] # attr_reader :label_provider + # Initializes this producer. # # @param acceptor [Acceptor] a sink/collector of diagnostic results @@ -229,6 +230,7 @@ class Diagnostic attr_reader :exception attr_reader :file attr_reader :source_pos + def initialize severity, issue, file, source_pos, arguments={}, exception=nil @severity = severity @issue = issue @@ -362,6 +364,7 @@ class Acceptor # The number of :error severity issues attr_reader :error_count + # Initializes this diagnostics acceptor. # By default, the acceptor is configured with a default severity producer. # @param severity_producer [SeverityProducer] the severity producer to use to determine severity of an issue diff --git a/lib/puppet/pops/visitor.rb b/lib/puppet/pops/visitor.rb index 0332c9f95dd..41f4c141745 100644 --- a/lib/puppet/pops/visitor.rb +++ b/lib/puppet/pops/visitor.rb @@ -13,6 +13,7 @@ module Puppet::Pops # class Visitor attr_reader :receiver, :message, :min_args, :max_args, :cache + def initialize(receiver, message, min_args=0, max_args=nil) raise ArgumentError.new("min_args must be >= 0") if min_args < 0 raise ArgumentError.new("max_args must be >= min_args or nil") if max_args && max_args < min_args diff --git a/lib/puppet/provider/package/windows.rb b/lib/puppet/provider/package/windows.rb index 3b01329b2cb..3759474e7bc 100644 --- a/lib/puppet/provider/package/windows.rb +++ b/lib/puppet/provider/package/windows.rb @@ -31,6 +31,7 @@ has_feature :versionable attr_accessor :package + class << self attr_accessor :paths end diff --git a/lib/puppet/ssl/error.rb b/lib/puppet/ssl/error.rb index a7443fd6b47..904ca168aa3 100644 --- a/lib/puppet/ssl/error.rb +++ b/lib/puppet/ssl/error.rb @@ -4,6 +4,7 @@ class SSLError < Puppet::Error; end class CertVerifyError < Puppet::SSL::SSLError attr_reader :code, :cert + def initialize(message, code, cert) super(message) @code = code diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index ebbab2650fe..ff40c73199f 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -2188,6 +2188,7 @@ class << self # @return [Boolean] true if the type should send itself a refresh event on change. # attr_accessor :self_refresh + include Enumerable, Puppet::Util::ClassGen include Puppet::Util diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 62f81fb96df..de348706734 100644 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -95,6 +95,7 @@ def event_name defaultto "0" attr_reader :output + desc "The expected exit code(s). An error will be returned if the executed command has some other exit code. Can be specified as an array of acceptable exit codes or a single value. diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index f23e0c62f2f..ec91e26c80e 100644 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -14,6 +14,7 @@ module Puppet Puppet::Type.type(:file).newparam(:source) do attr_accessor :source, :local + desc <<-'EOT' A source file, which will be copied into place on the local system. This attribute is mutually exclusive with `content` and `target`. Allowed diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb index 2fea6c7cb05..170e2864956 100644 --- a/lib/puppet/util/docs.rb +++ b/lib/puppet/util/docs.rb @@ -66,6 +66,7 @@ def doctable(headers, data) # There is nothing that would ever set this. It gets read in reference/type.rb, but will never have any value but nil. attr_reader :nodoc + def nodoc? nodoc end diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index 25487bb1331..392e9c67955 100644 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -15,6 +15,7 @@ class FileReadError < Puppet::Error; end class << self attr_accessor :name + include Puppet::Util::ClassGen end diff --git a/lib/puppet/util/windows/adsi.rb b/lib/puppet/util/windows/adsi.rb index b0079ba1f33..09a5b75c98d 100644 --- a/lib/puppet/util/windows/adsi.rb +++ b/lib/puppet/util/windows/adsi.rb @@ -250,6 +250,7 @@ def each(&block) end attr_reader :name + def initialize(name, native_object = nil) @name = name @native_object = native_object From 683c6bca22c7bdcda26f8cc616fd818a1f17050e Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:09:36 -0800 Subject: [PATCH 10/17] Layout/EmptyLinesAroundBeginBody This commit enables the Rubocop Layout/EmptyLinesAroundBeginBody cop and fixes the two offenses. --- .rubocop_todo.yml | 6 ------ lib/puppet/util/diff.rb | 1 - lib/puppet/util/retry_action.rb | 1 - 3 files changed, 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f9bedf43fcb..b7ed9dd1a73 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,12 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLinesAroundBeginBody: - Exclude: - - 'lib/puppet/util/diff.rb' - - 'lib/puppet/util/retry_action.rb' - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines diff --git a/lib/puppet/util/diff.rb b/lib/puppet/util/diff.rb index 7841b6f8fcd..1fe473f207b 100644 --- a/lib/puppet/util/diff.rb +++ b/lib/puppet/util/diff.rb @@ -44,7 +44,6 @@ def lcs_diff(data_old, data_new, format=:unified, context_lines=3) diffs.each do |piece| begin - hunk = ::Diff::LCS::Hunk.new( data_old, data_new, piece, context_lines, diff --git a/lib/puppet/util/retry_action.rb b/lib/puppet/util/retry_action.rb index d0843e19a9e..bfc22a8a079 100644 --- a/lib/puppet/util/retry_action.rb +++ b/lib/puppet/util/retry_action.rb @@ -41,7 +41,6 @@ def self.retry_action(options = {}) sleep(((2 ** failures) -1) * 0.1) retry - end end end From 175e6cf275618a1dc04890fbac2805715385739c Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:11:58 -0800 Subject: [PATCH 11/17] Layout/EmptyLinesAroundBlockBody This commit enables the Rubocop Layout/EmptyLinesAroundBlockBody cop and addresses all offenses. --- .rubocop_todo.yml | 6 ------ lib/puppet/confine_collection.rb | 1 - lib/puppet/face/config.rb | 3 --- lib/puppet/face/epp.rb | 2 -- lib/puppet/face/help.rb | 1 - lib/puppet/face/node/clean.rb | 1 - lib/puppet/functions.rb | 1 - lib/puppet/functions/call.rb | 1 - lib/puppet/functions/camelcase.rb | 1 - lib/puppet/functions/capitalize.rb | 1 - lib/puppet/functions/ceiling.rb | 1 - lib/puppet/functions/chomp.rb | 1 - lib/puppet/functions/chop.rb | 1 - lib/puppet/functions/defined.rb | 1 - lib/puppet/functions/epp.rb | 1 - lib/puppet/functions/floor.rb | 1 - lib/puppet/functions/inline_epp.rb | 1 - lib/puppet/functions/length.rb | 1 - lib/puppet/functions/lookup.rb | 2 -- lib/puppet/functions/lstrip.rb | 1 - lib/puppet/functions/new.rb | 1 - lib/puppet/functions/reduce.rb | 1 - lib/puppet/functions/rstrip.rb | 1 - lib/puppet/functions/size.rb | 1 - lib/puppet/functions/strip.rb | 1 - lib/puppet/functions/tree_each.rb | 1 - lib/puppet/functions/versioncmp.rb | 1 - lib/puppet/module_tool/applications/checksummer.rb | 1 - lib/puppet/network/formats.rb | 2 -- lib/puppet/parser/ast/resource.rb | 1 - lib/puppet/parser/functions/epp.rb | 1 - lib/puppet/parser/functions/generate.rb | 1 - lib/puppet/parser/functions/inline_epp.rb | 1 - lib/puppet/parser/functions/inline_template.rb | 1 - lib/puppet/parser/functions/realize.rb | 1 - lib/puppet/parser/functions/split.rb | 1 - lib/puppet/parser/functions/versioncmp.rb | 1 - lib/puppet/parser/script_compiler.rb | 1 - lib/puppet/pops/lookup/global_data_provider.rb | 1 - lib/puppet/pops/types/p_object_type.rb | 2 -- lib/puppet/pops/types/p_sensitive_type.rb | 1 - lib/puppet/pops/types/types.rb | 2 -- lib/puppet/provider/exec/windows.rb | 1 - lib/puppet/provider/group/directoryservice.rb | 1 - lib/puppet/provider/package/dnfmodule.rb | 1 - lib/puppet/provider/package/dpkg.rb | 1 - lib/puppet/provider/package/hpux.rb | 1 - lib/puppet/provider/package/pacman.rb | 1 - lib/puppet/provider/package/pip.rb | 1 - lib/puppet/provider/package/pip2.rb | 1 - lib/puppet/provider/package/pip3.rb | 1 - lib/puppet/provider/package/pkgin.rb | 1 - lib/puppet/provider/package/pkgng.rb | 1 - lib/puppet/provider/service/freebsd.rb | 2 -- lib/puppet/provider/service/openbsd.rb | 1 - lib/puppet/provider/service/openrc.rb | 1 - lib/puppet/provider/service/openwrt.rb | 1 - lib/puppet/provider/service/src.rb | 2 -- lib/puppet/provider/service/windows.rb | 1 - lib/puppet/provider/user/user_role_add.rb | 1 - lib/puppet/reference/type.rb | 1 - lib/puppet/reports/http.rb | 1 - lib/puppet/type/file.rb | 1 - lib/puppet/type/file/checksum_value.rb | 1 - lib/puppet/type/file/source.rb | 1 - lib/puppet/type/group.rb | 1 - lib/puppet/type/schedule.rb | 1 - lib/puppet/type/user.rb | 1 - lib/puppet/util/rdoc/generators/puppet_generator.rb | 1 - lib/puppet/util/windows/principal.rb | 2 -- lib/puppet/util/windows/registry.rb | 1 - lib/puppet/util/windows/security.rb | 3 --- lib/puppet/util/windows/sid.rb | 1 - 73 files changed, 90 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b7ed9dd1a73..74badcbc921 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,12 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only diff --git a/lib/puppet/confine_collection.rb b/lib/puppet/confine_collection.rb index 0abbd48aea6..b5d09503482 100644 --- a/lib/puppet/confine_collection.rb +++ b/lib/puppet/confine_collection.rb @@ -42,7 +42,6 @@ def summary value = klass.summarize(list) next if (value.respond_to?(:length) and value.length == 0) or (value == 0) result[klass.name] = value - end result end diff --git a/lib/puppet/face/config.rb b/lib/puppet/face/config.rb index dc0176f8429..a8101d92193 100644 --- a/lib/puppet/face/config.rb +++ b/lib/puppet/face/config.rb @@ -136,7 +136,6 @@ def report_section_and_environment(section_name, environment_name) EOT when_invoked do |name, value, options| - @default_section = false if options[:section] == DEFAULT_SECTION_MARKER options[:section] = DEFAULT_SECTION @@ -219,7 +218,6 @@ def report_section_and_environment(section_name, environment_name) EOT when_invoked do |name, options| - @default_section = false if options[:section] == DEFAULT_SECTION_MARKER options[:section] = DEFAULT_SECTION @@ -230,7 +228,6 @@ def report_section_and_environment(section_name, environment_name) if Puppet::FileSystem.exist?(path) Puppet::FileSystem.open(path, nil, 'r+:UTF-8') do |file| Puppet::Settings::IniFile.update(file) do |config| - # delete from both master section and server section if options[:section] == "master" || options[:section] == "server" master_setting_string = config.delete("master", name) diff --git a/lib/puppet/face/epp.rb b/lib/puppet/face/epp.rb index 7a69ff6c44a..8178ba292e6 100644 --- a/lib/puppet/face/epp.rb +++ b/lib/puppet/face/epp.rb @@ -333,7 +333,6 @@ compiler = create_compiler(options) compiler.with_context_overrides('For rendering epp') do - # Print to a buffer since the face needs to return the resulting string # and the face API is "all or nothing" # @@ -562,5 +561,4 @@ def effective_template(file, env) nil end end - end diff --git a/lib/puppet/face/help.rb b/lib/puppet/face/help.rb index 0d5d6ac6563..aa25b841df8 100644 --- a/lib/puppet/face/help.rb +++ b/lib/puppet/face/help.rb @@ -239,5 +239,4 @@ def is_face_app?(appname) # that you can't use the 'private' keyword inside of a Face definition. # See #14205. #private :is_face_app? - end diff --git a/lib/puppet/face/node/clean.rb b/lib/puppet/face/node/clean.rb index eca65250dae..2eb76d51951 100644 --- a/lib/puppet/face/node/clean.rb +++ b/lib/puppet/face/node/clean.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true Puppet::Face.define(:node, '0.0.1') do action(:clean) do - summary _("Clean up signed certs, cached facts, node objects, and reports for a node stored by the puppetmaster") arguments _(" [ ...]") description <<-'EOT' diff --git a/lib/puppet/functions.rb b/lib/puppet/functions.rb index 33ccb3dbc60..aff17aee510 100644 --- a/lib/puppet/functions.rb +++ b/lib/puppet/functions.rb @@ -737,7 +737,6 @@ def method3x # When function is not an rvalue function, make sure it produces nil # the_class.class_eval do - # Bypasses making the call via the dispatcher to make sure errors # are reported exactly the same way as in 3x. The dispatcher is still needed as it is # used to support other features than calling. diff --git a/lib/puppet/functions/call.rb b/lib/puppet/functions/call.rb index 47544056ce3..3b59f91c913 100644 --- a/lib/puppet/functions/call.rb +++ b/lib/puppet/functions/call.rb @@ -77,5 +77,4 @@ def call_impl_block(scope, function_name, *args, &block) def call_deferred(scope, deferred) Puppet::Pops::Evaluator::DeferredResolver.resolve(deferred, scope.compiler) end - end diff --git a/lib/puppet/functions/camelcase.rb b/lib/puppet/functions/camelcase.rb index a4c35850052..690e8f5a067 100644 --- a/lib/puppet/functions/camelcase.rb +++ b/lib/puppet/functions/camelcase.rb @@ -30,7 +30,6 @@ # Would both result in `['AbcDef', 'BcdXyz']` # Puppet::Functions.create_function(:camelcase) do - dispatch :on_numeric do param 'Numeric', :arg end diff --git a/lib/puppet/functions/capitalize.rb b/lib/puppet/functions/capitalize.rb index 7095451a833..b3d3177b9e6 100644 --- a/lib/puppet/functions/capitalize.rb +++ b/lib/puppet/functions/capitalize.rb @@ -29,7 +29,6 @@ # Would both result in `['Abc', 'Bcd']` # Puppet::Functions.create_function(:capitalize) do - dispatch :on_numeric do param 'Numeric', :arg end diff --git a/lib/puppet/functions/ceiling.rb b/lib/puppet/functions/ceiling.rb index 632255d2f25..345b10d65a3 100644 --- a/lib/puppet/functions/ceiling.rb +++ b/lib/puppet/functions/ceiling.rb @@ -34,5 +34,4 @@ def on_string(x) raise(ArgumentError, _('ceiling(): cannot convert given value to a floating point value.')) end end - end diff --git a/lib/puppet/functions/chomp.rb b/lib/puppet/functions/chomp.rb index 32b0a87a613..045adeaa924 100644 --- a/lib/puppet/functions/chomp.rb +++ b/lib/puppet/functions/chomp.rb @@ -25,7 +25,6 @@ # Would both result in `['hello', 'hi']` # Puppet::Functions.create_function(:chomp) do - dispatch :on_numeric do param 'Numeric', :arg end diff --git a/lib/puppet/functions/chop.rb b/lib/puppet/functions/chop.rb index bd13cd2d7b2..68efccfe4ed 100644 --- a/lib/puppet/functions/chop.rb +++ b/lib/puppet/functions/chop.rb @@ -35,7 +35,6 @@ # Would both result in `['hello', 'hi']` # Puppet::Functions.create_function(:chop) do - dispatch :on_numeric do param 'Numeric', :arg end diff --git a/lib/puppet/functions/defined.rb b/lib/puppet/functions/defined.rb index 5c8cac35d05..ce3e89c6c58 100644 --- a/lib/puppet/functions/defined.rb +++ b/lib/puppet/functions/defined.rb @@ -101,7 +101,6 @@ # @since 4.0.0 # Puppet::Functions.create_function(:'defined', Puppet::Functions::InternalFunction) do - dispatch :is_defined do scope_param required_repeated_param 'Variant[String, Type[CatalogEntry], Type[Type[CatalogEntry]]]', :vals diff --git a/lib/puppet/functions/epp.rb b/lib/puppet/functions/epp.rb index a59cf3b5b6b..95af8050df4 100644 --- a/lib/puppet/functions/epp.rb +++ b/lib/puppet/functions/epp.rb @@ -36,7 +36,6 @@ # @since 4.0.0 # Puppet::Functions.create_function(:epp, Puppet::Functions::InternalFunction) do - dispatch :epp do scope_param param 'String', :path diff --git a/lib/puppet/functions/floor.rb b/lib/puppet/functions/floor.rb index afd1fcf2aff..334a33ab85b 100644 --- a/lib/puppet/functions/floor.rb +++ b/lib/puppet/functions/floor.rb @@ -34,5 +34,4 @@ def on_string(x) raise(ArgumentError, _('floor(): cannot convert given value to a floating point value.')) end end - end diff --git a/lib/puppet/functions/inline_epp.rb b/lib/puppet/functions/inline_epp.rb index 8167c297177..5f3292cff1b 100644 --- a/lib/puppet/functions/inline_epp.rb +++ b/lib/puppet/functions/inline_epp.rb @@ -47,7 +47,6 @@ # @since 4.0.0 # Puppet::Functions.create_function(:inline_epp, Puppet::Functions::InternalFunction) do - dispatch :inline_epp do scope_param() param 'String', :template diff --git a/lib/puppet/functions/length.rb b/lib/puppet/functions/length.rb index 69e342d7bfc..0412b6f00f9 100644 --- a/lib/puppet/functions/length.rb +++ b/lib/puppet/functions/length.rb @@ -41,5 +41,4 @@ def string_length(s) def binary_length(bin) bin.length end - end diff --git a/lib/puppet/functions/lookup.rb b/lib/puppet/functions/lookup.rb index 1ebf8f552d6..b63b327b6e1 100644 --- a/lib/puppet/functions/lookup.rb +++ b/lib/puppet/functions/lookup.rb @@ -124,7 +124,6 @@ # # @since 4.0.0 Puppet::Functions.create_function(:lookup, Puppet::Functions::InternalFunction) do - local_types do type 'NameType = Variant[String, Array[String]]' type 'ValueType = Type' @@ -146,7 +145,6 @@ default_values_hash => Optional[Hash[String,Any]],\ merge => Optional[MergeType]\ }]" - end dispatch :lookup_1 do diff --git a/lib/puppet/functions/lstrip.rb b/lib/puppet/functions/lstrip.rb index 9bbf37f0849..54fab1cea84 100644 --- a/lib/puppet/functions/lstrip.rb +++ b/lib/puppet/functions/lstrip.rb @@ -26,7 +26,6 @@ # Would both result in `['hello', 'hi']` # Puppet::Functions.create_function(:lstrip) do - dispatch :on_numeric do param 'Numeric', :arg end diff --git a/lib/puppet/functions/new.rb b/lib/puppet/functions/new.rb index 34118fa5b88..31416763135 100644 --- a/lib/puppet/functions/new.rb +++ b/lib/puppet/functions/new.rb @@ -982,7 +982,6 @@ # @since 4.5.0 # Puppet::Functions.create_function(:new, Puppet::Functions::InternalFunction) do - dispatch :new_instance do scope_param param 'Type', :type diff --git a/lib/puppet/functions/reduce.rb b/lib/puppet/functions/reduce.rb index b502f063592..90e93af20f6 100644 --- a/lib/puppet/functions/reduce.rb +++ b/lib/puppet/functions/reduce.rb @@ -127,7 +127,6 @@ # @since 4.0.0 # Puppet::Functions.create_function(:reduce) do - dispatch :reduce_without_memo do param 'Iterable', :enumerable block_param 'Callable[2,2]', :block diff --git a/lib/puppet/functions/rstrip.rb b/lib/puppet/functions/rstrip.rb index 4681619a119..2430eff71ec 100644 --- a/lib/puppet/functions/rstrip.rb +++ b/lib/puppet/functions/rstrip.rb @@ -26,7 +26,6 @@ # Would both result in `['hello', 'hi']` # Puppet::Functions.create_function(:rstrip) do - dispatch :on_numeric do param 'Numeric', :arg end diff --git a/lib/puppet/functions/size.rb b/lib/puppet/functions/size.rb index f706cec7433..128891328b8 100644 --- a/lib/puppet/functions/size.rb +++ b/lib/puppet/functions/size.rb @@ -11,5 +11,4 @@ def generic_size(arg) call_function('length', arg) end - end diff --git a/lib/puppet/functions/strip.rb b/lib/puppet/functions/strip.rb index eaa3dffd067..36c07da5cf4 100644 --- a/lib/puppet/functions/strip.rb +++ b/lib/puppet/functions/strip.rb @@ -26,7 +26,6 @@ # Would both result in `['hello', 'hi']` # Puppet::Functions.create_function(:strip) do - dispatch :on_numeric do param 'Numeric', :arg end diff --git a/lib/puppet/functions/tree_each.rb b/lib/puppet/functions/tree_each.rb index 9617c5b4837..b9b5fd604c0 100644 --- a/lib/puppet/functions/tree_each.rb +++ b/lib/puppet/functions/tree_each.rb @@ -141,7 +141,6 @@ # @since 5.0.0 # Puppet::Functions.create_function(:tree_each) do - local_types do type "OptionsType = Struct[{\ container_type => Optional[Type],\ diff --git a/lib/puppet/functions/versioncmp.rb b/lib/puppet/functions/versioncmp.rb index 8059fbbe3c0..3c1b1407422 100644 --- a/lib/puppet/functions/versioncmp.rb +++ b/lib/puppet/functions/versioncmp.rb @@ -28,7 +28,6 @@ # `package` type. # Puppet::Functions.create_function(:versioncmp) do - dispatch :versioncmp do param 'String', :a param 'String', :b diff --git a/lib/puppet/module_tool/applications/checksummer.rb b/lib/puppet/module_tool/applications/checksummer.rb index f909231bdf9..2cc65e0c122 100644 --- a/lib/puppet/module_tool/applications/checksummer.rb +++ b/lib/puppet/module_tool/applications/checksummer.rb @@ -15,7 +15,6 @@ def run changes = [] sums = Puppet::ModuleTool::Checksums.new(@path) checksums.each do |child_path, canonical_checksum| - # Avoid checksumming the checksums.json file next if File.basename(child_path) == "checksums.json" diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index 4bec9c55aef..d9cd4662081 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -3,7 +3,6 @@ require_relative '../../puppet/util/json' Puppet::Network::FormatHandler.create_serialized_formats(:msgpack, :weight => 20, :mime => "application/x-msgpack", :required_methods => [:render_method, :intern_method], :intern_method => :from_data_hash) do - confine :feature => :msgpack def intern(klass, text) @@ -188,7 +187,6 @@ def render_multiple(data) Puppet::Network::FormatHandler.create(:flat, :mime => 'text/x-flat-text', :weight => 0) do - def flatten_hash(hash) hash.each_with_object({}) do |(k, v), h| if v.is_a? Hash diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index c2baa42e591..e7da2bf3615 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -26,7 +26,6 @@ def evaluate(scope) # instance. This handles things like: # file { '/foo': owner => blah; '/bar': owner => blah } @instances.map do |instance| - # Evaluate all of the specified params. paramobjects = instance.parameters.map { |param| param.safeevaluate(scope) } diff --git a/lib/puppet/parser/functions/epp.rb b/lib/puppet/parser/functions/epp.rb index d658a5c6fcd..7e62767b3a6 100644 --- a/lib/puppet/parser/functions/epp.rb +++ b/lib/puppet/parser/functions/epp.rb @@ -35,6 +35,5 @@ function fails to pass any required parameter. - Since 4.0.0") do |_args| - Puppet::Parser::Functions::Error.is4x('epp') end diff --git a/lib/puppet/parser/functions/generate.rb b/lib/puppet/parser/functions/generate.rb index c044bf817b0..d94fd3ae904 100644 --- a/lib/puppet/parser/functions/generate.rb +++ b/lib/puppet/parser/functions/generate.rb @@ -12,7 +12,6 @@ generators, so all shell metacharacters are passed directly to the generator, and all metacharacters are returned by the function. Consider cleaning white space from any string generated.") do |args| - #TRANSLATORS "fully qualified" refers to a fully qualified file system path raise Puppet::ParseError, _("Generators must be fully qualified") unless Puppet::Util.absolute_path?(args[0]) diff --git a/lib/puppet/parser/functions/inline_epp.rb b/lib/puppet/parser/functions/inline_epp.rb index b16aec8172e..cc86208d8a9 100644 --- a/lib/puppet/parser/functions/inline_epp.rb +++ b/lib/puppet/parser/functions/inline_epp.rb @@ -47,6 +47,5 @@ - Since 3.5 - Requires [future parser](https://puppet.com/docs/puppet/3.8/experiments_future.html) in Puppet 3.5 to 3.8") do |_arguments| - Puppet::Parser::Functions::Error.is4x('inline_epp') end diff --git a/lib/puppet/parser/functions/inline_template.rb b/lib/puppet/parser/functions/inline_template.rb index 0554bd86c4d..525a0548c7c 100644 --- a/lib/puppet/parser/functions/inline_template.rb +++ b/lib/puppet/parser/functions/inline_template.rb @@ -4,7 +4,6 @@ [the templating docs](https://puppet.com/docs/puppet/latest/lang_template.html) for more information. Note that if multiple template strings are specified, their output is all concatenated and returned as the output of the function.") do |vals| - if Puppet[:tasks] raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::FEATURE_NOT_SUPPORTED_WHEN_SCRIPTING, diff --git a/lib/puppet/parser/functions/realize.rb b/lib/puppet/parser/functions/realize.rb index 4439511df6a..4056c2973fb 100644 --- a/lib/puppet/parser/functions/realize.rb +++ b/lib/puppet/parser/functions/realize.rb @@ -7,7 +7,6 @@ bother with a full collection. It is slightly faster than a collection, and, of course, is a bit shorter. You must pass the object using a reference; e.g.: `realize User[luke]`." ) do |vals| - if Puppet[:tasks] raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING, diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb index c8d0a7c0726..01165a65273 100644 --- a/lib/puppet/parser/functions/split.rb +++ b/lib/puppet/parser/functions/split.rb @@ -23,7 +23,6 @@ module Puppet::Parser::Functions a regexp meta-character (.), which must be escaped. A simple way to do that for a single character is to enclose it in square brackets; a backslash will also escape a single character.") do |_args| - Error.is4x('split') end end diff --git a/lib/puppet/parser/functions/versioncmp.rb b/lib/puppet/parser/functions/versioncmp.rb index 47db7e4acf0..be26bfc7f28 100644 --- a/lib/puppet/parser/functions/versioncmp.rb +++ b/lib/puppet/parser/functions/versioncmp.rb @@ -26,6 +26,5 @@ `package` type. ") do |args| - return Puppet::Util::Package.versioncmp(args[0], args[1]) end diff --git a/lib/puppet/parser/script_compiler.rb b/lib/puppet/parser/script_compiler.rb index 70c0d47c1d9..ed7acb57eae 100644 --- a/lib/puppet/parser/script_compiler.rb +++ b/lib/puppet/parser/script_compiler.rb @@ -41,7 +41,6 @@ def compile # TRANSLATORS, "For running script" is not user facing Puppet.override( @context_overrides , "For running script") do - #TRANSLATORS "main" is a function name and should not be translated result = Puppet::Util::Profiler.profile(_("Script: Evaluated main"), [:script, :evaluate_main]) { evaluate_main } if block_given? diff --git a/lib/puppet/pops/lookup/global_data_provider.rb b/lib/puppet/pops/lookup/global_data_provider.rb index 8e4a39bba97..827dbfe6dfc 100644 --- a/lib/puppet/pops/lookup/global_data_provider.rb +++ b/lib/puppet/pops/lookup/global_data_provider.rb @@ -17,7 +17,6 @@ def unchecked_key_lookup(key, lookup_invocation, merge) scope = lookup_invocation.scope unless scope.is_a?(Hiera::Scope) return lookup_invocation.with_scope(Hiera::Scope.new(scope)) do |hiera_invocation| - # Confine to global scope unless an environment data provider has been defined (same as for hiera_xxx functions) adapter = lookup_invocation.lookup_adapter hiera_invocation.set_global_only unless adapter.global_only? || adapter.has_environment_data_provider?(lookup_invocation) diff --git a/lib/puppet/pops/types/p_object_type.rb b/lib/puppet/pops/types/p_object_type.rb index 5e9a05be410..164af7a256a 100644 --- a/lib/puppet/pops/types/p_object_type.rb +++ b/lib/puppet/pops/types/p_object_type.rb @@ -498,7 +498,6 @@ def create_new_function # Create and return a #new_XXX function where the dispatchers are added programmatically. Puppet::Functions.create_loaded_function(:"new_#{name}", loader) do - # The class that creates new instances must be available to the constructor methods # and is therefore declared as a variable and accessor on the class that represents # this added function. @@ -769,7 +768,6 @@ def _pcore_init_from_hash(init_hash) raise Puppet::ParseError, _('equality_include_type = false cannot be combined with non empty equality specification') unless @equality_include_type parent_eq_attrs = nil equality.each do |attr_name| - attr = parent_members[attr_name] if attr.nil? attr = @attributes[attr_name] || @functions[attr_name] diff --git a/lib/puppet/pops/types/p_sensitive_type.rb b/lib/puppet/pops/types/p_sensitive_type.rb index 507ba51cbd3..2883e4b294d 100644 --- a/lib/puppet/pops/types/p_sensitive_type.rb +++ b/lib/puppet/pops/types/p_sensitive_type.rb @@ -51,7 +51,6 @@ def instance?(o, guard = nil) def self.new_function(type) @new_function ||= Puppet::Functions.create_loaded_function(:new_Sensitive, type.loader) do - dispatch :from_sensitive do param 'Sensitive', :value end diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index 4aae311c3e9..a3663ca37dc 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -1186,7 +1186,6 @@ def assert_radix(radix) end radix end - end end @@ -2588,7 +2587,6 @@ def iterable_type(guard = nil) # def self.new_function(type) @new_function ||= Puppet::Functions.create_loaded_function(:new_array, type.loader) do - dispatch :to_array do param 'Variant[Array,Hash,Binary,Iterable]', :from optional_param 'Boolean[false]', :wrap diff --git a/lib/puppet/provider/exec/windows.rb b/lib/puppet/provider/exec/windows.rb index 821fa704d08..176a788f0d4 100644 --- a/lib/puppet/provider/exec/windows.rb +++ b/lib/puppet/provider/exec/windows.rb @@ -2,7 +2,6 @@ require_relative '../../../puppet/provider/exec' Puppet::Type.type(:exec).provide :windows, :parent => Puppet::Provider::Exec do - confine 'os.name' => :windows defaultfor 'os.name' => :windows diff --git a/lib/puppet/provider/group/directoryservice.rb b/lib/puppet/provider/group/directoryservice.rb index 4ed45434ceb..920afdbc515 100644 --- a/lib/puppet/provider/group/directoryservice.rb +++ b/lib/puppet/provider/group/directoryservice.rb @@ -19,5 +19,4 @@ def members_insync?(current, should) return current.sort.uniq == should.sort.uniq end end - end diff --git a/lib/puppet/provider/package/dnfmodule.rb b/lib/puppet/provider/package/dnfmodule.rb index 048c1404227..b2b785877bc 100644 --- a/lib/puppet/provider/package/dnfmodule.rb +++ b/lib/puppet/provider/package/dnfmodule.rb @@ -11,7 +11,6 @@ require_relative '../../../puppet/provider/package' Puppet::Type.type(:package).provide :dnfmodule, :parent => :dnf do - has_feature :installable, :uninstallable, :versionable, :supports_flavors, :disableable #has_feature :upgradeable # it's not (yet) feasible to make this upgradeable since module streams don't diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index cec45f07354..cc305fde2cb 100644 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -188,5 +188,4 @@ def unhold execute([:dpkg, "--set-selections"], :failonfail => false, :combine => false, :stdinfile => tmpfile.path.to_s) end end - end diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb index cd495e25046..5e40b34d32f 100644 --- a/lib/puppet/provider/package/hpux.rb +++ b/lib/puppet/provider/package/hpux.rb @@ -4,7 +4,6 @@ require_relative '../../../puppet/provider/package' Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package do - desc "HP-UX's packaging system." commands :swinstall => "/usr/sbin/swinstall", diff --git a/lib/puppet/provider/package/pacman.rb b/lib/puppet/provider/package/pacman.rb index 2c1237d9ec4..1d9619ab2e8 100644 --- a/lib/puppet/provider/package/pacman.rb +++ b/lib/puppet/provider/package/pacman.rb @@ -261,5 +261,4 @@ def install_from_repo pacman(*cmd) end end - end diff --git a/lib/puppet/provider/package/pip.rb b/lib/puppet/provider/package/pip.rb index 9264b8c9375..43f8dcb5078 100644 --- a/lib/puppet/provider/package/pip.rb +++ b/lib/puppet/provider/package/pip.rb @@ -7,7 +7,6 @@ require_relative '../../../puppet/provider/package_targetable' Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package::Targetable do - desc "Python packages via `pip`. This provider supports the `install_options` attribute, which allows command-line flags to be passed to pip. diff --git a/lib/puppet/provider/package/pip2.rb b/lib/puppet/provider/package/pip2.rb index 94b27d8a4b0..88247bb53a2 100644 --- a/lib/puppet/provider/package/pip2.rb +++ b/lib/puppet/provider/package/pip2.rb @@ -4,7 +4,6 @@ Puppet::Type.type(:package).provide :pip2, :parent => :pip do - desc "Python packages via `pip2`. This provider supports the `install_options` attribute, which allows command-line flags to be passed to pip2. diff --git a/lib/puppet/provider/package/pip3.rb b/lib/puppet/provider/package/pip3.rb index 49d243925c3..a5f558b4e3e 100644 --- a/lib/puppet/provider/package/pip3.rb +++ b/lib/puppet/provider/package/pip3.rb @@ -4,7 +4,6 @@ Puppet::Type.type(:package).provide :pip3, :parent => :pip do - desc "Python packages via `pip3`. This provider supports the `install_options` attribute, which allows command-line flags to be passed to pip3. diff --git a/lib/puppet/provider/package/pkgin.rb b/lib/puppet/provider/package/pkgin.rb index 22ad368e9fd..7dc1687c6d2 100644 --- a/lib/puppet/provider/package/pkgin.rb +++ b/lib/puppet/provider/package/pkgin.rb @@ -84,5 +84,4 @@ def latest def update pkgin("-y", :install, resource[:name]) end - end diff --git a/lib/puppet/provider/package/pkgng.rb b/lib/puppet/provider/package/pkgng.rb index f71e4e93699..01510cbd2f7 100644 --- a/lib/puppet/provider/package/pkgng.rb +++ b/lib/puppet/provider/package/pkgng.rb @@ -172,5 +172,4 @@ def origin def install_options join_options(@resource[:install_options]) end - end diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb index ed297d2ffe9..fd93fac0a0c 100644 --- a/lib/puppet/provider/service/freebsd.rb +++ b/lib/puppet/provider/service/freebsd.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true Puppet::Type.type(:service).provide :freebsd, :parent => :init do - desc "Provider for FreeBSD and DragonFly BSD. Uses the `rcvar` argument of init scripts and parses/edits rc files." confine 'os.name' => [:freebsd, :dragonfly] @@ -140,5 +139,4 @@ def stopcmd def statuscmd [self.initscript, :onestatus] end - end diff --git a/lib/puppet/provider/service/openbsd.rb b/lib/puppet/provider/service/openbsd.rb index b948c325969..52d8a54c505 100644 --- a/lib/puppet/provider/service/openbsd.rb +++ b/lib/puppet/provider/service/openbsd.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true Puppet::Type.type(:service).provide :openbsd, :parent => :init do - desc "Provider for OpenBSD's rc.d daemon control scripts" commands :rcctl => '/usr/sbin/rcctl' diff --git a/lib/puppet/provider/service/openrc.rb b/lib/puppet/provider/service/openrc.rb index 9d14d512d5b..01cd1660e6d 100644 --- a/lib/puppet/provider/service/openrc.rb +++ b/lib/puppet/provider/service/openrc.rb @@ -68,5 +68,4 @@ def stopcmd def statuscmd ((@resource.provider.get(:hasstatus) == true) || (@resource[:hasstatus] == :true)) && [command(:rcservice), @resource[:name], :status] end - end diff --git a/lib/puppet/provider/service/openwrt.rb b/lib/puppet/provider/service/openwrt.rb index 1c592e51ae3..ed728a3bcdc 100644 --- a/lib/puppet/provider/service/openwrt.rb +++ b/lib/puppet/provider/service/openwrt.rb @@ -33,5 +33,4 @@ def enabled? # As OpenWrt init script do not have status commands def statuscmd end - end diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb index ff6dc45012c..acc200da2fc 100644 --- a/lib/puppet/provider/service/src.rb +++ b/lib/puppet/provider/service/src.rb @@ -3,7 +3,6 @@ # AIX System Resource controller (SRC) Puppet::Type.type(:service).provide :src, :parent => :base do - desc "Support for AIX's System Resource controller. Services are started/stopped based on the `stopsrc` and `startsrc` @@ -143,6 +142,5 @@ def status self.debug(detail.message) return :stopped end - end diff --git a/lib/puppet/provider/service/windows.rb b/lib/puppet/provider/service/windows.rb index c5cbd5a602a..07ce696db67 100644 --- a/lib/puppet/provider/service/windows.rb +++ b/lib/puppet/provider/service/windows.rb @@ -2,7 +2,6 @@ # Windows Service Control Manager (SCM) provider Puppet::Type.type(:service).provide :windows, :parent => :service do - desc <<-EOT Support for Windows Service Control Manager (SCM). This provider can start, stop, enable, and disable services, and the SCM provides working diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index 271e7a6ddde..970c0169b34 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -4,7 +4,6 @@ require 'date' Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source => :useradd do - desc "User and role management on Solaris, via `useradd` and `roleadd`." defaultfor 'os.family' => :solaris diff --git a/lib/puppet/reference/type.rb b/lib/puppet/reference/type.rb index 6e06217acf1..c8a2e2be0f4 100644 --- a/lib/puppet/reference/type.rb +++ b/lib/puppet/reference/type.rb @@ -51,7 +51,6 @@ } types.sort_by(&:to_s).each { |name,type| - str << " ---------------- diff --git a/lib/puppet/reports/http.rb b/lib/puppet/reports/http.rb index f557402b14d..cc72db84910 100644 --- a/lib/puppet/reports/http.rb +++ b/lib/puppet/reports/http.rb @@ -4,7 +4,6 @@ require 'uri' Puppet::Reports.register_report(:http) do - desc <<-DESC Send reports via HTTP or HTTPS. This report processor submits reports as POST requests to the address in the `reporturl` setting. When a HTTPS URL diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 44b8b491139..7f85275ca03 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -1112,7 +1112,6 @@ def property_fix thing.sync unless thing.safe_insync?(currentvalue) end end - end # We put all of the properties in separate files, because there are so many diff --git a/lib/puppet/type/file/checksum_value.rb b/lib/puppet/type/file/checksum_value.rb index 3d589b1bf5e..044f0606093 100644 --- a/lib/puppet/type/file/checksum_value.rb +++ b/lib/puppet/type/file/checksum_value.rb @@ -50,6 +50,5 @@ def sync # so instruct the resource to write its contents. contents_sync(resource.parameter(:source)) end - end end diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index ec91e26c80e..8701e6808fe 100644 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -12,7 +12,6 @@ module Puppet # this state, during retrieval, modifies the appropriate other states # so that things get taken care of appropriately. Puppet::Type.type(:file).newparam(:source) do - attr_accessor :source, :local desc <<-'EOT' diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb index 6ba5505ae09..7dda166e6e9 100644 --- a/lib/puppet/type/group.rb +++ b/lib/puppet/type/group.rb @@ -38,7 +38,6 @@ module Puppet end defaultto :present - end newproperty(:gid) do diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index 88e69111b19..8786f56ca3d 100644 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -408,7 +408,6 @@ def self.mkdefaultschedules # And then one for every period @parameters.find { |p| p.name == :period }.value_collection.values.each { |value| - result << self.new( :name => value.to_s, :period => value diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index 9df5e7dac9b..2f7d206b9c1 100644 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -736,7 +736,6 @@ def generate value = [ value ] if value.is_a?(String) if value.is_a?(Array) value.each do |entry| - raise ArgumentError, _("Each entry for purge_ssh_keys must be a string, not a %{klass}") % { klass: entry.class } unless entry.is_a?(String) valid_home = Puppet::Util.absolute_path?(entry) || entry =~ %r{^~/|^%h/} diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index df19cfb4c53..29721c16e61 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -534,7 +534,6 @@ def value_hash @values["childs"] = cl unless cl.empty? @values["sections"] = @context.sections.map do |section| - secdata = { "sectitle" => section.title, "secsequence" => section.sequence, diff --git a/lib/puppet/util/windows/principal.rb b/lib/puppet/util/windows/principal.rb index a6947f433e3..bbaaac08d95 100644 --- a/lib/puppet/util/windows/principal.rb +++ b/lib/puppet/util/windows/principal.rb @@ -59,7 +59,6 @@ def self.lookup_account_name(system_name = nil, sanitize = true, account_name) FFI::MemoryPointer.new(:dword, 1) do |sid_length_ptr| FFI::MemoryPointer.new(:dword, 1) do |domain_length_ptr| FFI::MemoryPointer.new(:uint32, 1) do |name_use_enum_ptr| - sid_length_ptr.write_dword(MAXIMUM_SID_BYTE_LENGTH) success = LookupAccountNameW(system_name_ptr, account_name_ptr, sid_ptr, sid_length_ptr, FFI::Pointer::NULL, domain_length_ptr, name_use_enum_ptr) @@ -109,7 +108,6 @@ def self.lookup_account_sid(system_name = nil, sid_bytes) FFI::MemoryPointer.new(:dword, 1) do |name_length_ptr| FFI::MemoryPointer.new(:dword, 1) do |domain_length_ptr| FFI::MemoryPointer.new(:uint32, 1) do |name_use_enum_ptr| - sid_ptr.write_array_of_uchar(sid_bytes) if Puppet::Util::Windows::SID.IsValidSid(sid_ptr) == FFI::WIN32_FALSE diff --git a/lib/puppet/util/windows/registry.rb b/lib/puppet/util/windows/registry.rb index 352ef8c0de8..6c627bd27de 100644 --- a/lib/puppet/util/windows/registry.rb +++ b/lib/puppet/util/windows/registry.rb @@ -184,7 +184,6 @@ def reg_query_info_key_max_lengths(key) FFI::MemoryPointer.new(:dword) do |max_subkey_name_length_ptr| FFI::MemoryPointer.new(:dword) do |max_value_name_length_ptr| - status = RegQueryInfoKeyW(key.hkey, FFI::MemoryPointer::NULL, FFI::MemoryPointer::NULL, FFI::MemoryPointer::NULL, FFI::MemoryPointer::NULL, diff --git a/lib/puppet/util/windows/security.rb b/lib/puppet/util/windows/security.rb index 88952ece91b..768ab69fefb 100644 --- a/lib/puppet/util/windows/security.rb +++ b/lib/puppet/util/windows/security.rb @@ -476,7 +476,6 @@ def parse_dacl(dacl_ptr) 0.upto(ace_count - 1) do |i| FFI::MemoryPointer.new(:pointer, 1) do |ace_ptr| - next if GetAce(dacl_ptr, i, ace_ptr) == FFI::WIN32_FALSE # ACE structures vary depending on the type. We are only concerned with @@ -587,7 +586,6 @@ def get_security_descriptor(path) FFI::MemoryPointer.new(:pointer, 1) do |group_sid_ptr_ptr| FFI::MemoryPointer.new(:pointer, 1) do |dacl_ptr_ptr| FFI::MemoryPointer.new(:pointer, 1) do |sd_ptr_ptr| - rv = GetSecurityInfo( handle, :SE_FILE_OBJECT, @@ -606,7 +604,6 @@ def get_security_descriptor(path) FFI::MemoryPointer.new(:word, 1) do |control| FFI::MemoryPointer.new(:dword, 1) do |revision| sd_ptr_ptr.read_win32_local_pointer do |sd_ptr| - if GetSecurityDescriptorControl(sd_ptr, control, revision) == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Failed to get security descriptor control")) end diff --git a/lib/puppet/util/windows/sid.rb b/lib/puppet/util/windows/sid.rb index ebfc49129f8..1e23621b7e6 100644 --- a/lib/puppet/util/windows/sid.rb +++ b/lib/puppet/util/windows/sid.rb @@ -188,7 +188,6 @@ def sid_ptr_to_string(psid) def string_to_sid_ptr(string_sid, &block) FFI::MemoryPointer.from_string_to_wide_string(string_sid) do |lpcwstr| FFI::MemoryPointer.new(:pointer, 1) do |sid_ptr_ptr| - if ConvertStringSidToSidW(lpcwstr, sid_ptr_ptr) == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Failed to convert string SID: %{string_sid}") % { string_sid: string_sid }) end From f685157fb3e849572692187e514f139ee8a9eab8 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:13:40 -0800 Subject: [PATCH 12/17] Layout/EmptyLinesAroundClassBody This commit enables the Rubocop Layout/EmptyLinesAroundClassBody cop and addresses all offenses. --- .rubocop_todo.yml | 6 ------ lib/hiera/scope.rb | 1 - lib/puppet/application/agent.rb | 1 - lib/puppet/application/describe.rb | 5 ----- lib/puppet/application/device.rb | 1 - lib/puppet/application/lookup.rb | 1 - lib/puppet/application/script.rb | 1 - lib/puppet/application/ssl.rb | 1 - lib/puppet/environments.rb | 1 - lib/puppet/etc.rb | 1 - lib/puppet/external/dot.rb | 12 ------------ lib/puppet/file_bucket/dipper.rb | 1 - lib/puppet/file_serving/http_metadata.rb | 1 - lib/puppet/file_serving/metadata.rb | 2 -- lib/puppet/file_system/file_impl.rb | 1 - lib/puppet/file_system/uniquefile.rb | 1 - lib/puppet/file_system/windows.rb | 1 - lib/puppet/forge/cache.rb | 1 - lib/puppet/functions.rb | 2 -- lib/puppet/http/client.rb | 1 - lib/puppet/http/dns.rb | 1 - lib/puppet/http/external_client.rb | 2 -- lib/puppet/http/resolver/server_list.rb | 1 - lib/puppet/http/resolver/settings.rb | 1 - lib/puppet/http/resolver/srv.rb | 1 - lib/puppet/http/response_net_http.rb | 1 - lib/puppet/http/retry_after_handler.rb | 1 - lib/puppet/http/service/puppetserver.rb | 1 - lib/puppet/http/service/report.rb | 1 - lib/puppet/indirector/catalog/store_configs.rb | 2 -- lib/puppet/indirector/direct_file_server.rb | 1 - lib/puppet/indirector/facts/store_configs.rb | 1 - lib/puppet/indirector/file_bucket_file/file.rb | 1 - lib/puppet/indirector/node/json.rb | 1 - lib/puppet/indirector/node/store_configs.rb | 2 -- lib/puppet/info_service/class_information_service.rb | 1 - lib/puppet/module_tool/applications/checksummer.rb | 1 - lib/puppet/module_tool/applications/installer.rb | 1 - lib/puppet/module_tool/applications/upgrader.rb | 1 - lib/puppet/module_tool/contents_description.rb | 1 - lib/puppet/network/http/api/indirected_routes.rb | 1 - lib/puppet/network/http/api/indirection_type.rb | 1 - lib/puppet/network/http/api/server/v3.rb | 1 - .../network/http/api/server/v3/environments.rb | 1 - lib/puppet/node/environment.rb | 1 - lib/puppet/pal/catalog_compiler.rb | 1 - lib/puppet/parameter/value_collection.rb | 1 - lib/puppet/parser/ast/pops_bridge.rb | 1 - lib/puppet/parser/ast/resource.rb | 1 - lib/puppet/parser/catalog_compiler.rb | 1 - lib/puppet/parser/e4_parser_adapter.rb | 1 - lib/puppet/parser/scope.rb | 4 ---- lib/puppet/pops/evaluator/callable_signature.rb | 1 - lib/puppet/pops/evaluator/collector_transformer.rb | 1 - .../pops/evaluator/collectors/catalog_collector.rb | 1 - .../pops/evaluator/collectors/exported_collector.rb | 1 - .../pops/evaluator/collectors/fixed_set_collector.rb | 1 - lib/puppet/pops/evaluator/deferred_resolver.rb | 1 - lib/puppet/pops/evaluator/epp_evaluator.rb | 1 - lib/puppet/pops/evaluator/literal_evaluator.rb | 1 - lib/puppet/pops/evaluator/relationship_operator.rb | 1 - lib/puppet/pops/evaluator/runtime3_converter.rb | 1 - lib/puppet/pops/functions/function.rb | 1 - lib/puppet/pops/issue_reporter.rb | 1 - lib/puppet/pops/loader/base_loader.rb | 1 - lib/puppet/pops/loader/module_loaders.rb | 2 -- .../loader/puppet_resource_type_impl_instantiator.rb | 1 - lib/puppet/pops/loader/runtime3_type_loader.rb | 1 - lib/puppet/pops/loader/simple_environment_loader.rb | 2 -- lib/puppet/pops/loader/static_loader.rb | 1 - lib/puppet/pops/loaders.rb | 2 -- lib/puppet/pops/lookup/key_recorder.rb | 1 - lib/puppet/pops/lookup/lookup_adapter.rb | 1 - lib/puppet/pops/lookup/module_data_provider.rb | 1 - lib/puppet/pops/migration/migration_checker.rb | 1 - lib/puppet/pops/parser/code_merger.rb | 1 - lib/puppet/pops/parser/epp_parser.rb | 1 - lib/puppet/pops/parser/lexer2.rb | 1 - lib/puppet/pops/parser/locatable.rb | 2 -- lib/puppet/pops/parser/locator.rb | 3 --- lib/puppet/pops/resource/resource_type_impl.rb | 1 - lib/puppet/pops/serialization/time_factory.rb | 1 - lib/puppet/pops/types/class_loader.rb | 1 - lib/puppet/pops/types/p_binary_type.rb | 2 -- lib/puppet/pops/types/p_object_type.rb | 2 -- lib/puppet/pops/types/p_sensitive_type.rb | 1 - lib/puppet/pops/types/p_type_set_type.rb | 1 - lib/puppet/pops/types/p_uri_type.rb | 1 - lib/puppet/pops/types/ruby_generator.rb | 1 - lib/puppet/pops/types/string_converter.rb | 2 -- lib/puppet/pops/types/tree_iterators.rb | 2 -- lib/puppet/pops/types/type_assertion_error.rb | 1 - lib/puppet/pops/types/type_calculator.rb | 1 - lib/puppet/pops/types/types.rb | 8 -------- lib/puppet/pops/validation.rb | 3 --- lib/puppet/pops/visitor.rb | 1 - lib/puppet/property/list.rb | 1 - lib/puppet/property/ordered_list.rb | 1 - lib/puppet/provider/network_device.rb | 1 - lib/puppet/relationship.rb | 1 - lib/puppet/resource/status.rb | 1 - lib/puppet/settings/array_setting.rb | 1 - lib/puppet/settings/autosign_setting.rb | 1 - .../settings/certificate_revocation_setting.rb | 1 - lib/puppet/settings/config_file.rb | 1 - lib/puppet/settings/environment_conf.rb | 2 -- lib/puppet/settings/http_extra_headers_setting.rb | 1 - lib/puppet/settings/server_list_setting.rb | 1 - lib/puppet/ssl/certificate.rb | 1 - lib/puppet/ssl/certificate_request_attributes.rb | 1 - lib/puppet/ssl/certificate_signer.rb | 1 - lib/puppet/ssl/verifier.rb | 1 - lib/puppet/syntax_checkers/base64.rb | 1 - lib/puppet/syntax_checkers/epp.rb | 1 - lib/puppet/syntax_checkers/json.rb | 1 - lib/puppet/syntax_checkers/pp.rb | 1 - lib/puppet/transaction/event_manager.rb | 1 - lib/puppet/transaction/persistence.rb | 1 - lib/puppet/util/command_line/trollop.rb | 1 - lib/puppet/util/inifile.rb | 3 --- lib/puppet/util/json_lockfile.rb | 1 - lib/puppet/util/log.rb | 1 - lib/puppet/util/network_device/base.rb | 1 - lib/puppet/util/network_device/config.rb | 2 -- lib/puppet/util/network_device/transport/base.rb | 1 - lib/puppet/util/pidlock.rb | 1 - lib/puppet/util/profiler/around_profiler.rb | 1 - lib/puppet/util/rdoc/code_objects.rb | 1 - lib/puppet/util/rdoc/generators/puppet_generator.rb | 6 ------ lib/puppet/util/windows/adsi.rb | 1 - lib/puppet/util/windows/monkey_patches/process.rb | 1 - 131 files changed, 187 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 74badcbc921..ee4b064ca00 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,12 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only -Layout/EmptyLinesAroundClassBody: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLinesAroundExceptionHandlingKeywords: Enabled: false diff --git a/lib/hiera/scope.rb b/lib/hiera/scope.rb index 93cae37de2e..2bbe7684fa6 100644 --- a/lib/hiera/scope.rb +++ b/lib/hiera/scope.rb @@ -86,6 +86,5 @@ def find_hostclass(scope) # This is needed for type conversion to work def_delegators :@real, :call_function - end end diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index 4372f8d5680..93fc3bbf68c 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -7,7 +7,6 @@ require_relative '../../puppet/ssl/oids' class Puppet::Application::Agent < Puppet::Application - run_mode :agent def app_defaults diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index 2d4b0e56648..31a3f0a63d3 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -2,7 +2,6 @@ require_relative '../../puppet/application' class Formatter - def initialize(width) @width = width end @@ -48,11 +47,9 @@ def scrub(text) return text end end - end class TypeDoc - def initialize @format = Formatter.new(76) @types = {} @@ -160,7 +157,6 @@ def list_providers(type) list = type.providers.sort_by(&:to_s).join(", ") puts @format.wrap(list, :indent => 4) end - end class Puppet::Application::Describe < Puppet::Application @@ -250,5 +246,4 @@ def setup handle_help(nil) unless options[:list] || options[:types].size > 0 $stderr.puts "Warning: ignoring types when listing all types" if options[:list] && options[:types].size > 0 end - end diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb index 86f774cfc0c..aa53246d898 100644 --- a/lib/puppet/application/device.rb +++ b/lib/puppet/application/device.rb @@ -5,7 +5,6 @@ require_relative '../../puppet/ssl/oids' class Puppet::Application::Device < Puppet::Application - run_mode :agent attr_accessor :args, :agent, :host diff --git a/lib/puppet/application/lookup.rb b/lib/puppet/application/lookup.rb index 5e358b774e6..26df88dcc27 100644 --- a/lib/puppet/application/lookup.rb +++ b/lib/puppet/application/lookup.rb @@ -5,7 +5,6 @@ require_relative '../../puppet/parser/compiler' class Puppet::Application::Lookup < Puppet::Application - RUN_HELP = _("Run 'puppet lookup --help' for more details").freeze DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, and --merge-hash-arrays' TRUSTED_INFORMATION_FACTS = ["hostname", "domain", "fqdn", "clientcert"].freeze diff --git a/lib/puppet/application/script.rb b/lib/puppet/application/script.rb index 5ee6898192a..d4cac227f90 100644 --- a/lib/puppet/application/script.rb +++ b/lib/puppet/application/script.rb @@ -5,7 +5,6 @@ require_relative '../../puppet/parser/script_compiler' class Puppet::Application::Script < Puppet::Application - option("--debug","-d") option("--execute EXECUTE","-e") do |arg| options[:code] = arg diff --git a/lib/puppet/application/ssl.rb b/lib/puppet/application/ssl.rb index 65322e152e3..c69104c817f 100644 --- a/lib/puppet/application/ssl.rb +++ b/lib/puppet/application/ssl.rb @@ -3,7 +3,6 @@ require_relative '../../puppet/ssl/oids' class Puppet::Application::Ssl < Puppet::Application - run_mode :agent def summary diff --git a/lib/puppet/environments.rb b/lib/puppet/environments.rb index 597effec61a..e44b6a6fc32 100644 --- a/lib/puppet/environments.rb +++ b/lib/puppet/environments.rb @@ -139,7 +139,6 @@ def get_conf(name) # # @api private class StaticPrivate < Static - # Unlisted # # @!macro loader_list diff --git a/lib/puppet/etc.rb b/lib/puppet/etc.rb index 6fa4b74414f..ad7360d4906 100644 --- a/lib/puppet/etc.rb +++ b/lib/puppet/etc.rb @@ -40,7 +40,6 @@ # @api private module Puppet::Etc class << self - # Etc::getgrent returns an Etc::Group struct object # On first call opens /etc/group and returns parse of first entry. Each subsquent call # returns new struct the next entry or nil if EOF. Call ::endgrent to close file. diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb index eabf2a54c25..07b94a79353 100644 --- a/lib/puppet/external/dot.rb +++ b/lib/puppet/external/dot.rb @@ -116,7 +116,6 @@ def change_tab(t) # a root class for any element in dot notation class DOTSimpleElement - attr_accessor :name def initialize(params = {}) @@ -131,7 +130,6 @@ def to_s # an element that has options ( node, edge, or graph ) class DOTElement < DOTSimpleElement - # attr_reader :parent attr_accessor :name, :options @@ -158,14 +156,12 @@ def each_option_pair # @parent.delete( self ) if defined?( @parent ) and @parent # @parent = thing #end - end # This is used when we build nodes that have shape=record # ports don't have options :) class DOTPort < DOTSimpleElement - attr_accessor :label def initialize(params = {}) @@ -231,7 +227,6 @@ def to_s(t = '') def stringify(s) %("#{s.gsub('"', '\\"')}") end - end # A subgraph element is the same to graph, but has another header in dot @@ -274,24 +269,20 @@ def to_s(t = '') }.join( "\n" ) + "\n" hdr + options + nodes + t + "}\n" end - end # This is a graph. class DOTDigraph < DOTSubgraph - def initialize(params = {}, option_list = GRAPH_OPTS) super(params, option_list) @dot_string = 'digraph' end - end # This is an edge. class DOTEdge < DOTElement - attr_accessor :from, :to def initialize(params = {}, option_list = EDGE_OPTS) @@ -312,14 +303,11 @@ def to_s(t = '') i[1] ? t + $tab + "#{i[0]} = \"#{i[1]}\"" : nil }.compact.join( "\n" ) + "\n#{t}]\n" end - end class DOTDirectedEdge < DOTEdge - def edge_link '->' end - end end diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index 6f3fa9cd2f0..f0dafe8a363 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -172,5 +172,4 @@ def list(fromdate, todate) def absolutize_path( path ) Pathname.new(path).realpath end - end diff --git a/lib/puppet/file_serving/http_metadata.rb b/lib/puppet/file_serving/http_metadata.rb index 6c13848aeeb..6d198fb6352 100644 --- a/lib/puppet/file_serving/http_metadata.rb +++ b/lib/puppet/file_serving/http_metadata.rb @@ -4,7 +4,6 @@ # Simplified metadata representation, suitable for the information # that is available from HTTP headers. class Puppet::FileServing::HttpMetadata < Puppet::FileServing::Metadata - def initialize(http_response, path = '/dev/null') super(path) diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 2a92d5ea284..0d57438b2e5 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -8,7 +8,6 @@ # A class that handles retrieving file metadata. class Puppet::FileServing::Metadata < Puppet::FileServing::Base - include Puppet::Util::Checksums extend Puppet::Indirector @@ -168,5 +167,4 @@ def to_data_hash def self.from_data_hash(data) new(data.delete('path'), data) end - end diff --git a/lib/puppet/file_system/file_impl.rb b/lib/puppet/file_system/file_impl.rb index 857289c7204..969a895ecc5 100644 --- a/lib/puppet/file_system/file_impl.rb +++ b/lib/puppet/file_system/file_impl.rb @@ -2,7 +2,6 @@ # Abstract implementation of the Puppet::FileSystem # class Puppet::FileSystem::FileImpl - def pathname(path) path.is_a?(Pathname) ? path : Pathname.new(path) end diff --git a/lib/puppet/file_system/uniquefile.rb b/lib/puppet/file_system/uniquefile.rb index f430532dba2..23c7dc5aeca 100644 --- a/lib/puppet/file_system/uniquefile.rb +++ b/lib/puppet/file_system/uniquefile.rb @@ -184,5 +184,4 @@ def rmdir(*args) Dir.rmdir(*args) end end - end diff --git a/lib/puppet/file_system/windows.rb b/lib/puppet/file_system/windows.rb index 1839a0d4b66..0855f46a11e 100644 --- a/lib/puppet/file_system/windows.rb +++ b/lib/puppet/file_system/windows.rb @@ -209,5 +209,4 @@ def raise_if_symlinks_unsupported Puppet.warning _("The current user does not have the necessary permission to manage symlinks.") end end - end diff --git a/lib/puppet/forge/cache.rb b/lib/puppet/forge/cache.rb index 3cc5db13f8c..8ac2fa52074 100644 --- a/lib/puppet/forge/cache.rb +++ b/lib/puppet/forge/cache.rb @@ -8,7 +8,6 @@ class Puppet::Forge # # Provides methods for reading files from local cache, filesystem or network. class Cache - # Instantiate new cache for the +repository+ instance. def initialize(repository, options = {}) @repository = repository diff --git a/lib/puppet/functions.rb b/lib/puppet/functions.rb index aff17aee510..7123fa6730a 100644 --- a/lib/puppet/functions.rb +++ b/lib/puppet/functions.rb @@ -303,7 +303,6 @@ def self.any_signature(from, to, names) # # @api public class Function < Puppet::Pops::Functions::Function - # @api private def self.builder DispatcherBuilder.new(dispatcher, Puppet::Pops::Types::PCallableType::DEFAULT, loader) @@ -679,7 +678,6 @@ def call_function_with_scope(scope, function_name, *args, &block) end class Function3x < InternalFunction - # Table of optimized parameter names - 0 to 5 parameters PARAM_NAMES = [ [], diff --git a/lib/puppet/http/client.rb b/lib/puppet/http/client.rb index 88e913f6163..c925fcd10a0 100644 --- a/lib/puppet/http/client.rb +++ b/lib/puppet/http/client.rb @@ -85,7 +85,6 @@ # # @api public class Puppet::HTTP::Client - attr_reader :pool # Create a new http client instance. Use `Puppet.runtime[:http]` to get diff --git a/lib/puppet/http/dns.rb b/lib/puppet/http/dns.rb index d52c75881ab..9bb7657b9d8 100644 --- a/lib/puppet/http/dns.rb +++ b/lib/puppet/http/dns.rb @@ -3,7 +3,6 @@ module Puppet::HTTP class DNS - class CacheEntry attr_reader :records, :ttl, :resolution_time diff --git a/lib/puppet/http/external_client.rb b/lib/puppet/http/external_client.rb index eebe666d14e..dac494e2b76 100644 --- a/lib/puppet/http/external_client.rb +++ b/lib/puppet/http/external_client.rb @@ -7,7 +7,6 @@ # # @api private class Puppet::HTTP::ExternalClient < Puppet::HTTP::Client - # Create an external http client. # # @param [Class] http_client_class The class to create to handle the request @@ -85,5 +84,4 @@ def put(url, headers: {}, params: {}, options: {}) def delete(url, headers: {}, params: {}, options: {}) raise NotImplementedError end - end diff --git a/lib/puppet/http/resolver/server_list.rb b/lib/puppet/http/resolver/server_list.rb index 68ca2c38b5f..3d545e8a3e7 100644 --- a/lib/puppet/http/resolver/server_list.rb +++ b/lib/puppet/http/resolver/server_list.rb @@ -4,7 +4,6 @@ # # @api public class Puppet::HTTP::Resolver::ServerList < Puppet::HTTP::Resolver - # Create a server list resolver. # # @param [Puppet::HTTP::Client] client diff --git a/lib/puppet/http/resolver/settings.rb b/lib/puppet/http/resolver/settings.rb index 42a5fee09d9..b5b3d26e527 100644 --- a/lib/puppet/http/resolver/settings.rb +++ b/lib/puppet/http/resolver/settings.rb @@ -4,7 +4,6 @@ # # @api public class Puppet::HTTP::Resolver::Settings < Puppet::HTTP::Resolver - # Resolve a service using the default server and port settings for this service. # # @param [Puppet::HTTP::Session] session diff --git a/lib/puppet/http/resolver/srv.rb b/lib/puppet/http/resolver/srv.rb index e92cb84828c..9a557e66f5d 100644 --- a/lib/puppet/http/resolver/srv.rb +++ b/lib/puppet/http/resolver/srv.rb @@ -3,7 +3,6 @@ # # @api public class Puppet::HTTP::Resolver::SRV < Puppet::HTTP::Resolver - # Create an DNS SRV resolver. # # @param [Puppet::HTTP::Client] client diff --git a/lib/puppet/http/response_net_http.rb b/lib/puppet/http/response_net_http.rb index 70fbfe139c8..d3796d6f1e9 100644 --- a/lib/puppet/http/response_net_http.rb +++ b/lib/puppet/http/response_net_http.rb @@ -3,7 +3,6 @@ # # @api public class Puppet::HTTP::ResponseNetHTTP < Puppet::HTTP::Response - # Create a response associated with the URL. # # @param [URI] url diff --git a/lib/puppet/http/retry_after_handler.rb b/lib/puppet/http/retry_after_handler.rb index b63b8b0ceb6..b366737f3a3 100644 --- a/lib/puppet/http/retry_after_handler.rb +++ b/lib/puppet/http/retry_after_handler.rb @@ -6,7 +6,6 @@ # # @api private class Puppet::HTTP::RetryAfterHandler - # Create a handler to allow the system to sleep between HTTP requests # # @param [Integer] retry_limit number of retries allowed diff --git a/lib/puppet/http/service/puppetserver.rb b/lib/puppet/http/service/puppetserver.rb index 8e5692fe89f..890ecd8e078 100644 --- a/lib/puppet/http/service/puppetserver.rb +++ b/lib/puppet/http/service/puppetserver.rb @@ -4,7 +4,6 @@ # @api public # class Puppet::HTTP::Service::Puppetserver < Puppet::HTTP::Service - # Use `Puppet::HTTP::Session.route_to(:puppetserver)` to create or get an instance of this class. # # @param [Puppet::HTTP::Client] client diff --git a/lib/puppet/http/service/report.rb b/lib/puppet/http/service/report.rb index 559198b04b2..e7f2d3746e2 100644 --- a/lib/puppet/http/service/report.rb +++ b/lib/puppet/http/service/report.rb @@ -4,7 +4,6 @@ # @api public # class Puppet::HTTP::Service::Report < Puppet::HTTP::Service - # @return [String] Default API for the report service API = '/puppet/v3' diff --git a/lib/puppet/indirector/catalog/store_configs.rb b/lib/puppet/indirector/catalog/store_configs.rb index f0786c358bd..8a2580bbd00 100644 --- a/lib/puppet/indirector/catalog/store_configs.rb +++ b/lib/puppet/indirector/catalog/store_configs.rb @@ -3,7 +3,5 @@ require_relative '../../../puppet/resource/catalog' class Puppet::Resource::Catalog::StoreConfigs < Puppet::Indirector::StoreConfigs - desc %q{Part of the "storeconfigs" feature. Should not be directly set by end users.} - end diff --git a/lib/puppet/indirector/direct_file_server.rb b/lib/puppet/indirector/direct_file_server.rb index 97af2d93686..26e6a43978d 100644 --- a/lib/puppet/indirector/direct_file_server.rb +++ b/lib/puppet/indirector/direct_file_server.rb @@ -3,7 +3,6 @@ require_relative '../../puppet/indirector/terminus' class Puppet::Indirector::DirectFileServer < Puppet::Indirector::Terminus - include Puppet::FileServing::TerminusHelper def find(request) diff --git a/lib/puppet/indirector/facts/store_configs.rb b/lib/puppet/indirector/facts/store_configs.rb index b852445e72c..dabe645f51d 100644 --- a/lib/puppet/indirector/facts/store_configs.rb +++ b/lib/puppet/indirector/facts/store_configs.rb @@ -3,7 +3,6 @@ require_relative '../../../puppet/indirector/store_configs' class Puppet::Node::Facts::StoreConfigs < Puppet::Indirector::StoreConfigs - desc %q{Part of the "storeconfigs" feature. Should not be directly set by end users.} def allow_remote_requests? diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb index 0dc711179e2..aca7946db87 100644 --- a/lib/puppet/indirector/file_bucket_file/file.rb +++ b/lib/puppet/indirector/file_bucket_file/file.rb @@ -258,6 +258,5 @@ def copy_bucket_file_to_contents_file(contents_file, bucket_file) end end end - end end diff --git a/lib/puppet/indirector/node/json.rb b/lib/puppet/indirector/node/json.rb index 6e62acc6375..709061fc09d 100644 --- a/lib/puppet/indirector/node/json.rb +++ b/lib/puppet/indirector/node/json.rb @@ -5,5 +5,4 @@ class Puppet::Node::Json < Puppet::Indirector::JSON desc "Store node information as flat files, serialized using JSON, or deserialize stored JSON nodes." - end diff --git a/lib/puppet/indirector/node/store_configs.rb b/lib/puppet/indirector/node/store_configs.rb index 992f22f72a5..175ffa30ec5 100644 --- a/lib/puppet/indirector/node/store_configs.rb +++ b/lib/puppet/indirector/node/store_configs.rb @@ -3,7 +3,5 @@ require_relative '../../../puppet/node' class Puppet::Node::StoreConfigs < Puppet::Indirector::StoreConfigs - desc %q{Part of the "storeconfigs" feature. Should not be directly set by end users.} - end diff --git a/lib/puppet/info_service/class_information_service.rb b/lib/puppet/info_service/class_information_service.rb index c4f21409e22..c89fe4c7f46 100644 --- a/lib/puppet/info_service/class_information_service.rb +++ b/lib/puppet/info_service/class_information_service.rb @@ -4,7 +4,6 @@ require_relative '../../puppet/pops/evaluator/json_strict_literal_evaluator' class Puppet::InfoService::ClassInformationService - def initialize @file_to_result = {} @parser = Puppet::Pops::Parser::EvaluatingParser.new() diff --git a/lib/puppet/module_tool/applications/checksummer.rb b/lib/puppet/module_tool/applications/checksummer.rb index 2cc65e0c122..daa8cef94c1 100644 --- a/lib/puppet/module_tool/applications/checksummer.rb +++ b/lib/puppet/module_tool/applications/checksummer.rb @@ -5,7 +5,6 @@ module Puppet::ModuleTool module Applications class Checksummer < Application - def initialize(path, options = {}) @path = Pathname.new(path) super(options) diff --git a/lib/puppet/module_tool/applications/installer.rb b/lib/puppet/module_tool/applications/installer.rb index fc064cb9f8e..cb3b31859ac 100644 --- a/lib/puppet/module_tool/applications/installer.rb +++ b/lib/puppet/module_tool/applications/installer.rb @@ -15,7 +15,6 @@ module Puppet::ModuleTool module Applications class Installer < Application - include Puppet::ModuleTool::Errors include Puppet::Forge::Errors include Puppet::Network::Uri diff --git a/lib/puppet/module_tool/applications/upgrader.rb b/lib/puppet/module_tool/applications/upgrader.rb index dd38132016f..16e75060078 100644 --- a/lib/puppet/module_tool/applications/upgrader.rb +++ b/lib/puppet/module_tool/applications/upgrader.rb @@ -10,7 +10,6 @@ module Puppet::ModuleTool module Applications class Upgrader < Application - include Puppet::ModuleTool::Errors def initialize(name, options) diff --git a/lib/puppet/module_tool/contents_description.rb b/lib/puppet/module_tool/contents_description.rb index 02b4e098ae0..cc8ba379292 100644 --- a/lib/puppet/module_tool/contents_description.rb +++ b/lib/puppet/module_tool/contents_description.rb @@ -7,7 +7,6 @@ module Puppet::ModuleTool # # This class populates +Metadata+'s Puppet type information. class ContentsDescription - # Instantiate object for string +module_path+. def initialize(module_path) @module_path = module_path diff --git a/lib/puppet/network/http/api/indirected_routes.rb b/lib/puppet/network/http/api/indirected_routes.rb index 69217c82ab6..765b90b6155 100644 --- a/lib/puppet/network/http/api/indirected_routes.rb +++ b/lib/puppet/network/http/api/indirected_routes.rb @@ -2,7 +2,6 @@ require_relative '../../../../puppet/network/http/api/indirection_type' class Puppet::Network::HTTP::API::IndirectedRoutes - # How we map http methods and the indirection name in the URI # to an indirection method. METHOD_MAP = { diff --git a/lib/puppet/network/http/api/indirection_type.rb b/lib/puppet/network/http/api/indirection_type.rb index c26c1d114ec..af6c076b0e2 100644 --- a/lib/puppet/network/http/api/indirection_type.rb +++ b/lib/puppet/network/http/api/indirection_type.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true class Puppet::Network::HTTP::API::IndirectionType - INDIRECTION_TYPE_MAP = { "certificate" => :ca, "certificate_request" => :ca, diff --git a/lib/puppet/network/http/api/server/v3.rb b/lib/puppet/network/http/api/server/v3.rb index 33c0688d095..7146e652022 100644 --- a/lib/puppet/network/http/api/server/v3.rb +++ b/lib/puppet/network/http/api/server/v3.rb @@ -8,7 +8,6 @@ module HTTP class API module Server class V3 - def self.wrap(&block) lambda do |request, response| Puppet::Network::Authorization diff --git a/lib/puppet/network/http/api/server/v3/environments.rb b/lib/puppet/network/http/api/server/v3/environments.rb index d92457f0c5f..e49758fe3fb 100644 --- a/lib/puppet/network/http/api/server/v3/environments.rb +++ b/lib/puppet/network/http/api/server/v3/environments.rb @@ -8,7 +8,6 @@ class API module Server class V3 class Environments - def initialize(env_loader) @env_loader = env_loader end diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index f4032540859..08d3ca62e74 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -23,7 +23,6 @@ class Puppet::Node # logging functions. Logging functions are attached to the 'root' environment # when {Puppet::Parser::Functions.reset} is called. class Puppet::Node::Environment - NO_MANIFEST = :no_manifest # The create() factory method should be used instead. diff --git a/lib/puppet/pal/catalog_compiler.rb b/lib/puppet/pal/catalog_compiler.rb index a9bec724487..432db7b802d 100644 --- a/lib/puppet/pal/catalog_compiler.rb +++ b/lib/puppet/pal/catalog_compiler.rb @@ -9,7 +9,6 @@ module Pal # # @api public class CatalogCompiler < Compiler - # @api private def catalog internal_compiler.catalog diff --git a/lib/puppet/parameter/value_collection.rb b/lib/puppet/parameter/value_collection.rb index a2fcbde2eda..3fe43418e14 100644 --- a/lib/puppet/parameter/value_collection.rb +++ b/lib/puppet/parameter/value_collection.rb @@ -12,7 +12,6 @@ # @api private # class Puppet::Parameter::ValueCollection - # Aliases the given existing _other_ value with the additional given _name_. # @return [void] # @api private diff --git a/lib/puppet/parser/ast/pops_bridge.rb b/lib/puppet/parser/ast/pops_bridge.rb index 80e4f6acce0..fcb867affa8 100644 --- a/lib/puppet/parser/ast/pops_bridge.rb +++ b/lib/puppet/parser/ast/pops_bridge.rb @@ -7,7 +7,6 @@ # fundamental for the rest of the logic. # class Puppet::Parser::AST::PopsBridge - # Bridges to one Pops Model Expression # The @value is the expression # This is used to represent the body of a class, definition, or node, and for each parameter's default value diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index e7da2bf3615..72e14ae234d 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -3,7 +3,6 @@ # Instantiates resources of both native and user defined types. # class Puppet::Parser::AST::Resource < Puppet::Parser::AST::Branch - attr_accessor :type, :instances, :exported, :virtual def initialize(argshash) diff --git a/lib/puppet/parser/catalog_compiler.rb b/lib/puppet/parser/catalog_compiler.rb index 615f1ddd5c5..5f142962d0b 100644 --- a/lib/puppet/parser/catalog_compiler.rb +++ b/lib/puppet/parser/catalog_compiler.rb @@ -9,7 +9,6 @@ # deal with possible errors in a cached environment. # class Puppet::Parser::CatalogCompiler < Puppet::Parser::Compiler - # Evaluates the configured setup for a script + code in an environment with modules # def compile diff --git a/lib/puppet/parser/e4_parser_adapter.rb b/lib/puppet/parser/e4_parser_adapter.rb index 15855a0dbaa..4486617637e 100644 --- a/lib/puppet/parser/e4_parser_adapter.rb +++ b/lib/puppet/parser/e4_parser_adapter.rb @@ -7,7 +7,6 @@ module Parser # and makes use of the new evaluator. # class E4ParserAdapter - def initialize @file = '' @string = '' diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index e37a3890f66..363aae18d20 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -42,7 +42,6 @@ def catalog # Abstract base class for LocalScope and MatchScope # class Ephemeral - attr_reader :parent def initialize(parent = nil) @@ -75,7 +74,6 @@ def add_entries_to(target = {}, include_undef = false) end class LocalScope < Ephemeral - def initialize(parent=nil) super parent @symbols = {} @@ -120,7 +118,6 @@ def add_entries_to(target = {}, include_undef = false) end class MatchScope < Ephemeral - attr_accessor :match_data def initialize(parent = nil, match_data = nil) @@ -165,7 +162,6 @@ def add_entries_to(target = {}, include_undef = false) # do not include match data ($0-$n) super end - end # @api private diff --git a/lib/puppet/pops/evaluator/callable_signature.rb b/lib/puppet/pops/evaluator/callable_signature.rb index 1a4fcee3f87..6932ce70006 100644 --- a/lib/puppet/pops/evaluator/callable_signature.rb +++ b/lib/puppet/pops/evaluator/callable_signature.rb @@ -7,7 +7,6 @@ # @api public # class Puppet::Pops::Evaluator::CallableSignature - # Returns the names of the parameters as an array of strings. This does not include the name # of an optional block parameter. # diff --git a/lib/puppet/pops/evaluator/collector_transformer.rb b/lib/puppet/pops/evaluator/collector_transformer.rb index 65994331d01..91ce953e9e8 100644 --- a/lib/puppet/pops/evaluator/collector_transformer.rb +++ b/lib/puppet/pops/evaluator/collector_transformer.rb @@ -2,7 +2,6 @@ module Puppet::Pops module Evaluator class CollectorTransformer - def initialize @@query_visitor ||= Visitor.new(nil, "query", 1, 1) @@match_visitor ||= Visitor.new(nil, "match", 1, 1) diff --git a/lib/puppet/pops/evaluator/collectors/catalog_collector.rb b/lib/puppet/pops/evaluator/collectors/catalog_collector.rb index 6e87b182082..1d9f16e82da 100644 --- a/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +++ b/lib/puppet/pops/evaluator/collectors/catalog_collector.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true class Puppet::Pops::Evaluator::Collectors::CatalogCollector < Puppet::Pops::Evaluator::Collectors::AbstractCollector - # Creates a CatalogCollector using the AbstractCollector's # constructor to set the scope and overrides # diff --git a/lib/puppet/pops/evaluator/collectors/exported_collector.rb b/lib/puppet/pops/evaluator/collectors/exported_collector.rb index a331ee53f59..200d40b3aaf 100644 --- a/lib/puppet/pops/evaluator/collectors/exported_collector.rb +++ b/lib/puppet/pops/evaluator/collectors/exported_collector.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true class Puppet::Pops::Evaluator::Collectors::ExportedCollector < Puppet::Pops::Evaluator::Collectors::AbstractCollector - # Creates an ExportedCollector using the AbstractCollector's # constructor to set the scope and overrides # diff --git a/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb b/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb index 3781c93047c..556f1cbeeba 100644 --- a/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +++ b/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true class Puppet::Pops::Evaluator::Collectors::FixedSetCollector < Puppet::Pops::Evaluator::Collectors::AbstractCollector - # Creates a FixedSetCollector using the AbstractCollector constructor # to set the scope. It is not possible for a collection to have # overrides in this case, since we have a fixed set of resources that diff --git a/lib/puppet/pops/evaluator/deferred_resolver.rb b/lib/puppet/pops/evaluator/deferred_resolver.rb index b9789a9d2b4..7e32c66a215 100644 --- a/lib/puppet/pops/evaluator/deferred_resolver.rb +++ b/lib/puppet/pops/evaluator/deferred_resolver.rb @@ -184,7 +184,6 @@ def map_arguments(args) args.map {|v| resolve(v) } end private :map_arguments - end end end diff --git a/lib/puppet/pops/evaluator/epp_evaluator.rb b/lib/puppet/pops/evaluator/epp_evaluator.rb index 927ee766489..453ae05a4c1 100644 --- a/lib/puppet/pops/evaluator/epp_evaluator.rb +++ b/lib/puppet/pops/evaluator/epp_evaluator.rb @@ -2,7 +2,6 @@ # Handler of Epp call/evaluation from the epp and inline_epp functions # class Puppet::Pops::Evaluator::EppEvaluator - def self.inline_epp(scope, epp_source, template_args = nil) unless epp_source.is_a?(String) #TRANSLATORS 'inline_epp()' is a method name and 'epp' refers to 'Embedded Puppet (EPP) template' and should not be translated diff --git a/lib/puppet/pops/evaluator/literal_evaluator.rb b/lib/puppet/pops/evaluator/literal_evaluator.rb index c3da4c0c226..6c0974567da 100644 --- a/lib/puppet/pops/evaluator/literal_evaluator.rb +++ b/lib/puppet/pops/evaluator/literal_evaluator.rb @@ -16,7 +16,6 @@ module Evaluator # QualifiedReference # i.e. File, FooBar # class LiteralEvaluator - COMMA_SEPARATOR = ', ' def initialize diff --git a/lib/puppet/pops/evaluator/relationship_operator.rb b/lib/puppet/pops/evaluator/relationship_operator.rb index 65c70666f5f..e8def0c822a 100644 --- a/lib/puppet/pops/evaluator/relationship_operator.rb +++ b/lib/puppet/pops/evaluator/relationship_operator.rb @@ -10,7 +10,6 @@ module Evaluator # module. Later when more is cleaned up this can be simplified further. # class RelationshipOperator - # Provides access to the Puppet 3.x runtime (scope, etc.) # This separation has been made to make it easier to later migrate the evaluator to an improved runtime. # diff --git a/lib/puppet/pops/evaluator/runtime3_converter.rb b/lib/puppet/pops/evaluator/runtime3_converter.rb index 18b8b560943..67c20bcc796 100644 --- a/lib/puppet/pops/evaluator/runtime3_converter.rb +++ b/lib/puppet/pops/evaluator/runtime3_converter.rb @@ -168,7 +168,6 @@ def initialize(inner = false) # converter ensures that they are converted to String format # @api private class Runtime3FunctionArgumentConverter < Runtime3Converter - def convert_Regexp(o, scope, undef_value) # Puppet 3x cannot handle parameter values that are regular expressions. Turn into regexp string in # source form diff --git a/lib/puppet/pops/functions/function.rb b/lib/puppet/pops/functions/function.rb index 5e13dd3076d..4613b61c3d5 100644 --- a/lib/puppet/pops/functions/function.rb +++ b/lib/puppet/pops/functions/function.rb @@ -136,5 +136,4 @@ def internal_call_function(scope, function_name, args, &block) # Prevent non r-value functions from leaking their result (they are not written to care about this) Puppet::Parser::Functions.rvalue?(function_name) ? result : nil end - end diff --git a/lib/puppet/pops/issue_reporter.rb b/lib/puppet/pops/issue_reporter.rb index 516abd4d874..6b67670b35e 100644 --- a/lib/puppet/pops/issue_reporter.rb +++ b/lib/puppet/pops/issue_reporter.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops class IssueReporter - # @param acceptor [Validation::Acceptor] the acceptor containing reported issues # @option options [String] :message (nil) A message text to use as prefix in # a single Error message diff --git a/lib/puppet/pops/loader/base_loader.rb b/lib/puppet/pops/loader/base_loader.rb index b2cc5497813..a26fa5f2de3 100644 --- a/lib/puppet/pops/loader/base_loader.rb +++ b/lib/puppet/pops/loader/base_loader.rb @@ -10,7 +10,6 @@ module Loader # @api private # class BaseLoader < Loader - # The parent loader attr_reader :parent diff --git a/lib/puppet/pops/loader/module_loaders.rb b/lib/puppet/pops/loader/module_loaders.rb index 8381cbd8d07..fe93d7ff2a4 100644 --- a/lib/puppet/pops/loader/module_loaders.rb +++ b/lib/puppet/pops/loader/module_loaders.rb @@ -100,7 +100,6 @@ def private_loader=(loader) end class AbstractPathBasedModuleLoader < BaseLoader - # The name of the module, or nil, if this is a global "component", or "any module" if set to the `NAMESPACE_WILDCARD` (*) attr_reader :module_name @@ -430,7 +429,6 @@ def find_existing_path(typed_name) # @api private # class FileBased < AbstractPathBasedModuleLoader - attr_reader :smart_paths attr_reader :path_index diff --git a/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb b/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb index ee1d0c753cb..7548ab02276 100644 --- a/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +++ b/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb @@ -74,7 +74,6 @@ def self.create(loader, typed_name, source_ref, pp_code_string) Adapters::LoaderAdapter.adapt(resource_type_impl).loader_name = loader.loader_name resource_type_impl end - end end end diff --git a/lib/puppet/pops/loader/runtime3_type_loader.rb b/lib/puppet/pops/loader/runtime3_type_loader.rb index a3f4667271d..580f40d4d7f 100644 --- a/lib/puppet/pops/loader/runtime3_type_loader.rb +++ b/lib/puppet/pops/loader/runtime3_type_loader.rb @@ -98,7 +98,6 @@ def find_impl(typed_name) def allow_shadowing? true end - end end end diff --git a/lib/puppet/pops/loader/simple_environment_loader.rb b/lib/puppet/pops/loader/simple_environment_loader.rb index dd16195f4d7..f2f0ab6a646 100644 --- a/lib/puppet/pops/loader/simple_environment_loader.rb +++ b/lib/puppet/pops/loader/simple_environment_loader.rb @@ -6,7 +6,6 @@ # and what is loaded here overrides any child loaders (modules). # class Puppet::Pops::Loader::SimpleEnvironmentLoader < Puppet::Pops::Loader::BaseLoader - attr_accessor :private_loader # Never finds anything, everything "loaded" is set externally @@ -17,5 +16,4 @@ def find(typed_name) def to_s() "(SimpleEnvironmentLoader '#{loader_name}')" end - end diff --git a/lib/puppet/pops/loader/static_loader.rb b/lib/puppet/pops/loader/static_loader.rb index 10f269bf48e..9cc2b9e8df1 100644 --- a/lib/puppet/pops/loader/static_loader.rb +++ b/lib/puppet/pops/loader/static_loader.rb @@ -5,7 +5,6 @@ module Puppet::Pops module Loader class StaticLoader < Loader - BUILTIN_TYPE_NAMES = %w{ Component Exec diff --git a/lib/puppet/pops/loaders.rb b/lib/puppet/pops/loaders.rb index 23103ea6531..14b7e052e27 100644 --- a/lib/puppet/pops/loaders.rb +++ b/lib/puppet/pops/loaders.rb @@ -450,7 +450,6 @@ def configure_loaders_for_modules(parent_loader, environment) # what is available with a reasonable API. # class LoaderModuleData - attr_accessor :public_loader attr_accessor :private_loader attr_accessor :resolutions @@ -499,7 +498,6 @@ def dependency_names # Resolves module loaders - resolution of model dependencies is done by Puppet::Module # class ModuleResolver - def initialize(loaders) @loaders = loaders @index = {} diff --git a/lib/puppet/pops/lookup/key_recorder.rb b/lib/puppet/pops/lookup/key_recorder.rb index 457144bb473..234a40d1a06 100644 --- a/lib/puppet/pops/lookup/key_recorder.rb +++ b/lib/puppet/pops/lookup/key_recorder.rb @@ -3,7 +3,6 @@ # @api private # class Puppet::Pops::Lookup::KeyRecorder - def initialize() end diff --git a/lib/puppet/pops/lookup/lookup_adapter.rb b/lib/puppet/pops/lookup/lookup_adapter.rb index cef441b9eef..b230dea5088 100644 --- a/lib/puppet/pops/lookup/lookup_adapter.rb +++ b/lib/puppet/pops/lookup/lookup_adapter.rb @@ -10,7 +10,6 @@ module Lookup # # @api private class LookupAdapter < DataAdapter - LOOKUP_OPTIONS_PREFIX = LOOKUP_OPTIONS + '.' LOOKUP_OPTIONS_PREFIX.freeze LOOKUP_OPTIONS_PATTERN_START = '^' diff --git a/lib/puppet/pops/lookup/module_data_provider.rb b/lib/puppet/pops/lookup/module_data_provider.rb index 7b23fd83987..63a1069c4fb 100644 --- a/lib/puppet/pops/lookup/module_data_provider.rb +++ b/lib/puppet/pops/lookup/module_data_provider.rb @@ -5,7 +5,6 @@ module Puppet::Pops module Lookup # @api private class ModuleDataProvider < ConfiguredDataProvider - attr_reader :module_name def initialize(module_name, config = nil) diff --git a/lib/puppet/pops/migration/migration_checker.rb b/lib/puppet/pops/migration/migration_checker.rb index 8fc66d9ac60..64d7eb05ca7 100644 --- a/lib/puppet/pops/migration/migration_checker.rb +++ b/lib/puppet/pops/migration/migration_checker.rb @@ -3,7 +3,6 @@ # @api private # class Puppet::Pops::Migration::MigrationChecker - def initialize() end diff --git a/lib/puppet/pops/parser/code_merger.rb b/lib/puppet/pops/parser/code_merger.rb index f1136ffbf34..8d33487def8 100644 --- a/lib/puppet/pops/parser/code_merger.rb +++ b/lib/puppet/pops/parser/code_merger.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true class Puppet::Pops::Parser::CodeMerger - # Concatenates the logic in the array of parse results into one parse result. # @return Puppet::Parser::AST::BlockExpression # diff --git a/lib/puppet/pops/parser/epp_parser.rb b/lib/puppet/pops/parser/epp_parser.rb index 7429729be8b..28fb4b05b7d 100644 --- a/lib/puppet/pops/parser/epp_parser.rb +++ b/lib/puppet/pops/parser/epp_parser.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true # The EppParser is a specialized Puppet Parser that starts parsing in Epp Text mode class Puppet::Pops::Parser::EppParser < Puppet::Pops::Parser::Parser - # Initializes the epp parser support by creating a new instance of {Puppet::Pops::Parser::Lexer} # configured to start in Epp Lexing mode. # @return [void] diff --git a/lib/puppet/pops/parser/lexer2.rb b/lib/puppet/pops/parser/lexer2.rb index d59cefb8e19..be66a7339d4 100644 --- a/lib/puppet/pops/parser/lexer2.rb +++ b/lib/puppet/pops/parser/lexer2.rb @@ -770,7 +770,6 @@ def regexp_acceptable? true end end - end end end diff --git a/lib/puppet/pops/parser/locatable.rb b/lib/puppet/pops/parser/locatable.rb index 0965e0c7c6b..913c99f69e1 100644 --- a/lib/puppet/pops/parser/locatable.rb +++ b/lib/puppet/pops/parser/locatable.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true # Interface for something that is "locatable" (holds offset and length). class Puppet::Pops::Parser::Locatable - # The offset in the locator's content def offset end @@ -20,5 +19,4 @@ def initialize(offset, length) @length = length end end - end diff --git a/lib/puppet/pops/parser/locator.rb b/lib/puppet/pops/parser/locator.rb index b70c5b8f4d1..3b023de3eff 100644 --- a/lib/puppet/pops/parser/locator.rb +++ b/lib/puppet/pops/parser/locator.rb @@ -283,11 +283,9 @@ def char_offset(offset) def char_length(offset, end_offset) raise "Should not be called" end - end class LocatorForChars < AbstractLocator - def offset_on_line(offset) line_offset = line_index[ line_for_offset(offset)-1 ] offset - line_offset @@ -306,7 +304,6 @@ def char_length(offset, end_offset) def extract_text(offset, length) string.slice(offset, length) end - end # This implementation is for Ruby19 and Ruby20. It uses byteslice to get strings from byte based offsets. diff --git a/lib/puppet/pops/resource/resource_type_impl.rb b/lib/puppet/pops/resource/resource_type_impl.rb index 7c028aaeb71..ebef5815f9e 100644 --- a/lib/puppet/pops/resource/resource_type_impl.rb +++ b/lib/puppet/pops/resource/resource_type_impl.rb @@ -289,7 +289,6 @@ def apply_to_all def can_apply_to_target(target) raise NotImplementedError, "can_apply_to_target() - probably used when selecting a provider (device/host support)" end - end end end diff --git a/lib/puppet/pops/serialization/time_factory.rb b/lib/puppet/pops/serialization/time_factory.rb index 96644c7e476..ef60a2e7be1 100644 --- a/lib/puppet/pops/serialization/time_factory.rb +++ b/lib/puppet/pops/serialization/time_factory.rb @@ -8,7 +8,6 @@ module Serialization # @deprecated No longer in use. Functionality replaced by Timestamp # @api private class TimeFactory - NANO_DENOMINATOR = 10**9 def self.at(*args) diff --git a/lib/puppet/pops/types/class_loader.rb b/lib/puppet/pops/types/class_loader.rb index 6f9a3fcf08a..7f288b57297 100644 --- a/lib/puppet/pops/types/class_loader.rb +++ b/lib/puppet/pops/types/class_loader.rb @@ -127,7 +127,6 @@ def self.de_camel(fq_name) .downcase end private_class_method :de_camel - end end end diff --git a/lib/puppet/pops/types/p_binary_type.rb b/lib/puppet/pops/types/p_binary_type.rb index 2b20a894f7f..45813e0732f 100644 --- a/lib/puppet/pops/types/p_binary_type.rb +++ b/lib/puppet/pops/types/p_binary_type.rb @@ -15,7 +15,6 @@ module Types # # @api public class PBinaryType < PAnyType - # Represents a binary buffer # @api public class Binary @@ -227,7 +226,6 @@ def from_hash(hash) def _assignable?(o, guard) o.class == self.class end - end end end diff --git a/lib/puppet/pops/types/p_object_type.rb b/lib/puppet/pops/types/p_object_type.rb index 164af7a256a..514dbe0e5b2 100644 --- a/lib/puppet/pops/types/p_object_type.rb +++ b/lib/puppet/pops/types/p_object_type.rb @@ -272,7 +272,6 @@ def self.label(container, name) # Describes a named Attribute in an Object type # @api public class PAttribute < PAnnotatedMember - # @return [String,nil] The attribute kind as defined by #TYPE_ATTRIBUTE_KIND, or `nil` attr_reader :kind @@ -382,7 +381,6 @@ def self.feature_type # Describes a named Function in an Object type # @api public class PFunction < PAnnotatedMember - # @param name [String] The name of the attribute # @param container [PObjectType] The containing object type # @param init_hash [Hash{String=>Object}] Hash containing function options diff --git a/lib/puppet/pops/types/p_sensitive_type.rb b/lib/puppet/pops/types/p_sensitive_type.rb index 2883e4b294d..a95125365a9 100644 --- a/lib/puppet/pops/types/p_sensitive_type.rb +++ b/lib/puppet/pops/types/p_sensitive_type.rb @@ -8,7 +8,6 @@ module Types # # @api public class PSensitiveType < PTypeWithContainedType - class Sensitive def initialize(value) @value = value diff --git a/lib/puppet/pops/types/p_type_set_type.rb b/lib/puppet/pops/types/p_type_set_type.rb index a1bcb979aaf..a8429afe31b 100644 --- a/lib/puppet/pops/types/p_type_set_type.rb +++ b/lib/puppet/pops/types/p_type_set_type.rb @@ -10,7 +10,6 @@ module Types KEY_REFERENCES = 'references' class PTypeSetType < PMetaType - # A Loader that makes the types known to the TypeSet visible # # @api private diff --git a/lib/puppet/pops/types/p_uri_type.rb b/lib/puppet/pops/types/p_uri_type.rb index 779adaedd14..b4d18d49da9 100644 --- a/lib/puppet/pops/types/p_uri_type.rb +++ b/lib/puppet/pops/types/p_uri_type.rb @@ -2,7 +2,6 @@ module Puppet::Pops module Types class PURIType < PAnyType - # Tell evaluator that an members of instances of this type can be invoked using dot notation include TypeWithMembers diff --git a/lib/puppet/pops/types/ruby_generator.rb b/lib/puppet/pops/types/ruby_generator.rb index 9523ad0f552..424ce241aa2 100644 --- a/lib/puppet/pops/types/ruby_generator.rb +++ b/lib/puppet/pops/types/ruby_generator.rb @@ -4,7 +4,6 @@ module Types # @api private class RubyGenerator < TypeFormatter - RUBY_RESERVED_WORDS = { 'alias' => '_alias', 'begin' => '_begin', diff --git a/lib/puppet/pops/types/string_converter.rb b/lib/puppet/pops/types/string_converter.rb index 3d1c875c625..76517dcc3f7 100644 --- a/lib/puppet/pops/types/string_converter.rb +++ b/lib/puppet/pops/types/string_converter.rb @@ -10,7 +10,6 @@ module Types # @api private # class StringConverter - # @api private class FormatError < ArgumentError def initialize(type_string, actual, expected) @@ -1131,7 +1130,6 @@ def get_format(val_t, format_options) return Format.new("%s") end private :get_format - end end end diff --git a/lib/puppet/pops/types/tree_iterators.rb b/lib/puppet/pops/types/tree_iterators.rb index ec2ee545f32..3c8f1712170 100644 --- a/lib/puppet/pops/types/tree_iterators.rb +++ b/lib/puppet/pops/types/tree_iterators.rb @@ -124,7 +124,6 @@ def extract_option(options, key, default) end class DepthFirstTreeIterator < TreeIterator - # Creates a DepthFirstTreeIterator that by default treats all Array, Hash and Object instances as # containers - the 'containers' option can be set to a type that denotes which types of values # should be treated as containers - a `Variant[Array, Hash]` would for instance not treat @@ -249,7 +248,6 @@ def shift_level @recursed = true end private :shift_level - end end end diff --git a/lib/puppet/pops/types/type_assertion_error.rb b/lib/puppet/pops/types/type_assertion_error.rb index e5bee82a6ed..70de73192a5 100644 --- a/lib/puppet/pops/types/type_assertion_error.rb +++ b/lib/puppet/pops/types/type_assertion_error.rb @@ -4,7 +4,6 @@ module Puppet::Pops::Types # Raised when an assertion of actual type against an expected type fails. # class TypeAssertionError < Puppet::Error - # Returns the expected type # @return [PAnyType] expected type attr_reader :expected_type diff --git a/lib/puppet/pops/types/type_calculator.rb b/lib/puppet/pops/types/type_calculator.rb index 1b170fa581c..4f8cd161bd9 100644 --- a/lib/puppet/pops/types/type_calculator.rb +++ b/lib/puppet/pops/types/type_calculator.rb @@ -817,7 +817,6 @@ def common_scalar?(t1, t2) def common_numeric?(t1, t2) PNumericType::DEFAULT.assignable?(t1) && PNumericType::DEFAULT.assignable?(t2) end - end end end diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index a3663ca37dc..8411883779e 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -74,7 +74,6 @@ def self.register_ptypes(loader, ir) # @api public # class PAnyType < TypedModelObject - def self.register_ptype(loader, ir) @type = Pcore::create_object_type(loader, ir, self, 'Pcore::AnyType', 'Any', EMPTY_HASH) end @@ -464,7 +463,6 @@ def resolve(loader) # @api public # class PTypeType < PTypeWithContainedType - def self.register_ptype(loader, ir) create_ptype(loader, ir, 'AnyType', 'type' => { @@ -2506,7 +2504,6 @@ def _assignable?(o, guard) # @api public # class PArrayType < PCollectionType - def self.register_ptype(loader, ir) create_ptype(loader, ir, 'CollectionType', 'element_type' => { @@ -2655,7 +2652,6 @@ def _assignable?(o, guard) # @api public # class PHashType < PCollectionType - def self.register_ptype(loader, ir) create_ptype(loader, ir, 'CollectionType', 'key_type' => { @@ -3197,7 +3193,6 @@ def _assignable?(o, guard) # @api public # class PResourceType < PCatalogEntryType - def self.register_ptype(loader, ir) create_ptype(loader, ir, 'CatalogEntryType', 'type_name' => { @@ -3242,7 +3237,6 @@ def _assignable?(o, guard) # @api public # class POptionalType < PTypeWithContainedType - def self.register_ptype(loader, ir) create_ptype(loader, ir, 'AnyType', 'type' => { @@ -3302,7 +3296,6 @@ def _assignable?(o, guard) end class PTypeReferenceType < PAnyType - def self.register_ptype(loader, ir) create_ptype(loader, ir, 'AnyType', 'type_string' => PStringType::NON_EMPTY) end @@ -3351,7 +3344,6 @@ def _assignable?(o, guard) # # @api public class PTypeAliasType < PAnyType - def self.register_ptype(loader, ir) create_ptype(loader, ir, 'AnyType', 'name' => PStringType::NON_EMPTY, diff --git a/lib/puppet/pops/validation.rb b/lib/puppet/pops/validation.rb index fa1d77995e3..584eddaf1e4 100644 --- a/lib/puppet/pops/validation.rb +++ b/lib/puppet/pops/validation.rb @@ -26,7 +26,6 @@ module Validation # @api public # class Factory - # Produces a validator with the given acceptor as the recipient of produced diagnostics. # The acceptor is where detected issues are received (and typically collected). # @@ -169,7 +168,6 @@ def assert_issue issue # sets keys in the given argument hash that may be used in the formatting of the issue message. # class DiagnosticProducer - # A producer of severity for a given issue # @return [SeverityProducer] # @@ -355,7 +353,6 @@ def format_location diagnostic # answer questions about what was diagnosed. # class Acceptor - # All diagnostic in the order they were issued attr_reader :diagnostics diff --git a/lib/puppet/pops/visitor.rb b/lib/puppet/pops/visitor.rb index 41f4c141745..13d8450bd6d 100644 --- a/lib/puppet/pops/visitor.rb +++ b/lib/puppet/pops/visitor.rb @@ -119,6 +119,5 @@ def visit_this_3(receiver, thing, arg1, arg2, arg3) end visit_this(receiver, thing, [arg1, arg2, arg3]) end - end end diff --git a/lib/puppet/property/list.rb b/lib/puppet/property/list.rb index d7e8ede014b..7f042d743f5 100644 --- a/lib/puppet/property/list.rb +++ b/lib/puppet/property/list.rb @@ -7,7 +7,6 @@ class Property # For an ordered list see {Puppet::Property::OrderedList}. # class List < Property - def is_to_s(currentvalue) # rubocop:disable Naming/PredicateName currentvalue == :absent ? super(currentvalue) : currentvalue.join(delimiter) end diff --git a/lib/puppet/property/ordered_list.rb b/lib/puppet/property/ordered_list.rb index 7277fd2e1e5..fdda3dd308c 100644 --- a/lib/puppet/property/ordered_list.rb +++ b/lib/puppet/property/ordered_list.rb @@ -11,7 +11,6 @@ class Property # For an unordered list see {Puppet::Property::List}. # class OrderedList < List - def add_should_with_current(should, current) if current.is_a?(Array) #tricky trick diff --git a/lib/puppet/provider/network_device.rb b/lib/puppet/provider/network_device.rb index c4bf1f7494d..6a18c767033 100644 --- a/lib/puppet/provider/network_device.rb +++ b/lib/puppet/provider/network_device.rb @@ -2,7 +2,6 @@ # This is the base class of all prefetched network device provider class Puppet::Provider::NetworkDevice < Puppet::Provider - def self.device(url) raise "This provider doesn't implement the necessary device method" end diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 95aa990a6b0..4a5ae265634 100644 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -6,7 +6,6 @@ # It used to be a subclass of GRATR::Edge, but that class has weird hash # overrides that dramatically slow down the graphing. class Puppet::Relationship - # FormatSupport for serialization methods include Puppet::Network::FormatSupport include Puppet::Util::PsychSupport diff --git a/lib/puppet/resource/status.rb b/lib/puppet/resource/status.rb index 29f7ce28c48..ca68468fd97 100644 --- a/lib/puppet/resource/status.rb +++ b/lib/puppet/resource/status.rb @@ -5,7 +5,6 @@ module Puppet class Resource - # This class represents the result of evaluating a given resource. It # contains file and line information about the source, events generated # while evaluating the resource, timing information, and the status of the diff --git a/lib/puppet/settings/array_setting.rb b/lib/puppet/settings/array_setting.rb index 217e410f4d8..96d90673b6d 100644 --- a/lib/puppet/settings/array_setting.rb +++ b/lib/puppet/settings/array_setting.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true class Puppet::Settings::ArraySetting < Puppet::Settings::BaseSetting - def type :array end diff --git a/lib/puppet/settings/autosign_setting.rb b/lib/puppet/settings/autosign_setting.rb index 012eb7f0f37..7b66bdb699a 100644 --- a/lib/puppet/settings/autosign_setting.rb +++ b/lib/puppet/settings/autosign_setting.rb @@ -8,7 +8,6 @@ # # @api private class Puppet::Settings::AutosignSetting < Puppet::Settings::FileSetting - def munge(value) if ['true', true].include? value true diff --git a/lib/puppet/settings/certificate_revocation_setting.rb b/lib/puppet/settings/certificate_revocation_setting.rb index 018f8094ad3..91386c21aef 100644 --- a/lib/puppet/settings/certificate_revocation_setting.rb +++ b/lib/puppet/settings/certificate_revocation_setting.rb @@ -2,7 +2,6 @@ require_relative '../../puppet/settings/base_setting' class Puppet::Settings::CertificateRevocationSetting < Puppet::Settings::BaseSetting - def type :certificate_revocation end diff --git a/lib/puppet/settings/config_file.rb b/lib/puppet/settings/config_file.rb index 51434b5a101..6c07f3568e3 100644 --- a/lib/puppet/settings/config_file.rb +++ b/lib/puppet/settings/config_file.rb @@ -7,7 +7,6 @@ # Parses puppet configuration files # class Puppet::Settings::ConfigFile - ## # @param value_converter [Proc] a function that will convert strings into ruby types def initialize(value_converter) diff --git a/lib/puppet/settings/environment_conf.rb b/lib/puppet/settings/environment_conf.rb index d4461ce14a9..edf124613be 100644 --- a/lib/puppet/settings/environment_conf.rb +++ b/lib/puppet/settings/environment_conf.rb @@ -2,7 +2,6 @@ # Configuration settings for a single directory Environment. # @api private class Puppet::Settings::EnvironmentConf - ENVIRONMENT_CONF_ONLY_SETTINGS = [:modulepath, :manifest, :config_version].freeze VALID_SETTINGS = (ENVIRONMENT_CONF_ONLY_SETTINGS + [:environment_timeout, :environment_data_provider, :static_catalogs, :rich_data]).freeze @@ -221,5 +220,4 @@ def config_version @environment.config_version end end - end diff --git a/lib/puppet/settings/http_extra_headers_setting.rb b/lib/puppet/settings/http_extra_headers_setting.rb index 0b8c16994a3..d99adc8dc87 100644 --- a/lib/puppet/settings/http_extra_headers_setting.rb +++ b/lib/puppet/settings/http_extra_headers_setting.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true class Puppet::Settings::HttpExtraHeadersSetting < Puppet::Settings::BaseSetting - def type :http_extra_headers end diff --git a/lib/puppet/settings/server_list_setting.rb b/lib/puppet/settings/server_list_setting.rb index ab621f4eaab..8e85fcf0bcc 100644 --- a/lib/puppet/settings/server_list_setting.rb +++ b/lib/puppet/settings/server_list_setting.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true class Puppet::Settings::ServerListSetting < Puppet::Settings::ArraySetting - def type :server_list end diff --git a/lib/puppet/ssl/certificate.rb b/lib/puppet/ssl/certificate.rb index cc3742e9325..2d5e8a7f712 100644 --- a/lib/puppet/ssl/certificate.rb +++ b/lib/puppet/ssl/certificate.rb @@ -92,5 +92,4 @@ def get_ext_val(oid) raw_val end end - end diff --git a/lib/puppet/ssl/certificate_request_attributes.rb b/lib/puppet/ssl/certificate_request_attributes.rb index 5733ff79597..f455acc394a 100644 --- a/lib/puppet/ssl/certificate_request_attributes.rb +++ b/lib/puppet/ssl/certificate_request_attributes.rb @@ -7,7 +7,6 @@ # # @api private class Puppet::SSL::CertificateRequestAttributes - attr_reader :path, :custom_attributes, :extension_requests def initialize(path) diff --git a/lib/puppet/ssl/certificate_signer.rb b/lib/puppet/ssl/certificate_signer.rb index e50b4a06d7d..834934eb43c 100644 --- a/lib/puppet/ssl/certificate_signer.rb +++ b/lib/puppet/ssl/certificate_signer.rb @@ -5,7 +5,6 @@ # # @api private class Puppet::SSL::CertificateSigner - # @!attribute [r] digest # @return [OpenSSL::Digest] attr_reader :digest diff --git a/lib/puppet/ssl/verifier.rb b/lib/puppet/ssl/verifier.rb index caebb3028e1..000346f5e16 100644 --- a/lib/puppet/ssl/verifier.rb +++ b/lib/puppet/ssl/verifier.rb @@ -5,7 +5,6 @@ # # @api private class Puppet::SSL::Verifier - FIVE_MINUTES_AS_SECONDS = 5 * 60 attr_reader :ssl_context diff --git a/lib/puppet/syntax_checkers/base64.rb b/lib/puppet/syntax_checkers/base64.rb index 9f22eca95e9..54fbc950877 100644 --- a/lib/puppet/syntax_checkers/base64.rb +++ b/lib/puppet/syntax_checkers/base64.rb @@ -4,7 +4,6 @@ require_relative '../../puppet/syntax_checkers' require 'base64' class Puppet::SyntaxCheckers::Base64 < Puppet::Plugins::SyntaxCheckers::SyntaxChecker - # Checks the text for BASE64 syntax issues and reports them to the given acceptor. # This checker allows the most relaxed form of Base64, including newlines and missing padding. # It also accept URLsafe input. diff --git a/lib/puppet/syntax_checkers/epp.rb b/lib/puppet/syntax_checkers/epp.rb index 0ee5269d007..c2b25e0ed62 100644 --- a/lib/puppet/syntax_checkers/epp.rb +++ b/lib/puppet/syntax_checkers/epp.rb @@ -3,7 +3,6 @@ # @api public require_relative '../../puppet/syntax_checkers' class Puppet::SyntaxCheckers::EPP < Puppet::Plugins::SyntaxCheckers::SyntaxChecker - # Checks the text for Puppet Language EPP syntax issues and reports them to the given acceptor. # # Error messages from the checker are capped at 100 chars from the source text. diff --git a/lib/puppet/syntax_checkers/json.rb b/lib/puppet/syntax_checkers/json.rb index 6a28c124744..56834b92766 100644 --- a/lib/puppet/syntax_checkers/json.rb +++ b/lib/puppet/syntax_checkers/json.rb @@ -3,7 +3,6 @@ # @api public require_relative '../../puppet/syntax_checkers' class Puppet::SyntaxCheckers::Json < Puppet::Plugins::SyntaxCheckers::SyntaxChecker - # Checks the text for JSON syntax issues and reports them to the given acceptor. # # Error messages from the checker are capped at 100 chars from the source text. diff --git a/lib/puppet/syntax_checkers/pp.rb b/lib/puppet/syntax_checkers/pp.rb index 338c41a73cf..c0e4761b7a0 100644 --- a/lib/puppet/syntax_checkers/pp.rb +++ b/lib/puppet/syntax_checkers/pp.rb @@ -3,7 +3,6 @@ # @api public require_relative '../../puppet/syntax_checkers' class Puppet::SyntaxCheckers::PP < Puppet::Plugins::SyntaxCheckers::SyntaxChecker - # Checks the text for Puppet Language syntax issues and reports them to the given acceptor. # # Error messages from the checker are capped at 100 chars from the source text. diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb index 56d65ab7a8a..a5ebd0042d1 100644 --- a/lib/puppet/transaction/event_manager.rb +++ b/lib/puppet/transaction/event_manager.rb @@ -6,7 +6,6 @@ # # @api private class Puppet::Transaction::EventManager - # @!attribute [r] transaction # @return [Puppet::Transaction] The transaction associated with this event manager. attr_reader :transaction diff --git a/lib/puppet/transaction/persistence.rb b/lib/puppet/transaction/persistence.rb index ca3a7c7996e..559c5ec1696 100644 --- a/lib/puppet/transaction/persistence.rb +++ b/lib/puppet/transaction/persistence.rb @@ -7,7 +7,6 @@ # as calculating corrective_change). # @api private class Puppet::Transaction::Persistence - def self.allowed_classes @allowed_classes ||= [ Symbol, diff --git a/lib/puppet/util/command_line/trollop.rb b/lib/puppet/util/command_line/trollop.rb index 8ac29808627..da01c822883 100644 --- a/lib/puppet/util/command_line/trollop.rb +++ b/lib/puppet/util/command_line/trollop.rb @@ -48,7 +48,6 @@ class VersionNeeded < StandardError; end ## and consider calling it from within ## Trollop::with_standard_exception_handling. class Parser - ## The set of values that indicate a flag option when passed as the ## +:type+ parameter of #opt. FLAG_TYPES = [:flag, :bool, :boolean] diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb index e140d77e1ce..470c8fa80ea 100644 --- a/lib/puppet/util/inifile.rb +++ b/lib/puppet/util/inifile.rb @@ -102,11 +102,9 @@ def find_entry(key) end nil end - end class PhysicalFile - # @!attribute [r] filetype # @api private # @return [Puppet::Util::FileType::FileTypeFlat] @@ -262,7 +260,6 @@ def section_exists?(name) end class FileCollection - attr_reader :files def initialize diff --git a/lib/puppet/util/json_lockfile.rb b/lib/puppet/util/json_lockfile.rb index 514b23d92fa..eae9d7ea69c 100644 --- a/lib/puppet/util/json_lockfile.rb +++ b/lib/puppet/util/json_lockfile.rb @@ -41,5 +41,4 @@ def lock_data Puppet.warning _("Unable to read lockfile data from %{path}: not in JSON") % { path: @file_path } nil end - end diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 81091fd5823..bccc64f53c2 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -418,7 +418,6 @@ def to_s end msg end - end # This is for backward compatibility from when we changed the constant to diff --git a/lib/puppet/util/network_device/base.rb b/lib/puppet/util/network_device/base.rb index 350fe66622b..e956ecffbf9 100644 --- a/lib/puppet/util/network_device/base.rb +++ b/lib/puppet/util/network_device/base.rb @@ -5,7 +5,6 @@ require_relative '../../../puppet/util/network_device/transport/base' class Puppet::Util::NetworkDevice::Base - attr_accessor :url, :transport def initialize(url, options = {}) diff --git a/lib/puppet/util/network_device/config.rb b/lib/puppet/util/network_device/config.rb index ff0ee917e98..f8a8a489ec7 100644 --- a/lib/puppet/util/network_device/config.rb +++ b/lib/puppet/util/network_device/config.rb @@ -4,7 +4,6 @@ require_relative '../../../puppet/util/network_device' class Puppet::Util::NetworkDevice::Config - def self.main @main ||= self.new end @@ -102,5 +101,4 @@ def parse_directive(device, var, value, count) raise Puppet::Error, _("Invalid argument '%{var}' at %{error_location}") % { var: var, error_location: error_location_str } end end - end diff --git a/lib/puppet/util/network_device/transport/base.rb b/lib/puppet/util/network_device/transport/base.rb index 80392448315..caa2c9b80b1 100644 --- a/lib/puppet/util/network_device/transport/base.rb +++ b/lib/puppet/util/network_device/transport/base.rb @@ -23,5 +23,4 @@ def command(cmd, options = {}) yield output if block_given? end end - end diff --git a/lib/puppet/util/pidlock.rb b/lib/puppet/util/pidlock.rb index 84f125c5294..f546610f620 100644 --- a/lib/puppet/util/pidlock.rb +++ b/lib/puppet/util/pidlock.rb @@ -3,7 +3,6 @@ require_relative '../../puppet/util/lockfile' class Puppet::Util::Pidlock - def initialize(lockfile) @lockfile = Puppet::Util::Lockfile.new(lockfile) end diff --git a/lib/puppet/util/profiler/around_profiler.rb b/lib/puppet/util/profiler/around_profiler.rb index a59e90fecd6..632a9ea7b86 100644 --- a/lib/puppet/util/profiler/around_profiler.rb +++ b/lib/puppet/util/profiler/around_profiler.rb @@ -5,7 +5,6 @@ # # @api private class Puppet::Util::Profiler::AroundProfiler - def initialize @profilers = [] end diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb index e6564343c90..72e91f13af6 100644 --- a/lib/puppet/util/rdoc/code_objects.rb +++ b/lib/puppet/util/rdoc/code_objects.rb @@ -176,7 +176,6 @@ def find_symbol(symbol, method=nil) end result end - end # PuppetNode holds a puppet node diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index 29721c16e61..53b62263ae6 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -52,7 +52,6 @@ def new_markup(str, remove_para=false) # This is a specialized HTMLGenerator tailored to Puppet manifests class PuppetGenerator < HTMLGenerator - def PuppetGenerator.for(options) AllReferences::reset HtmlMethod::reset @@ -347,7 +346,6 @@ def main_url ref end - end # This module is used to generate a referenced full name list of ContextUser @@ -646,7 +644,6 @@ def <=>(other) end class HTMLPuppetModule < HtmlClass - def value_hash @values = super @@ -693,7 +690,6 @@ def facts def plugins @context.plugins end - end class HTMLPuppetPlugin < ContextUser @@ -811,7 +807,6 @@ def attribute_values def <=>(other) self.name <=> other.name end - end class HTMLPuppetResource @@ -893,7 +888,6 @@ def find_symbol(symbol, method=nil) res = @context.parent.find_symbol(symbol, method) res && res.viewer end - end class PuppetGeneratorInOne < HTMLGeneratorInOne diff --git a/lib/puppet/util/windows/adsi.rb b/lib/puppet/util/windows/adsi.rb index 09a5b75c98d..ebaa497c7f8 100644 --- a/lib/puppet/util/windows/adsi.rb +++ b/lib/puppet/util/windows/adsi.rb @@ -590,7 +590,6 @@ def self.delete(sid) end class Group < ADSIObject - # https://msdn.microsoft.com/en-us/library/aa706021.aspx # IADsGroup interface @object_class = 'group' diff --git a/lib/puppet/util/windows/monkey_patches/process.rb b/lib/puppet/util/windows/monkey_patches/process.rb index 25c714edf9e..0ff2584d9ba 100644 --- a/lib/puppet/util/windows/monkey_patches/process.rb +++ b/lib/puppet/util/windows/monkey_patches/process.rb @@ -29,7 +29,6 @@ module Process SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX) class << self - private :SetHandleInformation, :SetErrorMode, :CreateProcessW, :OpenProcess, :SetPriorityClass, :CreateProcessWithLogonW, :get_osfhandle, :get_errno From ee299549fec867424666ad7908384347eb677147 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:19:45 -0800 Subject: [PATCH 13/17] Layout/EmptyLinesAroundExceptionHandlingKeywords This commit enables the Rubocop Layout/EmptyLinesAroundExceptionHandlingKeywords cop and addresses all offenses. --- .rubocop_todo.yml | 4 ---- ext/windows/service/daemon.rb | 1 - lib/puppet/application/face_base.rb | 2 -- lib/puppet/application/script.rb | 2 -- lib/puppet/file_serving/configuration.rb | 1 - lib/puppet/indirector/node/exec.rb | 1 - lib/puppet/interface/face_collection.rb | 1 - lib/puppet/module_tool/applications/installer.rb | 1 - lib/puppet/module_tool/applications/upgrader.rb | 1 - lib/puppet/module_tool/metadata.rb | 1 - lib/puppet/pal/pal_impl.rb | 2 -- lib/puppet/parser/catalog_compiler.rb | 1 - lib/puppet/parser/compiler.rb | 1 - lib/puppet/parser/script_compiler.rb | 1 - lib/puppet/pops/evaluator/evaluator_impl.rb | 6 ------ lib/puppet/pops/evaluator/relationship_operator.rb | 1 - lib/puppet/pops/types/tree_iterators.rb | 2 -- lib/puppet/provider/user/useradd.rb | 1 - lib/puppet/util/symbolic_file_mode.rb | 1 - lib/puppet/util/windows/user.rb | 1 - 20 files changed, 32 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ee4b064ca00..037a97b8930 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,10 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLinesAroundMethodBody: Enabled: false diff --git a/ext/windows/service/daemon.rb b/ext/windows/service/daemon.rb index 9dab31542bd..5f6a6551eb1 100755 --- a/ext/windows/service/daemon.rb +++ b/ext/windows/service/daemon.rb @@ -96,7 +96,6 @@ def service_main(*argsv) end end @run_thread.join - rescue Exception => e log_exception(e) ensure diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index 94dd220ba72..ca3e15e506b 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -265,11 +265,9 @@ def main # --kelsey 2012-02-14 rescue SystemExit => detail status = detail.status - rescue => detail Puppet.log_exception(detail) Puppet.err _("Try 'puppet help %{face} %{action}' for usage") % { face: @face.name, action: @action.name } - ensure exit status end diff --git a/lib/puppet/application/script.rb b/lib/puppet/application/script.rb index d4cac227f90..483685674a4 100644 --- a/lib/puppet/application/script.rb +++ b/lib/puppet/application/script.rb @@ -211,7 +211,6 @@ def main topscope.merge_settings(node.environment.name, false) compiler.compile() - rescue Puppet::Error # already logged and handled by the compiler, including Puppet::ParseErrorWithIssue exit(1) @@ -223,7 +222,6 @@ def main exit(1) end end - ensure if @profiler Puppet::Util::Profiler.remove_profiler(@profiler) diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index 8329a7d76e2..00cf23ed7f0 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -107,7 +107,6 @@ def readconfig(check = true) rescue => detail Puppet.log_exception(detail, _("Error parsing fileserver configuration: %{detail}; using old configuration") % { detail: detail }) end - ensure # Make sure we've got our plugins and modules. mk_default_mounts diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index 237a849b276..0fc809aeff6 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -64,7 +64,6 @@ def translate(name, output) hash end - rescue => detail raise Puppet::Error, _("Could not load external node results for %{name}: %{detail}") % { name: name, detail: detail }, detail.backtrace end diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb index f8bd742a056..c2b66d86272 100644 --- a/lib/puppet/interface/face_collection.rb +++ b/lib/puppet/interface/face_collection.rb @@ -110,7 +110,6 @@ def self.safely_require(name, version = nil) path = @loader.expand(version ? ::File.join(version.to_s, name.to_s) : name) require path true - rescue LoadError => e raise unless e.message =~ %r{-- #{path}$} # ...guess we didn't find the file; return a much better problem. diff --git a/lib/puppet/module_tool/applications/installer.rb b/lib/puppet/module_tool/applications/installer.rb index cb3b31859ac..555bb6be0c0 100644 --- a/lib/puppet/module_tool/applications/installer.rb +++ b/lib/puppet/module_tool/applications/installer.rb @@ -229,7 +229,6 @@ def run results[:result] = :success results[:installed_modules] = releases results[:graph] = [ build_install_graph(releases.first, releases) ] - rescue ModuleToolError, ForgeError => err results[:error] = { :oneline => err.message, diff --git a/lib/puppet/module_tool/applications/upgrader.rb b/lib/puppet/module_tool/applications/upgrader.rb index 16e75060078..fe9c08809ec 100644 --- a/lib/puppet/module_tool/applications/upgrader.rb +++ b/lib/puppet/module_tool/applications/upgrader.rb @@ -202,7 +202,6 @@ def installed_release.priority results[:base_dir] = releases.first.install_dir results[:affected_modules] = releases results[:graph] = [ build_install_graph(releases.first, releases) ] - rescue VersionAlreadyInstalledError => e results[:result] = (e.newer_versions.empty? ? :noop : :failure) results[:error] = { :oneline => e.message, :multiline => e.multiline } diff --git a/lib/puppet/module_tool/metadata.rb b/lib/puppet/module_tool/metadata.rb index 9112768f075..ef8737dda61 100644 --- a/lib/puppet/module_tool/metadata.rb +++ b/lib/puppet/module_tool/metadata.rb @@ -149,7 +149,6 @@ def process_source(data) data['project_page'] ||= @data['project_page'] || source_uri.to_s data['issues_url'] ||= @data['issues_url'] || source_uri.to_s.sub(/\/*$/, '') + '/issues' end - rescue URI::Error return end diff --git a/lib/puppet/pal/pal_impl.rb b/lib/puppet/pal/pal_impl.rb index 79fcca6a9bc..5f008ab5abc 100644 --- a/lib/puppet/pal/pal_impl.rb +++ b/lib/puppet/pal/pal_impl.rb @@ -497,11 +497,9 @@ def self.main( end end end - rescue Puppet::Error # already logged and handled by the compiler, including Puppet::ParseErrorWithIssue raise - rescue => detail Puppet.log_exception(detail) raise diff --git a/lib/puppet/parser/catalog_compiler.rb b/lib/puppet/parser/catalog_compiler.rb index 5f142962d0b..cb5a2863b46 100644 --- a/lib/puppet/parser/catalog_compiler.rb +++ b/lib/puppet/parser/catalog_compiler.rb @@ -18,7 +18,6 @@ def compile Puppet.override(rich_data: true) do super end - rescue Puppet::ParseErrorWithIssue => detail detail.node = node.name Puppet.log_exception(detail) diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index f39dbeff1af..1cb9f0c2ae2 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -349,7 +349,6 @@ def evaluate_definitions # needs to be handled specifically as the error has the file/line/position where this # occurred rather than the resource fail(Puppet::Pops::Issues::RUNTIME_ERROR, detail, {:detail => detail.message}, detail) - rescue Puppet::Error => e # PuppetError has the ability to wrap an exception, if so, use the wrapped exception's # call stack instead diff --git a/lib/puppet/parser/script_compiler.rb b/lib/puppet/parser/script_compiler.rb index ed7acb57eae..b0fb6698980 100644 --- a/lib/puppet/parser/script_compiler.rb +++ b/lib/puppet/parser/script_compiler.rb @@ -49,7 +49,6 @@ def compile result end end - rescue Puppet::ParseErrorWithIssue => detail detail.node = node_name Puppet.log_exception(detail) diff --git a/lib/puppet/pops/evaluator/evaluator_impl.rb b/lib/puppet/pops/evaluator/evaluator_impl.rb index 20226b824f5..8949590929c 100644 --- a/lib/puppet/pops/evaluator/evaluator_impl.rb +++ b/lib/puppet/pops/evaluator/evaluator_impl.rb @@ -75,20 +75,17 @@ def type_calculator def evaluate(target, scope) begin @@eval_visitor.visit_this_1(self, target, scope) - rescue SemanticError => e # A raised issue may not know the semantic target, use errors call stack, but fill in the # rest from a supplied semantic object, or the target instruction if there is not semantic # object. # fail(e.issue, e.semantic || target, e.options, e) - rescue Puppet::PreformattedError => e # Already formatted with location information, and with the wanted call stack. # Note this is currently a specialized ParseError, so rescue-order is important # raise e - rescue Puppet::ParseError => e # ParseError may be raised in ruby code without knowing the location # in puppet code. @@ -105,16 +102,13 @@ def evaluate(target, scope) # error. Pass on its call stack. fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e) end - rescue Puppet::Error => e # PuppetError has the ability to wrap an exception, if so, use the wrapped exception's # call stack instead fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e.original || e) - rescue StopIteration => e # Ensure these are not rescued as StandardError raise e - rescue StandardError => e # All other errors, use its message and call stack fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e) diff --git a/lib/puppet/pops/evaluator/relationship_operator.rb b/lib/puppet/pops/evaluator/relationship_operator.rb index e8def0c822a..6436d0b75dd 100644 --- a/lib/puppet/pops/evaluator/relationship_operator.rb +++ b/lib/puppet/pops/evaluator/relationship_operator.rb @@ -171,7 +171,6 @@ def evaluate(left_right_evaluated, relationship_expression, scope) result = right end result - rescue NotCatalogTypeError => e fail(Issues::NOT_CATALOG_TYPE, relationship_expression, {:type => @type_calculator.string(e.type)}) rescue IllegalRelationshipOperandError => e diff --git a/lib/puppet/pops/types/tree_iterators.rb b/lib/puppet/pops/types/tree_iterators.rb index 3c8f1712170..2488c573c90 100644 --- a/lib/puppet/pops/types/tree_iterators.rb +++ b/lib/puppet/pops/types/tree_iterators.rb @@ -168,7 +168,6 @@ def next redo unless @with_values end return [@current_path.dup, value] - rescue StopIteration # end of current value's range of content # pop all until out of next values @@ -226,7 +225,6 @@ def next next unless @with_containers end return [@current_path.dup, value] - rescue StopIteration # end of current value's range of content # shift all until out of next values diff --git a/lib/puppet/provider/user/useradd.rb b/lib/puppet/provider/user/useradd.rb index 877112692c3..b6b80607fc8 100644 --- a/lib/puppet/provider/user/useradd.rb +++ b/lib/puppet/provider/user/useradd.rb @@ -196,7 +196,6 @@ def password=(value) :sensitive => has_sensitive_data? } output = execute(cmd, execute_options) - rescue => detail tempfile.close tempfile.delete diff --git a/lib/puppet/util/symbolic_file_mode.rb b/lib/puppet/util/symbolic_file_mode.rb index 9040273ab7f..4ad6fbf73fa 100644 --- a/lib/puppet/util/symbolic_file_mode.rb +++ b/lib/puppet/util/symbolic_file_mode.rb @@ -133,7 +133,6 @@ def symbolic_mode_to_int(modification, to_mode = 0, is_a_directory = false) # Now, assign back the value. final_mode[who] = value end - rescue Puppet::Error => e if part.inspect != modification.inspect rest = " at #{part.inspect}" diff --git a/lib/puppet/util/windows/user.rb b/lib/puppet/util/windows/user.rb index f1af5d86a1e..09fb97f8fd4 100644 --- a/lib/puppet/util/windows/user.rb +++ b/lib/puppet/util/windows/user.rb @@ -77,7 +77,6 @@ def password_is?(name, password, domain = '.') begin logon_user(name, password, domain) { |token| } rescue Puppet::Util::Windows::Error => detail - authenticated_error_codes = Set[ ERROR_ACCOUNT_RESTRICTION, ERROR_INVALID_LOGON_HOURS, From ff22ec885d28bef20cda61983cc6daf5270dedd8 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:21:47 -0800 Subject: [PATCH 14/17] Layout/EmptyLinesAroundMethodBody This commit enables the Rubocop Layout/EmptyLinesAroundMethodBody cop and addresses all offenses. --- .rubocop_todo.yml | 4 ---- lib/puppet/application.rb | 1 - lib/puppet/configurer/downloader.rb | 1 - lib/puppet/datatypes.rb | 1 - lib/puppet/external/dot.rb | 1 - lib/puppet/forge/errors.rb | 1 - lib/puppet/interface/action.rb | 1 - lib/puppet/module_tool.rb | 1 - lib/puppet/parser/ast/pops_bridge.rb | 1 - lib/puppet/pops/evaluator/runtime3_resource_support.rb | 1 - lib/puppet/pops/functions/dispatcher.rb | 1 - lib/puppet/pops/functions/function.rb | 1 - lib/puppet/pops/pcore.rb | 1 - lib/puppet/provider/package/apt.rb | 1 - lib/puppet/provider/package/blastwave.rb | 1 - lib/puppet/provider/package/pkgin.rb | 1 - lib/puppet/provider/package/yum.rb | 2 -- lib/puppet/provider/package/zypper.rb | 1 - lib/puppet/resource/type.rb | 1 - lib/puppet/settings.rb | 1 - lib/puppet/ssl/certificate_request.rb | 1 - lib/puppet/transaction.rb | 1 - lib/puppet/type.rb | 1 - lib/puppet/type/schedule.rb | 1 - lib/puppet/util/command_line/puppet_option_parser.rb | 1 - lib/puppet/util/log.rb | 1 - lib/puppet/util/rdoc.rb | 1 - lib/puppet/util/rdoc/parser/puppet_parser_core.rb | 1 - lib/puppet/util/reference.rb | 1 - lib/puppet/util/windows/sid.rb | 1 - 30 files changed, 34 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 037a97b8930..724d58a2f30 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,10 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLinesAroundMethodBody: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 4e301d7ebbe..00c8a2dddd3 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -399,7 +399,6 @@ def deprecated? # @return [void] # @api public def run - # I don't really like the names of these lifecycle phases. It would be nice to change them to some more meaningful # names, and make deprecated aliases. --cprice 2012-03-16 diff --git a/lib/puppet/configurer/downloader.rb b/lib/puppet/configurer/downloader.rb index 41e17fccf2e..05cbbcdb8de 100644 --- a/lib/puppet/configurer/downloader.rb +++ b/lib/puppet/configurer/downloader.rb @@ -40,7 +40,6 @@ def evaluate def initialize(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore) @name, @path, @source, @ignore, @environment, @source_permissions = name, path, source, ignore, environment, source_permissions - end def file diff --git a/lib/puppet/datatypes.rb b/lib/puppet/datatypes.rb index 2cc008dfdf1..3d9be7a6410 100644 --- a/lib/puppet/datatypes.rb +++ b/lib/puppet/datatypes.rb @@ -133,7 +133,6 @@ def self.create_type(type_name, &block) rescue StandardError => e raise ArgumentError, _("Data Type Load Error for type '%{type_name}': %{message}") % {type_name: type_name, message: e.message} end - end def self.create_loaded_type(type_name, loader, &block) diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb index 07b94a79353..4554ee1068b 100644 --- a/lib/puppet/external/dot.rb +++ b/lib/puppet/external/dot.rb @@ -199,7 +199,6 @@ def pop end def to_s(t = '') - # This code is totally incomprehensible; it needs to be replaced! label = @options['shape'] != 'record' && @ports.length == 0 ? diff --git a/lib/puppet/forge/errors.rb b/lib/puppet/forge/errors.rb index d0b000338a4..cb9d277f8ea 100644 --- a/lib/puppet/forge/errors.rb +++ b/lib/puppet/forge/errors.rb @@ -102,7 +102,6 @@ def initialize(options) # # @return [String] the multiline version of the error message def multiline - message = [] message << _('Request to Puppet Forge failed.') message << _(' The server being queried was %{uri}') % { uri: @uri } diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 730a47e2113..bcd563fe926 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -222,7 +222,6 @@ def deprecated? attr_reader :when_invoked def when_invoked=(block) - internal_name = "#{@name} implementation, required on Ruby 1.8".to_sym arity = @positional_arg_count = block.arity diff --git a/lib/puppet/module_tool.rb b/lib/puppet/module_tool.rb index 2153760904a..905911bb0ae 100644 --- a/lib/puppet/module_tool.rb +++ b/lib/puppet/module_tool.rb @@ -132,7 +132,6 @@ def self.set_option_defaults(options) # Note: environment will have expanded the path options[:target_dir] = face_environment.full_modulepath.first - end # Given a hash of options, we should discover or create a diff --git a/lib/puppet/parser/ast/pops_bridge.rb b/lib/puppet/parser/ast/pops_bridge.rb index fcb867affa8..c8ff7998f08 100644 --- a/lib/puppet/parser/ast/pops_bridge.rb +++ b/lib/puppet/parser/ast/pops_bridge.rb @@ -86,7 +86,6 @@ def initialize(program_model, context = {}) # efficient as it avoids one full scan of all logic via recursive enumeration/yield) # def instantiate(modname) - @program_model.definitions.map do |d| case d when Puppet::Pops::Model::HostClassDefinition diff --git a/lib/puppet/pops/evaluator/runtime3_resource_support.rb b/lib/puppet/pops/evaluator/runtime3_resource_support.rb index ae00e05753e..9fbdc190cc8 100644 --- a/lib/puppet/pops/evaluator/runtime3_resource_support.rb +++ b/lib/puppet/pops/evaluator/runtime3_resource_support.rb @@ -7,7 +7,6 @@ module Runtime3ResourceSupport CLASS_STRING = 'class' def self.create_resources(file, line, scope, virtual, exported, type_name, resource_titles, evaluated_parameters) - env = scope.environment # loader = Adapters::LoaderAdapter.loader_for_model_object(o, scope) diff --git a/lib/puppet/pops/functions/dispatcher.rb b/lib/puppet/pops/functions/dispatcher.rb index 4e1116eb65a..bdbabcc73fb 100644 --- a/lib/puppet/pops/functions/dispatcher.rb +++ b/lib/puppet/pops/functions/dispatcher.rb @@ -33,7 +33,6 @@ def find_matching_dispatcher(args, &block) # # @api private def dispatch(instance, calling_scope, args, &block) - dispatcher = find_matching_dispatcher(args, &block) unless dispatcher args_type = Puppet::Pops::Types::TypeCalculator.singleton.infer_set(block_given? ? args + [block] : args) diff --git a/lib/puppet/pops/functions/function.rb b/lib/puppet/pops/functions/function.rb index 4613b61c3d5..fad7358e1ac 100644 --- a/lib/puppet/pops/functions/function.rb +++ b/lib/puppet/pops/functions/function.rb @@ -105,7 +105,6 @@ def self.signatures # # @api public def internal_call_function(scope, function_name, args, &block) - the_loader = loader unless the_loader raise ArgumentError, _("Function %{class_name}(): cannot call function '%{function_name}' - no loader specified") % diff --git a/lib/puppet/pops/pcore.rb b/lib/puppet/pops/pcore.rb index 000bf76a45c..ccb48a52b3d 100644 --- a/lib/puppet/pops/pcore.rb +++ b/lib/puppet/pops/pcore.rb @@ -83,7 +83,6 @@ def self.init(loader, ir) } } PUPPET - end # Create and register a new `Object` type in the Puppet Type System and map it to an implementation class diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index 54f98e0c05a..4bcb861bd37 100644 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -177,7 +177,6 @@ def install raise Puppet::Error, _("Failed to update to version %{should}, got version %{version} instead") % { should: should, version: version } unless insync?(version) end - end # What's the latest package version available? diff --git a/lib/puppet/provider/package/blastwave.rb b/lib/puppet/provider/package/blastwave.rb index 13b57cb5e4c..f7bf65a5c4a 100644 --- a/lib/puppet/provider/package/blastwave.rb +++ b/lib/puppet/provider/package/blastwave.rb @@ -56,7 +56,6 @@ def self.blastlist(hash) } return list end - end # Split the different lines into hashes. diff --git a/lib/puppet/provider/package/pkgin.rb b/lib/puppet/provider/package/pkgin.rb index 7dc1687c6d2..d845e288333 100644 --- a/lib/puppet/provider/package/pkgin.rb +++ b/lib/puppet/provider/package/pkgin.rb @@ -11,7 +11,6 @@ has_feature :installable, :uninstallable, :upgradeable, :versionable def self.parse_pkgin_line(package) - # e.g. # vim-7.2.446;Vim editor (vi clone) without GUI match, name, version, status = *package.match(/([^\s;]+)-([^\s;]+)[;\s](=|>|<)?.+$/) diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index d5a39f19072..94656b77329 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -85,7 +85,6 @@ def self.prefetch(packages) # @param disableexcludes [Array] A list of repository excludes to disable for this query # @return [Hash] def self.latest_package_version(package, disablerepo, enablerepo, disableexcludes) - key = [disablerepo, enablerepo, disableexcludes] @latest_versions ||= {} @@ -149,7 +148,6 @@ def self.parse_updates(str) end def self.update_to_hash(pkgname, pkgversion) - # The pkgname string has two parts: name, and architecture. Architecture # is the portion of the string following the last "." character. All # characters preceding the final dot are the package name. Parse out diff --git a/lib/puppet/provider/package/zypper.rb b/lib/puppet/provider/package/zypper.rb index 44a56497cee..35516e439b2 100644 --- a/lib/puppet/provider/package/zypper.rb +++ b/lib/puppet/provider/package/zypper.rb @@ -177,7 +177,6 @@ def uninstall zypper(*options) end - end def insync?(is) diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index 1c9397924aa..a28677eb005 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -60,7 +60,6 @@ def child_of?(klass) # Now evaluate the code associated with this class or definition. def evaluate_code(resource) - static_parent = evaluate_parent_type(resource) scope = static_parent || resource.scope diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index 0afd32b2525..c59338a30be 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -278,7 +278,6 @@ def unsafe_clear(clear_cli = true, clear_application_defaults = false) # # @api private def clear_environment_settings(environment) - if environment.nil? return end diff --git a/lib/puppet/ssl/certificate_request.rb b/lib/puppet/ssl/certificate_request.rb index e2e015e7573..3800f0aef5b 100644 --- a/lib/puppet/ssl/certificate_request.rb +++ b/lib/puppet/ssl/certificate_request.rb @@ -296,7 +296,6 @@ def extension_request_attribute(options) # @return [Array>] A array of arrays containing the extension # OID the critical state if present, and the extension value. def unpack_extension_request(attribute) - unless attribute.value.is_a? OpenSSL::ASN1::Set raise Puppet::Error, _("In %{attr}, expected Set but found %{klass}") % { attr: attribute.oid, klass: attribute.value.class } end diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index de2aa6d6631..d0df384e362 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -331,7 +331,6 @@ def failed_dependencies?(resource) # up-front at failure time because the graph may be mutated as we # walk it. def propagate_failure(resource) - provider_class = resource.provider.class s = resource_status(resource) if prefetch_failed_providers[resource.type][provider_class.name] && !s.nil? diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index ff40c73199f..e4620734b97 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -2280,7 +2280,6 @@ def self.validate(&block) # @return [void] # def log(msg) - Puppet::Util::Log.create( :level => @parameters[:loglevel].value, :message => msg, diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index 8786f56ca3d..821ac7e8c9a 100644 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -418,7 +418,6 @@ def self.mkdefaultschedules end def match?(previous = nil, now = nil) - # If we've got a value, then convert it to a Time instance previous &&= Time.at(previous) diff --git a/lib/puppet/util/command_line/puppet_option_parser.rb b/lib/puppet/util/command_line/puppet_option_parser.rb index 5581c49495f..e9420b54b57 100644 --- a/lib/puppet/util/command_line/puppet_option_parser.rb +++ b/lib/puppet/util/command_line/puppet_option_parser.rb @@ -24,7 +24,6 @@ def initialize(usage_msg = nil) @parser = Trollop::Parser.new do banner usage_msg end - end # This parameter, if set, will tell the underlying option parser not to throw an diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index bccc64f53c2..cc048e9073e 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -21,7 +21,6 @@ class Puppet::Util::Log # Create a new destination type. def self.newdesttype(name, options = {}, &block) - dest = genclass( name, :parent => Puppet::Util::Log::Destination, diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb index 282c2998e2e..3771dcf964e 100644 --- a/lib/puppet/util/rdoc.rb +++ b/lib/puppet/util/rdoc.rb @@ -6,7 +6,6 @@ module Puppet::Util::RDoc # launch a rdoc documentation process # with the files/dir passed in +files+ def rdoc(outputdir, files, charset = nil) - # then rdoc require 'rdoc/rdoc' require 'rdoc/options' diff --git a/lib/puppet/util/rdoc/parser/puppet_parser_core.rb b/lib/puppet/util/rdoc/parser/puppet_parser_core.rb index 27045b01520..382df6fc141 100644 --- a/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +++ b/lib/puppet/util/rdoc/parser/puppet_parser_core.rb @@ -44,7 +44,6 @@ def find_object_named(container, name) # walk down the namespace and lookup/create container as needed def get_class_or_module(container, name) - # class ::A -> A is in the top level if name =~ /^::/ container = @top_level diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb index 89a895e1837..7f7d0468d37 100644 --- a/lib/puppet/util/reference.rb +++ b/lib/puppet/util/reference.rb @@ -54,7 +54,6 @@ def self.pdf(text) Dir.chdir("/tmp") do %x{texi2pdf puppetdoc.tex >/dev/null 2>/dev/null} end - end def self.references(environment) diff --git a/lib/puppet/util/windows/sid.rb b/lib/puppet/util/windows/sid.rb index 1e23621b7e6..7fea1e58903 100644 --- a/lib/puppet/util/windows/sid.rb +++ b/lib/puppet/util/windows/sid.rb @@ -137,7 +137,6 @@ def ads_to_principal(ads_object) # e.g. 'BUILTIN\Administrators'. Returns nil if an account # for that SID does not exist. def sid_to_name(value) - sid_bytes = [] begin string_to_sid_ptr(value) do |ptr| From 584abe3106b86a260f0328bb4be9257144d2397c Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 18 Dec 2023 16:23:43 -0800 Subject: [PATCH 15/17] Layout/EmptyLinesAroundModuleBody This commit enables the Rubocop Layout/EmptyLinesAroundModuleBody cop and addresses all offenses. --- .rubocop_todo.yml | 6 ------ lib/puppet/agent/locker.rb | 1 - lib/puppet/application.rb | 1 - lib/puppet/application_support.rb | 1 - lib/puppet/concurrent/lock.rb | 2 -- lib/puppet/concurrent/synchronized.rb | 2 -- lib/puppet/defaults.rb | 1 - lib/puppet/environments.rb | 1 - lib/puppet/external/dot.rb | 1 - lib/puppet/ffi/posix/functions.rb | 1 - lib/puppet/ffi/windows/functions.rb | 1 - lib/puppet/ffi/windows/structs.rb | 1 - lib/puppet/forge/errors.rb | 2 -- lib/puppet/gettext/module_translations.rb | 1 - lib/puppet/interface/documentation.rb | 1 - lib/puppet/interface/option_manager.rb | 1 - lib/puppet/loaders.rb | 1 - lib/puppet/module_tool/checksums.rb | 1 - lib/puppet/module_tool/contents_description.rb | 1 - lib/puppet/module_tool/dependency.rb | 1 - lib/puppet/module_tool/errors/installer.rb | 1 - lib/puppet/module_tool/errors/shared.rb | 1 - lib/puppet/module_tool/errors/uninstaller.rb | 1 - lib/puppet/module_tool/errors/upgrader.rb | 1 - lib/puppet/module_tool/metadata.rb | 1 - lib/puppet/module_tool/shared_behaviors.rb | 1 - lib/puppet/network/http_pool.rb | 1 - lib/puppet/pal/catalog_compiler.rb | 1 - lib/puppet/pal/compiler.rb | 2 -- lib/puppet/pal/function_signature.rb | 1 - lib/puppet/pal/pal_impl.rb | 1 - lib/puppet/pal/plan_signature.rb | 1 - lib/puppet/pal/script_compiler.rb | 2 -- lib/puppet/pal/task_signature.rb | 1 - lib/puppet/parser/abstract_compiler.rb | 2 -- lib/puppet/parser/files.rb | 1 - lib/puppet/parser/functions/split.rb | 1 - lib/puppet/plugins/syntax_checkers.rb | 1 - lib/puppet/pops/adapters.rb | 1 - lib/puppet/pops/evaluator/deferred_resolver.rb | 1 - lib/puppet/pops/evaluator/external_syntax_support.rb | 1 - lib/puppet/pops/evaluator/runtime3_converter.rb | 1 - lib/puppet/pops/evaluator/runtime3_resource_support.rb | 2 -- lib/puppet/pops/evaluator/runtime3_support.rb | 1 - lib/puppet/pops/loader/gem_support.rb | 1 - lib/puppet/pops/loader/loader.rb | 1 - lib/puppet/pops/loader/loader_paths.rb | 1 - lib/puppet/pops/loader/module_loaders.rb | 1 - lib/puppet/pops/loader/predefined_loader.rb | 2 -- lib/puppet/pops/loader/runtime3_type_loader.rb | 1 - lib/puppet/pops/lookup/explainer.rb | 1 - lib/puppet/pops/lookup/hiera_config.rb | 1 - lib/puppet/pops/model/ast.rb | 2 -- lib/puppet/pops/model/pn_transformer.rb | 2 -- lib/puppet/pops/parser/epp_support.rb | 2 -- lib/puppet/pops/parser/evaluating_parser.rb | 1 - lib/puppet/pops/parser/heredoc_support.rb | 1 - lib/puppet/pops/parser/interpolation_support.rb | 2 -- lib/puppet/pops/parser/lexer_support.rb | 3 --- lib/puppet/pops/parser/pn_parser.rb | 1 - lib/puppet/pops/patterns.rb | 2 -- lib/puppet/pops/resource/resource_type_impl.rb | 1 - lib/puppet/pops/serialization/abstract_writer.rb | 1 - lib/puppet/pops/serialization/json.rb | 1 - lib/puppet/pops/serialization/object.rb | 1 - lib/puppet/pops/serialization/to_stringified_converter.rb | 1 - lib/puppet/pops/types/annotatable.rb | 1 - lib/puppet/pops/types/iterable.rb | 1 - lib/puppet/pops/types/p_binary_type.rb | 1 - lib/puppet/pops/types/p_init_type.rb | 1 - lib/puppet/pops/types/p_meta_type.rb | 1 - lib/puppet/pops/types/p_object_type.rb | 1 - lib/puppet/pops/types/p_object_type_extension.rb | 1 - lib/puppet/pops/types/p_runtime_type.rb | 1 - lib/puppet/pops/types/p_sem_ver_range_type.rb | 1 - lib/puppet/pops/types/p_sem_ver_type.rb | 1 - lib/puppet/pops/types/p_sensitive_type.rb | 2 -- lib/puppet/pops/types/p_type_set_type.rb | 1 - lib/puppet/pops/types/puppet_object.rb | 1 - lib/puppet/pops/types/ruby_generator.rb | 1 - lib/puppet/pops/types/string_converter.rb | 1 - lib/puppet/pops/types/tree_iterators.rb | 1 - lib/puppet/pops/types/type_factory.rb | 1 - lib/puppet/pops/types/type_with_members.rb | 1 - lib/puppet/pops/types/types.rb | 1 - lib/puppet/pops/validation.rb | 1 - lib/puppet/pops/validation/checker4_0.rb | 1 - lib/puppet/pops/validation/tasks_checker.rb | 1 - lib/puppet/ssl/oids.rb | 1 - lib/puppet/type/file/data_sync.rb | 1 - lib/puppet/type/file/selcontext.rb | 1 - lib/puppet/type/service.rb | 1 - lib/puppet/util/backups.rb | 1 - lib/puppet/util/checksums.rb | 1 - lib/puppet/util/command_line/trollop.rb | 2 -- lib/puppet/util/execution.rb | 1 - lib/puppet/util/libuser.rb | 1 - lib/puppet/util/logging.rb | 1 - lib/puppet/util/plist.rb | 1 - lib/puppet/util/posix.rb | 1 - lib/puppet/util/rdoc/code_objects.rb | 1 - lib/puppet/util/rdoc/generators/puppet_generator.rb | 2 -- lib/puppet/util/rdoc/generators/template/puppet/puppet.rb | 2 -- lib/puppet/util/rdoc/parser/puppet_parser_core.rb | 1 - lib/puppet/util/rpm_compare.rb | 1 - lib/puppet/util/rubygems.rb | 1 - lib/puppet/util/selinux.rb | 1 - lib/puppet/util/windows/daemon.rb | 1 - lib/puppet/util/windows/process.rb | 1 - 109 files changed, 133 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 724d58a2f30..a9ee8c98795 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,12 +30,6 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyleAlignWith, Severity. # SupportedStylesAlignWith: keyword, variable, start_of_line diff --git a/lib/puppet/agent/locker.rb b/lib/puppet/agent/locker.rb index b0ac4162412..6a4c1618593 100644 --- a/lib/puppet/agent/locker.rb +++ b/lib/puppet/agent/locker.rb @@ -42,5 +42,4 @@ def lockfile @lockfile end private :lockfile - end diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 00c8a2dddd3..b8293e8b032 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -6,7 +6,6 @@ require_relative '../puppet/application_support' module Puppet - # Defines an abstract Puppet application. # # # Usage diff --git a/lib/puppet/application_support.rb b/lib/puppet/application_support.rb index 2a254c67fa8..1f38e29f0db 100644 --- a/lib/puppet/application_support.rb +++ b/lib/puppet/application_support.rb @@ -8,7 +8,6 @@ module Puppet module ApplicationSupport - # Pushes a Puppet Context configured with a remote environment for an agent # (one that exists at the master end), and a regular environment for other # modes. The configuration is overridden with options from the command line diff --git a/lib/puppet/concurrent/lock.rb b/lib/puppet/concurrent/lock.rb index 623cbe9ce1b..dafec737758 100644 --- a/lib/puppet/concurrent/lock.rb +++ b/lib/puppet/concurrent/lock.rb @@ -3,7 +3,6 @@ module Puppet module Concurrent - # A simple lock that at the moment only does any locking on jruby class Lock include Puppet::Concurrent::Synchronized @@ -11,7 +10,6 @@ def synchronize yield end end - end end diff --git a/lib/puppet/concurrent/synchronized.rb b/lib/puppet/concurrent/synchronized.rb index f74d3785d2b..57f71f6250a 100644 --- a/lib/puppet/concurrent/synchronized.rb +++ b/lib/puppet/concurrent/synchronized.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet module Concurrent - # Including Puppet::Concurrent::Synchronized into a class when running on JRuby # causes all of its instance methods to be synchronized on the instance itself. # When running on MRI it has no effect. @@ -11,6 +10,5 @@ module Concurrent else module Synchronized; end end - end end diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 10340ab921c..8062967d062 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -2,7 +2,6 @@ require_relative '../puppet/util/platform' module Puppet - def self.default_diffargs '-u' end diff --git a/lib/puppet/environments.rb b/lib/puppet/environments.rb index e44b6a6fc32..bd171f36294 100644 --- a/lib/puppet/environments.rb +++ b/lib/puppet/environments.rb @@ -3,7 +3,6 @@ # @api private module Puppet::Environments - class EnvironmentNotFound < Puppet::Error def initialize(environment_name, original = nil) environmentpath = Puppet[:environmentpath] diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb index 4554ee1068b..42c5956f3e0 100644 --- a/lib/puppet/external/dot.rb +++ b/lib/puppet/external/dot.rb @@ -8,7 +8,6 @@ # It also supports undirected edges. module DOT - # These global vars are used to make nice graph source. $tab = ' ' diff --git a/lib/puppet/ffi/posix/functions.rb b/lib/puppet/ffi/posix/functions.rb index b5f8a8a5b2a..b4eef0f8fa6 100644 --- a/lib/puppet/ffi/posix/functions.rb +++ b/lib/puppet/ffi/posix/functions.rb @@ -3,7 +3,6 @@ module Puppet::FFI::POSIX module Functions - extend FFI::Library ffi_convention :stdcall diff --git a/lib/puppet/ffi/windows/functions.rb b/lib/puppet/ffi/windows/functions.rb index f69869a4f25..89d3e04e835 100644 --- a/lib/puppet/ffi/windows/functions.rb +++ b/lib/puppet/ffi/windows/functions.rb @@ -3,7 +3,6 @@ module Puppet::FFI::Windows module Functions - extend FFI::Library include Puppet::FFI::Windows::Constants diff --git a/lib/puppet/ffi/windows/structs.rb b/lib/puppet/ffi/windows/structs.rb index 52ca771fb88..7254eb3cebf 100644 --- a/lib/puppet/ffi/windows/structs.rb +++ b/lib/puppet/ffi/windows/structs.rb @@ -4,7 +4,6 @@ module Puppet::FFI::Windows module Structs - extend FFI::Library extend Puppet::FFI::Windows::APITypes diff --git a/lib/puppet/forge/errors.rb b/lib/puppet/forge/errors.rb index cb9d277f8ea..69551a201cf 100644 --- a/lib/puppet/forge/errors.rb +++ b/lib/puppet/forge/errors.rb @@ -5,7 +5,6 @@ # Puppet::Forge specific exceptions module Puppet::Forge::Errors - # This exception is the parent for all Forge API errors class ForgeError < Puppet::Error # This is normally set by the child class, but if it is not this will @@ -110,5 +109,4 @@ def multiline message.join("\n") end end - end diff --git a/lib/puppet/gettext/module_translations.rb b/lib/puppet/gettext/module_translations.rb index 1a10ccc1404..334f48199b5 100644 --- a/lib/puppet/gettext/module_translations.rb +++ b/lib/puppet/gettext/module_translations.rb @@ -2,7 +2,6 @@ require_relative '../../puppet/gettext/config' module Puppet::ModuleTranslations - # @api private # Loads translation files for each of the specified modules, # if present. Requires the modules to have `forge_name` specified. diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index c50ffa9b0a6..9826c88cc57 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -110,7 +110,6 @@ def build_synopsis(face, action = nil, arguments = nil) end end end - end # This module can be mixed in to provide a full set of documentation diff --git a/lib/puppet/interface/option_manager.rb b/lib/puppet/interface/option_manager.rb index be957967b0a..f5658cd117b 100644 --- a/lib/puppet/interface/option_manager.rb +++ b/lib/puppet/interface/option_manager.rb @@ -5,7 +5,6 @@ # {Puppet::Interface.define define} block). # @api public module Puppet::Interface::OptionManager - # @api private def display_global_options(*args) @display_global_options ||= [] diff --git a/lib/puppet/loaders.rb b/lib/puppet/loaders.rb index 7527f97feaf..ef8b4e41be3 100644 --- a/lib/puppet/loaders.rb +++ b/lib/puppet/loaders.rb @@ -27,5 +27,4 @@ module Loader require_relative '../puppet/pops/loader/puppet_plan_instantiator' end end - end diff --git a/lib/puppet/module_tool/checksums.rb b/lib/puppet/module_tool/checksums.rb index e741020ecc5..143c1b8dacd 100644 --- a/lib/puppet/module_tool/checksums.rb +++ b/lib/puppet/module_tool/checksums.rb @@ -3,7 +3,6 @@ require_relative '../../puppet/network/format_support' module Puppet::ModuleTool - # = Checksums # # This class provides methods for generating checksums for data and adding diff --git a/lib/puppet/module_tool/contents_description.rb b/lib/puppet/module_tool/contents_description.rb index cc8ba379292..e0ebd1e8aa6 100644 --- a/lib/puppet/module_tool/contents_description.rb +++ b/lib/puppet/module_tool/contents_description.rb @@ -2,7 +2,6 @@ require_relative '../../puppet/module_tool' module Puppet::ModuleTool - # = ContentsDescription # # This class populates +Metadata+'s Puppet type information. diff --git a/lib/puppet/module_tool/dependency.rb b/lib/puppet/module_tool/dependency.rb index e950bfa000d..7b70f9689a3 100644 --- a/lib/puppet/module_tool/dependency.rb +++ b/lib/puppet/module_tool/dependency.rb @@ -3,7 +3,6 @@ require_relative '../../puppet/network/format_support' module Puppet::ModuleTool - class Dependency include Puppet::Network::FormatSupport diff --git a/lib/puppet/module_tool/errors/installer.rb b/lib/puppet/module_tool/errors/installer.rb index 2214e19d755..bd9065045eb 100644 --- a/lib/puppet/module_tool/errors/installer.rb +++ b/lib/puppet/module_tool/errors/installer.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::ModuleTool::Errors - class InstallError < ModuleToolError; end class AlreadyInstalledError < InstallError diff --git a/lib/puppet/module_tool/errors/shared.rb b/lib/puppet/module_tool/errors/shared.rb index ebe0a3b9bc0..ad5b85dd376 100644 --- a/lib/puppet/module_tool/errors/shared.rb +++ b/lib/puppet/module_tool/errors/shared.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::ModuleTool::Errors - class NoVersionsSatisfyError < ModuleToolError def initialize(options) @requested_name = options[:requested_name] diff --git a/lib/puppet/module_tool/errors/uninstaller.rb b/lib/puppet/module_tool/errors/uninstaller.rb index a2e7103398c..b98e10f8fb9 100644 --- a/lib/puppet/module_tool/errors/uninstaller.rb +++ b/lib/puppet/module_tool/errors/uninstaller.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::ModuleTool::Errors - class UninstallError < ModuleToolError; end class NoVersionMatchesError < UninstallError diff --git a/lib/puppet/module_tool/errors/upgrader.rb b/lib/puppet/module_tool/errors/upgrader.rb index 2fbb4058fca..8b2883f3177 100644 --- a/lib/puppet/module_tool/errors/upgrader.rb +++ b/lib/puppet/module_tool/errors/upgrader.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::ModuleTool::Errors - class UpgradeError < ModuleToolError def initialize(msg) @action = :upgrade diff --git a/lib/puppet/module_tool/metadata.rb b/lib/puppet/module_tool/metadata.rb index ef8737dda61..7aa56865dd5 100644 --- a/lib/puppet/module_tool/metadata.rb +++ b/lib/puppet/module_tool/metadata.rb @@ -6,7 +6,6 @@ require 'set' module Puppet::ModuleTool - # This class provides a data structure representing a module's metadata. # @api private class Metadata diff --git a/lib/puppet/module_tool/shared_behaviors.rb b/lib/puppet/module_tool/shared_behaviors.rb index bd5eebcffc8..d58c45f4662 100644 --- a/lib/puppet/module_tool/shared_behaviors.rb +++ b/lib/puppet/module_tool/shared_behaviors.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::ModuleTool::Shared - include Puppet::ModuleTool::Errors def get_local_constraints diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb index 663fab1f9af..c1b3abb4186 100644 --- a/lib/puppet/network/http_pool.rb +++ b/lib/puppet/network/http_pool.rb @@ -9,7 +9,6 @@ module Puppet::Network; end # @deprecated Use {Puppet::HTTP::Client} instead. # module Puppet::Network::HttpPool - @http_client_class = Puppet::Network::HTTP::Connection def self.http_client_class diff --git a/lib/puppet/pal/catalog_compiler.rb b/lib/puppet/pal/catalog_compiler.rb index 432db7b802d..e3c757fd1b6 100644 --- a/lib/puppet/pal/catalog_compiler.rb +++ b/lib/puppet/pal/catalog_compiler.rb @@ -102,6 +102,5 @@ def evaluate_ast_node internal_compiler.evaluate_ast_node end end - end end diff --git a/lib/puppet/pal/compiler.rb b/lib/puppet/pal/compiler.rb index 59c42dbc48e..ad44eeeced9 100644 --- a/lib/puppet/pal/compiler.rb +++ b/lib/puppet/pal/compiler.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet module Pal - # A configured compiler as obtained in the callback from `Puppet::Pal.with_script_compiler`. # (Later, there may also be a catalog compiler available.) # @@ -218,6 +217,5 @@ def topscope internal_compiler.topscope end end - end end diff --git a/lib/puppet/pal/function_signature.rb b/lib/puppet/pal/function_signature.rb index 8c49e14585f..fc64b06ea88 100644 --- a/lib/puppet/pal/function_signature.rb +++ b/lib/puppet/pal/function_signature.rb @@ -48,6 +48,5 @@ def callables signatures.is_a?(Puppet::Pops::Types::PVariantType) ? signatures.types : [signatures] end end - end end diff --git a/lib/puppet/pal/pal_impl.rb b/lib/puppet/pal/pal_impl.rb index 5f008ab5abc..4bc11bbc536 100644 --- a/lib/puppet/pal/pal_impl.rb +++ b/lib/puppet/pal/pal_impl.rb @@ -28,7 +28,6 @@ module Puppet # # @api public module Pal - # Defines a context in which multiple operations in an env with a script compiler can be performed in a given block. # The calls that takes place to PAL inside of the given block are all with the same instance of the compiler. # The parameter `configured_by_env` makes it possible to either use the configuration in the environment, or specify diff --git a/lib/puppet/pal/plan_signature.rb b/lib/puppet/pal/plan_signature.rb index 0f65a472b05..3618a7732f6 100644 --- a/lib/puppet/pal/plan_signature.rb +++ b/lib/puppet/pal/plan_signature.rb @@ -67,6 +67,5 @@ def params_type dispatcher.params_struct end end - end end diff --git a/lib/puppet/pal/script_compiler.rb b/lib/puppet/pal/script_compiler.rb index d433714c613..3049a2a85e8 100644 --- a/lib/puppet/pal/script_compiler.rb +++ b/lib/puppet/pal/script_compiler.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet module Pal - class ScriptCompiler < Compiler # Returns the signature of the given plan name # @param plan_name [String] the name of the plan to get the signature of @@ -69,6 +68,5 @@ def list_tasks(filter_regex = nil, error_collector = nil) list_loadable_kind(:task, filter_regex, error_collector) end end - end end diff --git a/lib/puppet/pal/task_signature.rb b/lib/puppet/pal/task_signature.rb index 889cddf24f3..9aa3a9f6cce 100644 --- a/lib/puppet/pal/task_signature.rb +++ b/lib/puppet/pal/task_signature.rb @@ -59,6 +59,5 @@ def task @task end end - end end diff --git a/lib/puppet/parser/abstract_compiler.rb b/lib/puppet/parser/abstract_compiler.rb index 98474e74e6e..b7fe6c12cd8 100644 --- a/lib/puppet/parser/abstract_compiler.rb +++ b/lib/puppet/parser/abstract_compiler.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Parser::AbstractCompiler - # Returns the catalog for a compilation. Must return a Puppet::Resource::Catalog or fail with an # error if the specific compiler does not support catalog operations. # @@ -33,5 +32,4 @@ def qualified_variables def topscope raise Puppet::DevError("Class '#{self.class}' should have implemented 'topscope'") end - end diff --git a/lib/puppet/parser/files.rb b/lib/puppet/parser/files.rb index e7773d3f8a4..935e7072c94 100644 --- a/lib/puppet/parser/files.rb +++ b/lib/puppet/parser/files.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::Parser::Files - module_function # Return a list of manifests as absolute filenames matching the given diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb index 01165a65273..eaedf35f80a 100644 --- a/lib/puppet/parser/functions/split.rb +++ b/lib/puppet/parser/functions/split.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::Parser::Functions - newfunction( :split, :type => :rvalue, :arity => 2, diff --git a/lib/puppet/plugins/syntax_checkers.rb b/lib/puppet/plugins/syntax_checkers.rb index 603418b9fde..de8b89853b0 100644 --- a/lib/puppet/plugins/syntax_checkers.rb +++ b/lib/puppet/plugins/syntax_checkers.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Plugins module SyntaxCheckers - # The lookup **key** for the multibind containing syntax checkers used to syntax check embedded string in non # puppet DSL syntax. # @api public diff --git a/lib/puppet/pops/adapters.rb b/lib/puppet/pops/adapters.rb index 412b441e004..b7d25110b86 100644 --- a/lib/puppet/pops/adapters.rb +++ b/lib/puppet/pops/adapters.rb @@ -3,7 +3,6 @@ # module Puppet::Pops module Adapters - class ObjectIdCacheAdapter < Puppet::Pops::Adaptable::Adapter attr_accessor :cache diff --git a/lib/puppet/pops/evaluator/deferred_resolver.rb b/lib/puppet/pops/evaluator/deferred_resolver.rb index 7e32c66a215..e35e176a5b2 100644 --- a/lib/puppet/pops/evaluator/deferred_resolver.rb +++ b/lib/puppet/pops/evaluator/deferred_resolver.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Evaluator - class DeferredValue def initialize(proc) @proc = proc diff --git a/lib/puppet/pops/evaluator/external_syntax_support.rb b/lib/puppet/pops/evaluator/external_syntax_support.rb index 36b702b9dc3..21668b5af3f 100644 --- a/lib/puppet/pops/evaluator/external_syntax_support.rb +++ b/lib/puppet/pops/evaluator/external_syntax_support.rb @@ -43,5 +43,4 @@ def lookup_keys_for_syntax(syntax) end result end - end diff --git a/lib/puppet/pops/evaluator/runtime3_converter.rb b/lib/puppet/pops/evaluator/runtime3_converter.rb index 67c20bcc796..bf163bb2ec2 100644 --- a/lib/puppet/pops/evaluator/runtime3_converter.rb +++ b/lib/puppet/pops/evaluator/runtime3_converter.rb @@ -217,5 +217,4 @@ def self.convert_return(val3x) @instance = self.new end - end diff --git a/lib/puppet/pops/evaluator/runtime3_resource_support.rb b/lib/puppet/pops/evaluator/runtime3_resource_support.rb index 9fbdc190cc8..b83d4a23633 100644 --- a/lib/puppet/pops/evaluator/runtime3_resource_support.rb +++ b/lib/puppet/pops/evaluator/runtime3_resource_support.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Evaluator - # @api private module Runtime3ResourceSupport CLASS_STRING = 'class' @@ -113,7 +112,6 @@ def self.find_defined_resource_type(scope, type_name) krt.find_definition(type_name) end private_class_method :find_defined_resource_type - end end end diff --git a/lib/puppet/pops/evaluator/runtime3_support.rb b/lib/puppet/pops/evaluator/runtime3_support.rb index cc92cb247eb..c0b9ef5bb0d 100644 --- a/lib/puppet/pops/evaluator/runtime3_support.rb +++ b/lib/puppet/pops/evaluator/runtime3_support.rb @@ -7,7 +7,6 @@ module Evaluator # # @api private module Runtime3Support - NAME_SPACE_SEPARATOR = '::' # Fails the evaluation of _semantic_ with a given issue. diff --git a/lib/puppet/pops/loader/gem_support.rb b/lib/puppet/pops/loader/gem_support.rb index 4e3106ade39..777be507eb3 100644 --- a/lib/puppet/pops/loader/gem_support.rb +++ b/lib/puppet/pops/loader/gem_support.rb @@ -9,7 +9,6 @@ # and then trying to access those. # module Puppet::Pops::Loader::GemSupport - # Produces the root directory of a gem given as an URI (gem://gemname/optional/path), or just the # gemname as a string. # diff --git a/lib/puppet/pops/loader/loader.rb b/lib/puppet/pops/loader/loader.rb index 08ab051eadb..694df6ffa1b 100644 --- a/lib/puppet/pops/loader/loader.rb +++ b/lib/puppet/pops/loader/loader.rb @@ -22,7 +22,6 @@ # module Puppet::Pops module Loader - ENVIRONMENT = 'environment' ENVIRONMENT_PRIVATE = 'environment private' diff --git a/lib/puppet/pops/loader/loader_paths.rb b/lib/puppet/pops/loader/loader_paths.rb index a5872850a27..91148e73d97 100644 --- a/lib/puppet/pops/loader/loader_paths.rb +++ b/lib/puppet/pops/loader/loader_paths.rb @@ -10,7 +10,6 @@ module Puppet::Pops module Loader module LoaderPaths - # Returns an array of SmartPath, each instantiated with a reference to the given loader (for root path resolution # and existence checks). The smart paths in the array appear in precedence order. The returned array may be # mutated. diff --git a/lib/puppet/pops/loader/module_loaders.rb b/lib/puppet/pops/loader/module_loaders.rb index fe93d7ff2a4..8bd233a0dfe 100644 --- a/lib/puppet/pops/loader/module_loaders.rb +++ b/lib/puppet/pops/loader/module_loaders.rb @@ -20,7 +20,6 @@ module Loader # @api private # module ModuleLoaders - # Wildcard module name for module loaders, makes loading possible from any namespace. NAMESPACE_WILDCARD = '*' diff --git a/lib/puppet/pops/loader/predefined_loader.rb b/lib/puppet/pops/loader/predefined_loader.rb index e9d4f9e3e89..23f3cfe3889 100644 --- a/lib/puppet/pops/loader/predefined_loader.rb +++ b/lib/puppet/pops/loader/predefined_loader.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::Pops::Loader - # A PredefinedLoader is a loader that is manually populated with loaded elements # before being used. It never loads anything on its own. # @@ -25,5 +24,4 @@ def synchronize(&block) yield end end - end diff --git a/lib/puppet/pops/loader/runtime3_type_loader.rb b/lib/puppet/pops/loader/runtime3_type_loader.rb index 580f40d4d7f..5a4af917d4c 100644 --- a/lib/puppet/pops/loader/runtime3_type_loader.rb +++ b/lib/puppet/pops/loader/runtime3_type_loader.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Loader - # Runtime3TypeLoader # === # Loads a resource type using the 3.x type loader diff --git a/lib/puppet/pops/lookup/explainer.rb b/lib/puppet/pops/lookup/explainer.rb index 0fa11390332..a38f5afe01c 100644 --- a/lib/puppet/pops/lookup/explainer.rb +++ b/lib/puppet/pops/lookup/explainer.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Lookup - # The ExplainNode contains information of a specific node in a tree traversed during # lookup. The tree can be traversed using the `parent` and `branches` attributes of # each node. diff --git a/lib/puppet/pops/lookup/hiera_config.rb b/lib/puppet/pops/lookup/hiera_config.rb index f8356be94ef..2f99bf50fcc 100644 --- a/lib/puppet/pops/lookup/hiera_config.rb +++ b/lib/puppet/pops/lookup/hiera_config.rb @@ -6,7 +6,6 @@ module Puppet::Pops module Lookup - # @api private class ScopeLookupCollectingInvocation < Invocation def initialize(scope) diff --git a/lib/puppet/pops/model/ast.rb b/lib/puppet/pops/model/ast.rb index 64f9be79747..0017a113ad7 100644 --- a/lib/puppet/pops/model/ast.rb +++ b/lib/puppet/pops/model/ast.rb @@ -4562,7 +4562,6 @@ def eql?(o) end alias == eql? end - end module Model @@ -4671,6 +4670,5 @@ def self.register_pcore_types Loaders.register_static_implementations(all_types) end end - end end diff --git a/lib/puppet/pops/model/pn_transformer.rb b/lib/puppet/pops/model/pn_transformer.rb index 416de658d7d..66b470619c2 100644 --- a/lib/puppet/pops/model/pn_transformer.rb +++ b/lib/puppet/pops/model/pn_transformer.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Model - class PNTransformer extend Puppet::Concurrent::ThreadLocalSingleton @@ -380,6 +379,5 @@ def if_to_pn(e, name) PN::Map.new(entries).as_call(name) end end - end end diff --git a/lib/puppet/pops/parser/epp_support.rb b/lib/puppet/pops/parser/epp_support.rb index 55e502a05e3..6c087d13414 100644 --- a/lib/puppet/pops/parser/epp_support.rb +++ b/lib/puppet/pops/parser/epp_support.rb @@ -6,7 +6,6 @@ module Parser # require 'strscan' module EppSupport - TOKEN_RENDER_STRING = [:RENDER_STRING, nil, 0] TOKEN_RENDER_EXPR = [:RENDER_EXPR, nil, 0] @@ -260,7 +259,6 @@ def scan(skip_leading=false) end end end - end end end diff --git a/lib/puppet/pops/parser/evaluating_parser.rb b/lib/puppet/pops/parser/evaluating_parser.rb index 47e3436a933..d8c94b0cd5e 100644 --- a/lib/puppet/pops/parser/evaluating_parser.rb +++ b/lib/puppet/pops/parser/evaluating_parser.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Parser - # Does not support "import" and parsing ruby files # class EvaluatingParser diff --git a/lib/puppet/pops/parser/heredoc_support.rb b/lib/puppet/pops/parser/heredoc_support.rb index 6aff4ccd2da..4d71b4532e0 100644 --- a/lib/puppet/pops/parser/heredoc_support.rb +++ b/lib/puppet/pops/parser/heredoc_support.rb @@ -146,7 +146,6 @@ def heredoc_text(lines, leading, has_margin, remove_break) result.gsub!(/\r?\n\z/m, '') if remove_break [result, margin_per_line] end - end end end diff --git a/lib/puppet/pops/parser/interpolation_support.rb b/lib/puppet/pops/parser/interpolation_support.rb index 0d821e413e6..94b3c3556e6 100644 --- a/lib/puppet/pops/parser/interpolation_support.rb +++ b/lib/puppet/pops/parser/interpolation_support.rb @@ -6,7 +6,6 @@ # of passing parameters and evaluating conditional logic has a negative impact on performance. # module Puppet::Pops::Parser::InterpolationSupport - PATTERN_VARIABLE = %r{(::)?(\w+::)*\w+} # This is the starting point for a double quoted string with possible interpolation @@ -246,5 +245,4 @@ def interpolate_uq_to(lexer) lexer.enqueue(queue.shift) end end - end diff --git a/lib/puppet/pops/parser/lexer_support.rb b/lib/puppet/pops/parser/lexer_support.rb index 23dc3447442..39f7da58fdb 100644 --- a/lib/puppet/pops/parser/lexer_support.rb +++ b/lib/puppet/pops/parser/lexer_support.rb @@ -2,14 +2,12 @@ module Puppet::Pops module Parser - require_relative '../../../puppet/util/multi_match' # This is an integral part of the Lexer. It is broken out into a separate module # for maintainability of the code, and making the various parts of the lexer focused. # module LexerSupport - # Returns "" if at end of input, else the following 5 characters with \n \r \t escaped def followed_by return "" if @scanner.eos? @@ -215,7 +213,6 @@ def get_bom(content) (content.getbyte(3) || ' ') ) end - end end end diff --git a/lib/puppet/pops/parser/pn_parser.rb b/lib/puppet/pops/parser/pn_parser.rb index 9922ee6be20..390151a4110 100644 --- a/lib/puppet/pops/parser/pn_parser.rb +++ b/lib/puppet/pops/parser/pn_parser.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Parser - class PNParser LIT_TRUE = 'true' LIT_FALSE = 'false' diff --git a/lib/puppet/pops/patterns.rb b/lib/puppet/pops/patterns.rb index eb2110fbc7e..b71857e836c 100644 --- a/lib/puppet/pops/patterns.rb +++ b/lib/puppet/pops/patterns.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true # The Patterns module contains common regular expression patters for the Puppet DSL language module Puppet::Pops::Patterns - # NUMERIC matches hex, octal, decimal, and floating point and captures several parts # 0 = entire matched number, leading and trailing whitespace and sign included # 1 = sign, +, - or nothing @@ -57,5 +56,4 @@ module Puppet::Pops::Patterns # A Numeric var name must be the decimal number 0, or a decimal number not starting with 0 NUMERIC_VAR_NAME = %r{\A(?:0|(?:[1-9][0-9]*))\z} - end diff --git a/lib/puppet/pops/resource/resource_type_impl.rb b/lib/puppet/pops/resource/resource_type_impl.rb index ebef5815f9e..bf90297f47f 100644 --- a/lib/puppet/pops/resource/resource_type_impl.rb +++ b/lib/puppet/pops/resource/resource_type_impl.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Resource - def self.register_ptypes(loader, ir) types = [Param, ResourceTypeImpl].map do |c| c.register_ptype(loader, ir) diff --git a/lib/puppet/pops/serialization/abstract_writer.rb b/lib/puppet/pops/serialization/abstract_writer.rb index 844dceec3d4..765ee16053c 100644 --- a/lib/puppet/pops/serialization/abstract_writer.rb +++ b/lib/puppet/pops/serialization/abstract_writer.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Serialization - MAX_INTEGER = 0x7fffffffffffffff MIN_INTEGER = -0x8000000000000000 diff --git a/lib/puppet/pops/serialization/json.rb b/lib/puppet/pops/serialization/json.rb index 42f3a9c650e..aa5f130c450 100644 --- a/lib/puppet/pops/serialization/json.rb +++ b/lib/puppet/pops/serialization/json.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Serialization - require_relative 'time_factory' require_relative 'abstract_reader' require_relative 'abstract_writer' diff --git a/lib/puppet/pops/serialization/object.rb b/lib/puppet/pops/serialization/object.rb index 42bd458b544..5931791e0d9 100644 --- a/lib/puppet/pops/serialization/object.rb +++ b/lib/puppet/pops/serialization/object.rb @@ -4,7 +4,6 @@ module Puppet::Pops module Serialization - # Instance reader for objects that implement {Types::PuppetObject} # @api private class ObjectReader diff --git a/lib/puppet/pops/serialization/to_stringified_converter.rb b/lib/puppet/pops/serialization/to_stringified_converter.rb index 241c4c46068..fb00270b247 100644 --- a/lib/puppet/pops/serialization/to_stringified_converter.rb +++ b/lib/puppet/pops/serialization/to_stringified_converter.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Serialization - # Class that can process an arbitrary object into a value that is assignable to `Data` # and where contents is converted from rich data to one of: # * Numeric (Integer, Float) diff --git a/lib/puppet/pops/types/annotatable.rb b/lib/puppet/pops/types/annotatable.rb index 3c5a45ad618..7530b662ddf 100644 --- a/lib/puppet/pops/types/annotatable.rb +++ b/lib/puppet/pops/types/annotatable.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - KEY_ANNOTATIONS = 'annotations' # Behaviour common to all Pcore annotatable classes diff --git a/lib/puppet/pops/types/iterable.rb b/lib/puppet/pops/types/iterable.rb index 2d213c75c91..3dcbac22f6b 100644 --- a/lib/puppet/pops/types/iterable.rb +++ b/lib/puppet/pops/types/iterable.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::Pops::Types - # Implemented by classes that can produce an iterator to iterate over their contents module IteratorProducer def iterator diff --git a/lib/puppet/pops/types/p_binary_type.rb b/lib/puppet/pops/types/p_binary_type.rb index 45813e0732f..b11747830d7 100644 --- a/lib/puppet/pops/types/p_binary_type.rb +++ b/lib/puppet/pops/types/p_binary_type.rb @@ -2,7 +2,6 @@ require 'base64' module Puppet::Pops module Types - # A Puppet Language Type that represents binary data content (a sequence of 8-bit bytes). # Instances of this data type can be created from `String` and `Array[Integer[0,255]]` # values. Also see the `binary_file` function for reading binary content from a file. diff --git a/lib/puppet/pops/types/p_init_type.rb b/lib/puppet/pops/types/p_init_type.rb index 1cab1fcee75..454318477a4 100644 --- a/lib/puppet/pops/types/p_init_type.rb +++ b/lib/puppet/pops/types/p_init_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # @api public class PInitType < PTypeWithContainedType def self.register_ptype(loader, ir) diff --git a/lib/puppet/pops/types/p_meta_type.rb b/lib/puppet/pops/types/p_meta_type.rb index f0a617933ff..2420df4430f 100644 --- a/lib/puppet/pops/types/p_meta_type.rb +++ b/lib/puppet/pops/types/p_meta_type.rb @@ -3,7 +3,6 @@ # @api private module Puppet::Pops module Types - KEY_NAME = 'name' KEY_TYPE = 'type' KEY_VALUE = 'value' diff --git a/lib/puppet/pops/types/p_object_type.rb b/lib/puppet/pops/types/p_object_type.rb index 514dbe0e5b2..dfd4b5969ef 100644 --- a/lib/puppet/pops/types/p_object_type.rb +++ b/lib/puppet/pops/types/p_object_type.rb @@ -4,7 +4,6 @@ module Puppet::Pops module Types - KEY_ATTRIBUTES = 'attributes' KEY_CHECKS = 'checks' KEY_CONSTANTS = 'constants' diff --git a/lib/puppet/pops/types/p_object_type_extension.rb b/lib/puppet/pops/types/p_object_type_extension.rb index bd9cc6e0b75..7584796bc41 100644 --- a/lib/puppet/pops/types/p_object_type_extension.rb +++ b/lib/puppet/pops/types/p_object_type_extension.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # Base class for Parameterized Object implementations. The wrapper impersonates the base # object and extends it with methods to filter assignable types and instances based on parameter # values. diff --git a/lib/puppet/pops/types/p_runtime_type.rb b/lib/puppet/pops/types/p_runtime_type.rb index 48b7b6f4014..da31c266a3e 100644 --- a/lib/puppet/pops/types/p_runtime_type.rb +++ b/lib/puppet/pops/types/p_runtime_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # @api public class PRuntimeType < PAnyType TYPE_NAME_OR_PATTERN = PVariantType.new([PStringType::NON_EMPTY, PTupleType.new([PRegexpType::DEFAULT, PStringType::NON_EMPTY])]) diff --git a/lib/puppet/pops/types/p_sem_ver_range_type.rb b/lib/puppet/pops/types/p_sem_ver_range_type.rb index 8b486799640..1c596d7de1a 100644 --- a/lib/puppet/pops/types/p_sem_ver_range_type.rb +++ b/lib/puppet/pops/types/p_sem_ver_range_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # An unparameterized type that represents all VersionRange instances # # @api public diff --git a/lib/puppet/pops/types/p_sem_ver_type.rb b/lib/puppet/pops/types/p_sem_ver_type.rb index 1465c6c63b3..86375605597 100644 --- a/lib/puppet/pops/types/p_sem_ver_type.rb +++ b/lib/puppet/pops/types/p_sem_ver_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # A Puppet Language Type that exposes the {{SemanticPuppet::Version}} and {{SemanticPuppet::VersionRange}}. # The version type is parameterized with version ranges. # diff --git a/lib/puppet/pops/types/p_sensitive_type.rb b/lib/puppet/pops/types/p_sensitive_type.rb index a95125365a9..0af1b969685 100644 --- a/lib/puppet/pops/types/p_sensitive_type.rb +++ b/lib/puppet/pops/types/p_sensitive_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # A Puppet Language type that wraps sensitive information. The sensitive type is parameterized by # the wrapped value type. # @@ -77,6 +76,5 @@ def _assignable?(o, guard) DEFAULT = PSensitiveType.new end - end end diff --git a/lib/puppet/pops/types/p_type_set_type.rb b/lib/puppet/pops/types/p_type_set_type.rb index a8429afe31b..94c09490e3f 100644 --- a/lib/puppet/pops/types/p_type_set_type.rb +++ b/lib/puppet/pops/types/p_type_set_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - KEY_NAME_AUTHORITY = 'name_authority' KEY_TYPES = 'types' KEY_ALIAS = 'alias' diff --git a/lib/puppet/pops/types/puppet_object.rb b/lib/puppet/pops/types/puppet_object.rb index 833822f28e3..bcc88593b60 100644 --- a/lib/puppet/pops/types/puppet_object.rb +++ b/lib/puppet/pops/types/puppet_object.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # Marker module for implementations that are mapped to Object types # @api public module PuppetObject diff --git a/lib/puppet/pops/types/ruby_generator.rb b/lib/puppet/pops/types/ruby_generator.rb index 424ce241aa2..281bc42362d 100644 --- a/lib/puppet/pops/types/ruby_generator.rb +++ b/lib/puppet/pops/types/ruby_generator.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # @api private class RubyGenerator < TypeFormatter RUBY_RESERVED_WORDS = { diff --git a/lib/puppet/pops/types/string_converter.rb b/lib/puppet/pops/types/string_converter.rb index 76517dcc3f7..80ef094fe7e 100644 --- a/lib/puppet/pops/types/string_converter.rb +++ b/lib/puppet/pops/types/string_converter.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Types - # Converts Puppet runtime objects to String under the control of a Format. # Use from Puppet Language is via the function `new`. # diff --git a/lib/puppet/pops/types/tree_iterators.rb b/lib/puppet/pops/types/tree_iterators.rb index 2488c573c90..ac317715d8e 100644 --- a/lib/puppet/pops/types/tree_iterators.rb +++ b/lib/puppet/pops/types/tree_iterators.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops::Types module Iterable - class TreeIterator include Iterable diff --git a/lib/puppet/pops/types/type_factory.rb b/lib/puppet/pops/types/type_factory.rb index 0ac8e3bdc02..358677ddfcb 100644 --- a/lib/puppet/pops/types/type_factory.rb +++ b/lib/puppet/pops/types/type_factory.rb @@ -626,7 +626,6 @@ def self.type_reference(type_string = nil) def self.is_range_parameter?(t) t.is_a?(Integer) || t == 'default' || :default == t end - end end end diff --git a/lib/puppet/pops/types/type_with_members.rb b/lib/puppet/pops/types/type_with_members.rb index 1efa690d361..043a39306ac 100644 --- a/lib/puppet/pops/types/type_with_members.rb +++ b/lib/puppet/pops/types/type_with_members.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Types - # Interface implemented by a type that has InvocableMembers module TypeWithMembers # @return [InvocableMember,nil] An invocable member if it exists, or `nil` diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index 8411883779e..2121f45fc51 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -15,7 +15,6 @@ module Puppet::Pops module Types - # The EMPTY_xxx declarations is for backward compatibility. They should not be explicitly referenced # @api private diff --git a/lib/puppet/pops/validation.rb b/lib/puppet/pops/validation.rb index 584eddaf1e4..3716db4b560 100644 --- a/lib/puppet/pops/validation.rb +++ b/lib/puppet/pops/validation.rb @@ -9,7 +9,6 @@ module Puppet::Pops # * **DiagnosticFormatter** - produces human readable output for a Diagnostic # module Validation - # This class is an abstract base implementation of a _model validation factory_ that creates a validator instance # and associates it with a fully configured DiagnosticProducer. # diff --git a/lib/puppet/pops/validation/checker4_0.rb b/lib/puppet/pops/validation/checker4_0.rb index 925daa02368..8c26d5733d4 100644 --- a/lib/puppet/pops/validation/checker4_0.rb +++ b/lib/puppet/pops/validation/checker4_0.rb @@ -3,7 +3,6 @@ module Puppet::Pops module Validation - # A Validator validates a model. # # Validation is performed on each model element in isolation. Each method should validate the model element's state diff --git a/lib/puppet/pops/validation/tasks_checker.rb b/lib/puppet/pops/validation/tasks_checker.rb index ce3461f3ae2..e6892647e9b 100644 --- a/lib/puppet/pops/validation/tasks_checker.rb +++ b/lib/puppet/pops/validation/tasks_checker.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Puppet::Pops module Validation - # Validator that limits the set of allowed expressions to not include catalog related operations # @api private class TasksChecker < Checker4_0 diff --git a/lib/puppet/ssl/oids.rb b/lib/puppet/ssl/oids.rb index d2587e595dd..5cba2facd59 100644 --- a/lib/puppet/ssl/oids.rb +++ b/lib/puppet/ssl/oids.rb @@ -28,7 +28,6 @@ # # @api private module Puppet::SSL::Oids - # Note: When updating the following OIDs make sure to also update the OID # definitions here: # https://github.com/puppetlabs/puppetserver/blob/master/src/clj/puppetlabs/puppetserver/certificate_authority.clj#L122-L159 diff --git a/lib/puppet/type/file/data_sync.rb b/lib/puppet/type/file/data_sync.rb index 3e4b8f6762d..ba03ec57494 100644 --- a/lib/puppet/type/file/data_sync.rb +++ b/lib/puppet/type/file/data_sync.rb @@ -94,6 +94,5 @@ def contents_sync(param) resource.write(param) return_event end - end end diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb index e3b961be86e..c2bedce5835 100644 --- a/lib/puppet/type/file/selcontext.rb +++ b/lib/puppet/type/file/selcontext.rb @@ -137,6 +137,5 @@ def sync @event = :file_changed defaultto { self.retrieve_default_context(:selrange) } end - end diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index c1a6c646808..cfdf967a7bb 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -6,7 +6,6 @@ # which is why they have a search path for initscripts and such module Puppet - Type.newtype(:service) do @doc = "Manage running services. Service support unfortunately varies widely by platform --- some platforms have very little if any concept of a diff --git a/lib/puppet/util/backups.rb b/lib/puppet/util/backups.rb index e9d9f33a269..43c1979156e 100644 --- a/lib/puppet/util/backups.rb +++ b/lib/puppet/util/backups.rb @@ -2,7 +2,6 @@ require 'find' require 'fileutils' module Puppet::Util::Backups - # Deal with backups. def perform_backup(file = nil) # if they specifically don't want a backup, then just say diff --git a/lib/puppet/util/checksums.rb b/lib/puppet/util/checksums.rb index 90d04c6b881..f9833eeb4cc 100644 --- a/lib/puppet/util/checksums.rb +++ b/lib/puppet/util/checksums.rb @@ -373,5 +373,4 @@ def checksum_stream(digest, block, lite = false) block.call(DigestLite.new(digest, lite)) digest.hexdigest end - end diff --git a/lib/puppet/util/command_line/trollop.rb b/lib/puppet/util/command_line/trollop.rb index da01c822883..22bf448035c 100644 --- a/lib/puppet/util/command_line/trollop.rb +++ b/lib/puppet/util/command_line/trollop.rb @@ -17,7 +17,6 @@ module Puppet module Util class CommandLine module Trollop - VERSION = "1.16.2" ## Thrown by Parser in the event of a commandline error. Not needed if @@ -818,7 +817,6 @@ def die arg, msg=nil end module_function :options, :die, :with_standard_exception_handling - end # module end end diff --git a/lib/puppet/util/execution.rb b/lib/puppet/util/execution.rb index 78b160136ba..6f97a94b3dc 100644 --- a/lib/puppet/util/execution.rb +++ b/lib/puppet/util/execution.rb @@ -16,7 +16,6 @@ class ExecutionFailure < Puppet::Error # in classes that needs to execute system commands. # @api public module Puppet::Util::Execution - # This is the full output from a process. The object itself (a String) is the # stdout of the process. # diff --git a/lib/puppet/util/libuser.rb b/lib/puppet/util/libuser.rb index cddcbe0e7ed..42c884615e1 100644 --- a/lib/puppet/util/libuser.rb +++ b/lib/puppet/util/libuser.rb @@ -9,5 +9,4 @@ def self.getenv newenv['LIBUSER_CONF'] = getconf newenv end - end diff --git a/lib/puppet/util/logging.rb b/lib/puppet/util/logging.rb index 2e006c904ef..d09849efc8d 100644 --- a/lib/puppet/util/logging.rb +++ b/lib/puppet/util/logging.rb @@ -5,7 +5,6 @@ module Puppet::Util module Logging - def send_log(level, message) Puppet::Util::Log.create({:level => level, :source => log_source, :message => message}.merge(log_metadata)) end diff --git a/lib/puppet/util/plist.rb b/lib/puppet/util/plist.rb index 064b92bffec..a3580084b61 100644 --- a/lib/puppet/util/plist.rb +++ b/lib/puppet/util/plist.rb @@ -3,7 +3,6 @@ require_relative '../../puppet/util/execution' module Puppet::Util::Plist - class FormatError < RuntimeError; end # So I don't have to prepend every method name with 'self.' Most of the diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index a9e216096ae..e7f76fdb874 100644 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true # Utility methods for interacting with POSIX objects; mostly user and group module Puppet::Util::POSIX - # This is a list of environment variables that we will set when we want to override the POSIX locale LOCALE_ENV_VARS = ['LANG', 'LC_ALL', 'LC_MESSAGES', 'LANGUAGE', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME'] diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb index 72e91f13af6..c5ce73540e7 100644 --- a/lib/puppet/util/rdoc/code_objects.rb +++ b/lib/puppet/util/rdoc/code_objects.rb @@ -2,7 +2,6 @@ require 'rdoc/code_objects' module RDoc - # This modules contains various class that are used to hold information # about the various Puppet language structures we found while parsing. # diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index 53b62263ae6..f8a3e16e176 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -4,7 +4,6 @@ require 'digest/md5' module Generators - # This module holds all the classes needed to generate the HTML documentation # of a bunch of puppet manifests. # @@ -895,5 +894,4 @@ def gen_method_index gen_an_index(HtmlMethod.all_methods, 'Defines') end end - end diff --git a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb index 2e2e61bc856..92b9c8233b9 100644 --- a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +++ b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb @@ -22,7 +22,6 @@ module RDoc module Page - FONTS = "Verdana,Arial,Helvetica,sans-serif" STYLE = %{ @@ -1062,7 +1061,6 @@ module Page } - end # module Page end # class RDoc diff --git a/lib/puppet/util/rdoc/parser/puppet_parser_core.rb b/lib/puppet/util/rdoc/parser/puppet_parser_core.rb index 382df6fc141..df953c3b717 100644 --- a/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +++ b/lib/puppet/util/rdoc/parser/puppet_parser_core.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true # Functionality common to both our RDoc version 1 and 2 parsers. module RDoc::PuppetParserCore - SITE = "__site__" def self.included(base) diff --git a/lib/puppet/util/rpm_compare.rb b/lib/puppet/util/rpm_compare.rb index e23ee1cd098..24eb7686420 100644 --- a/lib/puppet/util/rpm_compare.rb +++ b/lib/puppet/util/rpm_compare.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true module Puppet::Util::RpmCompare - ARCH_LIST = %w( noarch i386 i686 ppc ppc64 armv3l armv4b armv4l armv4tl armv5tel armv5tejl armv6l armv7l m68kmint s390 s390x ia64 x86_64 sh3 sh4 diff --git a/lib/puppet/util/rubygems.rb b/lib/puppet/util/rubygems.rb index a89f5743970..8269d39fec1 100644 --- a/lib/puppet/util/rubygems.rb +++ b/lib/puppet/util/rubygems.rb @@ -2,7 +2,6 @@ require_relative '../../puppet/util' module Puppet::Util::RubyGems - # Base/factory class for rubygems source. These classes introspec into # rubygems to in order to list where the rubygems system will look for files # to load. diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index abd15263d31..1817d5161d5 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -13,7 +13,6 @@ require 'pathname' module Puppet::Util::SELinux - S_IFREG = 0100000 S_IFDIR = 0040000 S_IFLNK = 0120000 diff --git a/lib/puppet/util/windows/daemon.rb b/lib/puppet/util/windows/daemon.rb index 957fc1c3dd1..3572d6242d8 100644 --- a/lib/puppet/util/windows/daemon.rb +++ b/lib/puppet/util/windows/daemon.rb @@ -2,7 +2,6 @@ require_relative '../../../puppet/ffi/windows' module Puppet::Util::Windows - # The Daemon class, based on the chef/win32-service implementation class Daemon include Puppet::FFI::Windows::Constants diff --git a/lib/puppet/util/windows/process.rb b/lib/puppet/util/windows/process.rb index 09ffc7144d9..f9566523fac 100644 --- a/lib/puppet/util/windows/process.rb +++ b/lib/puppet/util/windows/process.rb @@ -361,5 +361,4 @@ def supports_elevated_security? windows_major_version >= 6 end module_function :supports_elevated_security? - end From 66d053b119161797bb72feafc60aff3a14039243 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Tue, 19 Dec 2023 13:33:09 -0800 Subject: [PATCH 16/17] Layout/EmptyLineAfterGuardClause This commit enables the Rubocop Layout/EmptyLineAfterGuardClause cop and fixes all offenses. --- .rubocop_todo.yml | 4 --- lib/puppet/agent/disabler.rb | 1 + lib/puppet/application.rb | 2 ++ lib/puppet/application/agent.rb | 1 + lib/puppet/application/apply.rb | 2 ++ lib/puppet/application/describe.rb | 2 ++ lib/puppet/application/device.rb | 1 + lib/puppet/application/face_base.rb | 3 ++ lib/puppet/application/filebucket.rb | 2 ++ lib/puppet/application/lookup.rb | 1 + lib/puppet/application/resource.rb | 2 ++ lib/puppet/application/script.rb | 1 + lib/puppet/application/ssl.rb | 1 + lib/puppet/configurer.rb | 3 ++ lib/puppet/confine_collection.rb | 1 + lib/puppet/daemon.rb | 2 ++ lib/puppet/datatypes.rb | 4 +++ lib/puppet/defaults.rb | 2 ++ lib/puppet/environments.rb | 2 ++ lib/puppet/etc.rb | 1 + lib/puppet/face/epp.rb | 2 ++ lib/puppet/face/generate.rb | 1 + lib/puppet/face/help.rb | 1 + lib/puppet/face/module/changes.rb | 1 + lib/puppet/face/module/list.rb | 1 + lib/puppet/face/node/clean.rb | 1 + lib/puppet/file_bucket/dipper.rb | 5 +++ lib/puppet/file_serving/base.rb | 3 ++ lib/puppet/file_serving/configuration.rb | 1 + .../file_serving/configuration/parser.rb | 1 + lib/puppet/file_serving/fileset.rb | 2 ++ lib/puppet/file_serving/mount.rb | 1 + lib/puppet/file_serving/mount/file.rb | 2 ++ lib/puppet/file_serving/mount/modules.rb | 1 + lib/puppet/file_serving/mount/scripts.rb | 1 + lib/puppet/file_serving/mount/tasks.rb | 1 + lib/puppet/file_system/memory_file.rb | 1 + lib/puppet/file_system/memory_impl.rb | 2 ++ lib/puppet/file_system/posix.rb | 2 ++ lib/puppet/file_system/uniquefile.rb | 1 + lib/puppet/file_system/windows.rb | 3 ++ lib/puppet/forge/repository.rb | 1 + lib/puppet/functions.rb | 5 +++ lib/puppet/functions/binary_file.rb | 1 + lib/puppet/functions/defined.rb | 3 ++ lib/puppet/functions/dig.rb | 1 + lib/puppet/functions/eyaml_lookup_key.rb | 1 + lib/puppet/functions/hiera_include.rb | 1 + lib/puppet/functions/match.rb | 1 + lib/puppet/functions/new.rb | 1 + lib/puppet/functions/require.rb | 1 + lib/puppet/functions/slice.rb | 1 + lib/puppet/functions/then.rb | 1 + lib/puppet/functions/yaml_data.rb | 1 + lib/puppet/generate/models/type/property.rb | 1 + lib/puppet/generate/models/type/type.rb | 1 + lib/puppet/generate/type.rb | 3 ++ lib/puppet/gettext/config.rb | 5 +++ lib/puppet/graph/rb_tree_map.rb | 8 +++++ lib/puppet/graph/simple_graph.rb | 6 ++++ lib/puppet/http/client.rb | 3 ++ lib/puppet/http/external_client.rb | 1 + lib/puppet/http/pool.rb | 1 + lib/puppet/http/service/compiler.rb | 1 + lib/puppet/indirector.rb | 1 + lib/puppet/indirector/catalog/compiler.rb | 3 ++ lib/puppet/indirector/direct_file_server.rb | 2 ++ lib/puppet/indirector/facts/facter.rb | 1 + .../indirector/file_bucket_file/file.rb | 5 +++ .../indirector/file_bucket_file/rest.rb | 1 + lib/puppet/indirector/file_server.rb | 1 + lib/puppet/indirector/hiera.rb | 1 + lib/puppet/indirector/indirection.rb | 9 +++++ lib/puppet/indirector/json.rb | 1 + lib/puppet/indirector/memory.rb | 1 + lib/puppet/indirector/msgpack.rb | 2 ++ lib/puppet/indirector/node/exec.rb | 1 + lib/puppet/indirector/report/processor.rb | 1 + lib/puppet/indirector/request.rb | 1 + lib/puppet/indirector/terminus.rb | 2 ++ .../info_service/class_information_service.rb | 2 ++ lib/puppet/interface/action.rb | 3 ++ lib/puppet/interface/action_builder.rb | 3 ++ lib/puppet/interface/action_manager.rb | 1 + lib/puppet/interface/documentation.rb | 5 +++ lib/puppet/interface/face_collection.rb | 3 ++ lib/puppet/interface/option.rb | 6 ++++ lib/puppet/interface/option_builder.rb | 4 +++ lib/puppet/interface/option_manager.rb | 1 + lib/puppet/module.rb | 9 +++++ lib/puppet/module/plan.rb | 2 ++ lib/puppet/module/task.rb | 2 ++ .../module_tool/applications/application.rb | 1 + lib/puppet/module_tool/installed_modules.rb | 1 + lib/puppet/module_tool/metadata.rb | 2 ++ lib/puppet/module_tool/shared_behaviors.rb | 2 ++ lib/puppet/network/format.rb | 4 +++ lib/puppet/network/formats.rb | 6 ++++ lib/puppet/network/http/route.rb | 1 + lib/puppet/node.rb | 1 + lib/puppet/node/environment.rb | 3 ++ lib/puppet/node/facts.rb | 1 + lib/puppet/pal/compiler.rb | 5 +++ lib/puppet/pal/function_signature.rb | 1 + lib/puppet/pal/json_catalog_encoder.rb | 2 ++ lib/puppet/pal/pal_impl.rb | 3 ++ lib/puppet/pal/plan_signature.rb | 1 + lib/puppet/pal/script_compiler.rb | 2 ++ lib/puppet/parameter/path.rb | 1 + lib/puppet/parser/compiler.rb | 2 ++ .../relationship_validator.rb | 2 ++ lib/puppet/parser/functions.rb | 1 + .../parser/functions/create_resources.rb | 1 + lib/puppet/parser/relationship.rb | 2 ++ lib/puppet/parser/resource.rb | 5 +++ lib/puppet/parser/scope.rb | 13 ++++++++ lib/puppet/parser/type_loader.rb | 1 + lib/puppet/pops/adapters.rb | 2 ++ lib/puppet/pops/evaluator/access_operator.rb | 15 +++++++++ .../pops/evaluator/collector_transformer.rb | 2 ++ lib/puppet/pops/evaluator/compare_operator.rb | 12 +++++++ .../pops/evaluator/deferred_resolver.rb | 1 + lib/puppet/pops/evaluator/evaluator_impl.rb | 16 +++++++++ lib/puppet/pops/evaluator/puppet_proc.rb | 1 + .../pops/evaluator/relationship_operator.rb | 1 + .../pops/evaluator/runtime3_converter.rb | 3 ++ lib/puppet/pops/evaluator/runtime3_support.rb | 5 +++ lib/puppet/pops/issue_reporter.rb | 2 ++ lib/puppet/pops/issues.rb | 2 ++ lib/puppet/pops/loader/dependency_loader.rb | 2 ++ lib/puppet/pops/loader/gem_support.rb | 2 ++ lib/puppet/pops/loader/loader_paths.rb | 2 ++ lib/puppet/pops/loader/module_loaders.rb | 3 ++ .../loader/puppet_function_instantiator.rb | 1 + .../pops/loader/puppet_plan_instantiator.rb | 1 + .../loader/ruby_data_type_instantiator.rb | 2 ++ .../pops/loader/ruby_function_instantiator.rb | 2 ++ .../ruby_legacy_function_instantiator.rb | 3 ++ .../pops/loader/runtime3_type_loader.rb | 1 + .../loader/type_definition_instantiator.rb | 1 + lib/puppet/pops/loaders.rb | 4 +++ lib/puppet/pops/lookup/explainer.rb | 1 + lib/puppet/pops/lookup/hiera_config.rb | 7 ++++ lib/puppet/pops/lookup/interpolation.rb | 3 ++ lib/puppet/pops/lookup/lookup_adapter.rb | 2 ++ .../pops/lookup/module_data_provider.rb | 2 ++ lib/puppet/pops/lookup/sub_lookup.rb | 2 ++ lib/puppet/pops/merge_strategy.rb | 2 ++ lib/puppet/pops/model/ast.rb | 1 + lib/puppet/pops/model/factory.rb | 3 ++ lib/puppet/pops/parser/epp_support.rb | 1 + lib/puppet/pops/parser/evaluating_parser.rb | 3 ++ lib/puppet/pops/parser/heredoc_support.rb | 1 + lib/puppet/pops/parser/lexer2.rb | 2 ++ lib/puppet/pops/parser/lexer_support.rb | 1 + lib/puppet/pops/parser/locator.rb | 3 ++ lib/puppet/pops/parser/parser_support.rb | 1 + .../pops/resource/resource_type_impl.rb | 2 ++ .../pops/serialization/abstract_writer.rb | 1 + lib/puppet/pops/serialization/deserializer.rb | 1 + .../pops/serialization/from_data_converter.rb | 2 ++ lib/puppet/pops/serialization/json.rb | 3 ++ lib/puppet/pops/serialization/object.rb | 3 ++ lib/puppet/pops/serialization/serializer.rb | 1 + .../pops/serialization/to_data_converter.rb | 1 + lib/puppet/pops/time/timespan.rb | 9 +++++ lib/puppet/pops/time/timestamp.rb | 3 ++ lib/puppet/pops/types/class_loader.rb | 2 ++ lib/puppet/pops/types/iterable.rb | 5 +++ lib/puppet/pops/types/p_binary_type.rb | 1 + lib/puppet/pops/types/p_init_type.rb | 3 ++ lib/puppet/pops/types/p_object_type.rb | 18 ++++++++++ .../pops/types/p_object_type_extension.rb | 3 ++ lib/puppet/pops/types/p_runtime_type.rb | 2 ++ lib/puppet/pops/types/p_timespan_type.rb | 1 + lib/puppet/pops/types/p_type_set_type.rb | 3 ++ lib/puppet/pops/types/p_uri_type.rb | 1 + lib/puppet/pops/types/ruby_generator.rb | 4 +++ lib/puppet/pops/types/string_converter.rb | 8 +++++ lib/puppet/pops/types/tree_iterators.rb | 3 ++ lib/puppet/pops/types/type_calculator.rb | 6 ++++ lib/puppet/pops/types/type_factory.rb | 3 ++ .../pops/types/type_mismatch_describer.rb | 6 ++++ lib/puppet/pops/types/type_parser.rb | 2 ++ lib/puppet/pops/types/type_set_reference.rb | 1 + lib/puppet/pops/types/types.rb | 33 +++++++++++++++++++ lib/puppet/pops/validation.rb | 1 + lib/puppet/pops/validation/checker4_0.rb | 4 +++ lib/puppet/pops/validation/tasks_checker.rb | 1 + lib/puppet/pops/visitor.rb | 12 +++++++ lib/puppet/property.rb | 2 ++ lib/puppet/provider.rb | 3 ++ lib/puppet/provider/aix_object.rb | 4 +++ lib/puppet/provider/exec/posix.rb | 1 + lib/puppet/provider/exec/windows.rb | 1 + lib/puppet/provider/file/windows.rb | 2 ++ lib/puppet/provider/group/groupadd.rb | 4 +++ lib/puppet/provider/group/ldap.rb | 1 + lib/puppet/provider/group/windows_adsi.rb | 1 + lib/puppet/provider/ldap.rb | 1 + lib/puppet/provider/nameservice.rb | 3 ++ .../provider/nameservice/directoryservice.rb | 5 +++ lib/puppet/provider/package/dnfmodule.rb | 2 ++ lib/puppet/provider/package/dpkg.rb | 1 + lib/puppet/provider/package/gem.rb | 1 + lib/puppet/provider/package/hpux.rb | 1 + lib/puppet/provider/package/macports.rb | 1 + lib/puppet/provider/package/nim.rb | 2 ++ lib/puppet/provider/package/openbsd.rb | 1 + lib/puppet/provider/package/opkg.rb | 1 + lib/puppet/provider/package/pip.rb | 2 ++ lib/puppet/provider/package/pkg.rb | 3 ++ lib/puppet/provider/package/pkgdmg.rb | 4 +++ lib/puppet/provider/package/pkgin.rb | 1 + lib/puppet/provider/package/pkgng.rb | 2 ++ lib/puppet/provider/package/portage.rb | 2 ++ lib/puppet/provider/package/rpm.rb | 2 ++ lib/puppet/provider/package/sun.rb | 2 ++ .../provider/package/windows/package.rb | 1 + lib/puppet/provider/package/yum.rb | 4 +++ lib/puppet/provider/package/zypper.rb | 2 ++ lib/puppet/provider/parsedfile.rb | 4 +++ lib/puppet/provider/service/daemontools.rb | 1 + lib/puppet/provider/service/init.rb | 1 + lib/puppet/provider/service/launchd.rb | 4 +++ lib/puppet/provider/service/smf.rb | 2 ++ lib/puppet/provider/service/src.rb | 1 + lib/puppet/provider/service/systemd.rb | 2 ++ lib/puppet/provider/service/windows.rb | 2 ++ lib/puppet/provider/user/directoryservice.rb | 5 +++ lib/puppet/provider/user/ldap.rb | 1 + lib/puppet/provider/user/pw.rb | 1 + lib/puppet/provider/user/user_role_add.rb | 6 ++++ lib/puppet/provider/user/useradd.rb | 10 ++++++ lib/puppet/provider/user/windows_adsi.rb | 2 ++ lib/puppet/reference/providers.rb | 1 + lib/puppet/reference/type.rb | 1 + lib/puppet/relationship.rb | 1 + lib/puppet/reports/store.rb | 1 + lib/puppet/resource.rb | 5 +++ lib/puppet/resource/catalog.rb | 3 ++ lib/puppet/resource/type.rb | 10 ++++++ lib/puppet/resource/type_collection.rb | 3 ++ lib/puppet/settings.rb | 12 +++++++ lib/puppet/settings/base_setting.rb | 3 ++ lib/puppet/settings/environment_conf.rb | 2 ++ lib/puppet/settings/ttl_setting.rb | 1 + lib/puppet/ssl/base.rb | 3 ++ lib/puppet/ssl/certificate.rb | 2 ++ .../ssl/certificate_request_attributes.rb | 2 ++ lib/puppet/ssl/oids.rb | 1 + lib/puppet/syntax_checkers/base64.rb | 1 + lib/puppet/syntax_checkers/json.rb | 1 + lib/puppet/test/test_helper.rb | 2 ++ lib/puppet/transaction.rb | 3 ++ .../additional_resource_generator.rb | 3 ++ lib/puppet/transaction/event.rb | 1 + lib/puppet/transaction/event_manager.rb | 1 + lib/puppet/transaction/persistence.rb | 1 + lib/puppet/transaction/report.rb | 1 + lib/puppet/transaction/resource_harness.rb | 2 ++ lib/puppet/trusted_external.rb | 3 ++ lib/puppet/type.rb | 14 ++++++++ lib/puppet/type/exec.rb | 6 ++++ lib/puppet/type/file.rb | 10 ++++++ lib/puppet/type/file/checksum_value.rb | 1 + lib/puppet/type/file/content.rb | 2 ++ lib/puppet/type/file/data_sync.rb | 2 ++ lib/puppet/type/file/ensure.rb | 1 + lib/puppet/type/file/mode.rb | 2 ++ lib/puppet/type/file/selcontext.rb | 1 + lib/puppet/type/file/source.rb | 1 + lib/puppet/type/resources.rb | 4 +++ lib/puppet/type/schedule.rb | 1 + lib/puppet/type/service.rb | 3 ++ lib/puppet/type/tidy.rb | 4 +++ lib/puppet/type/user.rb | 4 +++ lib/puppet/util.rb | 1 + lib/puppet/util/autoload.rb | 4 +++ lib/puppet/util/backups.rb | 1 + lib/puppet/util/checksums.rb | 2 ++ lib/puppet/util/command_line/trollop.rb | 5 +++ lib/puppet/util/diff.rb | 1 + lib/puppet/util/docs.rb | 1 + lib/puppet/util/file_watcher.rb | 1 + lib/puppet/util/fileparsing.rb | 1 + lib/puppet/util/filetype.rb | 1 + lib/puppet/util/inifile.rb | 1 + lib/puppet/util/instance_loader.rb | 1 + lib/puppet/util/json_lockfile.rb | 2 ++ lib/puppet/util/log.rb | 6 ++++ lib/puppet/util/logging.rb | 4 +++ lib/puppet/util/metric.rb | 1 + lib/puppet/util/multi_match.rb | 2 ++ lib/puppet/util/package.rb | 2 ++ lib/puppet/util/package/version/debian.rb | 1 + lib/puppet/util/package/version/gem.rb | 1 + lib/puppet/util/package/version/pip.rb | 4 +++ lib/puppet/util/package/version/range.rb | 2 ++ lib/puppet/util/package/version/rpm.rb | 1 + lib/puppet/util/posix.rb | 2 ++ lib/puppet/util/provider_features.rb | 3 ++ lib/puppet/util/rdoc/code_objects.rb | 1 + .../util/rdoc/generators/puppet_generator.rb | 2 ++ .../util/rdoc/parser/puppet_parser_core.rb | 1 + lib/puppet/util/resource_template.rb | 1 + lib/puppet/util/rpm_compare.rb | 3 ++ lib/puppet/util/selinux.rb | 11 +++++++ lib/puppet/util/suidmanager.rb | 4 +++ lib/puppet/util/symbolic_file_mode.rb | 2 ++ lib/puppet/util/warnings.rb | 2 ++ lib/puppet/util/windows/adsi.rb | 8 +++++ lib/puppet/util/windows/com.rb | 2 ++ lib/puppet/util/windows/eventlog.rb | 1 + lib/puppet/util/windows/file.rb | 5 +++ lib/puppet/util/windows/principal.rb | 1 + lib/puppet/util/windows/process.rb | 1 + lib/puppet/util/windows/registry.rb | 1 + lib/puppet/util/windows/security.rb | 1 + lib/puppet/util/windows/service.rb | 10 ++++++ lib/puppet/util/windows/sid.rb | 1 + lib/puppet/version.rb | 1 + lib/puppet/x509/cert_provider.rb | 5 +++ util/rspec_grouper | 1 + 324 files changed, 872 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a9ee8c98795..e7846450031 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,10 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent: I18n/RailsI18n/DecorateString: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLineAfterGuardClause: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLineAfterMagicComment: Enabled: false diff --git a/lib/puppet/agent/disabler.rb b/lib/puppet/agent/disabler.rb index 7608f465e33..bfcf77e7251 100644 --- a/lib/puppet/agent/disabler.rb +++ b/lib/puppet/agent/disabler.rb @@ -41,6 +41,7 @@ def disable_message if data.has_key?(DISABLED_MESSAGE_JSON_KEY) return data[DISABLED_MESSAGE_JSON_KEY] end + nil end diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index b8293e8b032..52c159f22f6 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -169,6 +169,7 @@ def clear? # Thus, long-running background processes can potentially finish their work before a restart. def controlled_run(&block) return unless clear? + result = block.call Process.kill(:HUP, $PID) if restart_requested? result @@ -303,6 +304,7 @@ def run_mode(mode_name = nil) # @api public def environment_mode(mode_name) raise Puppet::Error, _("Invalid environment mode '%{mode_name}'") % { mode_name: mode_name } unless [:local, :remote, :not_required].include?(mode_name) + @environment_mode = mode_name end diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index 93fc3bbf68c..7e7a6f3e4e5 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -404,6 +404,7 @@ def log_config Puppet.settings.stringify_settings(:agent, :all).each_pair do |k,v| next if k.include?("password") || v.to_s.empty? + Puppet.debug("Using setting: #{k}=#{v}") end end diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index f5bd0544c03..960e6259e1b 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -381,6 +381,7 @@ def get_facts() def get_node() node = Puppet::Node.indirection.find(Puppet[:node_name_value]) raise _("Could not find node %{node}") % { node: Puppet[:node_name_value] } unless node + node end @@ -394,6 +395,7 @@ def get_manifest() else manifest = command_line.args.shift raise _("Could not find file %{manifest}") % { manifest: manifest } unless Puppet::FileSystem.exist?(manifest) + Puppet.warning(_("Only one file can be applied per run. Skipping %{files}") % { files: command_line.args.join(', ') }) if command_line.args.size > 0 end manifest diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index 31a3f0a63d3..208e5c67895 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -8,6 +8,7 @@ def initialize(width) def wrap(txt, opts) return "" unless txt && !txt.empty? + work = (opts[:scrub] ? scrub(txt) : txt) indent = (opts[:indent] ? opts[:indent] : 0) textLen = @width - indent @@ -56,6 +57,7 @@ def initialize Puppet::Type.loadall Puppet::Type.eachtype { |type| next if type.name == :component + @types[type.name] = type } end diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb index aa53246d898..ed4b7025a9c 100644 --- a/lib/puppet/application/device.rb +++ b/lib/puppet/application/device.rb @@ -233,6 +233,7 @@ def main if options[:facts] and !options[:target] raise _("facts command requires target") end + unless options[:apply].nil? raise _("missing argument: --target is required when using --apply") if options[:target].nil? raise _("%{file} does not exist, cannot apply") % { file: options[:apply] } unless File.file?(options[:apply]) diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index ca3e15e506b..dd4cfaf6628 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -158,6 +158,7 @@ def find_global_settings_argument(item) Puppet.settings.each do |_name, object| object.optparse_args.each do |arg| next unless arg =~ /^-/ + # sadly, we have to emulate some of optparse here... pattern = /^#{arg.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/ pattern.match item and return object @@ -170,8 +171,10 @@ def find_application_argument(item) self.class.option_parser_commands.each do |options, _function| options.each do |option| next unless option =~ /^-/ + pattern = /^#{option.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/ next unless pattern.match(item) + return { :argument => option =~ /[ =]/, :optional => option =~ /[ =]\[/ diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb index 788768223b9..a9a4d550940 100644 --- a/lib/puppet/application/filebucket.rb +++ b/lib/puppet/application/filebucket.rb @@ -213,6 +213,7 @@ def run_command @args = command_line.args command = args.shift return send(command) if %w{get backup restore diff list}.include? command + help end @@ -254,6 +255,7 @@ def restore def diff raise Puppet::Error, _("Need exactly two arguments: filebucket diff ") unless args.count == 2 + left = args.shift right = args.shift if Puppet::FileSystem.exist?(left) diff --git a/lib/puppet/application/lookup.rb b/lib/puppet/application/lookup.rb index 26df88dcc27..ba0611a447a 100644 --- a/lib/puppet/application/lookup.rb +++ b/lib/puppet/application/lookup.rb @@ -426,6 +426,7 @@ def retrieve_node_facts(node, given_facts) if facts.values.empty? raise _("No facts available for target node: %{node}") % { node: node} end + facts end end diff --git a/lib/puppet/application/resource.rb b/lib/puppet/application/resource.rb index 70af603bf9e..e71c6310876 100644 --- a/lib/puppet/application/resource.rb +++ b/lib/puppet/application/resource.rb @@ -21,6 +21,7 @@ def preinit Puppet::Type.typeloader.loadall(env) Puppet::Type.eachtype do |t| next if t.name == :component + types << t.name.to_s end puts types.sort @@ -241,6 +242,7 @@ def find_or_save_resources(type, name, params) if type == "file" raise _("Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc") end + Puppet::Resource.indirection.search( key, {} ) end end diff --git a/lib/puppet/application/script.rb b/lib/puppet/application/script.rb index 483685674a4..b64e4890bd8 100644 --- a/lib/puppet/application/script.rb +++ b/lib/puppet/application/script.rb @@ -137,6 +137,7 @@ def main else manifest = command_line.args.shift raise _("Could not find file %{manifest}") % { manifest: manifest } unless Puppet::FileSystem.exist?(manifest) + Puppet.warning(_("Only one file can be used per run. Skipping %{files}") % { files: command_line.args.join(', ') }) if command_line.args.size > 0 end diff --git a/lib/puppet/application/ssl.rb b/lib/puppet/application/ssl.rb index c69104c817f..94f623052d3 100644 --- a/lib/puppet/application/ssl.rb +++ b/lib/puppet/application/ssl.rb @@ -156,6 +156,7 @@ def main puppet ssl clean --target END end + clean(certname) when 'bootstrap' if !Puppet::Util::Log.sendlevel?(:info) diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index b76f0a51a1c..bdf3f3f4cce 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -445,6 +445,7 @@ def run_internal(options) if tries > 3 raise Puppet::Error, _("Catalog environment didn't stabilize after %{tries} fetches, aborting run") % { tries: tries } end + Puppet.notice _("Local environment: '%{local_env}' doesn't match server specified environment '%{catalog_env}', restarting agent run with environment '%{catalog_env}'") % { local_env: @environment, catalog_env: catalog.environment } @environment = catalog.environment report.environment = @environment @@ -457,6 +458,7 @@ def run_internal(options) # if we get here, ignore the cached catalog catalog = prepare_and_retrieve_catalog(nil, facts, options, query_options) return nil unless catalog + tries += 1 end @@ -579,6 +581,7 @@ def last_server_specified_environment if Puppet::FileSystem.exist?(Puppet[:lastrunfile]) summary = Puppet::Util::Yaml.safe_load_file(Puppet[:lastrunfile]) return [nil, nil] unless summary['application']['run_mode'] == 'agent' + initial_environment = summary['application']['initial_environment'] converged_environment = summary['application']['converged_environment'] @last_server_specified_environment = converged_environment if initial_environment != converged_environment diff --git a/lib/puppet/confine_collection.rb b/lib/puppet/confine_collection.rb index b5d09503482..09347eca793 100644 --- a/lib/puppet/confine_collection.rb +++ b/lib/puppet/confine_collection.rb @@ -41,6 +41,7 @@ def summary confines.each do |klass, list| value = klass.summarize(list) next if (value.respond_to?(:length) and value.length == 0) or (value == 0) + result[klass.name] = value end result diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index ecb036aff66..3c7b8bfa7fb 100644 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -25,6 +25,7 @@ class Puppet::Daemon def initialize(agent, pidfile, scheduler = Puppet::Scheduler::Scheduler.new()) raise Puppet::DevError, _("Daemons must have an agent") unless agent + @scheduler = scheduler @pidfile = pidfile @agent = agent @@ -80,6 +81,7 @@ def close_streams() def reexec raise Puppet::DevError, _("Cannot reexec unless ARGV arguments are set") unless argv + command = $0 + " " + argv.join(" ") Puppet.notice "Restarting with '#{command}'" stop(:exit => false) diff --git a/lib/puppet/datatypes.rb b/lib/puppet/datatypes.rb index 3d9be7a6410..037c45b9ab2 100644 --- a/lib/puppet/datatypes.rb +++ b/lib/puppet/datatypes.rb @@ -154,6 +154,7 @@ def initialize(type_name) def create_type(loader) raise ArgumentError, _('a data type must have an interface') unless @interface.is_a?(String) + created_type = Puppet::Pops::Types::PObjectType.new( @type_name, Puppet::Pops::Parser::EvaluatingParser.new.parse_string("{ #{@interface} }").body) @@ -193,16 +194,19 @@ def initialize(type_builder) def interface(type_string) raise ArgumentError, _('a data type can only have one interface') unless @type_builder.interface.nil? + @type_builder.interface = type_string end def implementation(&block) raise ArgumentError, _('a data type can only have one implementation') if @type_builder.has_implementation? + @type_builder.implementation = block end def implementation_class(ruby_class) raise ArgumentError, _('a data type can only have one implementation') if @type_builder.has_implementation? + @type_builder.implementation_class = ruby_class end diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 8062967d062..897bb795755 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -30,6 +30,7 @@ def self.valid_file_checksum_types def self.default_cadir return "" if Puppet::Util::Platform.windows? + old_ca_dir = "#{Puppet[:ssldir]}/ca" new_ca_dir = "/etc/puppetlabs/puppetserver/ca" @@ -370,6 +371,7 @@ def self.initialize_default_settings!(settings) paths = ENV['PATH'].split(File::PATH_SEPARATOR) Puppet::Util::Platform.default_paths.each do |path| next if paths.include?(path) + ENV['PATH'] = ENV['PATH'] + File::PATH_SEPARATOR + path end value diff --git a/lib/puppet/environments.rb b/lib/puppet/environments.rb index bd171f36294..ef3c8d800d9 100644 --- a/lib/puppet/environments.rb +++ b/lib/puppet/environments.rb @@ -158,6 +158,7 @@ def initialize(env_name, env_dir, environment) # @!macro loader_get_conf def get_conf(name) return nil unless name.intern == @env_name + Puppet::Settings::EnvironmentConf.load_from(@env_dir, []) end end @@ -266,6 +267,7 @@ def validated_directory(envdir) def valid_environment_names return [] unless Puppet::FileSystem.directory?(@environment_dir) + Puppet::FileSystem.children(@environment_dir).map do |child| Puppet::FileSystem.basename_string(child).intern if validated_directory(child) end.compact diff --git a/lib/puppet/etc.rb b/lib/puppet/etc.rb index ad7360d4906..963d5e6e42d 100644 --- a/lib/puppet/etc.rb +++ b/lib/puppet/etc.rb @@ -161,6 +161,7 @@ def puppet_etc_group_class # :canonical_ struct member. def override_field_values_to_utf8(struct) return nil if struct.nil? + new_struct = struct.is_a?(Etc::Passwd) ? puppet_etc_passwd_class.new : puppet_etc_group_class.new struct.each_pair do |member, value| if value.is_a?(String) diff --git a/lib/puppet/face/epp.rb b/lib/puppet/face/epp.rb index 8178ba292e6..d9ad057cb46 100644 --- a/lib/puppet/face/epp.rb +++ b/lib/puppet/face/epp.rb @@ -359,6 +359,7 @@ end end raise Puppet::Error, _("error while rendering epp") unless status + buffer.string end end @@ -528,6 +529,7 @@ def create_compiler(options) unless given_facts.instance_of?(Hash) raise _("Incorrect formatted data in %{fact_file} given via the --facts flag") % { fact_file: fact_file } end + # It is difficult to add to or modify the set of facts once the node is created # as changes does not show up in parameters. Rather than manually patching up # a node and risking future regressions, a new node is created from scratch diff --git a/lib/puppet/face/generate.rb b/lib/puppet/face/generate.rb index 7bc5fe4b606..a6b22a7f2e1 100644 --- a/lib/puppet/face/generate.rb +++ b/lib/puppet/face/generate.rb @@ -56,6 +56,7 @@ if Puppet::FileSystem.exist?(outputdir) && !Puppet::FileSystem.directory?(outputdir) raise ArgumentError, _("The output directory '%{outputdir}' exists and is not a directory") % { outputdir: outputdir } end + Puppet::FileSystem::mkpath(outputdir) generator.generate(inputs, outputdir, options[:force]) diff --git a/lib/puppet/face/help.rb b/lib/puppet/face/help.rb index aa25b841df8..bcc77c57f34 100644 --- a/lib/puppet/face/help.rb +++ b/lib/puppet/face/help.rb @@ -62,6 +62,7 @@ if actionname raise ArgumentError, _("The legacy subcommand '%{sub_command}' does not support supplying an action") % { sub_command: facename } end + # legacy apps already emit ronn output return render_application_help(facename) else diff --git a/lib/puppet/face/module/changes.rb b/lib/puppet/face/module/changes.rb index e5f087c43a0..743c3f5ac24 100644 --- a/lib/puppet/face/module/changes.rb +++ b/lib/puppet/face/module/changes.rb @@ -27,6 +27,7 @@ unless root_path raise ArgumentError, _("Could not find a valid module at %{path}") % { path: path.inspect } end + Puppet::ModuleTool::Applications::Checksummer.run(root_path, options) end diff --git a/lib/puppet/face/module/list.rb b/lib/puppet/face/module/list.rb index 001c2b66279..b3162b7acc3 100644 --- a/lib/puppet/face/module/list.rb +++ b/lib/puppet/face/module/list.rb @@ -213,6 +213,7 @@ def warn_unmet_dependencies(environment) def list_build_tree(list, ancestors=[], parent=nil, params={}) list.map do |mod| next if @seen[(mod.forge_name or mod.name)] + node = list_build_node(mod, parent, params) @seen[(mod.forge_name or mod.name)] = true diff --git a/lib/puppet/face/node/clean.rb b/lib/puppet/face/node/clean.rb index 2eb76d51951..993e38db9d1 100644 --- a/lib/puppet/face/node/clean.rb +++ b/lib/puppet/face/node/clean.rb @@ -102,6 +102,7 @@ def type_is_ensurable(resource) type = environment.known_resource_types.find_definition(resource.restype) return true if type && type.arguments.keys.include?('ensure') end + return false end end diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index f0dafe8a363..82250d012ff 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -38,6 +38,7 @@ def local? def backup(file) file_handle = Puppet::FileSystem.pathname(file) raise(ArgumentError, _("File %{file} does not exist") % { file: file }) unless Puppet::FileSystem.exist?(file_handle) + begin file_bucket_file = Puppet::FileBucket::File.new(file_handle, :bucket_path => @local_path) files_original_path = absolutize_path(file) @@ -61,6 +62,7 @@ def backup(file) # Diffs two filebucket files identified by their sums def diff(checksum_a, checksum_b, file_a, file_b) raise RuntimeError, _("Diff is not supported on this platform") if Puppet[:diff] == "" + if checksum_a source_path = "#{@rest_path}#{@checksum_type}/#{checksum_a}" if checksum_b @@ -95,6 +97,7 @@ def diff(checksum_a, checksum_b, file_a, file_b) end end raise Puppet::Error, _("Failed to diff files") unless file_diff + file_diff.to_s end @@ -109,6 +112,7 @@ def get_bucket_file(sum) file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path) raise Puppet::Error, _("File not found") unless file_bucket_file + file_bucket_file end @@ -164,6 +168,7 @@ def list(fromdate, todate) :fromdate => fromdate, :todate => todate) raise Puppet::Error, _("File not found") unless file_bucket_list + file_bucket_list.to_s end diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 5b2b95c1c60..2abc679f8e5 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -50,6 +50,7 @@ def links=(value) value = :manage if value == :ignore #TRANSLATORS ':link', ':manage', ':follow' should not be translated raise(ArgumentError, _(":links can only be set to :manage or :follow")) unless [:manage, :follow].include?(value) + @links = value end @@ -58,6 +59,7 @@ def links=(value) def path=(path) raise ArgumentError.new(_("Paths must be fully qualified")) unless Puppet::FileServing::Base.absolute?(path) + @path = path end @@ -67,6 +69,7 @@ def path=(path) def relative_path=(path) raise ArgumentError.new(_("Relative paths must not be fully qualified")) if Puppet::FileServing::Base.absolute?(path) + @relative_path = path end diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index 00cf23ed7f0..57e05f53d55 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -60,6 +60,7 @@ def split_path(request) mount = find_mount(mount_name, request.environment) return nil unless mount + if mount.name == "modules" and mount_name != "modules" # yay backward-compatibility path = "#{mount_name}/#{path}" diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb index 04f041f3d38..85f9d694d67 100644 --- a/lib/puppet/file_serving/configuration/parser.rb +++ b/lib/puppet/file_serving/configuration/parser.rb @@ -30,6 +30,7 @@ def parse value = $2 value.strip! raise(ArgumentError, _("Fileserver configuration file does not use '=' as a separator")) if value =~ /^=/ + case var when "path" path(mount, value) diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index e9bffc08cbb..b0ca063e0f3 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -91,6 +91,7 @@ def links=(links) links = links.to_sym #TRANSLATORS ":links" is a parameter name and should not be translated raise(ArgumentError, _("Invalid :links value '%{links}'") % { links: links }) unless [:manage, :follow].include?(links) + @links = links @stat_method = @links == :manage ? :lstat : :stat end @@ -116,6 +117,7 @@ def initialize_from_request(request) value = request.options[param.to_s] end next if value.nil? + value = true if value == "true" value = false if value == "false" value = Integer(value) if value.is_a?(String) and value =~ /^\d+$/ diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index 5e135db67a4..d85c55ae372 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -20,6 +20,7 @@ def initialize(name) unless name =~ %r{^[-\w]+$} raise ArgumentError, _("Invalid mount name format '%{name}'") % { name: name } end + @name = name super() diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 545ac56c8a3..b64607cb77e 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -55,6 +55,7 @@ def path=(path) else raise ArgumentError, _("%{path} does not exist or is not a directory") % { path: path } unless FileTest.directory?(path) raise ArgumentError, _("%{path} is not readable") % { path: path } unless FileTest.readable?(path) + @expandable = false end @path = path @@ -63,6 +64,7 @@ def path=(path) def search(path, request) path = complete_path(path, request.node) return nil unless path + [path] end diff --git a/lib/puppet/file_serving/mount/modules.rb b/lib/puppet/file_serving/mount/modules.rb index fdead3e20b5..b13c73dc24f 100644 --- a/lib/puppet/file_serving/mount/modules.rb +++ b/lib/puppet/file_serving/mount/modules.rb @@ -7,6 +7,7 @@ class Puppet::FileServing::Mount::Modules < Puppet::FileServing::Mount # Return an instance of the appropriate class. def find(path, request) raise _("No module specified") if path.to_s.empty? + module_name, relative_path = path.split("/", 2) mod = request.environment.module(module_name) return nil unless mod diff --git a/lib/puppet/file_serving/mount/scripts.rb b/lib/puppet/file_serving/mount/scripts.rb index 48d26998feb..746f235dec0 100644 --- a/lib/puppet/file_serving/mount/scripts.rb +++ b/lib/puppet/file_serving/mount/scripts.rb @@ -5,6 +5,7 @@ class Puppet::FileServing::Mount::Scripts < Puppet::FileServing::Mount # Return an instance of the appropriate class. def find(path, request) raise _("No module specified") if path.to_s.empty? + module_name, relative_path = path.split("/", 2) mod = request.environment.module(module_name) return nil unless mod diff --git a/lib/puppet/file_serving/mount/tasks.rb b/lib/puppet/file_serving/mount/tasks.rb index 045cb3c1f00..e344a758d16 100644 --- a/lib/puppet/file_serving/mount/tasks.rb +++ b/lib/puppet/file_serving/mount/tasks.rb @@ -4,6 +4,7 @@ class Puppet::FileServing::Mount::Tasks < Puppet::FileServing::Mount def find(path, request) raise _("No task specified") if path.to_s.empty? + module_name, task_path = path.split("/", 2) mod = request.environment.module(module_name) return nil unless mod diff --git a/lib/puppet/file_system/memory_file.rb b/lib/puppet/file_system/memory_file.rb index b7eed544cf0..30bd800622d 100644 --- a/lib/puppet/file_system/memory_file.rb +++ b/lib/puppet/file_system/memory_file.rb @@ -55,6 +55,7 @@ def each_line(&block) def handle raise Errno::ENOENT unless exist? + StringIO.new(@properties[:content] || '') end diff --git a/lib/puppet/file_system/memory_impl.rb b/lib/puppet/file_system/memory_impl.rb index 5493a0bb2a0..9ee6f746596 100644 --- a/lib/puppet/file_system/memory_impl.rb +++ b/lib/puppet/file_system/memory_impl.rb @@ -32,8 +32,10 @@ def readlink(path) path = path.path link = find(path) return Puppet::FileSystem::MemoryFile.a_missing_file(path) unless link + source = link.source_path return Puppet::FileSystem::MemoryFile.a_missing_file(link) unless source + find(source) || Puppet::FileSystem::MemoryFile.a_missing_file(source) end diff --git a/lib/puppet/file_system/posix.rb b/lib/puppet/file_system/posix.rb index 6b96248c67a..40f0872b396 100644 --- a/lib/puppet/file_system/posix.rb +++ b/lib/puppet/file_system/posix.rb @@ -30,6 +30,7 @@ def compare_stream(path, stream) def stream_blksize(*streams) streams.each do |s| next unless s.respond_to?(:stat) + size = blksize(s.stat) return size if size end @@ -40,6 +41,7 @@ def blksize(st) s = st.blksize return nil unless s return nil if s == 0 + s end diff --git a/lib/puppet/file_system/uniquefile.rb b/lib/puppet/file_system/uniquefile.rb index 23c7dc5aeca..a19a5a98108 100644 --- a/lib/puppet/file_system/uniquefile.rb +++ b/lib/puppet/file_system/uniquefile.rb @@ -79,6 +79,7 @@ def close! def unlink return unless @tmpname + begin File.unlink(@tmpname) rescue Errno::ENOENT diff --git a/lib/puppet/file_system/windows.rb b/lib/puppet/file_system/windows.rb index 0855f46a11e..0c2ea2de1b2 100644 --- a/lib/puppet/file_system/windows.rb +++ b/lib/puppet/file_system/windows.rb @@ -11,6 +11,7 @@ def open(path, mode, options, &block) # Ruby on Windows uses mode for setting file attributes like read-only and # archived, not for setting permissions like POSIX raise TypeError.new('mode must be specified as an Integer') if mode && !mode.is_a?(Numeric) + ::File.open(path, options, nil, &block) end @@ -60,6 +61,7 @@ def symlink(path, dest, options = {}) def symlink?(path) return false if ! Puppet.features.manages_symlinks? + Puppet::Util::Windows::File.symlink?(path) end @@ -102,6 +104,7 @@ def lstat(path) if ! Puppet.features.manages_symlinks? return Puppet::Util::Windows::File.stat(path) end + Puppet::Util::Windows::File.lstat(path) end diff --git a/lib/puppet/forge/repository.rb b/lib/puppet/forge/repository.rb index af7664e7921..307b9e5ea1b 100644 --- a/lib/puppet/forge/repository.rb +++ b/lib/puppet/forge/repository.rb @@ -30,6 +30,7 @@ def initialize(host, for_agent) # Return a Net::HTTPResponse read for this +path+. def make_http_request(path, io = nil) raise ArgumentError, "Path must start with forward slash" unless path.start_with?('/') + begin str = @uri.to_s str.chomp!('/') diff --git a/lib/puppet/functions.rb b/lib/puppet/functions.rb index 7123fa6730a..d784c603285 100644 --- a/lib/puppet/functions.rb +++ b/lib/puppet/functions.rb @@ -272,6 +272,7 @@ def self.default_dispatcher(the_class, func_name) unless the_class.method_defined?(func_name) raise ArgumentError, _("Function Creation Error, cannot create a default dispatcher for function '%{func_name}', no method with this name found") % { func_name: func_name } end + any_signature(*min_max_param(the_class.instance_method(func_name))) end @@ -349,6 +350,7 @@ def self.local_types(&block) if loader.nil? raise ArgumentError, _("No loader present. Call create_loaded_function(:myname, loader,...), instead of 'create_function' if running tests") end + aliases = LocalTypeAliasesBuilder.new(loader, name) aliases.instance_eval(&block) # Add the loaded types to the builder @@ -411,6 +413,7 @@ def initialize(dispatcher, all_callables, loader) def param(type, name) internal_param(type, name) raise ArgumentError, _('A required parameter cannot be added after an optional parameter') if @min != @max + @min += 1 @max += 1 end @@ -460,6 +463,7 @@ def repeated_param(type, name) def required_repeated_param(type, name) internal_param(type, name, true) raise ArgumentError, _('A required repeated parameter cannot be added after an optional parameter') if @min != @max + @min += 1 @max = :default end @@ -520,6 +524,7 @@ def return_type(type) unless type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType) raise ArgumentError, _("Argument to 'return_type' must be a String reference to a Puppet Data Type. Got %{type_class}") % { type_class: type.class } end + @return_type = type end diff --git a/lib/puppet/functions/binary_file.rb b/lib/puppet/functions/binary_file.rb index ad1d68ee8f6..d4225ac9d5b 100644 --- a/lib/puppet/functions/binary_file.rb +++ b/lib/puppet/functions/binary_file.rb @@ -28,6 +28,7 @@ def binary_file(scope, unresolved_path) #TRANSLATORS the string "binary_file()" should not be translated raise Puppet::ParseError, _("binary_file(): The given file '%{unresolved_path}' does not exist") % { unresolved_path: unresolved_path } end + Puppet::Pops::Types::PBinaryType::Binary.from_binary_string(Puppet::FileSystem.binread(path)) end end diff --git a/lib/puppet/functions/defined.rb b/lib/puppet/functions/defined.rb index ce3e89c6c58..1a33b1f298f 100644 --- a/lib/puppet/functions/defined.rb +++ b/lib/puppet/functions/defined.rb @@ -130,11 +130,13 @@ def is_defined(scope, *vals) # rubocop:disable Naming/PredicateName when Puppet::Pops::Types::PResourceType raise ArgumentError, _('The given resource type is a reference to all kind of types') if val.type_name.nil? + type = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, val.type_name) val.title.nil? ? type : scope.compiler.findresource(type, val.title) when Puppet::Pops::Types::PClassType raise ArgumentError, _('The given class type is a reference to all classes') if val.class_name.nil? + scope.compiler.findresource(:class, val.class_name) when Puppet::Pops::Types::PTypeType @@ -149,6 +151,7 @@ def is_defined(scope, *vals) # rubocop:disable Naming/PredicateName # (this is the same as asking for just the class' name, but with the added certainty that it cannot be a defined type. # raise ArgumentError, _('The given class type is a reference to all classes') if val.type.class_name.nil? + Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_hostclass(scope, val.type.class_name) end else diff --git a/lib/puppet/functions/dig.rb b/lib/puppet/functions/dig.rb index aa1dacc03d7..26fbac3ff08 100644 --- a/lib/puppet/functions/dig.rb +++ b/lib/puppet/functions/dig.rb @@ -38,6 +38,7 @@ def dig(data, *args) walked_path = [] args.reduce(data) do | d, k | return nil if d.nil? || k.nil? + if !(d.is_a?(Array) || d.is_a?(Hash)) t = Puppet::Pops::Types::TypeCalculator.infer(d) msg = _("The given data does not contain a Collection at %{walked_path}, got '%{type}'") % { walked_path: walked_path, type: t } diff --git a/lib/puppet/functions/eyaml_lookup_key.rb b/lib/puppet/functions/eyaml_lookup_key.rb index ca7262c15b3..e76c837f90b 100644 --- a/lib/puppet/functions/eyaml_lookup_key.rb +++ b/lib/puppet/functions/eyaml_lookup_key.rb @@ -53,6 +53,7 @@ def load_data_hash(options, context) else msg = _("%{path}: file does not contain a valid yaml hash") % { path: path } raise Puppet::DataBinding::LookupError, msg if Puppet[:strict] == :error && data != false + Puppet.warning(msg) {} end diff --git a/lib/puppet/functions/hiera_include.rb b/lib/puppet/functions/hiera_include.rb index 7f2a07ef896..a6fe41af01f 100644 --- a/lib/puppet/functions/hiera_include.rb +++ b/lib/puppet/functions/hiera_include.rb @@ -100,6 +100,7 @@ def merge_type def post_lookup(scope, key, value) raise Puppet::ParseError, _("Could not find data item %{key}") % { key: key } if value.nil? + call_function_with_scope(scope, 'include', value) unless value.empty? end end diff --git a/lib/puppet/functions/match.rb b/lib/puppet/functions/match.rb index e0248a82ce9..fe6abfa4cfb 100644 --- a/lib/puppet/functions/match.rb +++ b/lib/puppet/functions/match.rb @@ -104,6 +104,7 @@ def match_PVariantType(var_t, s) def match_PRegexpType(regexp_t, s) raise ArgumentError, _("Given Regexp Type has no regular expression") unless regexp_t.pattern + do_match(s, regexp_t.regexp) end diff --git a/lib/puppet/functions/new.rb b/lib/puppet/functions/new.rb index 31416763135..6307fbd32bd 100644 --- a/lib/puppet/functions/new.rb +++ b/lib/puppet/functions/new.rb @@ -991,6 +991,7 @@ def new_instance(scope, t, *args) return args[0] if args.size == 1 && !t.is_a?(Puppet::Pops::Types::PInitType) && t.instance?(args[0]) + result = assert_type(t, new_function_for_type(t).call(scope, *args)) return block_given? ? yield(result) : result end diff --git a/lib/puppet/functions/require.rb b/lib/puppet/functions/require.rb index 98963ace6b7..27a1f42c140 100644 --- a/lib/puppet/functions/require.rb +++ b/lib/puppet/functions/require.rb @@ -69,6 +69,7 @@ def require_impl(scope, *classes) # lookup the class in the scopes klass = (classobj = krt.find_hostclass(klass)) ? classobj.name : nil raise Puppet::ParseError.new(_("Could not find class %{klass}") % { klass: klass }) unless klass + ref = Puppet::Resource.new(:class, klass) resource = scope.resource resource.set_parameter(:require, [resource[:require]].flatten.compact << ref) diff --git a/lib/puppet/functions/slice.rb b/lib/puppet/functions/slice.rb index f0b6a779e85..be68958a6f8 100644 --- a/lib/puppet/functions/slice.rb +++ b/lib/puppet/functions/slice.rb @@ -116,6 +116,7 @@ def asserted_slice_serving_size(pblock, slice_size) if serving_size == 0 raise ArgumentError, _("slice(): block must define at least one parameter. Block has 0.") end + unless serving_size == 1 || serving_size == slice_size raise ArgumentError, _("slice(): block must define one parameter, or the same number of parameters as the given size of the slice (%{slice_size}). Block has %{serving_size}; %{parameter_names}") % { slice_size: slice_size, serving_size: serving_size, parameter_names: pblock.parameter_names.join(', ') } diff --git a/lib/puppet/functions/then.rb b/lib/puppet/functions/then.rb index 7765e03a685..a12d5e72f2c 100644 --- a/lib/puppet/functions/then.rb +++ b/lib/puppet/functions/then.rb @@ -73,6 +73,7 @@ def then(arg) return nil if arg.nil? + yield(arg) end end diff --git a/lib/puppet/functions/yaml_data.rb b/lib/puppet/functions/yaml_data.rb index 9d027a3e218..895de520da1 100644 --- a/lib/puppet/functions/yaml_data.rb +++ b/lib/puppet/functions/yaml_data.rb @@ -29,6 +29,7 @@ def yaml_data(options, context) else msg = _("%{path}: file does not contain a valid yaml hash" % { path: path }) raise Puppet::DataBinding::LookupError, msg if Puppet[:strict] == :error && data != false + Puppet.warning(msg) {} end diff --git a/lib/puppet/generate/models/type/property.rb b/lib/puppet/generate/models/type/property.rb index 828fe62ab21..7b6ab8e73a1 100644 --- a/lib/puppet/generate/models/type/property.rb +++ b/lib/puppet/generate/models/type/property.rb @@ -62,6 +62,7 @@ def self.get_puppet_type(property) boolean = strings.include?('\'true\'') || strings.include?('\'false\'') ? 'Boolean' : nil variant = [boolean, enum, pattern].reject { |t| t.nil? } return variant[0] if variant.size == 1 + "Variant[#{variant.join(', ')}]" end end diff --git a/lib/puppet/generate/models/type/type.rb b/lib/puppet/generate/models/type/type.rb index 528aaf924fa..22bc3c915d2 100644 --- a/lib/puppet/generate/models/type/type.rb +++ b/lib/puppet/generate/models/type/type.rb @@ -45,6 +45,7 @@ def initialize(type) sc.convert(mapping[1].map do |names| next if names.empty? raise Puppet::Error, _('title patterns that use procs are not supported.') unless names.size == 1 + names[0].to_s end, '%p') ] diff --git a/lib/puppet/generate/type.rb b/lib/puppet/generate/type.rb index 59a5e1408d4..424fa63f148 100644 --- a/lib/puppet/generate/type.rb +++ b/lib/puppet/generate/type.rb @@ -39,6 +39,7 @@ def type_name def format=(format) format = format.to_sym raise _("unsupported format '%{format}'.") % { format: format } unless self.class.supported_format?(format) + @format = format end @@ -126,6 +127,7 @@ def self.find_inputs(format = :pcore, environment = Puppet.lookup(:current_envir Puppet.debug "Searching '#{mod.name}' module for custom types." Dir.glob("#{directory}/*.rb") do |file| next unless Puppet::FileSystem.file?(file) + Puppet.debug "Found custom type source file '#{file}'." inputs << Input.new(mod.path, file, format) end @@ -169,6 +171,7 @@ def self.generate(inputs, outputdir = nil, force = false) templates = {} templates.default_proc = lambda { |_hash, key| raise _("template was not found at '%{key}'.") % { key: key } unless Puppet::FileSystem.file?(key) + template = Puppet::Util.create_erb(File.read(key)) template.filename = key template diff --git a/lib/puppet/gettext/config.rb b/lib/puppet/gettext/config.rb index 676ea5bd47d..7c30f18b89a 100644 --- a/lib/puppet/gettext/config.rb +++ b/lib/puppet/gettext/config.rb @@ -64,6 +64,7 @@ def self.loaded_text_domains # @param [String, Symbol] domain_name the name of the domain to create def self.reset_text_domain(domain_name) return if @gettext_disabled || !gettext_loaded? + domain_name = domain_name.to_sym Puppet.debug { "Reset text domain to #{domain_name.inspect}" } @@ -84,6 +85,7 @@ def self.reset_text_domain(domain_name) # non-default text domain. def self.clear_text_domain return if @gettext_disabled || !gettext_loaded? + FastGettext.text_domain = nil end @@ -113,6 +115,7 @@ def self.create_default_text_domain # @param [String, Symbol] domain_name the name of the domain to switch to def self.use_text_domain(domain_name) return if @gettext_disabled || !gettext_loaded? + domain_name = domain_name.to_sym if FastGettext.translation_repositories.include?(domain_name) @@ -136,6 +139,7 @@ def self.delete_all_text_domains # @param [String, Symbol] domain_name the name of the domain to delete def self.delete_text_domain(domain_name) return if @gettext_disabled || !gettext_loaded? + domain_name = domain_name.to_sym deleted = FastGettext.translation_repositories.delete(domain_name) @@ -268,6 +272,7 @@ def self.setup_locale # @param [String] locale the language portion of a locale string (e.g. "ja") def self.set_locale(locale) return if @gettext_disabled || !gettext_loaded? + # make sure we're not using the `available_locales` machinery FastGettext.default_available_locales = nil diff --git a/lib/puppet/graph/rb_tree_map.rb b/lib/puppet/graph/rb_tree_map.rb index 63a2e154d0d..ac49f1c453b 100644 --- a/lib/puppet/graph/rb_tree_map.rb +++ b/lib/puppet/graph/rb_tree_map.rb @@ -123,6 +123,7 @@ def delete(key) result = nil if @root return unless has_key? key + @root, result = delete_recursive(@root, key) @root.color = :black if @root @size -= 1 @@ -182,12 +183,14 @@ def each(&blk) def first return nil unless @root + node = min_recursive(@root) [node.key, node.value] end def last return nil unless @root + node = max_recursive(@root) [node.key, node.value] end @@ -288,6 +291,7 @@ def fixup def recursive_yield(node, &blk) return unless node + recursive_yield(node.left, &blk) yield node.key, node.value recursive_yield(node.right, &blk) @@ -302,6 +306,7 @@ def delete_recursive(node, key) if ( ( (key <=> node.key) == 0) && node.right.nil? ) return nil, node.value end + if ( !isred(node.right) && !isred(node.right.left) ) node.move_red_right end @@ -322,6 +327,7 @@ def delete_min_recursive(node) if node.left.nil? return nil, node.value end + if ( !isred(node.left) && !isred(node.left.left) ) node.move_red_left end @@ -335,6 +341,7 @@ def delete_max_recursive(node) node = node.rotate_right end return nil, node.value if node.right.nil? + if ( !isred(node.right) && !isred(node.right.left) ) node.move_red_right end @@ -345,6 +352,7 @@ def delete_max_recursive(node) def get_recursive(node, key) return nil if node.nil? + case key <=> node.key when 0 then return node when -1 then return get_recursive(node.left, key) diff --git a/lib/puppet/graph/simple_graph.rb b/lib/puppet/graph/simple_graph.rb index e07ccf4420d..96250dd8755 100644 --- a/lib/puppet/graph/simple_graph.rb +++ b/lib/puppet/graph/simple_graph.rb @@ -279,6 +279,7 @@ def add_vertex(vertex) # Remove a vertex from the graph. def remove_vertex!(v) return unless vertex?(v) + @upstream_from.clear @downstream_from.clear (@in_to[v].values+@out_from[v].values).flatten.each { |e| remove_edge!(e) } @@ -300,6 +301,7 @@ def vertices # since they have to specify what kind of edge it is. def add_edge(e,*a) return add_relationship(e,*a) unless a.empty? + e = Puppet::Relationship.from_data_hash(e) if e.is_a?(Hash) @upstream_from.clear @downstream_from.clear @@ -348,6 +350,7 @@ def remove_edge!(e) def adjacent(v, options = {}) ns = (options[:direction] == :in) ? @in_to[v] : @out_from[v] return [] unless ns + (options[:type] == :edges) ? ns.values.flatten : ns.keys end @@ -361,6 +364,7 @@ def walk(source, direction) until stack.empty? node = stack.shift next if seen.member? node + connected = adjacent(node, :direction => direction) connected.each do |target| yield node, target @@ -382,6 +386,7 @@ def tree_from_vertex(start, direction = :out) def downstream_from_vertex(v) return @downstream_from[v] if @downstream_from[v] + result = @downstream_from[v] = {} @out_from[v].keys.each do |node| result[node] = 1 @@ -396,6 +401,7 @@ def direct_dependents_of(v) def upstream_from_vertex(v) return @upstream_from[v] if @upstream_from[v] + result = @upstream_from[v] = {} @in_to[v].keys.each do |node| result[node] = 1 diff --git a/lib/puppet/http/client.rb b/lib/puppet/http/client.rb index c925fcd10a0..14e2affaeee 100644 --- a/lib/puppet/http/client.rb +++ b/lib/puppet/http/client.rb @@ -236,6 +236,7 @@ def head(url, headers: {}, params: {}, options: {}) # @api public def put(url, body, headers: {}, params: {}, options: {}) raise ArgumentError, "'put' requires a string 'body' argument" unless body.is_a?(String) + url = encode_query(url, params) request = Net::HTTP::Put.new(url, @default_headers.merge(headers)) @@ -264,6 +265,7 @@ def put(url, body, headers: {}, params: {}, options: {}) # @api public def post(url, body, headers: {}, params: {}, options: {}, &block) raise ArgumentError, "'post' requires a string 'body' argument" unless body.is_a?(String) + url = encode_query(url, params) request = Net::HTTP::Post.new(url, @default_headers.merge(headers)) @@ -468,6 +470,7 @@ def raise_error(message, cause, connected) def resolve_ssl_context(ssl_context, include_system_store) if ssl_context raise Puppet::HTTP::HTTPError, "The ssl_context and include_system_store parameters are mutually exclusive" if include_system_store + ssl_context elsif include_system_store system_ssl_context diff --git a/lib/puppet/http/external_client.rb b/lib/puppet/http/external_client.rb index dac494e2b76..72e11a8aaae 100644 --- a/lib/puppet/http/external_client.rb +++ b/lib/puppet/http/external_client.rb @@ -39,6 +39,7 @@ def get(url, headers: {}, params: {}, options: {}, &block) # @api private def post(url, body, headers: {}, params: {}, options: {}, &block) raise ArgumentError.new("'post' requires a string 'body' argument") unless body.is_a?(String) + url = encode_query(url, params) options[:use_ssl] = url.scheme == 'https' diff --git a/lib/puppet/http/pool.rb b/lib/puppet/http/pool.rb index 5b5fa27902a..ae62e83d4e0 100644 --- a/lib/puppet/http/pool.rb +++ b/lib/puppet/http/pool.rb @@ -77,6 +77,7 @@ def start(site, verifier, http) # @api private def close_connection(site, http) return false unless http.started? + Puppet.debug("Closing connection for #{site}") http.finish true diff --git a/lib/puppet/http/service/compiler.rb b/lib/puppet/http/service/compiler.rb index 3665ad26bb7..018cc261a8b 100644 --- a/lib/puppet/http/service/compiler.rb +++ b/lib/puppet/http/service/compiler.rb @@ -165,6 +165,7 @@ def post_catalog4(certname, persistence:, environment:, facts: nil, trusted_fact raise ArgumentError.new("The 'persistence' hash is missing the keys: #{missing.join(', ')}") end raise ArgumentError.new("Facts must be a Hash not a #{facts.class}") unless facts.nil? || facts.is_a?(Hash) + body = { certname: certname, persistence: persistence, diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb index 0634eb303e6..2e99f0e2ad9 100644 --- a/lib/puppet/indirector.rb +++ b/lib/puppet/indirector.rb @@ -37,6 +37,7 @@ def self.configure_routes(application_routes) # to override it. def indirects(indirection, options = {}) raise(ArgumentError, _("Already handling indirection for %{current}; cannot also handle %{next}") % { current: @indirection.name, next: indirection }) if @indirection + # populate this class with the various new methods extend ClassMethods include Puppet::Indirector::Envelope diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 8b11cfea7f4..203f1e43cff 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -22,6 +22,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code def extract_facts_from_request(request) text_facts = request.options[:facts] return unless text_facts + format = request.options[:facts_format] unless format raise ArgumentError, _("Facts but no fact format provided for %{request}") % { request: request.key } @@ -34,6 +35,7 @@ def extract_facts_from_request(request) unless facts.name == request.key raise Puppet::Error, _("Catalog for %{request} was requested with fact definition for the wrong node (%{fact_name}).") % { request: request.key.inspect, fact_name: facts.name.inspect } end + return facts end end @@ -87,6 +89,7 @@ def find(request) # filter-out a catalog to remove exported resources def filter(catalog) return catalog.filter { |r| r.virtual? } if catalog.respond_to?(:filter) + catalog end diff --git a/lib/puppet/indirector/direct_file_server.rb b/lib/puppet/indirector/direct_file_server.rb index 26e6a43978d..85afd32982e 100644 --- a/lib/puppet/indirector/direct_file_server.rb +++ b/lib/puppet/indirector/direct_file_server.rb @@ -7,11 +7,13 @@ class Puppet::Indirector::DirectFileServer < Puppet::Indirector::Terminus def find(request) return nil unless Puppet::FileSystem.exist?(request.key) + path2instance(request, request.key) end def search(request) return nil unless Puppet::FileSystem.exist?(request.key) + path2instances(request, request.key) end end diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index 15620659505..0928f1f80f5 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -35,6 +35,7 @@ def find(request) result = if request.options[:resolve_options] raise(Puppet::Error, _("puppet facts show requires version 4.0.40 or greater of Facter.")) unless Facter.respond_to?(:resolve) + find_with_options(request) elsif Puppet[:include_legacy_facts] # to_hash returns both structured and legacy facts diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb index aca7946db87..348e163694f 100644 --- a/lib/puppet/indirector/file_bucket_file/file.rb +++ b/lib/puppet/indirector/file_bucket_file/file.rb @@ -17,6 +17,7 @@ def find(request) # If filebucket mode is 'list' if request.options[:list_all] return nil unless ::File.exist?(request.options[:bucket_path]) + return list(request) end checksum, files_original_path = request_to_checksum_and_path(request) @@ -28,6 +29,7 @@ def find(request) other_contents_file = path_for(request.options[:bucket_path], request.options[:diff_with], 'contents') raise _("could not find diff_with %{diff}") % { diff: request.options[:diff_with] } unless Puppet::FileSystem.exist?(other_contents_file) raise _("Unable to diff on this platform") unless Puppet[:diff] != "" + return diff(Puppet::FileSystem.path_string(contents_file), Puppet::FileSystem.path_string(other_contents_file)) else #TRANSLATORS "FileBucket" should not be translated @@ -129,6 +131,7 @@ def matches(paths_file, files_original_path) def path_match(file_handle, files_original_path) return true unless files_original_path # if no path was provided, it's a match + file_handle.rewind file_handle.each_line do |line| return true if line.chomp == files_original_path @@ -203,8 +206,10 @@ def request_to_checksum_and_path(request) path = nil end raise ArgumentError, _("Unsupported checksum type %{checksum_type}") % { checksum_type: checksum_type.inspect } if checksum_type != Puppet[:digest_algorithm] + expected = method(checksum_type + "_hex_length").call raise _("Invalid checksum %{checksum}") % { checksum: checksum.inspect } if checksum !~ /^[0-9a-f]{#{expected}}$/ + [checksum, path] end diff --git a/lib/puppet/indirector/file_bucket_file/rest.rb b/lib/puppet/indirector/file_bucket_file/rest.rb index 4ebc402c9cc..bcc14b2dea6 100644 --- a/lib/puppet/indirector/file_bucket_file/rest.rb +++ b/lib/puppet/indirector/file_bucket_file/rest.rb @@ -16,6 +16,7 @@ def head(request) ) rescue Puppet::HTTP::ResponseError => e return nil if e.response.code == 404 + raise convert_to_http_error(e.response) end diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index dab0ad44813..0e8177316ff 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -30,6 +30,7 @@ def find(request) # if not. path = mount.find(relative_path, request) return nil unless path + path2instance(request, path) end diff --git a/lib/puppet/indirector/hiera.rb b/lib/puppet/indirector/hiera.rb index 55c34c7e3fa..7a1606fc6aa 100644 --- a/lib/puppet/indirector/hiera.rb +++ b/lib/puppet/indirector/hiera.rb @@ -12,6 +12,7 @@ def initialize(*args) #TRANSLATORS "Hiera" is the name of a code library and should not be translated raise _("Hiera terminus not supported without hiera library") end + super end diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 2c3f5f5b781..65dd0885016 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -33,12 +33,14 @@ def self.instances def self.model(name) match = @@indirections.find { |i| i.name == name } return nil unless match + match.model end # Create and return our cache terminus. def cache raise Puppet::DevError, _("Tried to cache when no cache class was set") unless cache_class + terminus(cache_class) end @@ -66,6 +68,7 @@ def delete def ttl=(value) #TRANSLATORS "TTL" stands for "time to live" and refers to a duration of time raise ArgumentError, _("Indirection TTL must be an integer") unless value.is_a?(Integer) + @ttl = value end @@ -101,6 +104,7 @@ def initialize(model, name, doc: nil, indirected_class: nil, cache_class: nil, t @doc = doc raise(ArgumentError, _("Indirection %{name} is already defined") % { name: @name }) if @@indirections.find { |i| i.name == @name } + @@indirections << self @indirected_class = indirected_class @@ -178,6 +182,7 @@ def validate_terminus_class(terminus_class) unless terminus_class and terminus_class.to_s != "" raise ArgumentError, _("Invalid terminus name %{terminus_class}") % { terminus_class: terminus_class.inspect } end + unless Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class) raise ArgumentError, _("Could not find terminus %{terminus_class} for indirection %{name}") % { terminus_class: terminus_class, name: self.name } @@ -265,6 +270,7 @@ def find_in_cache(request) # See if our instance is in the cache and up to date. cached = cache.find(request) if cache? && ! request.ignore_cache? return nil unless cached + if cached.expired? Puppet.info _("Not using expired %{indirection} for %{request} from cache; expired at %{expiration}") % { indirection: self.name, request: request.key, expiration: cached.expiration } return nil @@ -300,8 +306,10 @@ def search(key, options={}) result = terminus.search(request) if result raise Puppet::DevError, _("Search results from terminus %{terminus_name} are not an array") % { terminus_name: terminus.name } unless result.is_a?(Array) + result.each do |instance| next unless instance.respond_to? :expiration + instance.expiration ||= self.expiration end return result @@ -368,6 +376,7 @@ def make_terminus(terminus_class) unless klass raise ArgumentError, _("Could not find terminus %{terminus_class} for indirection %{indirection}") % { terminus_class: terminus_class, indirection: self.name } end + klass.new end end diff --git a/lib/puppet/indirector/json.rb b/lib/puppet/indirector/json.rb index 1a22143cf0e..be1b37414c8 100644 --- a/lib/puppet/indirector/json.rb +++ b/lib/puppet/indirector/json.rb @@ -26,6 +26,7 @@ def destroy(request) unless detail.is_a? Errno::ENOENT raise Puppet::Error, _("Could not destroy %{json} %{request}: %{detail}") % { json: self.name, request: request.key, detail: detail }, detail.backtrace end + 1 # emulate success... end diff --git a/lib/puppet/indirector/memory.rb b/lib/puppet/indirector/memory.rb index a6f9239eb2a..09c02259c78 100644 --- a/lib/puppet/indirector/memory.rb +++ b/lib/puppet/indirector/memory.rb @@ -13,6 +13,7 @@ def clear def destroy(request) raise ArgumentError.new(_("Could not find %{request} to destroy") % { request: request.key }) unless @instances.include?(request.key) + @instances.delete(request.key) end diff --git a/lib/puppet/indirector/msgpack.rb b/lib/puppet/indirector/msgpack.rb index deef54c5aae..aefcf214496 100644 --- a/lib/puppet/indirector/msgpack.rb +++ b/lib/puppet/indirector/msgpack.rb @@ -11,6 +11,7 @@ def initialize(*args) if ! Puppet.features.msgpack? raise _("MessagePack terminus not supported without msgpack library") end + super end @@ -33,6 +34,7 @@ def destroy(request) unless detail.is_a? Errno::ENOENT raise Puppet::Error, _("Could not destroy %{name} %{request}: %{detail}") % { name: self.name, request: request.key, detail: detail }, detail.backtrace end + 1 # emulate success... end diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index 0fc809aeff6..6fffb766ef7 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -10,6 +10,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec def command command = Puppet[:external_nodes] raise ArgumentError, _("You must set the 'external_nodes' parameter to use the external node terminus") unless command != _("none") + command.split end diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb index 1826b098c7e..5ca41518e07 100644 --- a/lib/puppet/indirector/report/processor.rb +++ b/lib/puppet/indirector/report/processor.rb @@ -49,6 +49,7 @@ def reports def processors(&blk) return [] if Puppet[:reports] == "none" + reports.each do |name| mod = Puppet::Reports.report(name) if mod diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index d8ab43b8f0e..5dee91dfc52 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -101,6 +101,7 @@ def indirection_name=(name) def model ind = indirection raise ArgumentError, _("Could not find indirection '%{indirection}'") % { indirection: indirection_name } unless ind + ind.model end diff --git a/lib/puppet/indirector/terminus.rb b/lib/puppet/indirector/terminus.rb index 812a00d968c..ba68f83cad6 100644 --- a/lib/puppet/indirector/terminus.rb +++ b/lib/puppet/indirector/terminus.rb @@ -52,6 +52,7 @@ def inherited(subclass) if longname =~ /# 0 + processed_name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" } if processed_name.empty? diff --git a/lib/puppet/info_service/class_information_service.rb b/lib/puppet/info_service/class_information_service.rb index c89fe4c7f46..72431aadad8 100644 --- a/lib/puppet/info_service/class_information_service.rb +++ b/lib/puppet/info_service/class_information_service.rb @@ -74,6 +74,7 @@ def extract_param(p) def extract_type(structure, p) return structure if p.type_expr.nil? + structure[:type] = typeexpr_to_string(p.type_expr) structure end @@ -81,6 +82,7 @@ def extract_type(structure, p) def extract_default(structure, p) value_expr = p.value return structure if value_expr.nil? + default_value = value_as_literal(value_expr) structure[:default_literal] = default_value unless default_value.nil? structure[:default_source] = extract_value_source(value_expr) diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index bcd563fe926..7c350ff5203 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -14,6 +14,7 @@ class Puppet::Interface::Action # @api private def initialize(face, name) raise "#{name.inspect} is an invalid action name" unless name.to_s =~ /^[a-z]\w*$/ + @face = face @name = name.to_sym @@ -125,6 +126,7 @@ def set_rendering_method_for(type, proc) if @when_rendering.has_key? type then raise ArgumentError, _("You can't define a rendering method for %{type} twice") % { type: type } end + # Now, the ugly bit. We add the method to our interface object, and # retrieve it, to rotate through the dance of getting a suitable method # object out of the whole process. --daniel 2011-04-18 @@ -315,6 +317,7 @@ def add_display_global_options(*args) #TRANSLATORS 'Puppet.settings' should not be translated raise ArgumentError, _("Global option %{option} does not exist in Puppet.settings") % { option: refopt } end + @display_global_options << refopt end @display_global_options.uniq! diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb index 1c0b2e2d20f..0f1765ded5d 100644 --- a/lib/puppet/interface/action_builder.rb +++ b/lib/puppet/interface/action_builder.rb @@ -17,6 +17,7 @@ class Puppet::Interface::ActionBuilder # @api private def self.build(face, name, &block) raise "Action #{name.inspect} must specify a block" unless block + new(face, name, &block).action end @@ -67,6 +68,7 @@ def when_rendering(type = nil, &block) #TRANSLATORS 'when_rendering' is a method name and should not be translated raise ArgumentError, _('You must give a block to when_rendering') end + @action.set_rendering_method_for(type, block) end @@ -141,6 +143,7 @@ def render_as(value = nil) # Metaprogram the simple DSL from the target class. Puppet::Interface::Action.instance_methods.grep(/=$/).each do |setter| next if setter =~ /^=/ + property = setter.to_s.chomp('=') unless method_defined? property diff --git a/lib/puppet/interface/action_manager.rb b/lib/puppet/interface/action_manager.rb index f63702487a7..35b8520723e 100644 --- a/lib/puppet/interface/action_manager.rb +++ b/lib/puppet/interface/action_manager.rb @@ -81,6 +81,7 @@ def get_default_action if default.length > 1 raise "The actions #{default.map(&:name).join(", ")} cannot all be default" end + default.first end diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index 9826c88cc57..220b7e24443 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -178,6 +178,7 @@ def short_description(value = nil) self.short_description = value unless value.nil? if @short_description.nil? then return nil if @description.nil? + lines = @description.split("\n") first_paragraph_break = lines.index('') || 5 grab = [5, first_paragraph_break].min @@ -209,6 +210,7 @@ def author(value = nil) #TRANSLATORS 'author' is an attribute name and should not be translated raise ArgumentError, _('author should be a single line; use multiple statements for multiple authors') end + @authors.push(Puppet::Interface::DocGen.strip_whitespace(value)) end @authors.empty? ? nil : @authors.join("\n") @@ -229,6 +231,7 @@ def author=(value) #TRANSLATORS 'author' is an attribute name and should not be translated raise ArgumentError, _('author should be a single line; use multiple statements') end + @authors = Array(value).map{|x| Puppet::Interface::DocGen.strip_whitespace(x) } end alias :authors= :author= @@ -250,6 +253,7 @@ def copyright(owner = nil, years = nil) #TRANSLATORS 'copyright' is an attribute name and should not be translated raise ArgumentError, _('copyright takes the owners names, then the years covered') end + self.copyright_owner = owner unless owner.nil? self.copyright_years = years unless years.nil? @@ -328,6 +332,7 @@ def munge_copyright_year(input) #TRANSLATORS 'copyright' is an attribute name and should not be translated raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect } end + Range.new(found[0].to_i, found[1].to_i) else #TRANSLATORS 'copyright' is an attribute name and should not be translated diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb index c2b66d86272..2d1285c28e9 100644 --- a/lib/puppet/interface/face_collection.rb +++ b/lib/puppet/interface/face_collection.rb @@ -27,6 +27,7 @@ def self.get_action_for_face(name, action_name, version) # elsewhere. Usually this will start from :current and all... face = self[name, version] return nil unless face + action = face.get_action(action_name) unless action # ...we need to search for it bound to an o{lder,ther} version. Since @@ -112,10 +113,12 @@ def self.safely_require(name, version = nil) true rescue LoadError => e raise unless e.message =~ %r{-- #{path}$} + # ...guess we didn't find the file; return a much better problem. nil rescue SyntaxError => e raise unless e.message =~ %r{#{path}\.rb:\d+: } + Puppet.err _("Failed to load face %{name}:\n%{detail}") % { name: name, detail: e } # ...but we just carry on after complaining. nil diff --git a/lib/puppet/interface/option.rb b/lib/puppet/interface/option.rb index 4cf143636a0..fb8040d5975 100644 --- a/lib/puppet/interface/option.rb +++ b/lib/puppet/interface/option.rb @@ -21,6 +21,7 @@ def initialize(parent, *declaration, &block) unless item =~ /^-[a-z]\b/ or item =~ /^--[^-]/ then raise ArgumentError, _("%{option}: long options need two dashes (--)") % { option: item.inspect } end + @optparse << item # Duplicate checking... @@ -36,6 +37,7 @@ def initialize(parent, *declaration, &block) if Puppet.settings.include? name then raise ArgumentError, _("%{option}: already defined in puppet") % { option: item.inspect } end + dup = dups[name] if dup raise ArgumentError, _("%{option}: duplicates existing alias %{duplicate} in %{parent}") % @@ -90,6 +92,7 @@ def optparse_to_optionname(declaration) unless found raise ArgumentError, _("Can't find a name in the declaration %{declaration}") % { declaration: declaration.inspect } end + found.captures.first end @@ -99,6 +102,7 @@ def optparse_to_name(declaration) unless name.to_s =~ /^[a-z]\w*$/ raise _("%{name} is an invalid option name") % { name: name.inspect } end + name.to_sym end @@ -122,6 +126,7 @@ def default=(proc) if required raise ArgumentError, _("%{name} can't be optional and have a default value") % { name: self } end + unless proc.is_a? Proc #TRANSLATORS 'proc' is a Ruby block of code raise ArgumentError, _("default value for %{name} is a %{class_name}, not a proc") % @@ -140,6 +145,7 @@ def required=(value) if has_default? raise ArgumentError, _("%{name} can't be optional and have a default value") % { name: self } end + @required = value end diff --git a/lib/puppet/interface/option_builder.rb b/lib/puppet/interface/option_builder.rb index e71c30c3817..b36888c0b7f 100644 --- a/lib/puppet/interface/option_builder.rb +++ b/lib/puppet/interface/option_builder.rb @@ -22,6 +22,7 @@ def initialize(face, *declaration, &block) # Metaprogram the simple DSL from the option class. Puppet::Interface::Option.instance_methods.grep(/=$/).each do |setter| next if setter =~ /^=/ + dsl = setter.to_s.chomp('=') unless private_method_defined? dsl @@ -52,6 +53,7 @@ def before_action(&block) #TRANSLATORS 'before_action' is a method name and should not be translated raise ArgumentError, _("before_action takes three arguments, action, args, and options") end + @option.before_action = block end @@ -72,6 +74,7 @@ def after_action(&block) #TRANSLATORS 'after_action' is a method name and should not be translated raise ArgumentError, _("after_action takes three arguments, action, args, and options") end + @option.after_action = block end @@ -100,6 +103,7 @@ def default_to(&block) #TRANSLATORS 'default_to' is a method name and should not be translated raise ArgumentError, _("%{option} default_to block should not take any arguments") % { option: @option } end + @option.default = block end end diff --git a/lib/puppet/interface/option_manager.rb b/lib/puppet/interface/option_manager.rb index f5658cd117b..be03cb5c04e 100644 --- a/lib/puppet/interface/option_manager.rb +++ b/lib/puppet/interface/option_manager.rb @@ -13,6 +13,7 @@ def display_global_options(*args) #TRANSLATORS 'Puppet.settings' references to the Puppet settings options and should not be translated raise ArgumentError, _("Global option %{option} does not exist in Puppet.settings") % { option: refopt } end + @display_global_options << refopt if refopt end @display_global_options.uniq! diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 98310073465..d38e74935b5 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -34,6 +34,7 @@ class InvalidFilePattern < Error; end # of +path+, return +nil+ def self.find(modname, environment = nil) return nil unless modname + # Unless a specific environment is given, use the current environment env = environment ? Puppet.lookup(:environments).get!(environment) : Puppet.lookup(:current_environment) env.module(modname) @@ -43,18 +44,21 @@ def self.is_module_directory?(name, path) # it must be a directory fullpath = File.join(path, name) return false unless Puppet::FileSystem.directory?(fullpath) + return is_module_directory_name?(name) end def self.is_module_directory_name?(name) # it must match an installed module name according to forge validator return true if name =~ /^[a-z][a-z0-9_]*$/ + return false end def self.is_module_namespaced_name?(name) # it must match the full module name according to forge validator return true if name =~ /^[a-zA-Z0-9]+[-][a-z][a-z0-9_]*$/ + return false end @@ -131,6 +135,7 @@ def has_metadata? end return nil unless Puppet::FileSystem.exist?(full_path) + return full_path end @@ -210,12 +215,14 @@ def license_file return @license_file if defined?(@license_file) return @license_file = nil unless path + @license_file = File.join(path, "License") end def read_metadata md_file = metadata_file return {} if md_file.nil? + content = File.read(md_file, :encoding => 'utf-8') content.empty? ? {} : Puppet::Util::Json.load(content) rescue Errno::ENOENT @@ -250,6 +257,7 @@ def load_metadata unless value.is_a?(Array) raise MissingMetadata, "The value for the key dependencies in the file metadata.json of the module #{self.name} must be an array, not: '#{value}'" end + value.each do |dep| name = dep['name'] dep['name'] = name.tr('-', '/') unless name.nil? @@ -289,6 +297,7 @@ def metadata_file return @metadata_file if defined?(@metadata_file) return @metadata_file = nil unless path + @metadata_file = File.join(path, "metadata.json") end diff --git a/lib/puppet/module/plan.rb b/lib/puppet/module/plan.rb index e9792dc0192..1eacd3bbd17 100644 --- a/lib/puppet/module/plan.rb +++ b/lib/puppet/module/plan.rb @@ -57,6 +57,7 @@ def initialize(plan_name, module_name) def self.is_plan_name?(name) return true if name =~ /^[a-z][a-z0-9_]*$/ + return false end @@ -74,6 +75,7 @@ def self.is_plans_filename?(path) if RESERVED_DATA_TYPES.include?(name) return [false, _("Plan name cannot be a Puppet data type, but was '%{name}'") % { name: name }] end + return [true] end diff --git a/lib/puppet/module/task.rb b/lib/puppet/module/task.rb index 47a419f4eda..92697fd2243 100644 --- a/lib/puppet/module/task.rb +++ b/lib/puppet/module/task.rb @@ -53,6 +53,7 @@ def initialize(task_name, module_name) def self.is_task_name?(name) return true if name =~ /^[a-z][a-z0-9_]*$/ + return false end @@ -64,6 +65,7 @@ def self.is_tasks_file?(path) def self.is_tasks_filename?(path) name_less_extension = File.basename(path, '.*') return false if not is_task_name?(name_less_extension) + FORBIDDEN_EXTENSIONS.each do |ext| return false if path.end_with?(ext) end diff --git a/lib/puppet/module_tool/applications/application.rb b/lib/puppet/module_tool/applications/application.rb index 3ba286a8c25..7133a79cd4c 100644 --- a/lib/puppet/module_tool/applications/application.rb +++ b/lib/puppet/module_tool/applications/application.rb @@ -34,6 +34,7 @@ def discuss(response, success, failure) def metadata(require_metadata = false) return @metadata if @metadata + @metadata = Puppet::ModuleTool::Metadata.new unless @path diff --git a/lib/puppet/module_tool/installed_modules.rb b/lib/puppet/module_tool/installed_modules.rb index b9a00d6b3ca..657122ebb08 100644 --- a/lib/puppet/module_tool/installed_modules.rb +++ b/lib/puppet/module_tool/installed_modules.rb @@ -23,6 +23,7 @@ def initialize(env) modules[path].each do |mod| @by_name[mod.name] = mod next unless mod.has_metadata? + release = ModuleRelease.new(self, mod) @modules[release.name] ||= release end diff --git a/lib/puppet/module_tool/metadata.rb b/lib/puppet/module_tool/metadata.rb index 7aa56865dd5..12485033657 100644 --- a/lib/puppet/module_tool/metadata.rb +++ b/lib/puppet/module_tool/metadata.rb @@ -39,6 +39,7 @@ def dashed_name # Returns a string that uniquely represents this version of this module. def release_name return nil unless @data['name'] && @data['version'] + [ dashed_name, @data['version'] ].join('-') end @@ -110,6 +111,7 @@ def to_json # Expose any metadata keys as callable reader methods. def method_missing(name, *args) return @data[name.to_s] if @data.key? name.to_s + super end diff --git a/lib/puppet/module_tool/shared_behaviors.rb b/lib/puppet/module_tool/shared_behaviors.rb index d58c45f4662..798c5393f26 100644 --- a/lib/puppet/module_tool/shared_behaviors.rb +++ b/lib/puppet/module_tool/shared_behaviors.rb @@ -53,6 +53,7 @@ def implicit_version(mod) if @conditions[mod].all? { |c| c[:queued] || c[:module] == :you } return :latest end + return :best end @@ -98,6 +99,7 @@ def resolve_constraints(dependencies, source = [{:name => :you}], seen = {}, act if !(forced? || @installed[mod].empty? || source.last[:name] == :you) next if range === SemanticPuppet::Version.parse(@installed[mod].first.version) + action = :upgrade elsif @installed[mod].empty? action = :install diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb index 818c2084cc6..f5415b10ff1 100644 --- a/lib/puppet/network/format.rb +++ b/lib/puppet/network/format.rb @@ -50,11 +50,13 @@ def initialize(name, options = {}, &block) def intern(klass, text) return klass.send(intern_method, text) if klass.respond_to?(intern_method) + raise NotImplementedError, "#{klass} does not respond to #{intern_method}; can not intern instances from #{mime}" end def intern_multiple(klass, text) return klass.send(intern_multiple_method, text) if klass.respond_to?(intern_multiple_method) + raise NotImplementedError, "#{klass} does not respond to #{intern_multiple_method}; can not intern multiple instances from #{mime}" end @@ -64,12 +66,14 @@ def mime=(mime) def render(instance) return instance.send(render_method) if instance.respond_to?(render_method) + raise NotImplementedError, "#{instance.class} does not respond to #{render_method}; can not render instances to #{mime}" end def render_multiple(instances) # This method implicitly assumes that all instances are of the same type. return instances[0].class.send(render_multiple_method, instances) if instances[0].class.respond_to?(render_multiple_method) + raise NotImplementedError, _("%{klass} does not respond to %{method}; can not render multiple instances to %{mime}") % { klass: instances[0].class, method: render_multiple_method, mime: mime } end diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index d9cd4662081..aadd8742033 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -8,6 +8,7 @@ def intern(klass, text) data = MessagePack.unpack(text) return data if data.is_a?(klass) + klass.from_data_hash(data) end @@ -112,6 +113,7 @@ def data_to_instance(klass, data) data = d end return data if data.is_a?(klass) + klass.from_data_hash(data) end end @@ -135,6 +137,7 @@ def render_multiple(instances) # have never supported JSON def data_to_instance(klass, data) return data if data.is_a?(klass) + klass.from_data_hash(data) end end @@ -234,6 +237,7 @@ def construct_output(data) def render(datum) return datum if datum.is_a?(String) || datum.is_a?(Numeric) + # Simple hash if datum.is_a?(Hash) data = flatten_hash(datum) @@ -280,6 +284,7 @@ def render_multiple(instances) def data_to_instance(klass, data) Puppet.override({:rich_data => true}) do return data if data.is_a?(klass) + klass.from_data_hash(data) end end @@ -297,6 +302,7 @@ def intern(klass, text) Puppet.override(rich_data: true) do data = MessagePack.unpack(text) return data if data.is_a?(klass) + klass.from_data_hash(data) end end diff --git a/lib/puppet/network/http/route.rb b/lib/puppet/network/http/route.rb index 8f6853886c5..2796a9366ee 100644 --- a/lib/puppet/network/http/route.rb +++ b/lib/puppet/network/http/route.rb @@ -74,6 +74,7 @@ def matches?(request) else Puppet.debug { "Did not match path (#{request.routing_path.inspect})" } end + return false end diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index e47346c17f9..22c487720a3 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -100,6 +100,7 @@ def has_environment_instance? def initialize(name, options = {}) raise ArgumentError, _("Node names cannot be nil") unless name + @name = name classes = options[:classes] diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index 08d3ca62e74..98bd1a72979 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -220,6 +220,7 @@ def externalize_path(filepath) # @api private def conflicting_manifest_settings? return false if !Puppet[:disable_per_environment_manifest] + original_manifest = configuration.raw_setting(:manifest) !original_manifest.nil? && !original_manifest.empty? && original_manifest != Puppet[:default_manifest] end @@ -354,6 +355,7 @@ def modules Puppet::FileSystem.basename_string(p) end.each do |name| next unless Puppet::Module.is_module_directory?(name, path) + warn_about_mistaken_path(path, name) if not seen_modules[name] module_references << {:name => name, :path => File.join(path, name)} @@ -452,6 +454,7 @@ def module_requirements modules.each do |mod| next unless mod.forge_name + deps[mod.forge_name] ||= [] mod.dependencies and mod.dependencies.each do |mod_dep| diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb index c0619b4120d..57b0a5db5e7 100644 --- a/lib/puppet/node/facts.rb +++ b/lib/puppet/node/facts.rb @@ -78,6 +78,7 @@ def sanitize def ==(other) return false unless self.name == other.name + values == other.values end diff --git a/lib/puppet/pal/compiler.rb b/lib/puppet/pal/compiler.rb index ad44eeeced9..34d516c535e 100644 --- a/lib/puppet/pal/compiler.rb +++ b/lib/puppet/pal/compiler.rb @@ -45,6 +45,7 @@ def function_signature(function_name) if func return FunctionSignature.new(func.class) end + # Could not find function nil end @@ -86,6 +87,7 @@ def evaluate_string(puppet_code, source_file = nil) unless puppet_code.is_a?(String) raise ArgumentError, _("The argument 'puppet_code' must be a String, got %{type}") % { type: puppet_code.class } end + evaluate(parse_string(puppet_code, source_file)) end @@ -140,6 +142,7 @@ def parse_string(code_string, source_file = nil) unless code_string.is_a?(String) raise ArgumentError, _("The argument 'code_string' must be a String, got %{type}") % { type: code_string.class } end + internal_evaluator.parse_string(code_string, source_file) end @@ -153,6 +156,7 @@ def parse_file(file) unless file.is_a?(String) raise ArgumentError, _("The argument 'file' must be a String, got %{type}") % { type: file.class } end + internal_evaluator.parse_file(file) end @@ -190,6 +194,7 @@ def create(data_type, *arguments) unless t.is_a?(Puppet::Pops::Types::PAnyType) raise ArgumentError, _("Given data_type value is not a data type, got '%{type}'") % {type: t.class} end + call_function('new', t, *arguments) end diff --git a/lib/puppet/pal/function_signature.rb b/lib/puppet/pal/function_signature.rb index fc64b06ea88..43bb2f63b44 100644 --- a/lib/puppet/pal/function_signature.rb +++ b/lib/puppet/pal/function_signature.rb @@ -32,6 +32,7 @@ def callable_with?(args, callable=nil) return true if callables.any? {|t| t.callable_with?(args) } return false unless block_given? + args_type = Puppet::Pops::Types::TypeCalculator.singleton.infer_set(callable.nil? ? args : args + [callable]) error_message = Puppet::Pops::Types::TypeMismatchDescriber.describe_signatures(@func.name, @func.signatures, args_type) yield error_message diff --git a/lib/puppet/pal/json_catalog_encoder.rb b/lib/puppet/pal/json_catalog_encoder.rb index c514c516dce..f446769c0ef 100644 --- a/lib/puppet/pal/json_catalog_encoder.rb +++ b/lib/puppet/pal/json_catalog_encoder.rb @@ -53,8 +53,10 @@ def encode_resource(type, title) # # TRANSLATORS 'type' and 'title' are internal parameter names - do not translate raise ArgumentError, _("Both type and title must be given") if type.nil? or title.nil? + r = possibly_filtered_catalog.resource(type, title) return nil if r.nil? + r.to_data_hash.to_json(:pretty => pretty) end diff --git a/lib/puppet/pal/pal_impl.rb b/lib/puppet/pal/pal_impl.rb index 4bc11bbc536..28ad79ab7c7 100644 --- a/lib/puppet/pal/pal_impl.rb +++ b/lib/puppet/pal/pal_impl.rb @@ -75,6 +75,7 @@ def self.with_script_compiler( # TRANSLATORS: do not translate the variable names in this error message raise ArgumentError, _("manifest_file or code_string cannot be given when configured_by_env is true") end + # Use the manifest setting manifest_file = Puppet[:manifest] else @@ -181,6 +182,7 @@ def self.with_catalog_compiler( # TRANSLATORS: do not translate the variable names in this error message raise ArgumentError, _("manifest_file or code_string cannot be given when configured_by_env is true") end + # Use the manifest setting manifest_file = Puppet[:manifest] else @@ -325,6 +327,7 @@ def self.in_environment(env_name, if env.nil? raise ArgumentError, _("No directory found for the environment '%{env_name}' on the path '%{envpath}'") % { env_name: env_name, envpath: envpath } end + # A given modulepath should override the default mid_modulepath = modulepath.nil? ? env.modulepath : modulepath env_path = env.configuration.path_to_env diff --git a/lib/puppet/pal/plan_signature.rb b/lib/puppet/pal/plan_signature.rb index 3618a7732f6..e7645561496 100644 --- a/lib/puppet/pal/plan_signature.rb +++ b/lib/puppet/pal/plan_signature.rb @@ -48,6 +48,7 @@ def callable_with?(args_hash) errors = Puppet::Pops::Types::TypeMismatchDescriber.singleton.describe_struct_signature(dispatcher.params_struct, param_scope).flatten return true if errors.empty? + if block_given? yield errors.map {|e| e.format }.join("\n") end diff --git a/lib/puppet/pal/script_compiler.rb b/lib/puppet/pal/script_compiler.rb index 3049a2a85e8..afdece49119 100644 --- a/lib/puppet/pal/script_compiler.rb +++ b/lib/puppet/pal/script_compiler.rb @@ -12,6 +12,7 @@ def plan_signature(plan_name) if func return PlanSignature.new(func) end + # Could not find plan nil end @@ -45,6 +46,7 @@ def task_signature(task_name) if task return TaskSignature.new(task) end + # Could not find task nil end diff --git a/lib/puppet/parameter/path.rb b/lib/puppet/parameter/path.rb index 3bfcae10b5a..2a3960a08d7 100644 --- a/lib/puppet/parameter/path.rb +++ b/lib/puppet/parameter/path.rb @@ -54,6 +54,7 @@ def unsafe_munge(paths) if paths.is_a?(Array) and ! self.class.arrays? then fail _("%{name} only accepts a single path, not an array of paths") % { name: name } end + paths end end diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 1cb9f0c2ae2..2c4d95c9449 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -235,6 +235,7 @@ def evaluate_ast_node # def evaluate_classes(classes, scope, lazy_evaluate = true) raise Puppet::DevError, _("No source for scope passed to evaluate_classes") unless scope.source + class_parameters = nil # if we are a param class, save the classes hash # and transform classes to be the keys @@ -563,6 +564,7 @@ def set_node_parameters # case a custom node terminus has done any mucking about with # node.parameters. next if param.to_s == 'environment' + # Ensure node does not leak Symbol instances in general @topscope[param.to_s] = value.is_a?(Symbol) ? value.to_s : value end diff --git a/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb b/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb index 6b0e5d5be2f..92f0cff2642 100644 --- a/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +++ b/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb @@ -6,6 +6,7 @@ def validate catalog.resources.each do |resource| next unless resource.is_a?(Puppet::Parser::Resource) next if resource.virtual? + resource.eachparam do |param| pclass = Puppet::Type.metaparamclass(param.name) validate_relationship(param) if !pclass.nil? && pclass < Puppet::Type::RelationshipMetaparam @@ -21,6 +22,7 @@ def validate_relationship(param) refs = param.value.is_a?(Array) ? param.value.flatten : [param.value] refs.each do |r| next if r.nil? || r == :undef + res = r.to_s begin found = catalog.resource(res) diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index 9648f8d4dd1..24ef728b091 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -213,6 +213,7 @@ def self.newfunction(name, options = {}, &block) elsif arity < 0 and args[0].size < (arity+1).abs raise ArgumentError, _("%{name}(): Wrong number of arguments given (%{arg_count} for minimum %{min_arg_count})") % { name: name, arg_count: args[0].size, min_arg_count: (arity+1).abs } end + r = Puppet::Pops::Evaluator::Runtime3FunctionArgumentConverter.convert_return(self.send(real_fname, args[0])) # avoid leaking aribtrary value if not being an rvalue function options[:type] == :rvalue ? r : nil diff --git a/lib/puppet/parser/functions/create_resources.rb b/lib/puppet/parser/functions/create_resources.rb index 60dedcf03a3..ca6ce55cd0f 100644 --- a/lib/puppet/parser/functions/create_resources.rb +++ b/lib/puppet/parser/functions/create_resources.rb @@ -60,6 +60,7 @@ raise ArgumentError, (_("create_resources(): wrong number of arguments (%{count}; must be 2 or 3)") % { count: args.length }) if args.length > 3 raise ArgumentError, (_('create_resources(): second argument must be a hash')) unless args[1].is_a?(Hash) + if args.length == 3 raise ArgumentError, (_('create_resources(): third argument, if provided, must be a hash')) unless args[2].is_a?(Hash) end diff --git a/lib/puppet/parser/relationship.rb b/lib/puppet/parser/relationship.rb index d4078eccfd2..74b7959aab6 100644 --- a/lib/puppet/parser/relationship.rb +++ b/lib/puppet/parser/relationship.rb @@ -44,6 +44,7 @@ def mk_relationship(source, target, catalog) unless catalog.resource(*target_ref) raise ArgumentError, _("Could not find resource '%{target}' for relationship from '%{source}'") % { target: target.to_s, source: source.to_s } end + Puppet.debug {"Adding relationship from #{source} to #{target} with '#{param_name}'"} if source_resource[rel_param].class != Array source_resource[rel_param] = [source_resource[rel_param]].compact @@ -60,6 +61,7 @@ def leftmost_alternative(x) if x.is_a?(Puppet::Pops::Evaluator::Collectors::AbstractCollector) collected = x.collected return collected.values unless collected.empty? + adapter = Puppet::Pops::Adapters::EmptyAlternativeAdapter.get(x) adapter.nil? ? [] : leftmost_alternative(adapter.empty_alternative) elsif x.is_a?(Array) && x.size == 1 && x[0].is_a?(Puppet::Pops::Evaluator::Collectors::AbstractCollector) diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index eaab49ea7e9..e93cf7a444a 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -34,6 +34,7 @@ def [](param) if param == :title return self.title end + if @parameters.has_key?(param) @parameters[param].value else @@ -69,6 +70,7 @@ def add_edge_to_stage # Retrieve the associated definition and evaluate it. def evaluate return if evaluated? + Puppet::Util::Profiler.profile(_("Evaluated resource %{res}") % { res: self }, [:compiler, :evaluate_resource, self]) do @evaluated = true if builtin_type? @@ -98,6 +100,7 @@ def exported=(value) # def finish_evaluation return if @evaluation_finished + add_scope_tags @evaluation_finished = true end @@ -111,6 +114,7 @@ def finish_evaluation # @api private def finish(do_validate = true) return if finished? + @finished = true finish_evaluation replace_sensitive_data @@ -125,6 +129,7 @@ def finished? def initialize(type, title, attributes, with_defaults = true) raise ArgumentError, _('Resources require a hash as last argument') unless attributes.is_a? Hash raise ArgumentError, _('Resources require a scope') unless attributes[:scope] + super(type, title, attributes) @source ||= scope.source diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 363aae18d20..f30c7d039c3 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -209,6 +209,7 @@ def parameter_reference_failure(from, to) # Parameters are evaluated in the order they have in the @params hash. keys = @params.keys raise Puppet::Error, _("%{callee}: expects a value for parameter $%{to}") % { callee: @callee_name, to: to } if keys.index(to) < keys.index(from) + raise Puppet::Error, _("%{callee}: default expression for $%{from} tries to illegally access not yet evaluated $%{to}") % { callee: @callee_name, from: from, to: to } end private :parameter_reference_failure @@ -223,12 +224,14 @@ def initialize(parent, callee_name, param_names) def [](name) access = @params[name] return super if access.nil? + throw(:unevaluated_parameter, name) unless access.assigned? access.value end def []=(name, value) raise Puppet::Error, _("Attempt to assign variable %{name} when evaluating parameters") % { name: name } if @read_only + @params[name] ||= Access.new @params[name].value = value end @@ -520,6 +523,7 @@ def variable_not_found(name, reason=nil) if BUILT_IN_VARS.include?(name) || name =~ Puppet::Pops::Patterns::NUMERIC_VAR_NAME return nil end + begin throw(:undefined_variable, reason) rescue UNCAUGHT_THROW_EXCEPTION @@ -610,6 +614,7 @@ def lookup_qualified_variable(fqn, options) qs = qualified_scope(class_name) unless qs.nil? return qs.get_local_variable(leaf_name) if qs.has_local_variable?(leaf_name) + iscope = qs.inherited_scope return lookup_qualified_variable("#{iscope.source.name}::#{leaf_name}", options) unless iscope.nil? end @@ -654,8 +659,10 @@ def has_enclosing_scope? def qualified_scope(classname) klass = find_hostclass(classname) raise _("class %{classname} could not be found") % { classname: classname } unless klass + kscope = class_scope(klass) raise _("class %{classname} has not been evaluated") % { classname: classname } unless kscope + kscope end private :qualified_scope @@ -687,6 +694,7 @@ def newscope(options = {}) def parent_module_name return nil unless @parent && @parent.source + @parent.source.module_name end @@ -703,6 +711,7 @@ def define_settings(type, params) if table.include?(param.name) raise Puppet::ParseError.new(_("Default already defined for %{type} { %{param} }; cannot redefine") % { type: type, param: param.name }, param.file, param.line) end + table[param.name] = param } end @@ -717,6 +726,7 @@ def merge_settings(env_name, set_in_this_scope=true) all_local = {} settings.each_key do |name| next if :name == name + key = name.to_s value = transform_setting(settings.value_sym(name, env_name)) if set_in_this_scope @@ -1011,6 +1021,7 @@ def ephemeral_from(match, file = nil, line = nil) new_ephemeral(false) else raise(ArgumentError,_("Invalid regex match data. Got a %{klass}") % { klass: match.class }) unless match.is_a?(MatchData) + # Create a match ephemeral and set values from match data new_match_scope(match) end @@ -1071,6 +1082,7 @@ def transform_and_assert_classnames(names) raise ArgumentError, _("Cannot use undef as a class name") when String raise ArgumentError, _("Cannot use empty string as a class name") if name.empty? + name.sub(/^([^:]{1,2})/, '::\1') when Puppet::Resource @@ -1080,6 +1092,7 @@ def transform_and_assert_classnames(names) when Puppet::Pops::Types::PClassType #TRANSLATORS "Class" and "Type" are Puppet keywords and should not be translated raise ArgumentError, _("Cannot use an unspecific Class[] Type") unless name.class_name + name.class_name.sub(/^([^:]{1,2})/, '::\1') when Puppet::Pops::Types::PResourceType diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb index e10c6a62389..22d19037076 100644 --- a/lib/puppet/parser/type_loader.rb +++ b/lib/puppet/parser/type_loader.rb @@ -64,6 +64,7 @@ def environment=(env) # Try to load the object with the given fully qualified name. def try_load_fqname(type, fqname) return nil if fqname == "" # special-case main. + files_to_try_for(fqname).each do |filename| begin imported_types = import_from_modules(filename) diff --git a/lib/puppet/pops/adapters.rb b/lib/puppet/pops/adapters.rb index b7d25110b86..443690d5d3e 100644 --- a/lib/puppet/pops/adapters.rb +++ b/lib/puppet/pops/adapters.rb @@ -124,6 +124,7 @@ def self.create_adapter(env) def self.loader_name_by_source(environment, instance, file) file = instance.file if file.nil? return nil if file.nil? || EMPTY_STRING == file + pn_adapter = PathsAndNameCacheAdapter.adapt(environment) dir = File.dirname(file) pn_adapter.cache.fetch(dir) do |key| @@ -136,6 +137,7 @@ def self.loader_name_by_source(environment, instance, file) # @api private def self.find_module_for_dir(environment, paths, dir) return nil if dir.nil? + file_path = Pathname.new(dir) paths.each do |path| begin diff --git a/lib/puppet/pops/evaluator/access_operator.rb b/lib/puppet/pops/evaluator/access_operator.rb index 6c45b3683c9..0bc9b9b972d 100644 --- a/lib/puppet/pops/evaluator/access_operator.rb +++ b/lib/puppet/pops/evaluator/access_operator.rb @@ -182,12 +182,14 @@ def access_PSemVerType(o, scope, keys) def access_PTimestampType(o, scope, keys) keys.flatten! fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, :base_type => o, :min=>0, :max => 2, :actual => keys.size) if keys.size > 2 + Types::TypeFactory.timestamp(*keys) end def access_PTimespanType(o, scope, keys) keys.flatten! fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, :base_type => o, :min=>0, :max => 2, :actual => keys.size) if keys.size > 2 + Types::TypeFactory.timespan(*keys) end @@ -209,6 +211,7 @@ def access_PCallableType(o, scope, keys) unless keys.size == 2 fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, :base_type => o, :min=>2, :max => 2, :actual => keys.size) end + unless keys[1].is_a?(Types::PAnyType) bad_type_specialization_key_type(o, 1, k, Types::PAnyType) end @@ -247,6 +250,7 @@ def assert_keys(keys, o, min, max, *allowed_classes) unless size.between?(min, max || Float::INFINITY) fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, :base_type => o, :min=>1, :max => max, :actual => keys.size) end + keys.each_with_index do |k, i| unless allowed_classes.any? {|clazz| k.is_a?(clazz) } bad_type_specialization_key_type(o, i, k, *allowed_classes) @@ -302,6 +306,7 @@ def access_PURIType(o, scope, keys) unless Types::PURIType::TYPE_URI_PARAM_TYPE.instance?(param) fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'URI-Type', :actual => param.class}) end + Types::PURIType.new(param) else fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'URI-Type', :min => 1, :actual => keys.size}) @@ -332,6 +337,7 @@ def access_PSensitiveType(o, scope, keys) unless type.is_a?(Types::PAnyType) fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Sensitive-Type', :actual => type.class}) end + Types::PSensitiveType.new(type) else fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Sensitive-Type', :min => 1, :actual => keys.size}) @@ -387,6 +393,7 @@ def access_PTypeType(o, scope, keys) unless keys[0].is_a?(Types::PAnyType) fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Type-Type', :actual => keys[0].class}) end + Types::PTypeType.new(keys[0]) else fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Type-Type', :min => 1, :actual => keys.size}) @@ -397,6 +404,7 @@ def access_PInitType(o, scope, keys) unless keys[0].is_a?(Types::PAnyType) fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Init-Type', :actual => keys[0].class}) end + Types::TypeFactory.init(*keys) end @@ -406,6 +414,7 @@ def access_PIterableType(o, scope, keys) unless keys[0].is_a?(Types::PAnyType) fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Iterable-Type', :actual => keys[0].class}) end + Types::PIterableType.new(keys[0]) else fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Iterable-Type', :min => 1, :actual => keys.size}) @@ -418,6 +427,7 @@ def access_PIteratorType(o, scope, keys) unless keys[0].is_a?(Types::PAnyType) fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Iterator-Type', :actual => keys[0].class}) end + Types::PIteratorType.new(keys[0]) else fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Iterator-Type', :min => 1, :actual => keys.size}) @@ -436,6 +446,7 @@ def access_PIntegerType(o, scope, keys) unless keys.size.between?(1, 2) fail(Issues::BAD_INTEGER_SLICE_ARITY, @semantic, {:actual => keys.size}) end + keys.each_with_index do |x, index| fail(Issues::BAD_INTEGER_SLICE_TYPE, @semantic.keys[index], {:actual => x.class}) unless (x.is_a?(Integer) || x == :default) @@ -448,6 +459,7 @@ def access_PFloatType(o, scope, keys) unless keys.size.between?(1, 2) fail(Issues::BAD_FLOAT_SLICE_ARITY, @semantic, {:actual => keys.size}) end + keys.each_with_index do |x, index| fail(Issues::BAD_FLOAT_SLICE_TYPE, @semantic.keys[index], {:actual => x.class}) unless (x.is_a?(Float) || x.is_a?(Integer) || x == :default) @@ -513,6 +525,7 @@ def access_PArrayType(o, scope, keys) unless keys[0].is_a?(Types::PAnyType) fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Array-Type', :actual => keys[0].class}) end + type = keys[0] size_t = nil when 2 @@ -686,11 +699,13 @@ def access_PClassType(o, scope, keys) if o.class_name.nil? result = keys.each_with_index.map do |c, i| fail(Issues::ILLEGAL_HOSTCLASS_NAME, @semantic.keys[i], {:name => c}) unless c.is_a?(String) + name = c.downcase # Remove leading '::' since all references are global, and 3x runtime does the wrong thing name = name[2..-1] if name[0,2] == NS fail(Issues::ILLEGAL_NAME, @semantic.keys[i], {:name=>c}) unless name =~ Patterns::NAME + Types::PClassType.new(name) end else diff --git a/lib/puppet/pops/evaluator/collector_transformer.rb b/lib/puppet/pops/evaluator/collector_transformer.rb index 91ce953e9e8..99f64575c9e 100644 --- a/lib/puppet/pops/evaluator/collector_transformer.rb +++ b/lib/puppet/pops/evaluator/collector_transformer.rb @@ -14,6 +14,7 @@ def transform(o, scope) raise ArgumentError, _("Expected CollectExpression") unless o.is_a? Model::CollectExpression raise "LHS is not a type" unless o.type_expr.is_a? Model::QualifiedReference + type = o.type_expr.value().downcase() if type == 'class' @@ -103,6 +104,7 @@ def query_ComparisonExpression(o, scope) end tags = tags.collect do |t| raise ArgumentError, _('Cannot transform a number to a tag') if t.is_a?(Numeric) + t.to_s.downcase end proc do |resource| diff --git a/lib/puppet/pops/evaluator/compare_operator.rb b/lib/puppet/pops/evaluator/compare_operator.rb index 5989dddba2c..2d9cf853e0c 100644 --- a/lib/puppet/pops/evaluator/compare_operator.rb +++ b/lib/puppet/pops/evaluator/compare_operator.rb @@ -48,12 +48,14 @@ def include?(a, b, scope) def cmp_String(a, b) return a.casecmp(b) if b.is_a?(String) + raise ArgumentError.new(_("A String is not comparable to a non String")) end # Equality is case independent. def equals_String(a, b) return false unless b.is_a?(String) + a.casecmp(b) == 0 end @@ -77,12 +79,14 @@ def equals_Numeric(a, b) def equals_Array(a, b) return false unless b.is_a?(Array) && a.size == b.size + a.each_index {|i| return false unless equals(a.slice(i), b.slice(i)) } true end def equals_Hash(a, b) return false unless b.is_a?(Hash) && a.size == b.size + a.each {|ak, av| return false unless equals(b[ak], av)} true end @@ -97,16 +101,19 @@ def cmp_Symbol(a, b) def cmp_Timespan(a, b) raise ArgumentError.new(_('Timespans are only comparable to Timespans, Integers, and Floats')) unless b.is_a?(Time::Timespan) || b.is_a?(Integer) || b.is_a?(Float) + a <=> b end def cmp_Timestamp(a, b) raise ArgumentError.new(_('Timestamps are only comparable to Timestamps, Integers, and Floats')) unless b.is_a?(Time::Timestamp) || b.is_a?(Integer) || b.is_a?(Float) + a <=> b end def cmp_Version(a, b) raise ArgumentError.new(_('Versions not comparable to non Versions')) unless b.is_a?(SemanticPuppet::Version) + a <=> b end @@ -168,6 +175,7 @@ def include_Array(a, b, scope) matched = nil a.each do |element| next unless element.is_a? String + matched = element.match(b) # nil, or MatchData break if matched end @@ -201,6 +209,7 @@ def match_Object(pattern, a, scope) # Matches only against strings def match_Regexp(regexp, left, scope) return false unless left.is_a? String + matched = regexp.match(left) set_match_data(matched, scope) unless scope.nil? # creates or clears ephemeral !!matched # convert to boolean @@ -237,16 +246,19 @@ def match_PAnyType(any_type, left, scope) def match_Array(array, left, scope) return false unless left.is_a?(Array) return false unless left.length == array.length + array.each_with_index.all? { | pattern, index| match(left[index], pattern, scope) } end def match_Hash(hash, left, scope) return false unless left.is_a?(Hash) + hash.all? {|x,y| match(left[x], y, scope) } end def match_Symbol(symbol, left, scope) return true if symbol == :default + equals(left, default) end end diff --git a/lib/puppet/pops/evaluator/deferred_resolver.rb b/lib/puppet/pops/evaluator/deferred_resolver.rb index e35e176a5b2..130ed7beaf9 100644 --- a/lib/puppet/pops/evaluator/deferred_resolver.rb +++ b/lib/puppet/pops/evaluator/deferred_resolver.rb @@ -180,6 +180,7 @@ def resolve_future(f) def map_arguments(args) return [] if args.nil? + args.map {|v| resolve(v) } end private :map_arguments diff --git a/lib/puppet/pops/evaluator/evaluator_impl.rb b/lib/puppet/pops/evaluator/evaluator_impl.rb index 8949590929c..40e816d9213 100644 --- a/lib/puppet/pops/evaluator/evaluator_impl.rb +++ b/lib/puppet/pops/evaluator/evaluator_impl.rb @@ -208,6 +208,7 @@ def assign_String(name, value, o, scope) if name =~ /::/ fail(Issues::CROSS_SCOPE_ASSIGNMENT, o.left_expr, {:name => name}) end + set_variable(name, value, o, scope) value end @@ -233,6 +234,7 @@ def assign_Array(lvalues, values, o, scope) if Puppet[:tasks] fail(Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING, o, {:operation => _('multi var assignment from class')}) end + # assign variables from class variables # lookup class resource and return one or more parameter values # TODO: behavior when class_name is nil @@ -259,6 +261,7 @@ def assign_Array(lvalues, values, o, scope) if values.size != lvalues.size fail(Issues::ILLEGAL_MULTI_ASSIGNMENT_SIZE, o, :expected =>lvalues.size, :actual => values.size) end + lvalues.zip(values).map { |lval, val| assign(lval, val, o, scope) } end end @@ -311,6 +314,7 @@ def eval_LiteralUndef(o, scope) def eval_QualifiedReference(o, scope) type = Types::TypeParser.singleton.interpret(o) fail(Issues::UNKNOWN_RESOURCE_TYPE, o, {:type_name => type.type_string }) if type.is_a?(Types::PTypeReferenceType) + type end @@ -405,6 +409,7 @@ def calculate(left, right, bin_expr, scope) unless left.is_a?(Array) fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left}) end + left + [right] end else @@ -415,6 +420,7 @@ def calculate(left, right, bin_expr, scope) if operator == '%' && (left.is_a?(Float) || right.is_a?(Float)) # Deny users the fun of seeing severe rounding errors and confusing results fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left}) if left.is_a?(Float) + fail(Issues::OPERATOR_NOT_APPLICABLE_WHEN, left_o, {:operator => operator, :left_value => left, :right_value => right}) end if right.is_a?(Time::TimeData) && !left.is_a?(Time::TimeData) @@ -781,12 +787,14 @@ def eval_ResourceExpression(o, scope) unless evaluated_name.class_name.nil? fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=> evaluated_name.to_s}) end + 'class' when Types::PResourceType unless evaluated_name.title().nil? fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=> evaluated_name.to_s}) end + evaluated_name.type_name # assume validated when Types::PTypeReferenceType @@ -821,6 +829,7 @@ def eval_ResourceExpression(o, scope) if titles.nil? fail(Issues::MISSING_TITLE, body.title) end + titles = [titles].flatten # Check types of evaluated titles and duplicate entries @@ -838,6 +847,7 @@ def eval_ResourceExpression(o, scope) elsif titles_to_body[title] fail(Issues::DUPLICATE_TITLE, o, {:title => title}) end + titles_to_body[title] = body end @@ -855,6 +865,7 @@ def eval_ResourceExpression(o, scope) if param_memo.include? p.name fail(Issues::DUPLICATE_ATTRIBUTE, o, {:attribute => p.name}) end + param_memo[p.name] = p end param_memo @@ -958,11 +969,13 @@ def eval_CallMethodExpression(o, scope) unless o.functor_expr.is_a? Model::NamedAccessExpression fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function accessor', :container => o}) end + receiver = unfold([], [o.functor_expr.left_expr], scope) name = o.functor_expr.right_expr unless name.is_a? Model::QualifiedName fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function name', :container => o}) end + name = name.value # the string function name obj = receiver[0] @@ -1226,9 +1239,11 @@ def concatenate(x, y) x.merge y # new hash with overwrite when URI raise ArgumentError.new(_('An URI can only be merged with an URI or String')) unless y.is_a?(String) || y.is_a?(URI) + x + y when Types::PBinaryType::Binary raise ArgumentError.new(_('Can only append Binary to a Binary')) unless y.is_a?(Types::PBinaryType::Binary) + Types::PBinaryType::Binary.from_binary_string(x.binary_buffer + y.binary_buffer) else concatenate([x], y) @@ -1295,6 +1310,7 @@ def unfold(result, array, scope) def unwind_parentheses(o) return o unless o.is_a?(Model::ParenthesizedExpression) + unwind_parentheses(o.expr) end private :unwind_parentheses diff --git a/lib/puppet/pops/evaluator/puppet_proc.rb b/lib/puppet/pops/evaluator/puppet_proc.rb index b915f49f75c..1021f4175e5 100644 --- a/lib/puppet/pops/evaluator/puppet_proc.rb +++ b/lib/puppet/pops/evaluator/puppet_proc.rb @@ -64,6 +64,7 @@ def arity parameters.reduce(0) do |memo, param| count = memo + 1 break -count unless param[0] == :req + count end end diff --git a/lib/puppet/pops/evaluator/relationship_operator.rb b/lib/puppet/pops/evaluator/relationship_operator.rb index 6436d0b75dd..33c724d5b0f 100644 --- a/lib/puppet/pops/evaluator/relationship_operator.rb +++ b/lib/puppet/pops/evaluator/relationship_operator.rb @@ -99,6 +99,7 @@ def assert_catalog_type(o, scope) unless @type_calculator.assignable?(@catalog_type, o) raise NotCatalogTypeError.new(o) end + # TODO must check if this is an abstract PResourceType (i.e. without a type_name) - which should fail ? # e.g. File -> File (and other similar constructs) - maybe the catalog protects against this since references # may be to future objects... diff --git a/lib/puppet/pops/evaluator/runtime3_converter.rb b/lib/puppet/pops/evaluator/runtime3_converter.rb index bf163bb2ec2..6d13004f58d 100644 --- a/lib/puppet/pops/evaluator/runtime3_converter.rb +++ b/lib/puppet/pops/evaluator/runtime3_converter.rb @@ -67,6 +67,7 @@ def convert_NilClass(o, scope, undef_value) def convert_Integer(o, scope, undef_value) return o unless o < MIN_INTEGER || o > MAX_INTEGER + range_end = o > MAX_INTEGER ? 'max' : 'min' raise Puppet::Error, "Use of a Ruby Integer outside of Puppet Integer #{range_end} range, got '#{"0x%x" % o}'" end @@ -75,6 +76,7 @@ def convert_BigDecimal(o, scope, undef_value) # transform to same value float value if possible without any rounding error f = o.to_f return f unless f != o + raise Puppet::Error, "Use of a Ruby BigDecimal value outside Puppet Float range, got '#{o}'" end @@ -107,6 +109,7 @@ def convert_Iterator(o, scope, undef_value) def convert_Symbol(o, scope, undef_value) return o unless o == :undef + !@inner ? undef_value : nil end diff --git a/lib/puppet/pops/evaluator/runtime3_support.rb b/lib/puppet/pops/evaluator/runtime3_support.rb index c0b9ef5bb0d..3161b1892bf 100644 --- a/lib/puppet/pops/evaluator/runtime3_support.rb +++ b/lib/puppet/pops/evaluator/runtime3_support.rb @@ -146,6 +146,7 @@ def create_local_scope_from(hash, scope) # is in the source. # raise ArgumentError, _("Internal error - attempt to create a local scope without a hash") unless hash.is_a?(Hash) + scope.ephemeral_from(hash) end @@ -252,10 +253,12 @@ def coerce_numeric(v, o, scope) if v.is_a?(Numeric) return v end + n = Utils.to_n(v) unless n fail(Issues::NOT_NUMERIC, o, {:value => v}) end + # this point is reached if there was a conversion optionally_fail(Issues::NUMERIC_COERCION, o, {:before => v, :after => n}) n @@ -373,6 +376,7 @@ def create_resource_overrides(o, scope, evaluated_resources, evaluated_parameter unless r.is_a?(Types::PResourceType) && r.type_name != 'class' fail(Issues::ILLEGAL_OVERRIDDEN_TYPE, o, {:actual => r} ) end + t = Runtime3ResourceSupport.find_resource_type(scope, r.type_name) resource = Puppet::Parser::Resource.new( t, r.title, { @@ -434,6 +438,7 @@ def get_resource_parameter_value(scope, resource, parameter_name) # def is_parameter_of_resource?(scope, resource, name) return false unless name.is_a?(String) + resource.valid_parameter?(name) end diff --git a/lib/puppet/pops/issue_reporter.rb b/lib/puppet/pops/issue_reporter.rb index 6b67670b35e..d046ce6f781 100644 --- a/lib/puppet/pops/issue_reporter.rb +++ b/lib/puppet/pops/issue_reporter.rb @@ -49,6 +49,7 @@ def self.assert_and_report(acceptor, options) unless emit_errors raise emit_exception.new(emit_message) end + formatter = Validation::DiagnosticFormatterPuppetStyle.new if errors.size == 1 || max_errors <= 1 # raise immediately @@ -83,6 +84,7 @@ def self.assert_and_report(acceptor, options) def self.format_with_prefix(prefix, message) return message unless prefix + [prefix, message].join(' ') end diff --git a/lib/puppet/pops/issues.rb b/lib/puppet/pops/issues.rb index 48b0f20bfe4..d1d38e8428d 100644 --- a/lib/puppet/pops/issues.rb +++ b/lib/puppet/pops/issues.rb @@ -93,6 +93,7 @@ def label_provider label_provider = @data[:label] #TRANSLATORS ":label" is a keyword and should not be translated raise Puppet::Error, _('Label provider key :label must be set to produce the text of the message!') unless label_provider + label_provider end @@ -101,6 +102,7 @@ def label_provider def semantic #TRANSLATORS ":semantic" is a keyword and should not be translated raise Puppet::Error, _('Label provider key :semantic must be set to produce the text of the message!') unless @data[:semantic] + @data[:semantic] end end diff --git a/lib/puppet/pops/loader/dependency_loader.rb b/lib/puppet/pops/loader/dependency_loader.rb index 425de8349d9..dfd17f6d532 100644 --- a/lib/puppet/pops/loader/dependency_loader.rb +++ b/lib/puppet/pops/loader/dependency_loader.rb @@ -44,6 +44,7 @@ def find(typed_name) # lookup otherwise). loaded = @dependency_loaders.reduce(nil) do |previous, loader| break previous if !previous.nil? + loader.load_typed(typed_name) end if loaded @@ -80,6 +81,7 @@ def loaded_entry_in_dependency(typed_name, check_dependencies) # lookup otherwise). @dependency_loaders.reduce(nil) do |previous, loader| break previous if !previous.nil? + loader.loaded_entry(typed_name, check_dependencies) end end diff --git a/lib/puppet/pops/loader/gem_support.rb b/lib/puppet/pops/loader/gem_support.rb index 777be507eb3..ef2dd5cd1ef 100644 --- a/lib/puppet/pops/loader/gem_support.rb +++ b/lib/puppet/pops/loader/gem_support.rb @@ -30,6 +30,7 @@ def gem_dir_from_uri(uri) unless spec raise ArgumentError, _("Gem not found %{uri}") % { uri: uri } end + # if path given append that, else append given subdir if uri.path.empty? spec.gem_dir @@ -46,6 +47,7 @@ def gem_dir_from_name(gem_name) unless spec raise ArgumentError, _("Gem not found '%{gem_name}'") % { gem_name: gem_name } end + spec.full_gem_path end end \ No newline at end of file diff --git a/lib/puppet/pops/loader/loader_paths.rb b/lib/puppet/pops/loader/loader_paths.rb index 91148e73d97..a0518d630ff 100644 --- a/lib/puppet/pops/loader/loader_paths.rb +++ b/lib/puppet/pops/loader/loader_paths.rb @@ -146,6 +146,7 @@ def effective_path(typed_name, start_index_in_name) parts = typed_name.name_parts if start_index_in_name > 0 return nil if start_index_in_name >= parts.size + parts = parts[start_index_in_name..-1] end "#{File.join(generic_path, parts)}#{extension}" @@ -369,6 +370,7 @@ def effective_path(typed_name, start_index_in_name) parts = typed_name.name_parts if start_index_in_name > 0 return nil if start_index_in_name >= parts.size + parts = parts[start_index_in_name..-1] end basename = File.join(generic_path, parts) diff --git a/lib/puppet/pops/loader/module_loaders.rb b/lib/puppet/pops/loader/module_loaders.rb index 8bd233a0dfe..5ce6b562546 100644 --- a/lib/puppet/pops/loader/module_loaders.rb +++ b/lib/puppet/pops/loader/module_loaders.rb @@ -136,6 +136,7 @@ def initialize(parent_loader, loaders, module_name, path, loader_name, loadables #TRANSLATORS 'loadables' is a variable containing loadable modules and should not be translated raise ArgumentError, _('given loadables are not of supported loadable kind') end + loaders.add_loader_by_name(self) end @@ -150,6 +151,7 @@ def discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_A relative_paths(sp).each do |rp| tp = sp.typed_name(type, name_authority, rp, global ? nil : @module_name) next unless sp.valid_name?(tp) + begin load_typed(tp) unless block_given? && !block.yield(tp) rescue StandardError => e @@ -402,6 +404,7 @@ def find_existing_path(typed_name) is_global = global? smart_paths.effective_paths(typed_name.type).each do |sp| next unless sp.valid_name?(typed_name) + origin = sp.effective_path(typed_name, is_global ? 0 : 1) unless origin.nil? if sp.fuzzy_matching? diff --git a/lib/puppet/pops/loader/puppet_function_instantiator.rb b/lib/puppet/pops/loader/puppet_function_instantiator.rb index 1285ba63c72..8d4f026a92f 100644 --- a/lib/puppet/pops/loader/puppet_function_instantiator.rb +++ b/lib/puppet/pops/loader/puppet_function_instantiator.rb @@ -34,6 +34,7 @@ def self.create(loader, typed_name, source_ref, pp_code_string) unless the_function_definition.is_a?(Model::FunctionDefinition) raise ArgumentError, _("The code loaded from %{source_ref} does not define the function '%{type_name}' - no function found.") % { source_ref: source_ref, type_name: typed_name.name } end + unless the_function_definition.name == typed_name.name expected = typed_name.name actual = the_function_definition.name diff --git a/lib/puppet/pops/loader/puppet_plan_instantiator.rb b/lib/puppet/pops/loader/puppet_plan_instantiator.rb index b479b3d827d..3729abf7d09 100644 --- a/lib/puppet/pops/loader/puppet_plan_instantiator.rb +++ b/lib/puppet/pops/loader/puppet_plan_instantiator.rb @@ -43,6 +43,7 @@ def self.create(loader, typed_name, source_ref, pp_code_string) unless the_plan_definition.is_a?(Model::PlanDefinition) raise ArgumentError, _("The code loaded from %{source_ref} does not define the plan '%{plan_name}' - no plan found.") % { source_ref: source_ref, plan_name: typed_name.name } end + unless the_plan_definition.name == typed_name.name expected = typed_name.name actual = the_plan_definition.name diff --git a/lib/puppet/pops/loader/ruby_data_type_instantiator.rb b/lib/puppet/pops/loader/ruby_data_type_instantiator.rb index 1e0014eba09..de8b05624d1 100644 --- a/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +++ b/lib/puppet/pops/loader/ruby_data_type_instantiator.rb @@ -17,6 +17,7 @@ def self.create(loader, typed_name, source_ref, ruby_code_string) unless ruby_code_string.is_a?(String) && ruby_code_string =~ /Puppet\:\:DataTypes\.create_type/ raise ArgumentError, _("The code loaded from %{source_ref} does not seem to be a Puppet 5x API data type - no create_type call.") % { source_ref: source_ref } end + # make the private loader available in a binding to allow it to be passed on loader_for_type = loader.private_loader here = get_binding(loader_for_type) @@ -27,6 +28,7 @@ def self.create(loader, typed_name, source_ref, ruby_code_string) unless created.name.casecmp(typed_name.name) == 0 raise ArgumentError, _("The code loaded from %{source_ref} produced mis-matched name, expected '%{type_name}', got %{created_name}") % { source_ref: source_ref, type_name: typed_name.name, created_name: created.name } end + created end diff --git a/lib/puppet/pops/loader/ruby_function_instantiator.rb b/lib/puppet/pops/loader/ruby_function_instantiator.rb index 8742d9c48e9..464d80f3354 100644 --- a/lib/puppet/pops/loader/ruby_function_instantiator.rb +++ b/lib/puppet/pops/loader/ruby_function_instantiator.rb @@ -17,6 +17,7 @@ def self.create(loader, typed_name, source_ref, ruby_code_string) unless ruby_code_string.is_a?(String) && ruby_code_string =~ /Puppet\:\:Functions\.create_function/ raise ArgumentError, _("The code loaded from %{source_ref} does not seem to be a Puppet 4x API function - no create_function call.") % { source_ref: source_ref } end + # make the private loader available in a binding to allow it to be passed on loader_for_function = loader.private_loader here = get_binding(loader_for_function) @@ -27,6 +28,7 @@ def self.create(loader, typed_name, source_ref, ruby_code_string) unless created.name.to_s == typed_name.name() raise ArgumentError, _("The code loaded from %{source_ref} produced mis-matched name, expected '%{type_name}', got %{created_name}") % { source_ref: source_ref, type_name: typed_name.name, created_name: created.name } end + # create the function instance - it needs closure (scope), and loader (i.e. where it should start searching for things # when calling functions etc. # It should be bound to global scope diff --git a/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb b/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb index 878ddec298e..f9c0e79ff1b 100644 --- a/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +++ b/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb @@ -45,6 +45,7 @@ def self.create(loader, typed_name, source_ref, ruby_code_string) # TRANSLATORS - the word 'newfunction' should not be translated as it is a method name. raise ArgumentError, _("Illegal legacy function definition! The code loaded from %{source_ref} did not return the result of calling 'newfunction'. Got '%{klass}'") % { source_ref: source_ref, klass: func_info.class } end + unless func_info[:name] == "function_#{typed_name.name()}" raise ArgumentError, _("The code loaded from %{source_ref} produced mis-matched name, expected 'function_%{type_name}', got '%{created_name}'") % { source_ref: source_ref, type_name: typed_name.name, created_name: func_info[:name] } @@ -73,6 +74,7 @@ def self.get_binding(loader_injected_arg) def self.assert_code(code_string, source_ref, result) ripped = Ripper.sexp(code_string) return false if ripped.nil? # Let the next real parse crash and tell where and what is wrong + ripped.each {|x| walk(x, source_ref, result) } true end @@ -80,6 +82,7 @@ def self.assert_code(code_string, source_ref, result) def self.walk(x, source_ref, result) return unless x.is_a?(Array) + first = x[0] case first when :fcall, :call diff --git a/lib/puppet/pops/loader/runtime3_type_loader.rb b/lib/puppet/pops/loader/runtime3_type_loader.rb index 5a4af917d4c..7f104db6c52 100644 --- a/lib/puppet/pops/loader/runtime3_type_loader.rb +++ b/lib/puppet/pops/loader/runtime3_type_loader.rb @@ -30,6 +30,7 @@ def to_s() # def find(typed_name) return nil unless typed_name.name_authority == Pcore::RUNTIME_NAME_AUTHORITY + case typed_name.type when :type value = nil diff --git a/lib/puppet/pops/loader/type_definition_instantiator.rb b/lib/puppet/pops/loader/type_definition_instantiator.rb index 6e3383f47f3..21da231bdde 100644 --- a/lib/puppet/pops/loader/type_definition_instantiator.rb +++ b/lib/puppet/pops/loader/type_definition_instantiator.rb @@ -90,6 +90,7 @@ def self.create_named_type(name, type_name, type_expr, name_authority) # @api private def self.named_definition(te) return 'Object' if te.is_a?(Model::LiteralHash) + te.is_a?(Model::AccessExpression) && (left = te.left_expr).is_a?(Model::QualifiedReference) ? left.cased_value : nil end diff --git a/lib/puppet/pops/loaders.rb b/lib/puppet/pops/loaders.rb index 14b7e052e27..7899e61e28b 100644 --- a/lib/puppet/pops/loaders.rb +++ b/lib/puppet/pops/loaders.rb @@ -37,6 +37,7 @@ def self.new(environment, for_agent = false, load_from_pcore = true) def initialize(environment, for_agent, load_from_pcore = true) # Protect against environment havoc raise ArgumentError.new(_("Attempt to redefine already initialized loaders for environment")) unless environment.loaders.nil? + environment.loaders = self @environment = environment @loaders_by_name = {} @@ -180,6 +181,7 @@ def self.catalog_loader def self.loaders loaders = Puppet.lookup(:loaders) { nil } raise Puppet::ParseError, _("Internal Error: Puppet Context ':loaders' missing") if loaders.nil? + loaders end @@ -216,6 +218,7 @@ def find_loader(module_name) if loader.nil? raise Puppet::ParseError, _("Internal Error: did not find public loader for module: '%{module_name}'") % { module_name: module_name } end + loader end end @@ -262,6 +265,7 @@ def add_loader_by_name(loader) if @loaders_by_name.include?(name) raise Puppet::ParseError, _("Internal Error: Attempt to redefine loader named '%{name}'") % { name: name } end + @loaders_by_name[name] = loader end diff --git a/lib/puppet/pops/lookup/explainer.rb b/lib/puppet/pops/lookup/explainer.rb index a38f5afe01c..e69db689fb7 100644 --- a/lib/puppet/pops/lookup/explainer.rb +++ b/lib/puppet/pops/lookup/explainer.rb @@ -289,6 +289,7 @@ def dump_on(io, indent, first_indent) def to_hash return branches[0].to_hash if branches.size == 1 + hash = super hash[:merge] = @merge.class.key options = options_wo_strategy diff --git a/lib/puppet/pops/lookup/hiera_config.rb b/lib/puppet/pops/lookup/hiera_config.rb index 2f99bf50fcc..f96b9874615 100644 --- a/lib/puppet/pops/lookup/hiera_config.rb +++ b/lib/puppet/pops/lookup/hiera_config.rb @@ -226,6 +226,7 @@ def find_line_matching(regexp, start_line = 1) File.foreach(@config_path) do |line| line_number += 1 next if line_number < start_line + quote = nil stripped = ''.dup line.each_codepoint do |cp| @@ -352,6 +353,7 @@ class HieraConfigV3 < HieraConfig def self.config_type return @@CONFIG_TYPE if class_variable_defined?(:@@CONFIG_TYPE) + tf = Types::TypeFactory nes_t = Types::PStringType::NON_EMPTY @@ -484,6 +486,7 @@ def create_merge_strategy class HieraConfigV4 < HieraConfig def self.config_type return @@CONFIG_TYPE if class_variable_defined?(:@@CONFIG_TYPE) + tf = Types::TypeFactory nes_t = Types::PStringType::NON_EMPTY @@ -563,6 +566,7 @@ def version class HieraConfigV5 < HieraConfig def self.config_type return @@CONFIG_TYPE if class_variable_defined?(:@@CONFIG_TYPE_V5) + tf = Types::TypeFactory nes_t = Types::PStringType::NON_EMPTY @@ -675,6 +679,7 @@ def create_configured_data_providers(lookup_invocation, parent_data_provider, us end end next if @config_path.nil? && !locations.nil? && locations.empty? # Default config and no existing paths found + options = he[KEY_OPTIONS] || defaults[KEY_OPTIONS] options = options.nil? ? EMPTY_HASH : interpolate(options, lookup_invocation, false) if(function_kind == KEY_V3_BACKEND) @@ -733,6 +738,7 @@ def validate_config(config, owner) unless owner.is_a?(ModuleDataProvider) fail(Issues::HIERA_DEFAULT_HIERARCHY_NOT_IN_MODULE, EMPTY_HASH, find_line_matching(/(?:^|\s+)#{KEY_DEFAULT_HIERARCHY}:/)) end + config[KEY_DEFAULT_HIERARCHY].each { |he| validate_hierarchy(he, defaults, owner) } end config @@ -756,6 +762,7 @@ def validate_hierarchy(he, defaults, owner) unless owner.is_a?(GlobalDataProvider) fail(Issues::HIERA_V3_BACKEND_NOT_GLOBAL, EMPTY_HASH, find_line_matching(/\s+#{KEY_V3_BACKEND}:/)) end + if v3_backend == 'json' || v3_backend == 'yaml' || v3_backend == 'hocon' && Puppet.features.hocon? # Disallow use of backends that have corresponding "data_hash" functions in version 5 fail(Issues::HIERA_V3_BACKEND_REPLACED_BY_DATA_HASH, { :function_name => v3_backend }, diff --git a/lib/puppet/pops/lookup/interpolation.rb b/lib/puppet/pops/lookup/interpolation.rb index 93772d9db88..88909b02462 100644 --- a/lib/puppet/pops/lookup/interpolation.rb +++ b/lib/puppet/pops/lookup/interpolation.rb @@ -58,6 +58,7 @@ def interpolate_string(subject, context, allow_methods) # Alias is only permitted if the entire string is equal to the interpolate expression fail(Issues::HIERA_INTERPOLATION_ALIAS_NOT_ENTIRE_STRING) if is_alias && subject != match + value = interpolate_method(method_key).call(key, lookup_invocation, subject) # break gsub and return value immediately if this was an alias substitution. The value might be something other than a String @@ -128,6 +129,7 @@ def interpolate_method(method_key) end interpolate_method = @@interpolate_methods[method_key] fail(Issues::HIERA_INTERPOLATION_UNKNOWN_INTERPOLATION_METHOD, :name => method_key) unless interpolate_method + interpolate_method end @@ -144,6 +146,7 @@ def get_method_and_data(data, allow_methods) match = data.match(/^(\w+)\((?:["]([^"]+)["]|[']([^']+)['])\)$/) if match fail(Issues::HIERA_INTERPOLATION_METHOD_SYNTAX_NOT_ALLOWED) unless allow_methods + key = match[1].to_sym data = match[2] || match[3] # double or single qouted else diff --git a/lib/puppet/pops/lookup/lookup_adapter.rb b/lib/puppet/pops/lookup/lookup_adapter.rb index b230dea5088..75e31c8ecc8 100644 --- a/lib/puppet/pops/lookup/lookup_adapter.rb +++ b/lib/puppet/pops/lookup/lookup_adapter.rb @@ -146,6 +146,7 @@ def lookup_global(key, lookup_invocation, merge_strategy) end rescue Puppet::DataBinding::LookupError => detail raise detail unless detail.issue_code.nil? + error = Puppet::Error.new(_("Lookup of key '%{key}' failed: %{detail}") % { key: lookup_invocation.top_key, detail: detail.message }) error.set_backtrace(detail.backtrace) raise error @@ -312,6 +313,7 @@ def validate_lookup_options(options, module_name) def compile_patterns(options) return nil if options.nil? + key_options = {} pattern_options = {} options.each_pair do |key, value| diff --git a/lib/puppet/pops/lookup/module_data_provider.rb b/lib/puppet/pops/lookup/module_data_provider.rb index 63a1069c4fb..5e158eb240c 100644 --- a/lib/puppet/pops/lookup/module_data_provider.rb +++ b/lib/puppet/pops/lookup/module_data_provider.rb @@ -48,6 +48,7 @@ def validate_data_hash(data_hash) module_prefix = "#{module_name}::" data_hash.each_key.reduce(data_hash) do |memo, k| next memo if k == LOOKUP_OPTIONS || k.start_with?(module_prefix) + msg = "#{yield} must use keys qualified with the name of the module" memo = memo.clone if memo.equal?(data_hash) memo.delete(k) @@ -82,6 +83,7 @@ def provider_root(lookup_invocation) env = lookup_invocation.scope.environment mod = env.module(module_name) raise Puppet::DataBinding::LookupError, _("Environment '%{env}', cannot find module '%{module_name}'") % { env: env.name, module_name: module_name } unless mod + Pathname.new(mod.path) end end diff --git a/lib/puppet/pops/lookup/sub_lookup.rb b/lib/puppet/pops/lookup/sub_lookup.rb index c31d09af2eb..0e7ff9f6569 100644 --- a/lib/puppet/pops/lookup/sub_lookup.rb +++ b/lib/puppet/pops/lookup/sub_lookup.rb @@ -19,6 +19,7 @@ module SubLookup # @api public def split_key(key) return [key] if key.match(SPECIAL).nil? + segments = key.split(/(\s*"[^"]+"\s*|\s*'[^']+'\s*|[^'".]+)/) if segments.empty? # Only happens if the original key was an empty string @@ -29,6 +30,7 @@ def split_key(key) segments.keep_if { |seg| seg != '.' } raise yield('Syntax error') unless segments.size * 2 == count + 1 + segments.map! do |segment| segment.strip! if segment.start_with?('"', "'") diff --git a/lib/puppet/pops/merge_strategy.rb b/lib/puppet/pops/merge_strategy.rb index ceb5aa00cea..2fc17525be1 100644 --- a/lib/puppet/pops/merge_strategy.rb +++ b/lib/puppet/pops/merge_strategy.rb @@ -28,6 +28,7 @@ def self.strategy(merge) #TRANSLATORS 'merge' is a variable name and 'strategy' is a key and should not be translated raise ArgumentError, _("The hash given as 'merge' must contain the name of a strategy in string form for the key 'strategy'") end + merge_options = merge.size == 1 ? EMPTY_HASH : merge else merge_strategy = merge @@ -36,6 +37,7 @@ def self.strategy(merge) merge_strategy = merge_strategy.to_sym if merge_strategy.is_a?(String) strategy_class = strategies[merge_strategy] raise ArgumentError, _("Unknown merge strategy: '%{strategy}'") % { strategy: merge_strategy } if strategy_class.nil? + merge_options == EMPTY_HASH ? strategy_class::INSTANCE : strategy_class.new(merge_options) end diff --git a/lib/puppet/pops/model/ast.rb b/lib/puppet/pops/model/ast.rb index 0017a113ad7..a5ac3db7a05 100644 --- a/lib/puppet/pops/model/ast.rb +++ b/lib/puppet/pops/model/ast.rb @@ -4568,6 +4568,7 @@ module Model @@pcore_ast_initialized = false def self.register_pcore_types return if @@pcore_ast_initialized + @@pcore_ast_initialized = true all_types = [ Parser::Locator::Locator19, diff --git a/lib/puppet/pops/model/factory.rb b/lib/puppet/pops/model/factory.rb index e04ef5399d9..4d037c7e25b 100644 --- a/lib/puppet/pops/model/factory.rb +++ b/lib/puppet/pops/model/factory.rb @@ -645,6 +645,7 @@ def record_position(locator, start_locatable, end_locatable) def self.set_resource_form(expr, form) # Note: Validation handles illegal combinations return false unless expr.instance_of?(self) && expr.model_class <= AbstractResource + expr['form'] = form return true end @@ -1043,8 +1044,10 @@ def self.transform_resource_wo_title(left, attribute_ops, lbrace_token, rbrace_t # Returning nil means accepting the given as a potential resource expression return nil unless attribute_ops.is_a? Array return nil unless left.model_class <= QualifiedName + keyed_entries = attribute_ops.map do |ao| return nil if ao[KEY_OPERATOR] == '+>' + KEY_ENTRY(infer(ao['attribute_name']), ao['value_expr']) end a_hash = HASH(keyed_entries) diff --git a/lib/puppet/pops/parser/epp_support.rb b/lib/puppet/pops/parser/epp_support.rb index 6c087d13414..efecd17f8eb 100644 --- a/lib/puppet/pops/parser/epp_support.rb +++ b/lib/puppet/pops/parser/epp_support.rb @@ -182,6 +182,7 @@ def scan(skip_leading=false) @skip_leading = skip_leading return nil if scanner.eos? + s = ''.dup until scanner.eos? part = @scanner.scan_until(/(<%)|\z/) diff --git a/lib/puppet/pops/parser/evaluating_parser.rb b/lib/puppet/pops/parser/evaluating_parser.rb index d8c94b0cd5e..8369fa418ec 100644 --- a/lib/puppet/pops/parser/evaluating_parser.rb +++ b/lib/puppet/pops/parser/evaluating_parser.rb @@ -57,6 +57,7 @@ def closure(model, scope) def evaluate(scope, model) return nil unless model + evaluator.evaluate(model, scope) end @@ -72,6 +73,7 @@ def evaluator if (Puppet.lookup(:migration_checker) { nil }) return Evaluator::EvaluatorImpl.new() end + @@evaluator ||= Evaluator::EvaluatorImpl.new() @@evaluator end @@ -96,6 +98,7 @@ def validator(acceptor) def assert_and_report(parse_result, file_source) return nil unless parse_result + if parse_result['source_ref'].nil? || parse_result['source_ref'] == '' parse_result['source_ref'] = file_source end diff --git a/lib/puppet/pops/parser/heredoc_support.rb b/lib/puppet/pops/parser/heredoc_support.rb index 4d71b4532e0..d4b314c3f11 100644 --- a/lib/puppet/pops/parser/heredoc_support.rb +++ b/lib/puppet/pops/parser/heredoc_support.rb @@ -85,6 +85,7 @@ def heredoc while !scn.eos? do one_line = scn.scan_until(/(?:\n|\z)/) raise eof_error unless one_line + md = one_line.match(endline_pattern) if md leading = md[1] diff --git a/lib/puppet/pops/parser/lexer2.rb b/lib/puppet/pops/parser/lexer2.rb index be66a7339d4..dd9bb77b505 100644 --- a/lib/puppet/pops/parser/lexer2.rb +++ b/lib/puppet/pops/parser/lexer2.rb @@ -357,6 +357,7 @@ def initialize() while escaped_end(value) more = scn.scan_until(PATTERN_REGEX_END) return emit(TOKEN_DIV, before) unless more + value << more end regex = value.sub(PATTERN_REGEX_A, '').sub(PATTERN_REGEX_Z, '').gsub(PATTERN_REGEX_ESC, '/') @@ -510,6 +511,7 @@ def initialize() invalid_number = nil before = scn.pos break if before == 0 + scn.pos = scn.pos - 1 end end diff --git a/lib/puppet/pops/parser/lexer_support.rb b/lib/puppet/pops/parser/lexer_support.rb index 39f7da58fdb..ec5e7063b24 100644 --- a/lib/puppet/pops/parser/lexer_support.rb +++ b/lib/puppet/pops/parser/lexer_support.rb @@ -11,6 +11,7 @@ module LexerSupport # Returns "" if at end of input, else the following 5 characters with \n \r \t escaped def followed_by return "" if @scanner.eos? + result = @scanner.rest[0,5] + "..." result.gsub!("\t", '\t') result.gsub!("\n", '\n') diff --git a/lib/puppet/pops/parser/locator.rb b/lib/puppet/pops/parser/locator.rb index 3b023de3eff..26f433ace30 100644 --- a/lib/puppet/pops/parser/locator.rb +++ b/lib/puppet/pops/parser/locator.rb @@ -58,6 +58,7 @@ def extract_tree_text(ast) last = first + ast.length ast._pcore_all_contents([]) do |m| next unless m.is_a?(Model::Positioned) + m_offset = m.offset m_last = m_offset + m.length first = m_offset if m_offset < first @@ -160,6 +161,7 @@ def ary_bsearch_i(ary, value) return nil if low == ary.length return nil if !satisfied + return low end @@ -178,6 +180,7 @@ def line_for_offset(offset) # use cache return @prev_line end + line_nbr = ary_bsearch_i(line_index, offset) if line_nbr # cache diff --git a/lib/puppet/pops/parser/parser_support.rb b/lib/puppet/pops/parser/parser_support.rb index 297b6715ded..e201df60edb 100644 --- a/lib/puppet/pops/parser/parser_support.rb +++ b/lib/puppet/pops/parser/parser_support.rb @@ -28,6 +28,7 @@ class Parser # Returns the token text of the given lexer token, or nil, if token is nil def token_text t return t if t.nil? + if t.is_a?(Factory) && t.model_class <= Model::QualifiedName t['value'] elsif t.is_a?(Model::QualifiedName) diff --git a/lib/puppet/pops/resource/resource_type_impl.rb b/lib/puppet/pops/resource/resource_type_impl.rb index bf90297f47f..c56f1cc89e2 100644 --- a/lib/puppet/pops/resource/resource_type_impl.rb +++ b/lib/puppet/pops/resource/resource_type_impl.rb @@ -72,6 +72,7 @@ def <=>(other) # Order is only maintained against other types, not arbitrary objects. # The natural order is based on the reference name used when comparing return nil unless other.is_a?(Puppet::CompilableResourceType) + # against other type instances. self.ref <=> other.ref end @@ -164,6 +165,7 @@ def initialize(name, properties = EMPTY_ARRAY, parameters = EMPTY_ARRAY, title_p # raise Puppet::DevError, _("you must specify title patterns when there are two or more key attributes") end + @title_patterns_hash.nil? ? [] : @title_patterns_hash.map { |k,v| [ k, v.map { |n| [ n.to_sym] } ] } end end diff --git a/lib/puppet/pops/serialization/abstract_writer.rb b/lib/puppet/pops/serialization/abstract_writer.rb index 765ee16053c..62ef8647b07 100644 --- a/lib/puppet/pops/serialization/abstract_writer.rb +++ b/lib/puppet/pops/serialization/abstract_writer.rb @@ -101,6 +101,7 @@ def write_tpl_qname(ep, qname) def write_tpl(ep, value) #TRANSLATORS 'Integers' is a Ruby class for numbers and should not be translated raise ArgumentError, _('Internal error. Integers cannot be tabulated in extension payload') if value.is_a?(Integer) + if @tabulate index = @written[value] if index.nil? diff --git a/lib/puppet/pops/serialization/deserializer.rb b/lib/puppet/pops/serialization/deserializer.rb index c70f0128629..c7828cfffdc 100644 --- a/lib/puppet/pops/serialization/deserializer.rb +++ b/lib/puppet/pops/serialization/deserializer.rb @@ -45,6 +45,7 @@ def read type_name = val.type_name type = Types::TypeParser.singleton.parse(type_name, @loader) raise SerializationError, _("No implementation mapping found for Puppet Type %{type_name}") % { type_name: type_name } if type.is_a?(Types::PTypeReferenceType) + result = type.read(val.attribute_count, self) if result.is_a?(Types::PObjectType) existing_type = loader.load(:type, result.name) diff --git a/lib/puppet/pops/serialization/from_data_converter.rb b/lib/puppet/pops/serialization/from_data_converter.rb index 438dde826ea..52e8e8fc0d2 100644 --- a/lib/puppet/pops/serialization/from_data_converter.rb +++ b/lib/puppet/pops/serialization/from_data_converter.rb @@ -124,6 +124,7 @@ def initialize(options = EMPTY_HASH) type = without_value { convert(type_value) } if type.is_a?(Hash) raise SerializationError, _('Unable to deserialize type from %{type}') % { type: type } unless @allow_unresolved + hash else pcore_type_hash_to_value(type, value) @@ -134,6 +135,7 @@ def initialize(options = EMPTY_HASH) unless @allow_unresolved raise SerializationError, _('No implementation mapping found for Puppet Type %{type_name}') % { type_name: type_value } end + hash else # not a string diff --git a/lib/puppet/pops/serialization/json.rb b/lib/puppet/pops/serialization/json.rb index aa5f130c450..67aebaab76e 100644 --- a/lib/puppet/pops/serialization/json.rb +++ b/lib/puppet/pops/serialization/json.rb @@ -249,6 +249,7 @@ def initialize(io) def re_initialize(io) parsed = parse_io(io) raise SerializationError, _("JSON stream is not an array. It is a %{klass}") % { klass: io.class.name } unless parsed.is_a?(Array) + @etor_stack = [parsed.each] end @@ -256,6 +257,7 @@ def read obj = nil loop do raise SerializationError, _('Unexpected end of input') if @etor_stack.empty? + etor = @etor_stack.last begin obj = etor.next @@ -270,6 +272,7 @@ def read ext_no = ext_etor.next ext_block = @type_registry[ext_no] raise SerializationError, _("Invalid input. %{ext_no} is not a valid extension number") % { ext_no: ext_no } if ext_block.nil? + obj = ext_block.call(nil) end obj diff --git a/lib/puppet/pops/serialization/object.rb b/lib/puppet/pops/serialization/object.rb index 5931791e0d9..d2b49a2f1cd 100644 --- a/lib/puppet/pops/serialization/object.rb +++ b/lib/puppet/pops/serialization/object.rb @@ -15,6 +15,7 @@ def read(type, impl_class, value_count, deserializer) unless value_count >= required_count && value_count <= max raise Serialization::SerializationError, _("Feature count mismatch for %{value0}. Expected %{required_count} - %{max}, actual %{value_count}") % { value0: impl_class.name, required_count: required_count, max: max, value_count: value_count } end + # Deserializer must know about this instance before we read its attributes val = deserializer.remember(impl_class.allocate) args = Array.new(value_count) { deserializer.read } @@ -25,6 +26,7 @@ def read(type, impl_class, value_count, deserializer) else attr = type[names[index]] raise Serialization::SerializationError, _("Missing default value for %{type_name}[%{name}]") % { type_name: type.name, name: names[index] } unless attr && attr.value? + args << attr.value end end @@ -48,6 +50,7 @@ def write(type, value, serializer) # Pop optional arguments that are default while args.size > required_count break unless type[names[args.size-1]].default_value?(args.last) + args.pop end diff --git a/lib/puppet/pops/serialization/serializer.rb b/lib/puppet/pops/serialization/serializer.rb index 3138fb990f9..e2c3b8440f7 100644 --- a/lib/puppet/pops/serialization/serializer.rb +++ b/lib/puppet/pops/serialization/serializer.rb @@ -135,6 +135,7 @@ def write_tabulated_first_time(value) impl_class = value.class type = Loaders.implementation_registry.type_for_module(impl_class) raise SerializationError, _("No Puppet Type found for %{klass}") % { klass: impl_class.name } unless type.is_a?(Types::PObjectType) + type.write(value, self) end end diff --git a/lib/puppet/pops/serialization/to_data_converter.rb b/lib/puppet/pops/serialization/to_data_converter.rb index a31b5db75ca..eac1e5e5e0e 100644 --- a/lib/puppet/pops/serialization/to_data_converter.rb +++ b/lib/puppet/pops/serialization/to_data_converter.rb @@ -271,6 +271,7 @@ def value_to_data_hash(value) # Pop optional arguments that are default while args.size > required_count break unless pcore_type[names[args.size-1]].default_value?(args.last) + args.pop end result = { diff --git a/lib/puppet/pops/time/timespan.rb b/lib/puppet/pops/time/timespan.rb index 17433eea7cf..8b0a4d221c2 100644 --- a/lib/puppet/pops/time/timespan.rb +++ b/lib/puppet/pops/time/timespan.rb @@ -477,6 +477,7 @@ def nanoseconds(group) # Using %L or %N to parse a string only makes sense when they are considered to be fractions. Using them # as a total quantity would introduce ambiguities. raise ArgumentError, _('Format specifiers %L and %N denotes fractions and must be used together with a specifier of higher magnitude') if use_total? + n = group.to_i p = 9 - group.length p <= 0 ? n : n * 10 ** p @@ -553,12 +554,15 @@ def format(timespan) def parse(timespan) md = regexp.match(timespan) raise ArgumentError, _("Unable to parse '%{timespan}' using format '%{format}'") % { timespan: timespan, format: @format } if md.nil? + nanoseconds = 0 md.captures.each_with_index do |group, index| segment = @segments[index] next if segment.is_a?(LiteralSegment) + group.lstrip! raise ArgumentError, _("Unable to parse '%{timespan}' using format '%{format}'") % { timespan: timespan, format: @format } unless group =~ /\A[0-9]+\z/ + nanoseconds += segment.nanoseconds(group) end Timespan.new(timespan.start_with?('-') ? -nanoseconds : nanoseconds) @@ -627,6 +631,7 @@ def append_literal(bld, codepoint) def internal_parse(str) bld = [] raise ArgumentError, _('Format must be a String') unless str.is_a?(String) + highest = -1 state = STATE_LITERAL padchar = '0' @@ -654,10 +659,12 @@ def internal_parse(str) state = STATE_LITERAL when 0x2D # '-' raise ArgumentError, bad_format_specifier(str, fstart, position) unless state == STATE_PAD + padchar = nil state = STATE_WIDTH when 0x5F # '_' raise ArgumentError, bad_format_specifier(str, fstart, position) unless state == STATE_PAD + padchar = ' ' state = STATE_WIDTH when 0x44 # 'D' @@ -686,6 +693,7 @@ def internal_parse(str) state = STATE_LITERAL else # only digits allowed at this point raise ArgumentError, bad_format_specifier(str, fstart, position) unless codepoint >= 0x30 && codepoint <= 0x39 + if state == STATE_PAD && codepoint == 0x30 padchar = '0' else @@ -701,6 +709,7 @@ def internal_parse(str) end raise ArgumentError, bad_format_specifier(str, fstart, position) unless state == STATE_LITERAL + unless highest == -1 hc = SEGMENT_CLASS_BY_ORDINAL[highest] bld.find { |s| s.instance_of?(hc) }.set_use_total diff --git a/lib/puppet/pops/time/timestamp.rb b/lib/puppet/pops/time/timestamp.rb index 16771b2a54c..f00721fb2ef 100644 --- a/lib/puppet/pops/time/timestamp.rb +++ b/lib/puppet/pops/time/timestamp.rb @@ -39,6 +39,7 @@ def self.utc_offset(timezone) hash = DateTime._strptime(timezone, '%z') offset = hash.nil? ? nil : hash[:offset] raise ArgumentError, _("Illegal timezone '%{timezone}'") % { timezone: timezone } if offset.nil? + offset end end @@ -74,6 +75,7 @@ def self.parse(str, format = :default, timezone = nil) format.each do |fmt| parsed = DateTime._strptime(str, fmt) next if parsed.nil? + if parsed.include?(:leftover) || (has_timezone && parsed.include?(:zone)) parsed = nil next @@ -89,6 +91,7 @@ def self.parse(str, format = :default, timezone = nil) if parsed.nil? || parsed.include?(:leftover) raise ArgumentError, _("Unable to parse '%{str}' using format '%{format}'") % { str: str, format: format } end + if has_timezone && parsed.include?(:zone) raise ArgumentError, _( 'Using a Timezone designator in format specification is mutually exclusive to providing an explicit timezone argument') diff --git a/lib/puppet/pops/types/class_loader.rb b/lib/puppet/pops/types/class_loader.rb index 7f288b57297..b113638b64c 100644 --- a/lib/puppet/pops/types/class_loader.rb +++ b/lib/puppet/pops/types/class_loader.rb @@ -37,6 +37,7 @@ def self.provide_from_type(type) case type when PRuntimeType raise ArgumentError.new("Only Runtime type 'ruby' is supported, got #{type.runtime}") unless type.runtime == :ruby + provide_from_string(type.runtime_type_name) when PBooleanType @@ -95,6 +96,7 @@ def self.provide_from_name_path(name, name_path) end end return nil unless result.is_a?(Module) + result end private_class_method :provide_from_string diff --git a/lib/puppet/pops/types/iterable.rb b/lib/puppet/pops/types/iterable.rb index 3dcbac22f6b..67b38438961 100644 --- a/lib/puppet/pops/types/iterable.rb +++ b/lib/puppet/pops/types/iterable.rb @@ -33,6 +33,7 @@ module Iterable def self.asserted_iterable(my_caller, obj, infer_elements = false) iter = self.on(obj, nil, infer_elements) raise ArgumentError, "#{my_caller.class}(): wrong argument type (#{obj.class}; is not Iterable." if iter.nil? + iter end @@ -168,6 +169,7 @@ def step(step, &block) def to_a raise Puppet::Error, 'Attempt to create an Array from an unbounded Iterable' if unbounded? + super end @@ -230,6 +232,7 @@ def any?(&block) def step(step, &block) raise ArgumentError if step <= 0 + r = self r = r.step_iterator(step) if step > 1 @@ -282,6 +285,7 @@ class StepIterator < Iterator def initialize(element_type, enumeration, step_size) super(element_type, enumeration) raise ArgumentError if step_size <= 0 + @step_size = step_size end @@ -313,6 +317,7 @@ class IntegerRangeIterator < Iterator def initialize(range, step = 1) raise ArgumentError if step == 0 + @range = range @step_size = step @current = (step < 0 ? range.to : range.from) - step diff --git a/lib/puppet/pops/types/p_binary_type.rb b/lib/puppet/pops/types/p_binary_type.rb index b11747830d7..6481802f54b 100644 --- a/lib/puppet/pops/types/p_binary_type.rb +++ b/lib/puppet/pops/types/p_binary_type.rb @@ -75,6 +75,7 @@ def self.from_string(encoded_string) unless encoded_string.valid_encoding? raise ArgumentError, _("The given string in encoding '%{enc}' is invalid. Cannot create a Binary UTF-8 representation") % { enc: enc } end + # Convert to UTF-8 (if not already UTF-8), and then to binary encoded_string = (enc == "UTF-8") ? encoded_string.dup : encoded_string.encode('UTF-8') encoded_string.force_encoding("ASCII-8BIT") diff --git a/lib/puppet/pops/types/p_init_type.rb b/lib/puppet/pops/types/p_init_type.rb index 454318477a4..de1e1f292e8 100644 --- a/lib/puppet/pops/types/p_init_type.rb +++ b/lib/puppet/pops/types/p_init_type.rb @@ -24,6 +24,7 @@ def initialize(type, init_args) if type.nil? raise ArgumentError, _('Init cannot be parameterized with an undefined type and additional arguments') unless @init_args.empty? + @initialized = true else @initialized = false @@ -70,6 +71,7 @@ def hash def new_function return super if type.nil? + assert_initialized target_type = type @@ -152,6 +154,7 @@ def assert_initialized if @type.instance_of?(PInitType) || @type.instance_of?(POptionalType) || @type.instance_of?(PNotUndefType) raise ArgumentError.new end + new_func = @type.new_function rescue ArgumentError raise ArgumentError, _("Creation of new instance of type '%{type_name}' is not supported") % { type_name: @type.to_s } diff --git a/lib/puppet/pops/types/p_object_type.rb b/lib/puppet/pops/types/p_object_type.rb index dfd4b5969ef..69b9aa228ff 100644 --- a/lib/puppet/pops/types/p_object_type.rb +++ b/lib/puppet/pops/types/p_object_type.rb @@ -173,6 +173,7 @@ def assert_can_be_overridden(member) unless @type.assignable?(member.type) raise Puppet::ParseError, _("%{member} attempts to override %{label} with a type that does not match") % { member: member.label, label: label } end + member end @@ -243,6 +244,7 @@ def invoke(receiver, scope, args, &block) args_type = TypeCalculator.infer_set(block_given? ? args + [block] : args) found = @dispatch.find { |d| d.type.callable?(args_type) } raise ArgumentError, TypeMismatchDescriber.describe_signatures(label, @dispatch, args_type) if found.nil? + found.invoke(receiver, scope, args, &block) end @@ -286,12 +288,14 @@ def initialize(name, container, init_hash) if name == Serialization::PCORE_TYPE_KEY || name == Serialization::PCORE_VALUE_KEY raise Puppet::ParseError, _("The attribute '%{name}' is reserved and cannot be used") % { name: name} end + @kind = init_hash[KEY_KIND] if @kind == ATTRIBUTE_KIND_CONSTANT # final is implied if init_hash.include?(KEY_FINAL) && !@final #TRANSLATOR 'final => false' is puppet syntax and should not be translated raise Puppet::ParseError, _("%{label} of kind 'constant' cannot be combined with final => false") % { label: label } end + @final = true end @@ -299,10 +303,12 @@ def initialize(name, container, init_hash) if @kind == ATTRIBUTE_KIND_DERIVED || @kind == ATTRIBUTE_KIND_GIVEN_OR_DERIVED raise Puppet::ParseError, _("%{label} of kind '%{kind}' cannot be combined with an attribute value") % { label: label, kind: @kind } end + v = init_hash[KEY_VALUE] @value = v == :default ? v : TypeAsserter.assert_instance_of(nil, type, v) {"#{label} #{KEY_VALUE}" } else raise Puppet::ParseError, _("%{label} of kind 'constant' requires a value") % { label: label } if @kind == ATTRIBUTE_KIND_CONSTANT + @value = :undef # Not to be confused with nil or :default end end @@ -352,6 +358,7 @@ def value? def value # An error must be raised here since `nil` is a valid value and it would be bad to leak the :undef symbol raise Puppet::Error, "#{label} has no value" if @value == :undef + @value end @@ -440,6 +447,7 @@ def instance?(o, guard = nil) else name = o.class.name return false if name.nil? # anonymous class that doesn't implement PuppetObject is not an instance + ir = Loaders.implementation_registry type = ir.nil? ? nil : ir.type_for_module(name) !type.nil? && assignable?(type, guard) @@ -554,6 +562,7 @@ def implementation_class(create = true) # @api private def implementation_class=(cls) raise ArgumentError, "attempt to redefine implementation class for #{label}" unless @implementation_class.nil? + @implementation_class = cls end @@ -569,6 +578,7 @@ def implementation_override=(block) if !@implementation_class.nil? || instance_variable_defined?(:@implementation_override) raise ArgumentError, "attempt to redefine implementation override for #{label}" end + @implementation_override = block end @@ -627,6 +637,7 @@ def parameter_info(impl_class) if init_param_names.size < param_count || init_non_opt_count > param_count raise Serialization::SerializationError, "Initializer for class #{impl_class.name} does not match the attributes of #{name}" end + init_param_names = init_param_names[0, param_count] if init_param_names.size > param_count unless init_param_names == param_names # Reorder needed to match initialize method arguments @@ -682,6 +693,7 @@ def _pcore_init_from_hash(init_hash) check_self_recursion(self) rp = resolved_parent raise Puppet::ParseError, _("reference to unresolved type '%{name}'") % { :name => rp.type_string } if rp.is_a?(PTypeReferenceType) + if rp.is_a?(PObjectType) parent_object_type = rp parent_members = rp.members(true) @@ -719,6 +731,7 @@ def _pcore_init_from_hash(init_hash) if attr_specs.include?(key) raise Puppet::ParseError, _("attribute %{label}[%{key}] is defined as both a constant and an attribute") % { label: label, key: key } end + attr_spec = { # Type must be generic here, or overrides would become impossible KEY_TYPE => TypeCalculator.infer(value).generalize, @@ -750,6 +763,7 @@ def _pcore_init_from_hash(init_hash) func = PFunction.new(key, self, func_spec) name = func.name raise Puppet::ParseError, _("%{label} conflicts with attribute with the same name") % { label: func.label } if @attributes.include?(name) + [name, func.assert_override(parent_members)] end].freeze end @@ -763,6 +777,7 @@ def _pcore_init_from_hash(init_hash) unless equality.empty? #TRANSLATORS equality_include_type = false should not be translated raise Puppet::ParseError, _('equality_include_type = false cannot be combined with non empty equality specification') unless @equality_include_type + parent_eq_attrs = nil equality.each do |attr_name| attr = parent_members[attr_name] @@ -782,6 +797,7 @@ def _pcore_init_from_hash(init_hash) if attr.nil? raise Puppet::ParseError, _("%{label} equality is referencing non existent attribute '%{attribute}'") % { label: label, attribute: attr_name } end + raise Puppet::ParseError, _("%{label} equality is referencing %{attribute}. Only attribute references are allowed") % { label: label, attribute: attr.label } end @@ -977,6 +993,7 @@ def functions(include_parent = false) def check_self_recursion(originator) unless @parent.nil? raise Puppet::Error, "The Object type '#{originator.label}' inherits from itself" if @parent.equal?(originator) + @parent.check_self_recursion(originator) end end @@ -1087,6 +1104,7 @@ def find_equality_definer_of(attr) p = type.resolved_parent return type unless p.is_a?(PObjectType) return type unless p.equality_attributes.include?(attr.name) + type = p end nil diff --git a/lib/puppet/pops/types/p_object_type_extension.rb b/lib/puppet/pops/types/p_object_type_extension.rb index 7584796bc41..941d42c83be 100644 --- a/lib/puppet/pops/types/p_object_type_extension.rb +++ b/lib/puppet/pops/types/p_object_type_extension.rb @@ -53,6 +53,7 @@ def [](name) def initialize(base_type, init_parameters) pts = base_type.type_parameters(true) raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using []') % { label: base_type.label } if pts.empty? + @base_type = base_type named_args = init_parameters.size == 1 && init_parameters[0].is_a?(Hash) @@ -69,6 +70,7 @@ def initialize(base_type, init_parameters) if tp.nil? raise Puppet::ParseError, _("'%{pn}' is not a known type parameter for %{label}-Type") % { pn: pn, label: base_type.label } end + by_name[pn] = check_param(tp, pv) unless pv == :default end else @@ -82,6 +84,7 @@ def initialize(base_type, init_parameters) if by_name.empty? raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using an empty parameter list') % { label: base_type.label } end + @parameters = by_name end diff --git a/lib/puppet/pops/types/p_runtime_type.rb b/lib/puppet/pops/types/p_runtime_type.rb index da31c266a3e..42af4deb75c 100644 --- a/lib/puppet/pops/types/p_runtime_type.rb +++ b/lib/puppet/pops/types/p_runtime_type.rb @@ -69,8 +69,10 @@ def runtime_type_name def class_or_module raise "Only ruby classes or modules can be produced by this runtime, got '#{runtime}" unless runtime == :ruby raise 'A pattern based Runtime type cannot produce a class or module' if @name_or_pattern.is_a?(Array) + com = ClassLoader.provide(self) raise "The name #{@name_or_pattern} does not represent a ruby class or module" if com.nil? + com end diff --git a/lib/puppet/pops/types/p_timespan_type.rb b/lib/puppet/pops/types/p_timespan_type.rb index ce10241ef51..05bccad09aa 100644 --- a/lib/puppet/pops/types/p_timespan_type.rb +++ b/lib/puppet/pops/types/p_timespan_type.rb @@ -71,6 +71,7 @@ def convert_arg(arg, min) impl_class.new(arg * Time::NSECS_PER_SEC) else raise ArgumentError, "Unable to create a #{impl_class.name} from a #{arg.class.name}" unless arg.nil? || arg == :default + nil end end diff --git a/lib/puppet/pops/types/p_type_set_type.rb b/lib/puppet/pops/types/p_type_set_type.rb index 94c09490e3f..088feb60a8a 100644 --- a/lib/puppet/pops/types/p_type_set_type.rb +++ b/lib/puppet/pops/types/p_type_set_type.rb @@ -144,6 +144,7 @@ def _pcore_init_from_hash(init_hash) unless ranges.all? { |range| (range & ref.version_range).nil? } raise ArgumentError, "TypeSet '#{@name}' references TypeSet '#{ref_na}/#{ref_name}' more than once using overlapping version ranges" end + ranges << ref.version_range end @@ -153,6 +154,7 @@ def _pcore_init_from_hash(init_hash) if @types.has_key?(ref_alias) raise ArgumentError, "TypeSet '#{@name}' references a TypeSet using alias '#{ref_alias}'. The alias collides with the name of a declared type" end + ref_map[ref_alias] = ref @dc_to_cc_map[ref_alias.downcase] = ref_alias @@ -191,6 +193,7 @@ def _pcore_init_hash def [](qname) if qname.is_a?(Loader::TypedName) return nil unless qname.type == :type && qname.name_authority == @name_authority + qname = qname.name end diff --git a/lib/puppet/pops/types/p_uri_type.rb b/lib/puppet/pops/types/p_uri_type.rb index b4d18d49da9..8b60f9695b3 100644 --- a/lib/puppet/pops/types/p_uri_type.rb +++ b/lib/puppet/pops/types/p_uri_type.rb @@ -151,6 +151,7 @@ def _pcore_init_hash def _assignable?(o, guard = nil) return false unless o.class == self.class return true if @parameters.nil? + o_params = o.parameters || EMPTY_HASH eval = Parser::EvaluatingParser.singleton.evaluator diff --git a/lib/puppet/pops/types/ruby_generator.rb b/lib/puppet/pops/types/ruby_generator.rb index 281bc42362d..b4a00fe001d 100644 --- a/lib/puppet/pops/types/ruby_generator.rb +++ b/lib/puppet/pops/types/ruby_generator.rb @@ -43,6 +43,7 @@ def remove_common_namespace(namespace_segments, name) segments = name.split(TypeFormatter::NAME_SEGMENT_SEPARATOR) namespace_segments.size.times do |idx| break if segments.empty? || namespace_segments[idx] != segments[0] + segments.shift end segments @@ -68,6 +69,7 @@ def create_class(obj) hash[key] = cls end raise ArgumentError, "Expected a Puppet Type, got '#{obj.class.name}'" unless obj.is_a?(PAnyType) + @dynamic_classes[obj] end @@ -103,6 +105,7 @@ def module_definition(types, comment, *impl_subst) min_prefix_length.times do |idx| segment = segments_array[0][idx] break unless segments_array.all? { |sn| sn[idx] == segment } + common_prefix << segment end @@ -157,6 +160,7 @@ def implementation_names(object_types) ir = Loaders.implementation_registry impl_name = ir.module_name_for_type(type) raise Puppet::Error, "Unable to create an instance of #{type.name}. No mapping exists to runtime object" if impl_name.nil? + impl_name end end diff --git a/lib/puppet/pops/types/string_converter.rb b/lib/puppet/pops/types/string_converter.rb index 80ef094fe7e..9eb84bfe872 100644 --- a/lib/puppet/pops/types/string_converter.rb +++ b/lib/puppet/pops/types/string_converter.rb @@ -109,11 +109,13 @@ def initialize(fmt) unless @format.is_a?(String) && @format.length == 1 raise ArgumentError, "The format must be a one letter format specifier, got '#{@format}'" end + @format = @format.to_sym flags = match[1].split('') || [] unless flags.uniq.size == flags.size raise ArgumentError, "The same flag can only be used once, got '#{fmt}'" end + @left = flags.include?('-') @alt = flags.include?('#') @plus = (flags.include?(' ') ? :space : (flags.include?('+') ? :plus : :ignore)) @@ -125,6 +127,7 @@ def initialize(fmt) if !@delimiters.nil? raise ArgumentError, "Only one of the delimiters [ { ( < | can be given in the format flags, got '#{fmt}'" end + @delimiters = d end @@ -153,6 +156,7 @@ def self.merge(lower, higher) unless lower && higher return lower || higher end + lower.merge(higher) end @@ -529,11 +533,13 @@ def validate_input(fmt) unless fmt.is_a?(Hash) raise ArgumentError, "expected a hash with type to format mappings, got instance of '#{fmt.class}'" end + fmt.reduce({}) do | result, entry| key, value = entry unless key.is_a?(Types::PAnyType) raise ArgumentError, "top level keys in the format hash must be data types, got instance of '#{key.class}'" end + if value.is_a?(Hash) result[key] = validate_container_input(value) else @@ -550,6 +556,7 @@ def validate_container_input(fmt) if (fmt.keys - FMT_KEYS).size > 0 raise ArgumentError, "only #{FMT_KEYS.map {|k| "'#{k}'"}.join(', ')} are allowed in a container format, got #{fmt}" end + result = Format.new(fmt['format']) result.separator = fmt['separator'] result.separator2 = fmt['separator2'] @@ -1126,6 +1133,7 @@ def string_PURIType(val_type, val, format_map, indentation) def get_format(val_t, format_options) fmt = format_options.find {|k,_| k.assignable?(val_t) } return fmt[1] unless fmt.nil? + return Format.new("%s") end private :get_format diff --git a/lib/puppet/pops/types/tree_iterators.rb b/lib/puppet/pops/types/tree_iterators.rb index ac317715d8e..034c73dad05 100644 --- a/lib/puppet/pops/types/tree_iterators.rb +++ b/lib/puppet/pops/types/tree_iterators.rb @@ -37,6 +37,7 @@ def initialize(enum, options=EMPTY_HASH) unless DEFAULT_CONTAINERS.assignable?(@containers_t) raise ArgumentError, _("Only Array, Hash, and Object types can be used as container types. Got %{type}") % {type: @containers_t} end + @with_root = extract_option(options, 'include_root', true) @with_containers = extract_option(options, 'include_containers', true) @with_values = extract_option(options, 'include_values', true) @@ -44,6 +45,7 @@ def initialize(enum, options=EMPTY_HASH) unless @with_containers || @with_values raise ArgumentError, _("Options 'include_containers' and 'include_values' cannot both be false") end + @include_refs = !!options['include_refs'] end @@ -91,6 +93,7 @@ def step(step, &block) def indexer_on(val) return nil unless @containers_t.instance?(val) + if val.is_a?(Array) val.size.times elsif val.is_a?(Hash) diff --git a/lib/puppet/pops/types/type_calculator.rb b/lib/puppet/pops/types/type_calculator.rb index 4f8cd161bd9..b5b47033aa1 100644 --- a/lib/puppet/pops/types/type_calculator.rb +++ b/lib/puppet/pops/types/type_calculator.rb @@ -142,6 +142,7 @@ def self.infer_callable_methods_t(o) ) return nil end + # For other objects (e.g. PObjectType instances, and runtime types) full inference needed, since that will # cover looking into the runtime type registry. # @@ -197,6 +198,7 @@ def callable?(callable, args) # Answers if the two given types describe the same type def equals(left, right) return false unless left.is_a?(PAnyType) && right.is_a?(PAnyType) + # Types compare per class only - an extra test must be made if the are mutually assignable # to find all types that represent the same type of instance # @@ -455,6 +457,7 @@ def common_type(t1, t2) if t1.runtime == t2.runtime && t1.runtime_type_name == t2.runtime_type_name return t1 end + # finding the common super class requires that names are resolved to class # NOTE: This only supports runtime type of :ruby c1 = ClassLoader.provide_from_type(t1) @@ -528,9 +531,11 @@ def infer_Object(o) else name = o.class.name return PRuntimeType.new(:ruby, nil) if name.nil? # anonymous class that doesn't implement PuppetObject is impossible to infer + ir = Loaders.implementation_registry type = ir.nil? ? nil : ir.type_for_module(name) return PRuntimeType.new(:ruby, name) if type.nil? + if type.is_a?(PObjectType) && type.parameterized? type = PObjectTypeExtension.create_from_instance(type, o) end @@ -750,6 +755,7 @@ def unwrap_single_variant(possible_variant) # def size_range(range) return [1,1] if range.nil? + from = range.from to = range.to x = from.nil? ? 1 : from diff --git a/lib/puppet/pops/types/type_factory.rb b/lib/puppet/pops/types/type_factory.rb index 358677ddfcb..418f165c422 100644 --- a/lib/puppet/pops/types/type_factory.rb +++ b/lib/puppet/pops/types/type_factory.rb @@ -179,6 +179,7 @@ def self.struct(hash = {}) # TODO: Should have stricter name rule if key_type.is_a?(String) raise ArgumentError, 'Struct element key cannot be an empty String' if key_type.empty? + key_type = string(key_type) # Must make key optional if the value can be Undef key_type = optional(key_type) if tc.assignable?(value_type, PUndefType::DEFAULT) @@ -431,9 +432,11 @@ def self.resource(type_name = nil, title = nil) when String type_name = TypeFormatter.singleton.capitalize_segments(type_name) raise ArgumentError, "Illegal type name '#{type_name}'" unless type_name =~ Patterns::CLASSREF_EXT + PResourceType.new(type_name, title) when nil raise ArgumentError, 'The type name cannot be nil, if title is given' unless title.nil? + PResourceType::DEFAULT else raise ArgumentError, "The type name cannot be a #{type_name.class.name}" diff --git a/lib/puppet/pops/types/type_mismatch_describer.rb b/lib/puppet/pops/types/type_mismatch_describer.rb index 88ef956cd5c..ca52daaa5cc 100644 --- a/lib/puppet/pops/types/type_mismatch_describer.rb +++ b/lib/puppet/pops/types/type_mismatch_describer.rb @@ -127,6 +127,7 @@ def hash def chop_path(element_index) return self if element_index >= @path.size + chopped_path = @path.clone chopped_path.delete_at(element_index) copy = self.clone @@ -585,6 +586,7 @@ def get_deferred_function_return_type(value) .load(:function, value.name) dispatcher = func.class.dispatcher.find_matching_dispatcher(value.arguments) raise ArgumentError, "No matching arity found for #{func.class.name} with arguments #{value.arguments}" unless dispatcher + dispatcher.type.return_type end private :get_deferred_function_return_type @@ -739,6 +741,7 @@ def describe_PVariantType(expected, original, actual, path) types.each_with_index do |vt, index| d = describe(vt, actual, path + [VariantPathElement.new(index)]) return EMPTY_ARRAY if d.empty? + variant_descriptions << d end descriptions = merge_descriptions(path.length, SizeMismatch, variant_descriptions) @@ -759,6 +762,7 @@ def merge_descriptions(varying_path_position, size_mismatch_class, variant_descr # If they all have the same canonical path, then we can compact this into one generic_mismatch = mismatches.inject do |prev, curr| break nil unless prev.canonical_path == curr.canonical_path + prev.merge(prev.path, curr) end unless generic_mismatch.nil? @@ -774,6 +778,7 @@ def merge_descriptions(varying_path_position, size_mismatch_class, variant_descr def describe_POptionalType(expected, original, actual, path) return EMPTY_ARRAY if actual.is_a?(PUndefType) || expected.optional_type.nil? + internal_describe(expected.optional_type, original.is_a?(PTypeAliasType) ? original : expected, actual, path) end @@ -887,6 +892,7 @@ def describe_argument_tuple(expected, actual, path) def describe_tuple(expected, original, actual, path, size_mismatch_class) return EMPTY_ARRAY if expected == actual || expected.types.empty? && (actual.is_a?(PArrayType)) + expected_size = expected.size_type || TypeFactory.range(*expected.size_range) if actual.is_a?(PTupleType) diff --git a/lib/puppet/pops/types/type_parser.rb b/lib/puppet/pops/types/type_parser.rb index d2ce73c586e..3123caed0cd 100644 --- a/lib/puppet/pops/types/type_parser.rb +++ b/lib/puppet/pops/types/type_parser.rb @@ -39,6 +39,7 @@ def parse(string, context = nil) if t return t end + model = @parser.parse_string(string) interpret(model.model.body, context) end @@ -484,6 +485,7 @@ def interpret_AccessExpression(ast, context) raise_invalid_parameters_error('Boolean', '1', parameters.size) unless parameters.size == 1 p = parameters[0] raise Puppet::ParseError, 'Boolean parameter must be true or false' unless p == true || p == false + TypeFactory.boolean(p) when 'integer' diff --git a/lib/puppet/pops/types/type_set_reference.rb b/lib/puppet/pops/types/type_set_reference.rb index b19119a9466..7f9fd9a35f8 100644 --- a/lib/puppet/pops/types/type_set_reference.rb +++ b/lib/puppet/pops/types/type_set_reference.rb @@ -49,6 +49,7 @@ def resolve(loader) unless @version_range.include?(@type_set.version) raise ArgumentError, "#{self} resolves to an incompatible version. Expected #{@version_range}, got #{type_set.version}" end + nil end diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index 2121f45fc51..feb10990f9e 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -60,8 +60,10 @@ def self.register_ptypes(loader, ir) ] Types.constants.each do |c| next if c == :PType || c == :PHostClassType + cls = Types.const_get(c) next unless cls.is_a?(Class) && cls < self + type = cls.register_ptype(loader, ir) types << type unless type.nil? end @@ -131,6 +133,7 @@ def assignable?(o, guard = nil) return true if self.class == PAnyType # An empty variant may be assignable to NotUndef[T] if T is assignable to empty variant return _assignable?(o, guard) if is_a?(PNotUndefType) && o.types.empty? + !o.types.empty? && o.types.all? { |vt| assignable?(vt, guard) } when POptionalType # Assignable if undef and contained type is assignable @@ -535,6 +538,7 @@ def _assignable?(o, guard) return false unless o.is_a?(PTypeType) return true if @type.nil? # wide enough to handle all types return false if o.type.nil? # wider than t + @type.assignable?(o.type, guard) end end @@ -822,6 +826,7 @@ def instance?(o, guard = nil) # @api private def _assignable?(o, guard) return true if self == o + svalues = values if svalues.empty? return true if o.is_a?(PStringType) || o.is_a?(PEnumType) || o.is_a?(PPatternType) @@ -939,6 +944,7 @@ def initialize(from, to = Float::INFINITY) from = -Float::INFINITY if from.nil? || from == :default to = Float::INFINITY if to.nil? || to == :default raise ArgumentError, "'from' must be less or equal to 'to'. Got (#{from}, #{to}" if from > to + @from = from @to = to end @@ -997,6 +1003,7 @@ def unbounded? # @api_private def _assignable?(o, guard) return false unless o.is_a?(self.class) + # If o min and max are within the range of t @from <= o.numeric_from && @to >= o.numeric_to end @@ -1063,6 +1070,7 @@ def iterable_type(guard = nil) # Returns Float.Infinity if one end of the range is unbound def size return Float::INFINITY if @from == -Float::INFINITY || @to == Float::INFINITY + 1+(to-from).abs end @@ -1802,6 +1810,7 @@ def instance?(o, guard = nil) # def _assignable?(o, guard) return true if self == o + case o when PStringType v = o.value @@ -2068,6 +2077,7 @@ def elements def instance?(o, guard = nil) # The inferred type of a class derived from Hash is either Runtime or Object. It's not assignable to the Struct type. return false unless o.instance_of?(Hash) + matched = 0 @elements.all? do |e| key = e.name @@ -2241,6 +2251,7 @@ def resolve(loader) def instance?(o, guard = nil) # The inferred type of a class derived from Array is either Runtime or Object. It's not assignable to the Tuple type. return false unless o.instance_of?(Array) + if @size_type return false unless @size_type.instance?(o.size, guard) else @@ -2277,6 +2288,7 @@ def repeat_last_range if @size_type.nil? return [1, 1] end + types_size = @types.size from, to = @size_type.range min = from - (types_size-1) @@ -2307,15 +2319,18 @@ def new_function def _assignable?(o, guard) return true if self == o return false unless o.is_a?(PTupleType) || o.is_a?(PArrayType) + s_types = types size_s = size_type || PIntegerType.new(*size_range) if o.is_a?(PTupleType) size_o = o.size_type || PIntegerType.new(*o.size_range) return false unless size_s.assignable?(size_o, guard) + unless s_types.empty? o_types = o.types return size_s.numeric_from == 0 if o_types.empty? + o_types.size.times do |index| return false unless (s_types[index] || s_types[-1]).assignable?(o_types[index], guard) end @@ -2323,12 +2338,14 @@ def _assignable?(o, guard) else size_o = o.size_type || PCollectionType::DEFAULT_SIZE return false unless size_s.assignable?(size_o, guard) + unless s_types.empty? o_entry = o.element_type # Array of anything can not be assigned (unless tuple is tuple of anything) - this case # was handled at the top of this method. # return false if o_entry.nil? + [s_types.size, size_o.range[1]].min.times { |index| return false unless (s_types[index] || s_types[-1]).assignable?(o_entry, guard) } end end @@ -2419,6 +2436,7 @@ def callable_with?(args, block = nil) # nil param_types and compatible return type means other Callable is assignable return true if @param_types.nil? return false unless @param_types.instance?(args) + if @block_type.nil? block == nil else @@ -2492,6 +2510,7 @@ def _assignable?(o, guard) other_param_types = o.param_types return false if other_param_types.nil? || !other_param_types.assignable?(@param_types, guard) + # names are ignored, they are just information # Blocks must be compatible this_block_t = @block_type || PUndefType::DEFAULT @@ -2571,6 +2590,7 @@ def instance?(o, guard = nil) # The inferred type of a class derived from Array is either Runtime or Object. It's not assignable to the Array type. return false unless o.instance_of?(Array) return false unless o.all? {|element| @element_type.instance?(element, guard) } + size_t = size_type size_t.nil? || size_t.instance?(o.size, guard) end @@ -2721,6 +2741,7 @@ def hash def instance?(o, guard = nil) # The inferred type of a class derived from Hash is either Runtime or Object. It's not assignable to the Hash type. return false unless o.instance_of?(Hash) + if o.keys.all? {|key| @key_type.instance?(key, guard) } && o.values.all? {|value| @value_type.instance?(value, guard) } size_t = size_type size_t.nil? || size_t.instance?(o.size, guard) @@ -2757,6 +2778,7 @@ def resolve(loader) def self.array_as_hash(value) return value unless value.is_a?(Array) + result = {} value.each_with_index {|v, idx| result[idx] = array_as_hash(v) } result @@ -2793,6 +2815,7 @@ def from_tree(tuple_array, build_option = nil) if build_option.nil? return from_tuples(tuple_array) end + # only remaining possible options is 'tree' or 'hash_tree' all_hashes = build_option == 'hash_tree' @@ -2826,6 +2849,7 @@ def from_array(from) unless from.size % 2 == 0 raise TypeConversionError.new(_('odd number of arguments for Hash')) end + Hash[*from] end when Hash @@ -2857,6 +2881,7 @@ def _assignable?(o, guard) size_s = size_type return true if (size_s.nil? || size_s.from == 0) && o.is_the_empty_hash? return false unless @key_type.assignable?(o.key_type, guard) && @value_type.assignable?(o.value_type, guard) + super when PStructType # hash must accept String as key type @@ -2989,6 +3014,7 @@ def really_instance?(o, guard = nil) @types.reduce(-1) do |memo, type| ri = type.really_instance?(o, guard) break ri if ri > 0 + ri > memo ? ri : memo end end @@ -3012,6 +3038,7 @@ def assignable?(o, guard = nil) return super unless o.is_a?(PVariantType) # If empty, all Variant types match irrespective of the types they hold (including being empty) return true if types.empty? + # Since this variant is not empty, an empty Variant cannot match, because it matches nothing # otherwise all types in o must be assignable to this !o.types.empty? && o.types.all? { |vt| super(vt, guard) } @@ -3180,6 +3207,7 @@ def _assignable?(o, guard) return false unless o.is_a?(PClassType) # Class = Class[name}, Class[name] != Class return true if @class_name.nil? + # Class[name] = Class[name] @class_name == o.class_name end @@ -3286,6 +3314,7 @@ def new_function def _assignable?(o, guard) return true if o.is_a?(PUndefType) return true if @type.nil? + if o.is_a?(POptionalType) @type.assignable?(o.optional_type, guard) else @@ -3382,6 +3411,7 @@ def assignable?(o, guard = nil) # @raise [Puppet::Error] unless the type has been resolved prior to calling this method def resolved_type raise Puppet::Error, "Reference to unresolved type #{@name}" unless @resolved_type + @resolved_type end @@ -3444,6 +3474,7 @@ def visit(type, _) def set_self_recursion_status return if @self_recursion || @resolved_type.is_a?(PTypeReferenceType) + @self_recursion = true guard = RecursionGuard.new accept(NoopTypeAcceptor::INSTANCE, guard) @@ -3481,6 +3512,7 @@ def resolve(loader) unless real_type_asserter.other_type_detected? raise ArgumentError, "Type alias '#{name}' cannot be resolved to a real type" end + @self_recursion = guard.recursive_this?(self) # All aliases involved must re-check status since this alias is now resolved if @self_recursion @@ -3578,6 +3610,7 @@ def when_self_recursion_detected resolved_types = @resolved_type.types real_types = resolved_types.select do |type| next false if type == self + real_type_asserter = AssertOtherTypeAcceptor.new type.accept(real_type_asserter, RecursionGuard.new) real_type_asserter.other_type_detected? diff --git a/lib/puppet/pops/validation.rb b/lib/puppet/pops/validation.rb index 3716db4b560..1eccc2a558a 100644 --- a/lib/puppet/pops/validation.rb +++ b/lib/puppet/pops/validation.rb @@ -133,6 +133,7 @@ def []=(issue, level) unless issue.demotable? || level == :error raise Puppet::DevError.new(_("Attempt to demote the hard issue '%{issue_code}' to %{level}") % { issue_code: issue.issue_code, level: level }) end + @severities[issue] = level end diff --git a/lib/puppet/pops/validation/checker4_0.rb b/lib/puppet/pops/validation/checker4_0.rb index 8c26d5733d4..a5e2c0f4e10 100644 --- a/lib/puppet/pops/validation/checker4_0.rb +++ b/lib/puppet/pops/validation/checker4_0.rb @@ -283,6 +283,7 @@ def check_CallNamedFunctionExpression(o) # ok (a call to a type) return nil end + case functor when Model::QualifiedName # ok @@ -871,6 +872,7 @@ def check_VariableExpression(o) # The expression must be a qualified name or an integer name_expr = o.expr return if name_expr.is_a?(Model::LiteralInteger) + if !name_expr.is_a?(Model::QualifiedName) acceptor.accept(Issues::ILLEGAL_EXPRESSION, o, :feature => 'name', :container => o) else @@ -1109,12 +1111,14 @@ def idem_IfExpression(o) # Case expression is idem, if test, and all options are idem def idem_CaseExpression(o) return false if !idem(o.test) + ! o.options.any? {|opt| !idem(opt) } end # An option is idem if values and the then_expression are idem def idem_CaseOption(o) return false if o.values.any? { |value| !idem(value) } + idem(o.then_expr) end diff --git a/lib/puppet/pops/validation/tasks_checker.rb b/lib/puppet/pops/validation/tasks_checker.rb index e6892647e9b..d532fd6d5c5 100644 --- a/lib/puppet/pops/validation/tasks_checker.rb +++ b/lib/puppet/pops/validation/tasks_checker.rb @@ -9,6 +9,7 @@ def in_ApplyExpression? step = -1 until container(step) == top do return true if container(step).is_a? Puppet::Pops::Model::ApplyBlockExpression + step -= 1 end end diff --git a/lib/puppet/pops/visitor.rb b/lib/puppet/pops/visitor.rb index 13d8450bd6d..ba7a663114b 100644 --- a/lib/puppet/pops/visitor.rb +++ b/lib/puppet/pops/visitor.rb @@ -35,6 +35,7 @@ def visit(thing, *args) # Visit an explicit receiver def visit_this(receiver, thing, args) raise "Visitor Error: Too few arguments passed. min = #{@min_args}" unless args.length >= @min_args + if @max_args raise "Visitor Error: Too many arguments passed. max = #{@max_args}" unless args.length <= @max_args end @@ -45,18 +46,22 @@ def visit_this(receiver, thing, args) thing.class.ancestors().each do |ancestor| name = ancestor.name next if name.nil? + method_name = :"#{@message}_#{name.split(DOUBLE_COLON).last}" next unless receiver.respond_to?(method_name, true) + @cache[thing.class] = method_name return receiver.send(method_name, thing, *args) end end + raise "Visitor Error: the configured receiver (#{receiver.class}) can't handle instance of: #{thing.class}" end # Visit an explicit receiver def visit_this_class(receiver, clazz, args) raise "Visitor Error: Too few arguments passed. min = #{@min_args}" unless args.length >= @min_args + if @max_args raise "Visitor Error: Too many arguments passed. max = #{@max_args}" unless args.length <= @max_args end @@ -67,12 +72,15 @@ def visit_this_class(receiver, clazz, args) clazz.ancestors().each do |ancestor| name = ancestor.name next if name.nil? + method_name = :"#{@message}_#{name.split(DOUBLE_COLON).last}" next unless receiver.respond_to?(method_name, true) + @cache[clazz] = method_name return receiver.send(method_name, clazz, *args) end end + raise "Visitor Error: the configured receiver (#{receiver.class}) can't handle instance of: #{clazz}" end @@ -84,6 +92,7 @@ def visit_this_0(receiver, thing) if method_name return receiver.send(method_name, thing) end + visit_this(receiver, thing, NO_ARGS) end @@ -95,6 +104,7 @@ def visit_this_1(receiver, thing, arg) if method_name return receiver.send(method_name, thing, arg) end + visit_this(receiver, thing, [arg]) end @@ -106,6 +116,7 @@ def visit_this_2(receiver, thing, arg1, arg2) if method_name return receiver.send(method_name, thing, arg1, arg2) end + visit_this(receiver, thing, [arg1, arg2]) end @@ -117,6 +128,7 @@ def visit_this_3(receiver, thing, arg1, arg2, arg3) if method_name return receiver.send(method_name, thing, arg1, arg2, arg3) end + visit_this(receiver, thing, [arg1, arg2, arg3]) end end diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb index fcaaf103d0e..5298af41de8 100644 --- a/lib/puppet/property.rb +++ b/lib/puppet/property.rb @@ -98,6 +98,7 @@ def array_matching=(value) value = value.intern if value.is_a?(String) #TRANSLATORS 'Property#array_matching', 'first', and 'all' should not be translated raise ArgumentError, _("Supported values for Property#array_matching are 'first' and 'all'") unless [:first, :all].include?(value) + @array_matching = value end @@ -169,6 +170,7 @@ def self.newvalue(name, options = {}, &block) if instance_methods(false).include?(method) raise ArgumentError, _("Attempt to redefine method %{method} with block") % { method: method } end + define_method(method, &value.block) else # Let the method be an alias for calling the providers setter unless we already have this method diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb index 0ed8f664076..b8d420b9591 100644 --- a/lib/puppet/provider.rb +++ b/lib/puppet/provider.rb @@ -267,6 +267,7 @@ def self.default? # @api private def self.default_match return nil if some_default_match(@notdefaults) # Blacklist means this provider cannot be a default + some_default_match(@defaults) end @@ -398,6 +399,7 @@ def self.mk_resource_methods [resource_type.validproperties, resource_type.parameters].flatten.each do |attr| attr = attr.intern next if attr == :name + define_method(attr) do if @property_hash[attr].nil? :absent @@ -574,6 +576,7 @@ def inspect def <=>(other) # We can only have ordering against other providers. return nil unless other.is_a? Puppet::Provider + # Otherwise, order by the providers class name. return self.class.name <=> other.class.name end diff --git a/lib/puppet/provider/aix_object.rb b/lib/puppet/provider/aix_object.rb index 99ec2179db7..ac09abbbc13 100644 --- a/lib/puppet/provider/aix_object.rb +++ b/lib/puppet/provider/aix_object.rb @@ -334,6 +334,7 @@ def ia_module_args raise ArgumentError, _("Cannot have both 'forcelocal' and 'ia_load_module' at the same time!") if @resource[:ia_load_module] && @resource[:forcelocal] return ["-R", @resource[:ia_load_module].to_s] if @resource[:ia_load_module] return ["-R", "files"] if @resource[:forcelocal] + [] end @@ -364,6 +365,7 @@ def modify_object(new_attributes) # Gets a Puppet property's value from object_info def get(property) return :absent unless exists? + object_info[property] || :absent end @@ -418,6 +420,7 @@ def attributes=(new_attributes) # the attributes property. def object_info(refresh = false) return @object_info if @object_info && ! refresh + @object_info = nil begin @@ -464,6 +467,7 @@ def create mappings[:aix_attribute].each do |property, aix_attribute| property_should = @resource.should(property) next if property_should.nil? + attributes[aix_attribute.name] = aix_attribute.convert_property_value(property_should) end diff --git a/lib/puppet/provider/exec/posix.rb b/lib/puppet/provider/exec/posix.rb index dd414313cab..dc6ccee9dc5 100644 --- a/lib/puppet/provider/exec/posix.rb +++ b/lib/puppet/provider/exec/posix.rb @@ -37,6 +37,7 @@ def checkexe(command) elsif !File.executable?(exe) raise ArgumentError, _("'%{exe}' is not executable") % { exe: exe } end + return end diff --git a/lib/puppet/provider/exec/windows.rb b/lib/puppet/provider/exec/windows.rb index 176a788f0d4..c035a74a7c2 100644 --- a/lib/puppet/provider/exec/windows.rb +++ b/lib/puppet/provider/exec/windows.rb @@ -41,6 +41,7 @@ def checkexe(command) elsif !File.file?(exe) raise ArgumentError, _("'%{exe}' is a %{klass}, not a file") % { exe: exe, klass: File.ftype(exe) } end + return end diff --git a/lib/puppet/provider/file/windows.rb b/lib/puppet/provider/file/windows.rb index e0c46940555..1af26574e62 100644 --- a/lib/puppet/provider/file/windows.rb +++ b/lib/puppet/provider/file/windows.rb @@ -37,6 +37,7 @@ def id2name(id) def owner return :absent unless resource.stat + get_owner(resource[:path]) end @@ -50,6 +51,7 @@ def owner=(should) def group return :absent unless resource.stat + get_group(resource[:path]) end diff --git a/lib/puppet/provider/group/groupadd.rb b/lib/puppet/provider/group/groupadd.rb index 78b8bccdf69..b77088ec382 100644 --- a/lib/puppet/provider/group/groupadd.rb +++ b/lib/puppet/provider/group/groupadd.rb @@ -24,17 +24,20 @@ def exists? return !!localgid if @resource.forcelocal? + super end def gid return localgid if @resource.forcelocal? + get(:gid) end def localgid group = findgroup(:group_name, resource[:name]) return group[:gid] if group + false end @@ -124,6 +127,7 @@ def members_insync?(current, should) def members_to_s(current) return '' if current.nil? || !current.kind_of?(Array) + current.join(',') end diff --git a/lib/puppet/provider/group/ldap.rb b/lib/puppet/provider/group/ldap.rb index 2194cb5414c..81f82ce4bda 100644 --- a/lib/puppet/provider/group/ldap.rb +++ b/lib/puppet/provider/group/ldap.rb @@ -30,6 +30,7 @@ existing.each do |hash| value = hash[:gid] next unless value + num = value[0].to_i largest = num if num > largest end diff --git a/lib/puppet/provider/group/windows_adsi.rb b/lib/puppet/provider/group/windows_adsi.rb index 2ff92de70ba..5865c1b66e2 100644 --- a/lib/puppet/provider/group/windows_adsi.rb +++ b/lib/puppet/provider/group/windows_adsi.rb @@ -40,6 +40,7 @@ def members_insync?(current, should) def members_to_s(users) return '' if users.nil? or !users.kind_of?(Array) + users = users.map do |user_name| sid = Puppet::Util::Windows::SID.name_to_principal(user_name) if !sid diff --git a/lib/puppet/provider/ldap.rb b/lib/puppet/provider/ldap.rb index 5b6ffdd3f5c..692556a5425 100644 --- a/lib/puppet/provider/ldap.rb +++ b/lib/puppet/provider/ldap.rb @@ -80,6 +80,7 @@ def flush def initialize(*args) raise(Puppet::DevError, _("No LDAP Configuration defined for %{class_name}") % { class_name: self.class }) unless self.class.manager raise(Puppet::DevError, _("Invalid LDAP Configuration defined for %{class_name}") % { class_name: self.class }) unless self.class.manager.valid? + super @property_hash = @property_hash.inject({}) do |result, ary| diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb index 12a1f8b4cde..533b6e9da1a 100644 --- a/lib/puppet/provider/nameservice.rb +++ b/lib/puppet/provider/nameservice.rb @@ -45,6 +45,7 @@ def options(name, hash) unless resource_type.valid_parameter?(name) raise Puppet::DevError, _("%{name} is not a valid attribute for %{resource_type}") % { name: name, resource_type: resource_type.name } end + @options ||= {} @options[name] ||= {} @@ -59,6 +60,7 @@ def resource_type=(resource_type) super @resource_type.validproperties.each do |prop| next if prop == :ensure + define_method(prop) { get(prop) || :absent} unless public_method_defined?(prop) define_method(prop.to_s + "=") { |*vals| set(prop, *vals) } unless public_method_defined?(prop.to_s + "=") end @@ -263,6 +265,7 @@ def set(param, value) self.class.validate(param, value) cmd = modifycmd(param, munge(param, value)) raise Puppet::DevError, _("Nameservice command must be an array") unless cmd.is_a?(Array) + sensitive = has_sensitive_data?(param) begin execute(cmd, {:failonfail => true, :combine => true, :custom_environment => @custom_environment, :sensitive => sensitive}) diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index 25310527c58..773fdca18ee 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -88,6 +88,7 @@ def self.get_ds_path # with a group type, this will be /Groups. # @ds_path is an attribute of the class itself. return @ds_path if defined?(@ds_path) + # JJM: "Users" or "Groups" etc ... (Based on the Puppet::Type) # Remember this is a class method, so self.class is Class # Also, @resource_type seems to be the reference to the @@ -118,6 +119,7 @@ def self.generate_attribute_hash(input_hash, *type_properties) input_hash.each_key do |key| ds_attribute = key.sub("dsAttrTypeStandard:", "") next unless (ds_to_ns_attribute_map.keys.include?(ds_attribute) and type_properties.include? ds_to_ns_attribute_map[ds_attribute]) + ds_value = input_hash[key] case ds_to_ns_attribute_map[ds_attribute] when :members @@ -311,6 +313,7 @@ def ensure=(ensure_value) if ensure_value == :present @resource.class.validproperties.each do |name| next if name == :ensure + # LAK: We use property.sync here rather than directly calling # the settor method because the properties might do some kind # of conversion. In particular, the user gid property might @@ -408,6 +411,7 @@ def create # Now we create all the standard properties Puppet::Type.type(@resource.class.name).validproperties.each do |property| next if property == :ensure + value = @resource.should(property) if property == :gid and value.nil? value = self.class.next_system_id('gid') @@ -422,6 +426,7 @@ def create exec_arg_vector = self.class.get_exec_preamble("-create", @resource[:name]) exec_arg_vector << ns_to_ds_attribute_map[property.intern] next if property == :password # skip setting the password here + exec_arg_vector << value.to_s begin execute(exec_arg_vector) diff --git a/lib/puppet/provider/package/dnfmodule.rb b/lib/puppet/provider/package/dnfmodule.rb index b2b785877bc..1ebbc17af1a 100644 --- a/lib/puppet/provider/package/dnfmodule.rb +++ b/lib/puppet/provider/package/dnfmodule.rb @@ -28,6 +28,7 @@ def self.prefetch(packages) if Puppet::Util::Package.versioncmp(current_version, '3.0.1') < 0 raise Puppet::Error, _("Modules are not supported on DNF versions lower than 3.0.1") end + super end @@ -37,6 +38,7 @@ def self.instances execute(cmd).each_line do |line| # select only lines with actual packages since DNF clutters the output next unless line =~ /\[[eix]\][, ]/ + line.gsub!(/\[d\]/, '') # we don't care about the default flag flavor = if line.include?('[i]') diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index cc305fde2cb..8c3c6ab1e9e 100644 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -90,6 +90,7 @@ def install unless file raise ArgumentError, _("You cannot install dpkg packages without a source") end + args = [] if @resource[:configfiles] == :keep diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index fc90df71b76..72ae2eedf52 100644 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -155,6 +155,7 @@ def self.gemsplit(desc) def insync?(is) return false unless is && is != :absent + is = [is] unless is.is_a? Array should = @resource[:ensure] diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb index 5e40b34d32f..dadb30fc6b0 100644 --- a/lib/puppet/provider/package/hpux.rb +++ b/lib/puppet/provider/package/hpux.rb @@ -22,6 +22,7 @@ def self.instances # source and name are required def install raise ArgumentError, _("source must be provided to install HP-UX packages") unless resource[:source] + args = standard_args + ["-s", resource[:source], resource[:name]] swinstall(*args) end diff --git a/lib/puppet/provider/package/macports.rb b/lib/puppet/provider/package/macports.rb index 909a317b086..a21012d13bd 100644 --- a/lib/puppet/provider/package/macports.rb +++ b/lib/puppet/provider/package/macports.rb @@ -74,6 +74,7 @@ def install def query result = self.class.parse_installed_query_line(execute([command(:port), "-q", :installed, @resource[:name]], :failonfail => false, :combine => false)) return {} if result.nil? + return result end diff --git a/lib/puppet/provider/package/nim.rb b/lib/puppet/provider/package/nim.rb index 4f412a0f9ca..b1444267209 100644 --- a/lib/puppet/provider/package/nim.rb +++ b/lib/puppet/provider/package/nim.rb @@ -267,6 +267,7 @@ def determine_latest_version(showres_output, package_name) unless packages.has_key?(package_name) return nil end + if (packages[package_name].count == 1) version = packages[package_name].keys[0] return packages[package_name][version], nil @@ -282,6 +283,7 @@ def determine_package_type(showres_output, package_name, version) unless (packages.has_key?(package_name) and packages[package_name].has_key?(version)) return nil end + packages[package_name][version] end end diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb index f05f15bc403..7ffdf9ceece 100644 --- a/lib/puppet/provider/package/openbsd.rb +++ b/lib/puppet/provider/package/openbsd.rb @@ -217,6 +217,7 @@ def get_version return master_version unless master_version == 0 return '' if version == -1 + raise Puppet::Error, _("%{version} is not available for this package") % { version: version } end rescue Puppet::ExecutionFailure diff --git a/lib/puppet/provider/package/opkg.rb b/lib/puppet/provider/package/opkg.rb index 875022d03f7..17b46d5675f 100644 --- a/lib/puppet/provider/package/opkg.rb +++ b/lib/puppet/provider/package/opkg.rb @@ -65,6 +65,7 @@ def query if output =~ /^(\S+) - (\S+)/ return { :ensure => $2 } end + nil rescue Puppet::ExecutionFailure return { diff --git a/lib/puppet/provider/package/pip.rb b/lib/puppet/provider/package/pip.rb index 43f8dcb5078..1052ef2df1c 100644 --- a/lib/puppet/provider/package/pip.rb +++ b/lib/puppet/provider/package/pip.rb @@ -82,6 +82,7 @@ def self.instances(target_command = nil) process.collect do |line| pkg = parse(line) next unless pkg + pkg[:command] = command packages << new(pkg) end @@ -303,6 +304,7 @@ def install_options def insync?(is) return false unless is && is != :absent + begin should = @resource[:ensure] should_range = PIP_VERSION_RANGE.parse(should, PIP_VERSION) diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb index f4c8f0753af..e16dc648286 100644 --- a/lib/puppet/provider/package/pkg.rb +++ b/lib/puppet/provider/package/pkg.rb @@ -245,6 +245,7 @@ def install(nofail = false) if tries > 4 raise Puppet::Error, _("Pkg could not install %{name} after %{tries} tries. Aborting run") % { name: name, tries: tries } end + sleep 2 ** tries tries += 1 r = exec_cmd(command(:pkg), command, *args, name) @@ -279,6 +280,7 @@ def update r = install(true) # 4 == /No updates available for this image./ return if [0,4].include? r[:exit] + raise Puppet::Error, _("Unable to update %{package}") % { package: r[:out] } end @@ -286,6 +288,7 @@ def update def query r = exec_cmd(command(:pkg), 'list', '-Hv', @resource[:name]) return {:ensure => :absent, :name => @resource[:name]} if r[:exit] != 0 + self.class.parse_line(r[:out]) end diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb index 7aab81204da..e1b18493df4 100644 --- a/lib/puppet/provider/package/pkgdmg.rb +++ b/lib/puppet/provider/package/pkgdmg.rb @@ -78,6 +78,7 @@ def self.installpkgdmg(source, name) unless source =~ /\.dmg$/i || source =~ /\.pkg$/i raise Puppet::Error.new(_("Mac OS X PKG DMGs must specify a source string ending in .dmg or flat .pkg file")) end + require 'open-uri' # Dead code; this is never used. The File.open call 20-ish lines south of here used to be Kernel.open but changed in '09. -NF cached_source = source tmpdir = Dir.mktmpdir @@ -106,6 +107,7 @@ def self.installpkgdmg(source, name) xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-mountrandom", "/tmp", dmg.path hdiutil_info = Puppet::Util::Plist.parse_plist(xml_str) raise Puppet::Error.new(_("No disk entities returned by mount at %{path}") % { path: dmg.path }) unless hdiutil_info.has_key?("system-entities") + mounts = hdiutil_info["system-entities"].collect { |entity| entity["mount-point"] }.compact @@ -145,10 +147,12 @@ def install unless source raise Puppet::Error.new(_("Mac OS X PKG DMGs must specify a package source.")) end + name = @resource[:name] unless name raise Puppet::Error.new(_("Mac OS X PKG DMGs must specify a package name.")) end + self.class.installpkgdmg(source,name) end end diff --git a/lib/puppet/provider/package/pkgin.rb b/lib/puppet/provider/package/pkgin.rb index d845e288333..c65231fd1ab 100644 --- a/lib/puppet/provider/package/pkgin.rb +++ b/lib/puppet/provider/package/pkgin.rb @@ -77,6 +77,7 @@ def uninstall def latest package = parse_pkgsearch_line.detect{ |p| p[:status] == '<' } return properties[:ensure] if not package + return package[:ensure] end diff --git a/lib/puppet/provider/package/pkgng.rb b/lib/puppet/provider/package/pkgng.rb index 01510cbd2f7..b5b1c1b3057 100644 --- a/lib/puppet/provider/package/pkgng.rb +++ b/lib/puppet/provider/package/pkgng.rb @@ -39,6 +39,7 @@ def self.get_latest_version(origin) if ['!', '?'].include?(compare) return nil end + latest_version = status.split(' ').last.split(')').first return latest_version end @@ -94,6 +95,7 @@ def repo_tag_from_urn(urn) # extract repo tag from URN: urn:freebsd:repo: match = /^urn:freebsd:repo:(.+)$/.match(urn) raise ArgumentError urn.inspect unless match + match[1] end diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb index 1bdf6fcd785..1731cafb657 100644 --- a/lib/puppet/provider/package/portage.rb +++ b/lib/puppet/provider/package/portage.rb @@ -243,6 +243,7 @@ def latest def eix_get_version_for_versions(versions, target) # [2.7.10-r1,2.7.12,3.4.3-r1,3.4.5,3.5.2] 3.5.2 return nil if versions.nil? + versions = versions.split(',') # [2.7.10-r1 2.7.12 3.4.3-r1 3.4.5 3.5.2] versions.find { |version| version == target } @@ -254,6 +255,7 @@ def eix_get_version_for_versions(versions, target) def eix_get_version_for_slot(versions_and_slots, slot) # [2.7.12:2.7 3.4.5:3.4 3.5.2:3.5] 3.5 return nil if versions_and_slots.nil? + versions_and_slots = versions_and_slots.split(',') # [2.7.12:2.7 3.4.5:3.4 3.5.2:3.5] versions_and_slots.map! { |version_and_slot| version_and_slot.split(':') } diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb index bfad001df37..da81bff055f 100644 --- a/lib/puppet/provider/package/rpm.rb +++ b/lib/puppet/provider/package/rpm.rb @@ -42,6 +42,7 @@ def self.current_version return @current_version unless @current_version.nil? + output = rpm "--version" @current_version = output.gsub('RPM version ', '').strip end @@ -247,6 +248,7 @@ def self.nevra_to_multiversion_hash(multiline) if list.size == 1 return list[0] end + return list end end diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb index 77d38390970..2331423c9c0 100644 --- a/lib/puppet/provider/package/sun.rb +++ b/lib/puppet/provider/package/sun.rb @@ -75,6 +75,7 @@ def info2hash(device = nil) pkgs[0]['ERROR'] end return self.class.namemap(pkgs[0]) if errmsg.nil? + # according to commit 41356a7 some errors do not raise an exception # so even though pkginfo passed, we have to check the actual output raise Puppet::Error, _("Unable to get information about package %{name} because of: %{errmsg}") % { name: @resource[:name], errmsg: errmsg } @@ -96,6 +97,7 @@ def query def install #TRANSLATORS Sun refers to the company name, do not translate raise Puppet::Error, _("Sun packages must specify a package source") unless @resource[:source] + options = { :adminfile => @resource[:adminfile], :responsefile => @resource[:responsefile], diff --git a/lib/puppet/provider/package/windows/package.rb b/lib/puppet/provider/package/windows/package.rb index 9b0e4a8904e..89a96a41e2c 100644 --- a/lib/puppet/provider/package/windows/package.rb +++ b/lib/puppet/provider/package/windows/package.rb @@ -70,6 +70,7 @@ def self.installer_class(resource) when /\.exe"?\Z/i fail(_("The source does not exist: '%{source}'") % { source: resource[:source] }) unless Puppet::FileSystem.exist?(resource[:source]) || resource[:source].start_with?('http://', 'https://') + ExePackage else fail(_("Don't know how to install '%{source}'") % { source: resource[:source] }) diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 94656b77329..e8e0c0837bf 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -68,6 +68,7 @@ def insync?(is) def self.prefetch(packages) raise Puppet::Error, _("The yum provider can only be used as root") if Process.euid != 0 + super end @@ -335,6 +336,7 @@ def latest self.debug "Yum didn't find updates, current version (#{properties[:ensure]}) is the latest" version = properties[:ensure] raise Puppet::DevError, _("Tried to get latest on a missing package") if version == :absent || version == :purged + return version end end @@ -372,9 +374,11 @@ def disableexcludes # @return [Array] All hash values with the given key. def scan_options(options, key) return [] unless options.is_a?(Enumerable) + values = options.map do | repo | value = if repo.is_a?(String) next unless repo.include?('=') + Hash[*repo.strip.split('=')] # make it a hash else repo diff --git a/lib/puppet/provider/package/zypper.rb b/lib/puppet/provider/package/zypper.rb index 35516e439b2..313d3935379 100644 --- a/lib/puppet/provider/package/zypper.rb +++ b/lib/puppet/provider/package/zypper.rb @@ -38,6 +38,7 @@ def self.list_updates pkg_ver = line.split(/\s*\|\s*/) # ignore zypper headers next unless pkg_ver[0] == 'v' + avail_updates[pkg_ver[2]] = pkg_ver[4] end @@ -70,6 +71,7 @@ def best_version(should) output.lines.each do |line| pkg_ver = line.split(/\s*\|\s*/) next unless pkg_ver[1] == @resource[:name] + begin rpm_version = Puppet::Util::Package::Version::Rpm.parse(pkg_ver[3]) diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb index 0afdef743e3..63992db338d 100644 --- a/lib/puppet/provider/parsedfile.rb +++ b/lib/puppet/provider/parsedfile.rb @@ -236,6 +236,7 @@ def self.prefetch(resources = nil) # @param [Array] resources A list of resources using this class as a provider def self.match_providers_with_resources(resources) return unless resources + matchers = resources.dup @records.each do |record| # Skip things like comments and blank lines @@ -314,6 +315,7 @@ def self.prefetch_target(target) # Is there an existing record with this name? def self.record?(name) return nil unless @records + @records.find { |r| r[:name] == name } end @@ -380,6 +382,7 @@ def self.targets(resources = nil) targets = [] # First get the default target raise Puppet::DevError, _("Parsed Providers must define a default target") unless self.default_target + targets << self.default_target # Then get each of the file objects @@ -471,6 +474,7 @@ def initialize(record) # Retrieve the current state from disk. def prefetch raise Puppet::DevError, _("Somehow got told to prefetch with no resource set") unless @resource + self.class.prefetch(@resource[:name] => @resource) end diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb index f71ff0bd67b..9b58fcbccce 100644 --- a/lib/puppet/provider/service/daemontools.rb +++ b/lib/puppet/provider/service/daemontools.rb @@ -110,6 +110,7 @@ def service def daemon path = resource[:path] raise Puppet::Error.new("#{self.class.name} must specify a path for daemon directory") unless path + File.join(path, resource[:name]) end diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index 004a6cf17b0..a960f6b12ca 100644 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -98,6 +98,7 @@ def self.get_services(defpath, exclude = self.excludes) next if Puppet::FileSystem.directory?(fullpath) next unless Puppet::FileSystem.executable?(fullpath) next unless is_init?(fullpath) + instances << new(:name => name, :path => path, :hasstatus => true) end end diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index efdaa9a3e60..cc20afa9481 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -135,12 +135,14 @@ def self.return_globbed_list_of_file_paths(path) # @api private def self.make_label_to_path_map(refresh=false) return @label_to_path_map if @label_to_path_map and not refresh + @label_to_path_map = {} launchd_paths.each do |path| return_globbed_list_of_file_paths(path).each do |filepath| Puppet.debug("Reading launchd plist #{filepath}") job = read_plist(filepath) next if job.nil? + if job.respond_to?(:key) && job.key?("Label") @label_to_path_map[job["Label"]] = filepath else @@ -185,6 +187,7 @@ def self.job_list begin output = launchctl :list raise Puppet::Error.new("launchctl list failed to return any data.") if output.nil? + output.split("\n").each do |line| @job_list[line.split(/\s/).last] = :running end @@ -209,6 +212,7 @@ def self.read_overrides overrides = read_plist(launchd_overrides) break unless overrides.nil? raise Puppet::Error.new(_('Unable to read overrides plist, too many attempts')) if i == 20 + Puppet.info(_('Overrides file could not be read, trying again.')) Kernel.sleep(0.1) i += 1 diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb index ca572b98fe2..9fc98607c5a 100644 --- a/lib/puppet/provider/service/smf.rb +++ b/lib/puppet/provider/service/smf.rb @@ -130,6 +130,7 @@ def enable def enabled? return :false unless service_exists? + _property, _type, value = svccfg("-s", self.service_fmri, "listprop", "general/enabled").split(' ') value == 'true' ? :true : :false end @@ -168,6 +169,7 @@ def wait(*desired_states) loop do states = self.service_states break if desired_states.include?(states[:current]) && states[:next].nil? + Kernel.sleep(1) end end diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb index acc200da2fc..e092bc1c984 100644 --- a/lib/puppet/provider/service/src.rb +++ b/lib/puppet/provider/service/src.rb @@ -73,6 +73,7 @@ def wait(desired_state) loop do status = self.status break if status == desired_state.to_sym + sleep(1) end end diff --git a/lib/puppet/provider/service/systemd.rb b/lib/puppet/provider/service/systemd.rb index 4b55c8b43b9..28d35f635bf 100644 --- a/lib/puppet/provider/service/systemd.rb +++ b/lib/puppet/provider/service/systemd.rb @@ -92,6 +92,7 @@ def get_start_link_count def cached_enabled? return @cached_enabled if @cached_enabled + cmd = [command(:systemctl), 'is-enabled', '--', @resource[:name]] result = execute(cmd, :failonfail => false) @cached_enabled = { output: result.chomp, exitcode: result.exitstatus } @@ -112,6 +113,7 @@ def enabled? # The indirect state indicates that the unit is not enabled. return :false if output == 'indirect' return :true if (code == 0) + if (output.empty?) && (code > 0) && (Puppet.runtime[:facter].value('os.family').casecmp('debian').zero?) ret = debian_enabled? return ret if ret diff --git a/lib/puppet/provider/service/windows.rb b/lib/puppet/provider/service/windows.rb index 07ce696db67..9646763377c 100644 --- a/lib/puppet/provider/service/windows.rb +++ b/lib/puppet/provider/service/windows.rb @@ -133,6 +133,7 @@ def logonaccount_insync?(current) def logonaccount return unless Puppet::Util::Windows::Service.exists?(@resource[:name]) + Puppet::Util::Windows::Service.logon_account(@resource[:name]) end @@ -156,6 +157,7 @@ def normalize_logonaccount @logonaccount_information ||= Puppet::Util::Windows::SID.name_to_principal(logon_account) return logon_account unless @logonaccount_information return ".\\#{@logonaccount_information.account}" if @logonaccount_information.domain == Puppet::Util::Windows::ADSI.computer_name + @logonaccount_information.domain_account end diff --git a/lib/puppet/provider/user/directoryservice.rb b/lib/puppet/provider/user/directoryservice.rb index 5cf710bcc64..5ffcd4b1f3a 100644 --- a/lib/puppet/provider/user/directoryservice.rb +++ b/lib/puppet/provider/user/directoryservice.rb @@ -105,6 +105,7 @@ def self.generate_attribute_hash(input_hash) input_hash.each_key do |key| ds_attribute = key.sub("dsAttrTypeStandard:", "") next unless ds_to_ns_attribute_map.keys.include?(ds_attribute) + ds_value = input_hash[key] case ds_to_ns_attribute_map[ds_attribute] when :gid, :uid @@ -217,6 +218,7 @@ def self.get_salted_sha512_pbkdf2(field, embedded_binary_plist, user_name = "") if value == nil raise Puppet::Error, "Invalid #{field} given for user #{user_name}" end + value.unpack('H*').first when 'iterations' Integer(embedded_binary_plist['SALTED-SHA512-PBKDF2'][field]) @@ -232,6 +234,7 @@ def self.get_sha1(guid) password_hash_file = "#{password_hash_dir}/#{guid}" if Puppet::FileSystem.exist?(password_hash_file) and File.file?(password_hash_file) raise Puppet::Error, "Could not read password hash file at #{password_hash_file}" if not File.readable?(password_hash_file) + f = File.new(password_hash_file) password_hash = f.read f.close @@ -268,6 +271,7 @@ def create # Iterate through valid User type properties valid_properties.each do |attribute| next if attribute == :ensure + value = @resource.should(attribute) # Value defaults @@ -449,6 +453,7 @@ def salt=(value) if %w(home uid).include?(setter_method) raise Puppet::Error, "OS X version #{self.class.get_os_version} does not allow changing #{setter_method} using puppet" end + begin dscl '.', '-change', "/Users/#{resource.name}", self.class.ns_to_ds_attribute_map[setter_method.intern], @property_hash[setter_method.intern], value rescue Puppet::ExecutionFailure => e diff --git a/lib/puppet/provider/user/ldap.rb b/lib/puppet/provider/user/ldap.rb index 63b10df41ba..70669257532 100644 --- a/lib/puppet/provider/user/ldap.rb +++ b/lib/puppet/provider/user/ldap.rb @@ -40,6 +40,7 @@ existing.each do |hash| value = hash[:uid] next unless value + num = value[0].to_i largest = num if num > largest end diff --git a/lib/puppet/provider/user/pw.rb b/lib/puppet/provider/user/pw.rb index 3db82ab644a..92f8d052740 100644 --- a/lib/puppet/provider/user/pw.rb +++ b/lib/puppet/provider/user/pw.rb @@ -31,6 +31,7 @@ def addcmd cmd = [command(:pw), "useradd", @resource[:name]] @resource.class.validproperties.each do |property| next if property == :ensure or property == :password + value = @resource.should(property) if value and value != "" cmd << flag(property) << munge(property,value) diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index 970c0169b34..9303702b9d4 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -50,6 +50,7 @@ def add_properties Puppet::Type.type(:user).validproperties.each do |property| #skip the password because we can't create it with the solaris useradd next if [:ensure, :password, :password_min_age, :password_max_age, :password_warn_days].include?(property) + # 1680 Now you can set the hashed passwords on solaris:lib/puppet/provider/user/user_role_add.rb # the value needs to be quoted, mostly because -c might # have spaces in it @@ -176,6 +177,7 @@ def target_file_path #No abstraction, all esoteric knowledge of file formats, yay def shadow_entry return @shadow_entry if defined? @shadow_entry + @shadow_entry = File.readlines(target_file_path) .reject { |r| r =~ /^[^\w]/ }. # PUP-229: don't suppress the empty fields @@ -185,21 +187,25 @@ def shadow_entry def password return :absent unless shadow_entry + shadow_entry[1] end def password_min_age return :absent unless shadow_entry + shadow_entry[3].empty? ? -1 : shadow_entry[3] end def password_max_age return :absent unless shadow_entry + shadow_entry[4].empty? ? -1 : shadow_entry[4] end def password_warn_days return :absent unless shadow_entry + shadow_entry[5].empty? ? -1 : shadow_entry[5] end diff --git a/lib/puppet/provider/user/useradd.rb b/lib/puppet/provider/user/useradd.rb index b6b80607fc8..e95f013f695 100644 --- a/lib/puppet/provider/user/useradd.rb +++ b/lib/puppet/provider/user/useradd.rb @@ -55,36 +55,43 @@ def exists? return !!localuid if @resource.forcelocal? + super end def uid return localuid if @resource.forcelocal? + get(:uid) end def gid return localgid if @resource.forcelocal? + get(:gid) end def comment return localcomment if @resource.forcelocal? + get(:comment) end def shell return localshell if @resource.forcelocal? + get(:shell) end def home return localhome if @resource.forcelocal? + get(:home) end def groups return localgroups if @resource.forcelocal? + super end @@ -113,6 +120,7 @@ def local_username def localuid user = finduser(:account, resource[:name]) return user[:uid] if user + false end @@ -279,6 +287,7 @@ def add_properties Puppet::Type.type(:user).validproperties.sort.each do |property| value = get_value_for_property(property) next if value.nil? || property == :password + # the value needs to be quoted, mostly because -c might # have spaces in it cmd << flag(property) << munge(property, value) @@ -291,6 +300,7 @@ def get_value_for_property(property) return nil if property_manages_password_age?(property) return nil if property == :groups and @resource.forcelocal? return nil if property == :expiry and @resource.forcelocal? + value = @resource.should(property) return nil if !value || value == "" diff --git a/lib/puppet/provider/user/windows_adsi.rb b/lib/puppet/provider/user/windows_adsi.rb index 3b859f00057..ee9430b6166 100644 --- a/lib/puppet/provider/user/windows_adsi.rb +++ b/lib/puppet/provider/user/windows_adsi.rb @@ -69,6 +69,7 @@ def groups_insync?(current, should) def groups_to_s(groups) return '' if groups.nil? || !groups.kind_of?(Array) + groups = groups.map do |group_name| sid = Puppet::Util::Windows::SID.name_to_principal(group_name) if sid.account =~ /\\/ @@ -138,6 +139,7 @@ def password # avoid a LogonUserW style password check when the resource is not yet # populated with a password (as is the case with `puppet resource user`) return nil if @resource[:password].nil? + user.password_is?( @resource[:password] ) ? @resource[:password] : nil end diff --git a/lib/puppet/reference/providers.rb b/lib/puppet/reference/providers.rb index 9d1d0d28405..a74571f6651 100644 --- a/lib/puppet/reference/providers.rb +++ b/lib/puppet/reference/providers.rb @@ -4,6 +4,7 @@ Puppet::Type.loadall Puppet::Type.eachtype do |klass| next unless klass && klass.providers.length > 0 + types << klass end types.sort! { |a,b| a.name.to_s <=> b.name.to_s } diff --git a/lib/puppet/reference/type.rb b/lib/puppet/reference/type.rb index c8a2e2be0f4..d36e282c966 100644 --- a/lib/puppet/reference/type.rb +++ b/lib/puppet/reference/type.rb @@ -6,6 +6,7 @@ Puppet::Type.eachtype { |type| next if type.name == :component next if type.name == :whit + types[type.name] = type } diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 4a5ae265634..b6ddcd427db 100644 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -28,6 +28,7 @@ def self.from_data_hash(data) def event=(event) #TRANSLATORS 'NONE' should not be translated raise ArgumentError, _("You must pass a callback for non-NONE events") if event != :NONE and ! callback + @event = event end diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb index 04647299927..6c861873f66 100644 --- a/lib/puppet/reports/store.rb +++ b/lib/puppet/reports/store.rb @@ -53,6 +53,7 @@ def self.destroy(host) if Puppet::FileSystem.exist?(dir) Dir.entries(dir).each do |file| next if ['.','..'].include?(file) + file = File.join(dir, file) Puppet::FileSystem.unlink(file) if File.file?(file) end diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index 03711c261df..ac32501deb7 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -51,8 +51,10 @@ def self.from_data_hash(data) def initialize_from_hash(data) type = data['type'] raise ArgumentError, _('No resource type provided in serialized data') unless type + title = data['title'] raise ArgumentError, _('No resource title provided in serialized data') unless title + @type, @title = self.class.type_and_title(type, title) params = data['parameters'] @@ -184,6 +186,7 @@ def ==(other) return false unless other.respond_to?(:title) and self.type == other.type and self.title == other.title return false unless to_hash == other.to_hash + true end @@ -321,6 +324,7 @@ def initialize(type, title = nil, attributes = EMPTY_HASH) # Set things like environment, strictness first. attributes.each do |attr, value| next if attr == :parameters + send(attr.to_s + "=", value) end @@ -589,6 +593,7 @@ def self.extract_type_and_title(argtype, argtitle) def self.munge_type_name(value) return :main if value == :main return TYPE_CLASS if value == '' || value.nil? || value.to_s.casecmp('component') == 0 + Puppet::Pops::Types::TypeFormatter.singleton.capitalize_segments(value.to_s) end private_class_method :munge_type_name diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 02041650e87..ae378240fc2 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -199,6 +199,7 @@ def alias(resource, key) existing = @resource_table[newref] if existing return if existing == resource + resource_declaration = Puppet::Util::Errors.error_location(resource.file, resource.line) msg = if resource_declaration.empty? #TRANSLATORS 'alias' should not be translated @@ -290,6 +291,7 @@ def create_resource(type, options) unless klass raise ArgumentError, _("Unknown resource type %{type}") % { type: type } end + resource = klass.new(options) return unless resource @@ -539,6 +541,7 @@ def write_resource_file Puppet::FileSystem.open(resourcefile.value, resourcefile.mode.to_i(8), "w:UTF-8") do |f| to_print = resources.map do |resource| next unless resource.managed? + "#{resource.ref.downcase}" end.compact f.puts to_print.join("\n") diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index a28677eb005..36b3475255f 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -93,6 +93,7 @@ def initialize(type, name, options = {}) [:code, :doc, :line, :file, :parent].each do |param| value = options[param] next unless value + send(param.to_s + '=', value) end @@ -116,6 +117,7 @@ def match(string) def merge(other) fail _("%{name} is not a class; cannot add code to it") % { name: name } unless type == :hostclass fail _("%{name} is not a class; cannot add code from it") % { name: other.name } unless other.type == :hostclass + if name == "" && Puppet.settings[:freeze_main] # It is ok to merge definitions into main even if freeze is on (definitions are nodes, classes, defines, functions, and types) unless other.code.is_definitions_only? @@ -257,11 +259,13 @@ def set_resource_parameters(resource, scope) def inject_external_parameters(resource, scope) # Only lookup parameters for host classes return unless type == :hostclass + parameters = resource.parameters arguments.each do |param_name, default| sym_name = param_name.to_sym param = parameters[sym_name] next unless param.nil? || param.value.nil? + catch(:no_such_key) do bound_value = Puppet::Pops::Lookup.search_and_merge("#{name}::#{param_name}", Puppet::Pops::Lookup::Invocation.new(scope), nil) # Assign bound value but don't let an undef trump a default expression @@ -273,12 +277,15 @@ def inject_external_parameters(resource, scope) def assign_defaults(resource, param_scope, scope) return unless resource.is_a?(Puppet::Parser::Resource) + parameters = resource.parameters arguments.each do |param_name, default| next if default.nil? + name = param_name.to_sym param = parameters[name] next unless param.nil? || param.value.nil? + value = exceptwrap { param_scope.evaluate3x(param_name, default, scope) } resource[name] = value param_scope[param_name] = value @@ -330,6 +337,7 @@ def set_argument_types(name_to_type_hash) @argument_types = {} @parameter_struct = nil return unless name_to_type_hash + name_to_type_hash.each do |name, t| # catch internal errors unless @arguments.include?(name) @@ -338,6 +346,7 @@ def set_argument_types(name_to_type_hash) unless t.is_a? Puppet::Pops::Types::PAnyType raise Puppet::DevError, _("Parameter '%{name}' is given a type that is not a Puppet Type, got %{class_name}") % { name: name, class_name: t.class } end + @argument_types[name] = t end end @@ -357,6 +366,7 @@ def evaluate_parent_type(resource) klass = parent_type(resource.scope) parent_resource = resource.scope.compiler.catalog.resource(:class, klass.name) || resource.scope.compiler.catalog.resource(:node, klass.name) if klass return unless klass && parent_resource + parent_resource.evaluate unless parent_resource.evaluated? parent_scope(resource.scope, klass) end diff --git a/lib/puppet/resource/type_collection.rb b/lib/puppet/resource/type_collection.rb index 49014653520..092c115ec18 100644 --- a/lib/puppet/resource/type_collection.rb +++ b/lib/puppet/resource/type_collection.rb @@ -73,6 +73,7 @@ def add_hostclass(instance) def handle_hostclass_merge(instance) # Only main class (named '') can be merged (for purpose of merging top-scopes). return instance unless instance.name == '' + if instance.type == :hostclass && (other = @hostclasses[instance.name]) && other.type == :hostclass other.merge(instance) # throw is used to signal merge - avoids dupe checks and adding it to hostclasses @@ -219,12 +220,14 @@ def munge_name(name) def dupe_check(instance, hash) dupe = hash[instance.name] return unless dupe + message = yield dupe instance.fail Puppet::ParseError, message end def dupe_check_singleton(instance, set) return if set.empty? + message = yield set[0] instance.fail Puppet::ParseError, message end diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index c59338a30be..c4c186d6ac3 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -153,6 +153,7 @@ def initialize @cache = Concurrent::Hash.new do |hash, key| @cache_lock.synchronize do break hash[key] if hash.key?(key) + hash[key] = Concurrent::Hash.new end end @@ -160,6 +161,7 @@ def initialize @values = Concurrent::Hash.new do |hash, key| @values_lock.synchronize do break hash[key] if hash.key?(key) + hash[key] = Concurrent::Hash.new end end @@ -561,6 +563,7 @@ def generate_manifest def print_configs return print_config_options if value(:configprint) != "" return generate_config if value(:genconfig) + generate_manifest if value(:genmanifest) end @@ -582,6 +585,7 @@ def preferred_run_mode def preferred_run_mode=(mode) mode = mode.to_s.downcase.intern raise ValidationError, "Invalid run mode '#{mode}'" unless [:server, :master, :agent, :user].include?(mode) + @preferred_run_mode_name = mode # Changing the run mode has far-reaching consequences. Flush any cached # settings so they will be re-generated. @@ -766,6 +770,7 @@ def newsetting(hash) unless klass raise ArgumentError, _("Invalid setting type '%{type}'") % { type: type } end + hash.delete(:type) else # The only implicit typing we still do for settings is to fall back to "String" type if they didn't explicitly @@ -806,6 +811,7 @@ def reparse_config_files def files return @files if @files + @files = [] [main_config_file, user_config_file].each do |path| if Puppet::FileSystem.exist?(path) @@ -829,6 +835,7 @@ def any_files_changed? def reuse return unless defined?(@used) + new = @used @used = [] self.use(*new) @@ -1021,6 +1028,7 @@ def define_settings(section, defs) hash[:name] = name hash[:section] = section raise ArgumentError, _("Setting %{name} is already defined") % { name: name } if @config.include?(name) + tryconfig = newsetting(hash) short = tryconfig.short if short @@ -1028,6 +1036,7 @@ def define_settings(section, defs) if other raise ArgumentError, _("Setting %{name} is already using short name '%{short}'") % { name: other.name, short: short } end + @shortnames[short] = tryconfig end @config[name] = tryconfig @@ -1060,6 +1069,7 @@ def to_catalog(*sections) file = @config[key] next if file.value.nil? next unless (sections.nil? or sections.include?(file.section)) + resource = file.to_resource next unless resource next if catalog.resource(resource.ref) @@ -1616,11 +1626,13 @@ def include?(name) if Puppet::Settings::EnvironmentConf::VALID_SETTINGS.include?(name) && conf return true end + false end def lookup(name) return nil unless Puppet::Settings::EnvironmentConf::VALID_SETTINGS.include?(name) + conf.send(name) if conf end diff --git a/lib/puppet/settings/base_setting.rb b/lib/puppet/settings/base_setting.rb index dabb9595ffe..be5a2d7938a 100644 --- a/lib/puppet/settings/base_setting.rb +++ b/lib/puppet/settings/base_setting.rb @@ -43,6 +43,7 @@ def call_hook=(value) #TRANSLATORS 'call_hook' is a Puppet option name and should not be translated raise ArgumentError, _("Invalid option %{value} for call_hook") % { value: value } end + @call_hook = value end @@ -128,6 +129,7 @@ def iscreated? # short name for the element def short=(value) raise ArgumentError, _("Short names can only be one character.") if value.to_s.length != 1 + @short = value.to_s end @@ -142,6 +144,7 @@ def default(check_application_defaults_first = false) default_value = @default end return default_value unless check_application_defaults_first + return @settings.value(name, :application_defaults, true) || default_value end diff --git a/lib/puppet/settings/environment_conf.rb b/lib/puppet/settings/environment_conf.rb index edf124613be..a3cb50f9db6 100644 --- a/lib/puppet/settings/environment_conf.rb +++ b/lib/puppet/settings/environment_conf.rb @@ -170,6 +170,7 @@ def get_setting(setting_name, default = nil) def expand_glob(path) return nil if path.nil? + if path =~ /[*?\[\{]/ Dir.glob(path) else @@ -179,6 +180,7 @@ def expand_glob(path) def absolute(path) return nil if path.nil? + if path =~ /^\$/ # Path begins with $something interpolatable path diff --git a/lib/puppet/settings/ttl_setting.rb b/lib/puppet/settings/ttl_setting.rb index f4674a23804..d08b80d9ceb 100644 --- a/lib/puppet/settings/ttl_setting.rb +++ b/lib/puppet/settings/ttl_setting.rb @@ -38,6 +38,7 @@ def self.munge(value, param_name) if value < 0 raise Puppet::Settings::ValidationError, _("Invalid negative 'time to live' %{value} - did you mean 'unlimited'?") % { value: value.inspect } end + value when value == 'unlimited' diff --git a/lib/puppet/ssl/base.rb b/lib/puppet/ssl/base.rb index 05917081cdb..d3601fab765 100644 --- a/lib/puppet/ssl/base.rb +++ b/lib/puppet/ssl/base.rb @@ -25,6 +25,7 @@ def self.wraps(klass) def self.wrapped_class raise(Puppet::DevError, _("%{name} has not declared what class it wraps") % { name: self }) unless defined?(@wrapped_class) + @wrapped_class end @@ -96,6 +97,7 @@ def read(path) # Convert our thing to pem. def to_s return "" unless content + content.to_pem end @@ -106,6 +108,7 @@ def to_data_hash # Provide the full text of the thing we're dealing with. def to_text return "" unless content + content.to_text end diff --git a/lib/puppet/ssl/certificate.rb b/lib/puppet/ssl/certificate.rb index 2d5e8a7f712..20bb02b3e59 100644 --- a/lib/puppet/ssl/certificate.rb +++ b/lib/puppet/ssl/certificate.rb @@ -21,6 +21,7 @@ def self.supported_formats def self.subject_alt_names_for(cert) alts = cert.extensions.find{|ext| ext.oid == "subjectAltName"} return [] unless alts + alts.value.split(/\s*,\s*/) end @@ -30,6 +31,7 @@ def subject_alt_names def expiration return nil unless content + content.not_after end diff --git a/lib/puppet/ssl/certificate_request_attributes.rb b/lib/puppet/ssl/certificate_request_attributes.rb index f455acc394a..96f71a2214d 100644 --- a/lib/puppet/ssl/certificate_request_attributes.rb +++ b/lib/puppet/ssl/certificate_request_attributes.rb @@ -25,11 +25,13 @@ def load if ! hash.is_a?(Hash) raise Puppet::Error, _("invalid CSR attributes, expected instance of Hash, received instance of %{klass}") % { klass: hash.class } end + @custom_attributes = hash.delete('custom_attributes') || {} @extension_requests = hash.delete('extension_requests') || {} if not hash.keys.empty? raise Puppet::Error, _("unexpected attributes %{keys} in %{path}") % { keys: hash.keys.inspect, path: @path.inspect } end + return true end return false diff --git a/lib/puppet/ssl/oids.rb b/lib/puppet/ssl/oids.rb index 5cba2facd59..9cfbff19f85 100644 --- a/lib/puppet/ssl/oids.rb +++ b/lib/puppet/ssl/oids.rb @@ -128,6 +128,7 @@ def self.parse_custom_oid_file(custom_oid_file, map_key='oid_mapping') if shortname.nil? || longname.nil? raise Puppet::Error, _("Error loading ssl custom OIDs mapping file from '%{custom_oid_file}': incomplete definition of oid '%{oid}'") % { custom_oid_file: custom_oid_file, oid: oid } end + oid_defns << [oid, shortname, longname] end diff --git a/lib/puppet/syntax_checkers/base64.rb b/lib/puppet/syntax_checkers/base64.rb index 54fbc950877..6853ee8780b 100644 --- a/lib/puppet/syntax_checkers/base64.rb +++ b/lib/puppet/syntax_checkers/base64.rb @@ -18,6 +18,7 @@ def check(text, syntax, acceptor, source_pos) raise ArgumentError.new(_("Base64 syntax checker: the text to check must be a String.")) unless text.is_a?(String) raise ArgumentError.new(_("Base64 syntax checker: the syntax identifier must be a String, e.g. json, data+json")) unless syntax.is_a?(String) raise ArgumentError.new(_("Base64 syntax checker: invalid Acceptor, got: '%{klass}'.") % { klass: acceptor.class.name }) unless acceptor.is_a?(Puppet::Pops::Validation::Acceptor) + cleaned_text = text.gsub(/[\r?\n[:blank:]]/, '') begin # Do a strict decode64 on text with all whitespace stripped since the non strict version diff --git a/lib/puppet/syntax_checkers/json.rb b/lib/puppet/syntax_checkers/json.rb index 56834b92766..44da2937348 100644 --- a/lib/puppet/syntax_checkers/json.rb +++ b/lib/puppet/syntax_checkers/json.rb @@ -17,6 +17,7 @@ def check(text, syntax, acceptor, source_pos) raise ArgumentError.new(_("Json syntax checker: the text to check must be a String.")) unless text.is_a?(String) raise ArgumentError.new(_("Json syntax checker: the syntax identifier must be a String, e.g. json, data+json")) unless syntax.is_a?(String) raise ArgumentError.new(_("Json syntax checker: invalid Acceptor, got: '%{klass}'.") % { klass: acceptor.class.name }) unless acceptor.is_a?(Puppet::Pops::Validation::Acceptor) + #raise ArgumentError.new("Json syntax checker: location_info must be a Hash") unless location_info.is_a?(Hash) begin diff --git a/lib/puppet/test/test_helper.rb b/lib/puppet/test/test_helper.rb index bed71c9172b..b9a0b2db98a 100644 --- a/lib/puppet/test/test_helper.rb +++ b/lib/puppet/test/test_helper.rb @@ -94,6 +94,7 @@ def self.before_each_test() # only once. # return unless @@reentry_count == 0 + @@reentry_count = 1 Puppet.mark_context(ROLLBACK_MARK) @@ -157,6 +158,7 @@ def self.after_each_test() # Ensure that a matching tear down only happens once per completed setup # (see #before_each_test). return unless @@reentry_count == 1 + @@reentry_count = 0 Puppet.settings.send(:clear_everything_for_tests) diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index d0df384e362..38e59396614 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -126,6 +126,7 @@ def evaluate(&block) # We don't automatically assign unsuitable providers, so if there # is one, it must have been selected by the user. return if missing_tags?(resource) + if resource.provider resource.err _("Provider %{name} is not functional on this host") % { name: resource.provider.class.name } else @@ -342,6 +343,7 @@ def propagate_failure(resource) relationship_graph.direct_dependencies_of(resource).each do |dep| s = resource_status(dep) next if s.nil? + failed.merge(s.failed_dependencies) if s.dependency_failed? failed.add(dep) if s.failed? || s.failed_to_restart? end @@ -374,6 +376,7 @@ def prefetch(provider_class, resources) type_name = provider_class.resource_type.name return if @prefetched_providers[type_name][provider_class.name] || @prefetch_failed_providers[type_name][provider_class.name] + Puppet.debug { "Prefetching #{provider_class.name} resources for #{type_name}" } begin provider_class.prefetch(resources) diff --git a/lib/puppet/transaction/additional_resource_generator.rb b/lib/puppet/transaction/additional_resource_generator.rb index 166a8fa1d58..e5b7dc96c15 100644 --- a/lib/puppet/transaction/additional_resource_generator.rb +++ b/lib/puppet/transaction/additional_resource_generator.rb @@ -19,6 +19,7 @@ def initialize(catalog, relationship_graph, prioritizer) def generate_additional_resources(resource) return unless resource.respond_to?(:generate) + begin generated = resource.generate rescue => detail @@ -26,6 +27,7 @@ def generate_additional_resources(resource) resource.log_exception(detail, _("Failed to generate additional resources using 'generate': %{detail}") % { detail: detail }) end return unless generated + generated = [generated] unless generated.is_a?(Array) generated.collect! do |res| @catalog.resource(res.ref) || res @@ -53,6 +55,7 @@ def generate_additional_resources(resource) def eval_generate(resource) return false unless resource.respond_to?(:eval_generate) raise Puppet::DevError, _("Depthfirst resources are not supported by eval_generate") if resource.depthfirst? + begin generated = replace_duplicates_with_catalog_resources(resource.eval_generate) return false if generated.empty? diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb index 151918dada0..62b601720cc 100644 --- a/lib/puppet/transaction/event.rb +++ b/lib/puppet/transaction/event.rb @@ -123,6 +123,7 @@ def send_log def status=(value) raise ArgumentError, _("Event status can only be %{statuses}") % { statuses: EVENT_STATUSES.join(', ') } unless EVENT_STATUSES.include?(value) + @status = value end diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb index a5ebd0042d1..87379e46f98 100644 --- a/lib/puppet/transaction/event_manager.rb +++ b/lib/puppet/transaction/event_manager.rb @@ -117,6 +117,7 @@ def queue_events_for_resource(source, target, callback, events) def queued_events(resource) callbacks = @event_queues[resource] return unless callbacks + callbacks.each do |callback, events| yield callback, events unless events.empty? end diff --git a/lib/puppet/transaction/persistence.rb b/lib/puppet/transaction/persistence.rb index 559c5ec1696..e27c34eda85 100644 --- a/lib/puppet/transaction/persistence.rb +++ b/lib/puppet/transaction/persistence.rb @@ -74,6 +74,7 @@ def load unless Puppet::FileSystem.exist?(filename) return end + unless File.file?(filename) Puppet.warning(_("Transaction store file %{filename} is not a file, ignoring") % { filename: filename }) return diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index bb78124ca8b..5807702e6d0 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -391,6 +391,7 @@ def summary }.each do |label| value = report[key][label] next if value == 0 + value = "%0.2f" % value if value.is_a?(Float) ret += " %15s %s\n" % [Puppet::Util::Metric.labelize(label) + ":", value] end diff --git a/lib/puppet/transaction/resource_harness.rb b/lib/puppet/transaction/resource_harness.rb index 2a271ccfbea..f6ac5f57aec 100644 --- a/lib/puppet/transaction/resource_harness.rb +++ b/lib/puppet/transaction/resource_harness.rb @@ -36,6 +36,7 @@ def evaluate(resource) def scheduled?(resource) return true if Puppet[:ignoreschedules] + schedule = schedule(resource) return true unless schedule @@ -55,6 +56,7 @@ def schedule(resource) name = resource[:schedule] return nil unless name + resource.catalog.resource(:schedule, name) || resource.fail(_("Could not find schedule %{name}") % { name: name }) end diff --git a/lib/puppet/trusted_external.rb b/lib/puppet/trusted_external.rb index 21f9edf26a7..cb6ea513664 100644 --- a/lib/puppet/trusted_external.rb +++ b/lib/puppet/trusted_external.rb @@ -4,11 +4,13 @@ module Puppet::TrustedExternal def retrieve(certname) command = Puppet[:trusted_external_command] return nil unless command + Puppet.debug { _("Retrieving trusted external data from %{command}") % {command: command} } setting_type = Puppet.settings.setting(:trusted_external_command).type if setting_type == :file return fetch_data(command, certname) end + # command is a directory. Thus, data is a hash of => for # each executable file in command. For example, if the files 'servicenow.rb', # 'unicorn.sh' are in command, then data is the following hash: @@ -25,6 +27,7 @@ def retrieve(certname) unless data[basename].nil? raise Puppet::Error, _("There is more than one '%{basename}' script in %{dir}") % { basename: basename, dir: command } end + data[basename] = fetch_data(abs_path, certname) end data diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index e4620734b97..344d23c1389 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -100,6 +100,7 @@ def <=>(other) # Order is only maintained against other types, not arbitrary objects. # The natural order is based on the reference name used when comparing return nil unless other.is_a?(Puppet::CompilableResourceType) || other.class.is_a?(Puppet::CompilableResourceType) + # against other type instances. self.ref <=> other.ref end @@ -294,6 +295,7 @@ def self.metaparam?(param) # def self.metaparamclass(name) return nil if name.nil? + @@metaparamhash[name.intern] end @@ -549,6 +551,7 @@ def self.paramdoc(param) # @return [Array] Returns the parameter names def self.parameters return [] unless defined?(@parameters) + @parameters.collect { |klass| klass.name } end @@ -568,6 +571,7 @@ def self.propertybyname(name) def self.validattr?(name) name = name.intern return true if name == :name + @validattrs ||= {} unless @validattrs.include?(name) @@ -596,6 +600,7 @@ def self.validproperties # @return [Boolean] Returns true if the given name is the name of an existing parameter def self.validparameter?(name) raise Puppet::DevError, _("Class %{class_name} has not defined parameters") % { class_name: self } unless defined?(@parameters) + !!(@paramhash.include?(name) or @@metaparamhash.include?(name)) end @@ -631,6 +636,7 @@ def add_property_parameter(prop_name) # def name_var return @name_var_cache unless @name_var_cache.nil? + key_attributes = self.class.key_attributes @name_var_cache = (key_attributes.length == 1) && key_attributes.first end @@ -906,6 +912,7 @@ def value(name) # @return [???] the version of the catalog or 0 if there is no catalog. def version return 0 unless catalog + catalog.version end @@ -1065,6 +1072,7 @@ def retrieve properties.each do |property| next if property.name == :ensure + if ensure_state == :absent result[property] = :absent else @@ -1309,6 +1317,7 @@ def pathbuilder unless list == [:all] list.each do |param| next if @resource.class.validattr?(param) + fail "Cannot audit #{param}: not a valid attribute for #{resource}" end end @@ -1317,6 +1326,7 @@ def pathbuilder munge do |args| properties_to_audit(args).each do |param| next unless resource.class.validproperty?(param) + resource.newattr(param) end end @@ -2090,6 +2100,7 @@ def autorelation(rel_type, rel_catalog = nil) # Retrieve the list of names from the block. list = self.instance_eval(&block) next unless list + list = [list] unless list.is_a?(Array) # Collect the current prereqs @@ -2406,6 +2417,7 @@ def set_sensitive_parameters(sensitive_parameters) parameters.each do |_name, param| next if param.sensitive + if param.is_a?(Puppet::Parameter) param.sensitive = param.is_sensitive if param.respond_to?(:is_sensitive) end @@ -2513,6 +2525,7 @@ def name def parent return nil unless catalog return @parent if @parent + parents = catalog.adjacent(self, :direction => :in) @parent = if parents parents.shift @@ -2602,6 +2615,7 @@ def to_resource # We've already got property values next if param.is_a?(Puppet::Property) + resource[name] = param.value end diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index de348706734..067aef57a20 100644 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -148,6 +148,7 @@ def sync debug("Exec try #{try+1}/#{tries}") if tries > 1 @output, @status = provider.run(self.resource[:command]) break if self.should.include?(@status.exitstatus.to_s) + if try_sleep > 0 and tries > 1 debug("Sleeping for #{try_sleep} seconds between tries") sleep try_sleep @@ -354,9 +355,11 @@ def value=(*values) unless value =~ /^[\d]+$/ raise ArgumentError, _("Tries must be an integer") end + value = Integer(value) end raise ArgumentError, _("Tries must be an integer >= 1") if value < 1 + value end @@ -371,9 +374,11 @@ def value=(*values) unless value =~ /^[-\d.]+$/ raise ArgumentError, _("try_sleep must be a number") end + value = Float(value) end raise ArgumentError, _("try_sleep cannot be a negative number") if value < 0 + value end @@ -650,6 +655,7 @@ def self.instances def check_all_attributes(refreshing = false) self.class.checks.each { |check| next if refreshing and check == :refreshonly + if @parameters.include?(check) val = @parameters[check].value val = [val] unless val.is_a? Array diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 7f85275ca03..b458d65ed8b 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -406,6 +406,7 @@ def self.title_patterns # The user/group property automatically converts to IDs should = @parameters[property].shouldorig next unless should + val = should[0] if val.is_a?(Integer) or val =~ /^\d+$/ nil @@ -458,6 +459,7 @@ def self.title_patterns def self.[](path) return nil unless path + super(path.gsub(/\/+/, '/').sub(/\/$/, '')) end @@ -570,6 +572,7 @@ def initialize(hash) def mark_children_for_purging(children) children.each do |_name, child| next if child[:source] + child[:ensure] = :absent end end @@ -696,6 +699,7 @@ def recurse_link(children) def recurse_local result = perform_recursion(self[:path]) return {} unless result + result.inject({}) do |hash, meta| next hash if meta.relative_path == "." @@ -735,8 +739,10 @@ def recurse_remote_metadata end next unless result + top = result.find { |r| r.relative_path == "." } return [] if top && top.ftype != "directory" + result.each do |data| if data.relative_path == '.' data.source = source @@ -746,6 +752,7 @@ def recurse_remote_metadata end end break result if result and ! result.empty? and sourceselect == :first + result end.flatten.compact @@ -866,12 +873,14 @@ def should_be_file? # The user doesn't really care, apparently if self[:ensure] == :present return true unless stat + return(stat.ftype == "file" ? true : false) end # If we've gotten here, then :ensure isn't set return true if self[:content] return true if stat and stat.ftype == "file" + false end @@ -1087,6 +1096,7 @@ def desired_checksum(property, path) # due to HttpMetadata the checksum type may fallback to mtime, so recheck return if SOURCE_ONLY_CHECKSUMS.include?(meta.checksum_type) + meta.checksum elsif property && property.name == :content str = property.actual_content diff --git a/lib/puppet/type/file/checksum_value.rb b/lib/puppet/type/file/checksum_value.rb index 044f0606093..fbf7578d6bd 100644 --- a/lib/puppet/type/file/checksum_value.rb +++ b/lib/puppet/type/file/checksum_value.rb @@ -24,6 +24,7 @@ def insync?(is) def property_matches?(current, desired) return true if super(current, desired) + return date_matches?(resource.parameter(:checksum).value, current, desired) end diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index aa4ab27082c..93288c38037 100644 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -117,6 +117,7 @@ def property_matches?(current, desired) # The inherited equality is always accepted, so use it if valid. return true if super(current, desired) + return date_matches?(checksum_type, current, desired) end @@ -167,6 +168,7 @@ def content_is_really_a_checksum? def read_file_from_filebucket dipper = resource.bucket raise "Could not get filebucket from file" unless dipper + sum = should.sub(/\{\w+\}/, '') dipper.getfile(sum) diff --git a/lib/puppet/type/file/data_sync.rb b/lib/puppet/type/file/data_sync.rb index ba03ec57494..829ca11811c 100644 --- a/lib/puppet/type/file/data_sync.rb +++ b/lib/puppet/type/file/data_sync.rb @@ -66,6 +66,7 @@ def date_matches?(checksum_type, current, desired) begin if checksum?(current) || checksum?(desired) raise if !time_types.include?(sumtype(current).to_sym) || !time_types.include?(sumtype(desired).to_sym) + current = sumdata(current) desired = sumdata(desired) end @@ -78,6 +79,7 @@ def date_matches?(checksum_type, current, desired) def retrieve_checksum(resource) stat = resource.stat return :absent unless stat + ftype = stat.ftype # Don't even try to manage the content on directories or links return nil if ['directory', 'link', 'fifo', 'socket'].include?(ftype) diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 3fca1b01690..4f888e8e1f9 100644 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -100,6 +100,7 @@ module Puppet newvalue(:link, :event => :link_created, :required_features => :manages_symlinks) do property = resource.property(:target) fail "Cannot create a symlink without a target" unless property + property.retrieve property.mklink end diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb index aedd065bcbc..9b4091d1fe0 100644 --- a/lib/puppet/type/file/mode.rb +++ b/lib/puppet/type/file/mode.rb @@ -125,6 +125,7 @@ def insync?(currentvalue) if provider.respond_to?(:munge_windows_system_group) munged_mode = provider.munge_windows_system_group(currentvalue, @should) return false if munged_mode.nil? + currentvalue = munged_mode end stat = @resource.stat @@ -138,6 +139,7 @@ def insync?(currentvalue) def property_matches?(current, desired) return false unless current + current_bits = normalize_symbolic_mode(current) desired_bits = desired_mode_from_current(desired, current).to_s(8) current_bits == desired_bits diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb index c2bedce5835..804da83a290 100644 --- a/lib/puppet/type/file/selcontext.rb +++ b/lib/puppet/type/file/selcontext.rb @@ -28,6 +28,7 @@ class SELFileContext < Puppet::Property def retrieve return :absent unless @resource.stat + context = self.get_selinux_current_context(@resource[:path]) is = parse_selinux_context(name, context) if name == :selrange and selinux_support? diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index 8701e6808fe..3b266f72650 100644 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -186,6 +186,7 @@ def metadata return @metadata if @metadata return nil unless value + value.each do |source| begin options = { diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 94d2cee1867..9ee37b199fe 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -116,6 +116,7 @@ def able_to_ensure_absent?(resource) # right now, because it only supports purging. def generate return [] unless self.purge? + resource_type.instances .reject { |r| catalog.resource_refs.include? r.ref } .select { |r| check(r) } @@ -133,6 +134,7 @@ def resource_type unless type raise Puppet::DevError, _("Could not find resource type") end + @resource_type = type end @resource_type @@ -142,6 +144,7 @@ def resource_type def user_check(resource) return true unless self[:name] == "user" return true unless self[:unless_system_user] + resource[:audit] = :uid current_values = resource.retrieve_resource current_uid = current_values[resource.property(:uid)] @@ -149,6 +152,7 @@ def user_check(resource) return false if system_users.include?(resource[:name]) return false if unless_uids && unless_uids.include?(current_uid) + if current_uid.is_a?(String) # Windows user; is a system user if any regex matches. WINDOWS_SYSTEM_SID_REGEXES.none? { |regex| current_uid =~ regex } diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index 821ac7e8c9a..482ad7f8353 100644 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -382,6 +382,7 @@ def match?(previous, now) return true if @resource[:range] return true if value.has_key?(now.wday) + false end end diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index cfdf967a7bb..f2d792694ca 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -92,6 +92,7 @@ def retrieve def insync?(current) return provider.enabled_insync?(current) if provider.respond_to?(:enabled_insync?) + super(current) end end @@ -139,6 +140,7 @@ def sync def insync?(current) return provider.logonaccount_insync?(current) if provider.respond_to?(:logonaccount_insync?) + super(current) end end @@ -277,6 +279,7 @@ def insync?(current) begin value = value.to_i raise if value < 1 + value rescue raise Puppet::Error.new(_("\"%{value}\" is not a positive integer: the timeout parameter must be specified as a positive integer") % { value: value }) diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index 319bdfa742b..5ecf71d1d9a 100644 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -100,6 +100,7 @@ # Make sure we convert to an array. munge do |value| fail _("Tidy can't use matches with recurse 0, false, or undef") if "#{@resource[:recurse]}" =~ /^(0|false|)$/ + [value].flatten end @@ -308,6 +309,7 @@ def generate dir = ::File.dirname(path) resource = files_by_name[dir] next unless resource + if resource[:require] resource[:require] << Puppet::Resource.new(:file, path) else @@ -353,12 +355,14 @@ def tidy?(path) [:age, :size].each do |name| param = parameter(name) next unless param + tested = true return true if param.tidy?(path, stat) end # If they don't specify either, then the file should always be removed. return true unless tested + false end diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index 2f7d206b9c1..a98d7205138 100644 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -193,6 +193,7 @@ def insync?(is) if !@should.empty? && provider.respond_to?(:comments_insync?) return provider.comments_insync?(is, @should) end + super(is) end @@ -203,6 +204,7 @@ def change_to_s(currentvalue, newvalue) if newvalue.is_a?(String) && !Encoding.compatible?(currentvalue, newvalue) return super(currentvalue, newvalue.dup.force_encoding(currentvalue.encoding)) end + super(currentvalue, newvalue) end end @@ -733,6 +735,7 @@ def generate if [ :true, :false ].include? value.to_s.intern return end + value = [ value ] if value.is_a?(String) if value.is_a?(Array) value.each do |entry| @@ -834,6 +837,7 @@ def unknown_keys_in_file(keyfile) # the authorized_keys file may contain UTF-8 comments Puppet::FileSystem.open(keyfile, nil, 'r:UTF-8').each do |line| next unless line =~ Puppet::Type.type(:ssh_authorized_key).keyline_regex + # the name is stored in the 4th capture of the regex name = $4 if name.empty? diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index a756b226de1..018418163aa 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -668,6 +668,7 @@ def replace_file(file, default_mode, staging_location: nil, validate_callback: n if Puppet::FileSystem.exist?(file) && Puppet::FileSystem.directory?(file) raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: file } end + File.rename(tempfile.path, Puppet::FileSystem.path_string(file)) end ensure diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index edb430bc3e9..1534af795d2 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -60,8 +60,10 @@ def mark_loaded(name, file) def changed?(name, env) name = cleanpath(name).chomp('.rb') return true unless loaded.include?(name) + file, old_mtime = loaded[name] return true unless file == get_file(name, env) + begin old_mtime.to_i != File.mtime(file).to_i rescue Errno::ENOENT @@ -74,6 +76,7 @@ def changed?(name, env) def load_file(name, env) file = get_file(name.to_s, env) return false unless file + begin mark_loaded(name, file) Kernel.load file @@ -176,6 +179,7 @@ def cleanpath(path) def initialize(obj, path) @path = path.to_s raise ArgumentError, _("Autoload paths cannot be fully qualified") if Puppet::Util.absolute_path?(@path) + @object = obj end diff --git a/lib/puppet/util/backups.rb b/lib/puppet/util/backups.rb index 43c1979156e..967e0102652 100644 --- a/lib/puppet/util/backups.rb +++ b/lib/puppet/util/backups.rb @@ -23,6 +23,7 @@ def perform_backup_with_bucket(fileobj) when "directory" # we don't need to backup directories when recurse is on return true if self[:recurse] + info _("Recursively backing up to filebucket") Find.find(self[:path]) { |f| backup_file_with_filebucket(f) if File.file?(f) } when "file"; backup_file_with_filebucket(file) diff --git a/lib/puppet/util/checksums.rb b/lib/puppet/util/checksums.rb index f9833eeb4cc..956f9587353 100644 --- a/lib/puppet/util/checksums.rb +++ b/lib/puppet/util/checksums.rb @@ -232,6 +232,7 @@ def mtime(content) def mtime?(string) return true if string.is_a? Time + !!DateTime.parse(string) rescue false @@ -302,6 +303,7 @@ def ctime(content) def ctime?(string) return true if string.is_a? Time + !!DateTime.parse(string) rescue false diff --git a/lib/puppet/util/command_line/trollop.rb b/lib/puppet/util/command_line/trollop.rb index 22bf448035c..db42612cac1 100644 --- a/lib/puppet/util/command_line/trollop.rb +++ b/lib/puppet/util/command_line/trollop.rb @@ -169,6 +169,7 @@ def opt name, desc="", opts={} when nil; nil else raise ArgumentError, _("unsupported argument type '%{type}'") % { type: opts[:type] } unless TYPES.include?(opts[:type]) + opts[:type] end @@ -195,6 +196,7 @@ def opt name, desc="", opts={} if opts[:default].empty? raise ArgumentError, _("multiple argument type cannot be deduced from an empty array for '%{value0}'") % { value0: opts[:default][0].class.name } end + case opts[:default][0] # the first element determines the types when Integer; :ints when Numeric; :floats @@ -634,11 +636,13 @@ def each_arg args def parse_integer_parameter param, arg raise CommandlineError, _("option '%{arg}' needs an integer") % { arg: arg } unless param =~ /^\d+$/ + param.to_i end def parse_float_parameter param, arg raise CommandlineError, _("option '%{arg}' needs a floating-point number") % { arg: arg } unless param =~ FLOAT_RE + param.to_f end @@ -668,6 +672,7 @@ def collect_argument_parameters args, start_at def resolve_default_short_options @order.each do |type, name| next unless type == :opt + opts = @specs[name] next if opts[:short] diff --git a/lib/puppet/util/diff.rb b/lib/puppet/util/diff.rb index 1fe473f207b..11213fc106e 100644 --- a/lib/puppet/util/diff.rb +++ b/lib/puppet/util/diff.rb @@ -50,6 +50,7 @@ def lcs_diff(data_old, data_new, format=:unified, context_lines=3) file_length_difference) file_length_difference = hunk.file_length_difference next unless oldhunk + # Hunks may overlap, which is why we need to be careful when our # diff includes lines of context. Otherwise, we might print # redundant lines. diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb index 170e2864956..d204ad5c457 100644 --- a/lib/puppet/util/docs.rb +++ b/lib/puppet/util/docs.rb @@ -116,6 +116,7 @@ def markdown_definitionlist(term, definition) def scrub(text) # One-liners are easy! (One-liners may be buffered with extra newlines.) return text.strip if text.strip !~ /\n/ + excluding_first_line = text.partition("\n").last indent = excluding_first_line.scan(/^[ \t]*(?=\S)/).min || '' # prevent nil # Clean hanging indent, if any diff --git a/lib/puppet/util/file_watcher.rb b/lib/puppet/util/file_watcher.rb index 5dc591cd512..4999f3a5ff5 100644 --- a/lib/puppet/util/file_watcher.rb +++ b/lib/puppet/util/file_watcher.rb @@ -16,6 +16,7 @@ def changed? def watch(filename) return if watching?(filename) + @files[filename] = Puppet::Util::WatchedFile.new(filename) end diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index 294b8a944c5..0137296676e 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -42,6 +42,7 @@ def fields=(fields) @fields = fields.collect do |field| r = field.intern raise ArgumentError.new(_("Cannot have fields named %{name}") % { name: r }) if INVALID_FIELDS.include?(r) + r end end diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index 392e9c67955..d431a083f69 100644 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -82,6 +82,7 @@ def bucket def initialize(path, default_mode = nil) raise ArgumentError.new(_("Path is nil")) if path.nil? + @path = path @default_mode = default_mode end diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb index 470c8fa80ea..a570a233268 100644 --- a/lib/puppet/util/inifile.rb +++ b/lib/puppet/util/inifile.rb @@ -138,6 +138,7 @@ def read if text.nil? raise IniParseError, _("Cannot read nonexistent file %{file}") % { file: @file.inspect } end + parse(text) end diff --git a/lib/puppet/util/instance_loader.rb b/lib/puppet/util/instance_loader.rb index cf67e760f43..dce10a35777 100644 --- a/lib/puppet/util/instance_loader.rb +++ b/lib/puppet/util/instance_loader.rb @@ -51,6 +51,7 @@ def loaded_instance(type, name) name = name.intern instances = instance_hash(type) return nil unless instances + unless instances.include? name if instance_loader(type).load(name, Puppet.lookup(:current_environment)) unless instances.include? name diff --git a/lib/puppet/util/json_lockfile.rb b/lib/puppet/util/json_lockfile.rb index eae9d7ea69c..5b366cce0eb 100644 --- a/lib/puppet/util/json_lockfile.rb +++ b/lib/puppet/util/json_lockfile.rb @@ -34,8 +34,10 @@ def lock(lock_data = nil) # they will be converted to Strings. def lock_data return nil unless file_locked? + file_contents = super return nil if file_contents.nil? or file_contents.empty? + Puppet::Util::Json.load(file_contents) rescue Puppet::Util::Json::ParseError Puppet.warning _("Unable to read lockfile data from %{path}: not in JSON") % { path: @file_path } diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index cc048e9073e..a4e5f080bb6 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -84,6 +84,7 @@ def Log.autoflush=(v) def Log.create(hash) raise Puppet::DevError, _("Logs require a level") unless hash.include?(:level) raise Puppet::DevError, _("Invalid log level %{level}") % { level: hash[:level] } unless @levels.index(hash[:level]) + @levels.index(hash[:level]) >= @loglevel ? Puppet::Util::Log.new(hash) : nil end @@ -207,6 +208,7 @@ def Log.queuemessage(msg) def Log.flushqueue return unless @destinations.size >= 1 + @queued.each do |msg| Log.newmessage(msg) end @@ -312,6 +314,7 @@ def initialize(args) [:file, :line, :pos, :issue_code, :environment, :node, :backtrace].each do |attr| value = args[attr] next unless value + send(attr.to_s + '=', value) end @@ -331,6 +334,7 @@ def initialize_from_hash(data) %w(file line pos issue_code environment node backtrace).each do |name| value = data[name] next unless value + send(name + '=', value) end end @@ -369,6 +373,7 @@ def to_structured_hash def message=(msg) #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class raise ArgumentError, _("Puppet::Util::Log requires a message") unless msg + @message = msg.to_s end @@ -377,6 +382,7 @@ def level=(level) raise ArgumentError, _("Puppet::Util::Log requires a log level") unless level #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class raise ArgumentError, _("Puppet::Util::Log requires a symbol or string") unless level.respond_to? "to_sym" + @level = level.to_sym raise ArgumentError, _("Invalid log level %{level}") % { level: @level } unless self.class.validlevel?(@level) diff --git a/lib/puppet/util/logging.rb b/lib/puppet/util/logging.rb index d09849efc8d..2a9e0944209 100644 --- a/lib/puppet/util/logging.rb +++ b/lib/puppet/util/logging.rb @@ -13,6 +13,7 @@ def send_log(level, message) Puppet::Util::Log.eachlevel do |level| # handle debug a special way for performance reasons next if level == :debug + define_method(level) do |args| args = args.join(" ") if args.is_a?(Array) send_log(level, args) @@ -31,6 +32,7 @@ def send_log(level, message) # def debug(*args) return nil unless Puppet::Util::Log.level == :debug + if block_given? send_log(:debug, yield(*args)) else @@ -177,6 +179,7 @@ def puppet_deprecation_warning(message, options = {}) # Either :file and :line and/or :key must be passed. def warn_once(kind, key, message, file = nil, line = nil, level = :warning) return if Puppet[:disable_warnings].include?(kind) + $unique_warnings ||= {} if $unique_warnings.length < 100 then if (! $unique_warnings.has_key?(key)) then @@ -260,6 +263,7 @@ def self.setup_facter_logging! def issue_deprecation_warning(message, key, file, line, use_caller) return if Puppet[:disable_warnings].include?('deprecations') + $deprecation_warnings ||= {} if $deprecation_warnings.length < 100 key ||= (offender = get_deprecation_offender) diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index ae6643ccdea..71616b5a1b7 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -51,6 +51,7 @@ def initialize(name,label = nil) def newvalue(name,value,label = nil) raise ArgumentError.new("metric name #{name.inspect} is not a string") unless name.is_a? String + label ||= self.class.labelize(name) @values.push [name,label,value] end diff --git a/lib/puppet/util/multi_match.rb b/lib/puppet/util/multi_match.rb index 12e1fbba1c1..9d82feebdb3 100644 --- a/lib/puppet/util/multi_match.rb +++ b/lib/puppet/util/multi_match.rb @@ -27,9 +27,11 @@ def ===(other) case other when MultiMatch return false unless other.values.size == values.size + other.values.each_with_index {|v, i| return false unless lv[i] === v || v === lv[i]} when Array return false unless other.size == values.size + other.each_with_index {|v, i| return false unless lv[i] === v || v === lv[i]} else false diff --git a/lib/puppet/util/package.rb b/lib/puppet/util/package.rb index ec643449bac..09d4c6f0a2c 100644 --- a/lib/puppet/util/package.rb +++ b/lib/puppet/util/package.rb @@ -20,8 +20,10 @@ def versioncmp(version_a, version_b, ignore_trailing_zeroes = false) return 1 if b == '-' return -1 if a == '.' return 1 if b == '.' + if a =~ /^\d+$/ && b =~ /^\d+$/ return a.to_s.upcase <=> b.to_s.upcase if a =~ /^0/ || b =~ /^0/ + return a.to_i <=> b.to_i end return a.upcase <=> b.upcase diff --git a/lib/puppet/util/package/version/debian.rb b/lib/puppet/util/package/version/debian.rb index 3f7c4a2542d..1f1e0d2d7b1 100644 --- a/lib/puppet/util/package/version/debian.rb +++ b/lib/puppet/util/package/version/debian.rb @@ -43,6 +43,7 @@ def eql?(other) def <=>(other) return nil unless other.is_a?(self.class) + cmp = @epoch <=> other.epoch if cmp == 0 cmp = compare_upstream_version(other) diff --git a/lib/puppet/util/package/version/gem.rb b/lib/puppet/util/package/version/gem.rb index c946bd65253..355dc0f7f52 100644 --- a/lib/puppet/util/package/version/gem.rb +++ b/lib/puppet/util/package/version/gem.rb @@ -4,6 +4,7 @@ class Gem < ::Gem::Version def self.parse(version) raise ValidationFailure, version unless version.is_a? String raise ValidationFailure, version unless version =~ ANCHORED_VERSION_PATTERN + new(version) end diff --git a/lib/puppet/util/package/version/pip.rb b/lib/puppet/util/package/version/pip.rb index 1ee43b9e3c5..1965a5ee705 100644 --- a/lib/puppet/util/package/version/pip.rb +++ b/lib/puppet/util/package/version/pip.rb @@ -71,6 +71,7 @@ def eql?(other) def <=>(other) raise ValidationFailure, other.to_s unless other.is_a?(self.class) + compare(key, other.key) end @@ -118,6 +119,7 @@ def compose_key(epoch, release, pre, post, dev, local) release_key = release.reverse release_key.each_with_index do |element, index| break unless element == 0 + release_key.delete_at(index) unless release_key.at(index + 1) != 0 end release_key.reverse! @@ -151,9 +153,11 @@ def compare(this, other) end elsif (this.is_a? Array) && !(other.is_a? Array) raise Puppet::Error, "Cannot compare #{this} (Array) with #{other} (#{other.class}). Only ±Float::INFINITY accepted." unless other.abs == Float::INFINITY + return other == -Float::INFINITY ? 1 : -1 elsif !(this.is_a? Array) && (other.is_a? Array) raise Puppet::Error, "Cannot compare #{this} (#{this.class}) with #{other} (Array). Only ±Float::INFINITY accepted." unless this.abs == Float::INFINITY + return this == -Float::INFINITY ? -1 : 1 end this <=> other diff --git a/lib/puppet/util/package/version/range.rb b/lib/puppet/util/package/version/range.rb index 80f27d2b09d..5a312fb2a43 100644 --- a/lib/puppet/util/package/version/range.rb +++ b/lib/puppet/util/package/version/range.rb @@ -30,9 +30,11 @@ class ValidationFailure < ArgumentError; end # @api public def self.parse(range_string, version_class) raise ValidationFailure, "Unable to parse '#{range_string}' as a string" unless range_string.is_a?(String) + simples = range_string.split(RANGE_SPLIT).map do |simple| match, operator, version = *simple.match(FULL_REGEX) raise ValidationFailure, "Unable to parse '#{simple}' as a version range identifier" unless match + case operator when '>' Gt.new(version_class::parse(version)) diff --git a/lib/puppet/util/package/version/rpm.rb b/lib/puppet/util/package/version/rpm.rb index 3a92046b5b7..a33a64196b7 100644 --- a/lib/puppet/util/package/version/rpm.rb +++ b/lib/puppet/util/package/version/rpm.rb @@ -14,6 +14,7 @@ class ValidationFailure < ArgumentError; end def self.parse(ver) raise ValidationFailure unless ver.is_a?(String) + version = rpm_parse_evr(ver) new(version[:epoch], version[:version], version[:release], version[:arch]).freeze end diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index e7f76fdb874..a0102cbf3eb 100644 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -177,11 +177,13 @@ def get_posix_value(location, id_field, field) if field.is_a?(Integer) name = get_posix_field(location, :name, field) return nil unless name + id = get_posix_field(location, id_field, name) check_value = id else id = get_posix_field(location, id_field, field) return nil unless id + name = get_posix_field(location, :name, id) check_value = name end diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb index dafae92427e..d34cc101713 100644 --- a/lib/puppet/util/provider_features.rb +++ b/lib/puppet/util/provider_features.rb @@ -62,6 +62,7 @@ def methods_available?(obj) def feature(name, docs, hash = {}) @features ||= {} raise Puppet::DevError, _("Feature %{name} is already defined") % { name: name } if @features.include?(name) + begin obj = ProviderFeature.new(name, docs, **hash) @features[obj.name] = obj @@ -79,6 +80,7 @@ def featuredocs str = ''.dup @features ||= {} return nil if @features.empty? + names = @features.keys.sort_by(&:to_s) names.each do |name| doc = @features[name].docs.gsub(/\n\s+/, " ") @@ -128,6 +130,7 @@ def feature_module # Create a method that will list all functional features. @feature_module.send(:define_method, :features) do return false unless defined?(features) + features.keys.find_all { |n| feature?(n) }.sort_by(&:to_s) end diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb index c5ce73540e7..f53310312ba 100644 --- a/lib/puppet/util/rdoc/code_objects.rb +++ b/lib/puppet/util/rdoc/code_objects.rb @@ -68,6 +68,7 @@ def add_node(name,superclass) if cls return cls end + @node_container ||= add_module(NormalModule, "__nodes__") cls = @node_container.add_class(PuppetNode, name, superclass) @nodes[name] = cls if !@done_documenting diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index f8a3e16e176..fc88b98e3d1 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -114,6 +114,7 @@ def build_indices # build the modules, classes and per modules classes and define list @toplevels.each do |toplevel| next unless toplevel.document_self + file = HtmlFile.new(toplevel, @options, FILE_DIR) classes = [] methods = [] @@ -566,6 +567,7 @@ def build_attribute_list(section) res = [] atts.each do |att| next unless att.section == section + if att.visibility == :public || att.visibility == :protected || @options.show_all entry = { "name" => CGI.escapeHTML(att.name), diff --git a/lib/puppet/util/rdoc/parser/puppet_parser_core.rb b/lib/puppet/util/rdoc/parser/puppet_parser_core.rb index df953c3b717..c072900874d 100644 --- a/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +++ b/lib/puppet/util/rdoc/parser/puppet_parser_core.rb @@ -35,6 +35,7 @@ def scan # but from which we are not descendant. def find_object_named(container, name) return container if container.name == name + container.each_classmodule do |m| return m if m.name == name end diff --git a/lib/puppet/util/resource_template.rb b/lib/puppet/util/resource_template.rb index 9e411a5444a..0d49a0aa0f9 100644 --- a/lib/puppet/util/resource_template.rb +++ b/lib/puppet/util/resource_template.rb @@ -46,6 +46,7 @@ def evaluate def initialize(file, resource) raise ArgumentError, _("Template %{file} does not exist") % { file: file } unless Puppet::FileSystem.exist?(file) + @file = file @resource = resource end diff --git a/lib/puppet/util/rpm_compare.rb b/lib/puppet/util/rpm_compare.rb index 24eb7686420..1423b8ba472 100644 --- a/lib/puppet/util/rpm_compare.rb +++ b/lib/puppet/util/rpm_compare.rb @@ -83,6 +83,7 @@ def rpmvercmp(str1, str2) # where alpha also includes ''; "numeric segments are always newer than alpha segments" if segment2.length == 0 return 1 if isnum + return -1 end @@ -105,6 +106,7 @@ def rpmvercmp(str1, str2) # if we haven't returned anything yet, "whichever version still has characters left over wins" return 1 if str1.length > str2.length return -1 if str1.length < str2.length + 0 end @@ -148,6 +150,7 @@ def compare_values(s1, s2) return 0 if s1.nil? && s2.nil? return 1 if ( not s1.nil? ) && s2.nil? return -1 if s1.nil? && (not s2.nil?) + return rpmvercmp(s1, s2) end diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index 1817d5161d5..cbd1c13694d 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -22,6 +22,7 @@ def self.selinux_support? if Selinux.is_selinux_enabled == 1 return true end + false end @@ -33,10 +34,12 @@ def selinux_support? # SELinux support or if the SELinux call fails then return nil. def get_selinux_current_context(file) return nil unless selinux_support? + retval = Selinux.lgetfilecon(file) if retval == -1 return nil end + retval[1] end @@ -47,6 +50,7 @@ def get_selinux_default_context(file, resource_ensure=nil) # If the filesystem has no support for SELinux labels, return a default of nil # instead of what matchpathcon would return return nil unless selinux_label_support?(file) + # If the file exists we should pass the mode to matchpathcon for the most specific # matching. If not, we can pass a mode of 0. begin @@ -66,6 +70,7 @@ def get_selinux_default_context(file, resource_ensure=nil) if retval == -1 return nil end + retval[1] end @@ -76,10 +81,12 @@ def parse_selinux_context(component, context) if context.nil? or context == "unlabeled" return nil end + components = /^([^\s:]+):([^\s:]+):([^\s:]+)(?::([\sa-zA-Z0-9:,._-]+))?$/.match(context) unless components raise Puppet::Error, _("Invalid context to parse: %{context}") % { context: context } end + case component when :seluser components[1] @@ -149,6 +156,7 @@ def set_selinux_context(file, value, component = false) def set_selinux_default_context(file, resource_ensure=nil) new_context = get_selinux_default_context(file, resource_ensure) return nil unless new_context + cur_context = get_selinux_current_context(file) if new_context != cur_context set_selinux_context(file, new_context) @@ -179,6 +187,7 @@ def selinux_category_to_label(category) line.strip! next if line.empty? next if line[0] == "#" # skip comments + line.gsub!(/[[:space:]]+/m, '') mapping = line.split("=", 2) if category == mapping[1] @@ -204,6 +213,7 @@ def selinux_category_to_label(category) def selinux_label_support?(file) fstype = find_fs(file) return false if fstype.nil? + filesystems = ['ext2', 'ext3', 'ext4', 'gfs', 'gfs2', 'xfs', 'jfs', 'btrfs', 'tmpfs', 'zfs'] filesystems.include?(fstype) end @@ -256,6 +266,7 @@ def read_mounts mounts.each_line do |line| params = line.split(' ') next if params[2] == 'rootfs' + mntpoint[params[1]] = params[2] end mntpoint diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index 2ac72788a12..54504d012d5 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -18,6 +18,7 @@ module Puppet::Util::SUIDManager def osx_maj_ver return @osx_maj_ver unless @osx_maj_ver.nil? + @osx_maj_ver = Puppet.runtime[:facter].value('os.macosx.version.major') || false end module_function :osx_maj_ver @@ -142,12 +143,15 @@ def change_user(user, permanently=false) # Make sure the passed argument is a number. def convert_xid(type, id) return id if id.kind_of? Integer + map = {:gid => :group, :uid => :user} raise ArgumentError, _("Invalid id type %{type}") % { type: type } unless map.include?(type) + ret = Puppet::Util.send(type, id) if ret == nil raise Puppet::Error, _("Invalid %{klass}: %{id}") % { klass: map[type], id: id } end + ret end module_function :convert_xid diff --git a/lib/puppet/util/symbolic_file_mode.rb b/lib/puppet/util/symbolic_file_mode.rb index 4ad6fbf73fa..802008fad1c 100644 --- a/lib/puppet/util/symbolic_file_mode.rb +++ b/lib/puppet/util/symbolic_file_mode.rb @@ -17,6 +17,7 @@ def valid_symbolic_mode?(value) value = normalize_symbolic_mode(value) return true if value =~ /^0?[0-7]{1,4}$/ return true if value =~ /^([ugoa]*[-=+][-=+rstwxXugo]*)(,[ugoa]*[-=+][-=+rstwxXugo]*)*$/ + return false end @@ -75,6 +76,7 @@ def symbolic_mode_to_int(modification, to_mode = 0, is_a_directory = false) begin _, to, dsl = /^([ugoa]*)([-+=].*)$/.match(part).to_a if dsl.nil? then raise Puppet::Error, _('Missing action') end + to = "a" unless to and to.length > 0 # We want a snapshot of the mode before we start messing with it to diff --git a/lib/puppet/util/warnings.rb b/lib/puppet/util/warnings.rb index e1f882f81a7..9c0029fc881 100644 --- a/lib/puppet/util/warnings.rb +++ b/lib/puppet/util/warnings.rb @@ -9,6 +9,7 @@ def notice_once(msg) def debug_once(msg) return nil unless Puppet[:debug] + Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.debug msg } end @@ -25,6 +26,7 @@ def self.maybe_log(message, klass) @stampwarnings ||= {} @stampwarnings[klass] ||= [] return nil if @stampwarnings[klass].include? message + yield @stampwarnings[klass] << message nil diff --git a/lib/puppet/util/windows/adsi.rb b/lib/puppet/util/windows/adsi.rb index ebaa497c7f8..9cef5c094b0 100644 --- a/lib/puppet/util/windows/adsi.rb +++ b/lib/puppet/util/windows/adsi.rb @@ -59,6 +59,7 @@ def computer_name if GetComputerNameW(buffer, buffer_size) == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Failed to get computer name")) end + @computer_name = buffer.read_wide_string(buffer_size.read_dword) end end @@ -194,6 +195,7 @@ def name_sid_hash(names, allow_unresolved = false) sids = names.map do |name| sid = Puppet::Util::Windows::SID.name_to_principal(name, allow_unresolved) raise Puppet::Error.new( _("Could not resolve name: %{name}") % { name: name } ) if !sid + [sid.sid, sid] end @@ -211,6 +213,7 @@ def exists?(name_or_sid) if sid.account_type == "SidType#{@object_class.capitalize}".to_sym # Check if we're getting back a local user when domain-joined return true unless [:MEMBER_WORKSTATION, :MEMBER_SERVER].include?(Puppet::Util::Windows::ADSI.domain_role) + # The resource domain and the computer name are not always case-matching return sid.domain.casecmp(Puppet::Util::Windows::ADSI.computer_name) == 0 end @@ -220,6 +223,7 @@ def exists?(name_or_sid) # https://msdn.microsoft.com/en-us/library/cc234477.aspx well_known = sid.account_type == :SidTypeWellKnownGroup return false if sid.account_type != :SidTypeAlias && !well_known + name_or_sid = "#{sid.domain}\\#{sid.account}" end @@ -319,6 +323,7 @@ def logon(name, password) def create(name) # Windows error 1379: The specified local group already exists. raise Puppet::Error.new(_("Cannot create user if group '%{name}' exists.") % { name: name }) if Puppet::Util::Windows::ADSI::Group.exists? name + new(name, Puppet::Util::Windows::ADSI.create(name, @object_class)) end end @@ -488,6 +493,7 @@ def expired? rescue WIN32OLERuntimeError => e # This OLE error code indicates the property can't be found in the cache raise e unless e.message =~ /8000500D/m + false end @@ -503,6 +509,7 @@ def self.current_user_name if GetUserNameW(buffer, buffer_size) == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Failed to get user name")) end + # buffer_size includes trailing NULL user_name = buffer.read_wide_string(buffer_size.read_dword - 1) end @@ -602,6 +609,7 @@ def list_all def create(name) # Windows error 2224: The account already exists. raise Puppet::Error.new( _("Cannot create group if user '%{name}' exists.") % { name: name } ) if Puppet::Util::Windows::ADSI::User.exists?(name) + new(name, Puppet::Util::Windows::ADSI.create(name, @object_class)) end end diff --git a/lib/puppet/util/windows/com.rb b/lib/puppet/util/windows/com.rb index f8aa36af62c..63a4af3c502 100644 --- a/lib/puppet/util/windows/com.rb +++ b/lib/puppet/util/windows/com.rb @@ -143,6 +143,7 @@ def initialize(pointer) if Puppet::Util::Windows::COM.FAILED(result = @vtbl[name].call(self, *args)) raise Puppet::Util::Windows::Error.new(_("Failed to call %{klass}::%{name} with HRESULT: %{result}.") % { klass: self, name: name, result: result }, result) end + result end end @@ -184,6 +185,7 @@ def initialize(opts = {}) if Puppet::Util::Windows::COM.FAILED(result = @vtbl[name].call(self, *args)) raise Puppet::Util::Windows::Error.new(_("Failed to call %{klass}::%{name} with HRESULT: %{result}.") % { klass: self, name: name, result: result }, result) end + result end end diff --git a/lib/puppet/util/windows/eventlog.rb b/lib/puppet/util/windows/eventlog.rb index 883774b9b49..90ed820e61c 100644 --- a/lib/puppet/util/windows/eventlog.rb +++ b/lib/puppet/util/windows/eventlog.rb @@ -60,6 +60,7 @@ def report_event(args = {}) unless args[:data].is_a?(String) raise ArgumentError, _("data must be a string, not %{class_name}") % { class_name: args[:data].class } end + from_string_to_wide_string(args[:data]) do |message_ptr| FFI::MemoryPointer.new(:pointer) do |message_array_ptr| message_array_ptr.write_pointer(message_ptr) diff --git a/lib/puppet/util/windows/file.rb b/lib/puppet/util/windows/file.rb index dc17fae7e87..9e020d5e59a 100644 --- a/lib/puppet/util/windows/file.rb +++ b/lib/puppet/util/windows/file.rb @@ -28,6 +28,7 @@ def replace_file(target, source) ) return true if result != FFI::WIN32_FALSE + raise Puppet::Util::Windows::Error.new("ReplaceFile(#{target}, #{source})") end module_function :replace_file @@ -38,6 +39,7 @@ def move_file_ex(source, target, flags = 0) flags) return true if result != FFI::WIN32_FALSE + raise Puppet::Util::Windows::Error .new("MoveFileEx(#{source}, #{target}, #{flags.to_s(8)})") end @@ -48,6 +50,7 @@ def symlink(target, symlink) result = CreateSymbolicLinkW(wide_string(symlink.to_s), wide_string(target.to_s), flags) return true if result != FFI::WIN32_FALSE + raise Puppet::Util::Windows::Error.new( "CreateSymbolicLink(#{symlink}, #{target}, #{flags.to_s(8)})") end @@ -131,6 +134,7 @@ def self.create_file(file_name, desired_access, share_mode, security_attributes, flags_and_attributes, template_file_handle) return result unless result == INVALID_HANDLE_VALUE + raise Puppet::Util::Windows::Error.new( "CreateFile(#{file_name}, #{desired_access.to_s(8)}, #{share_mode.to_s(8)}, " + "#{security_attributes}, #{creation_disposition.to_s(8)}, " + @@ -206,6 +210,7 @@ def reparse_point?(file_name) attributes = get_attributes(file_name, false) return false if (attributes == INVALID_FILE_ATTRIBUTES) + (attributes & FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT end module_function :reparse_point? diff --git a/lib/puppet/util/windows/principal.rb b/lib/puppet/util/windows/principal.rb index bbaaac08d95..d33398c24e5 100644 --- a/lib/puppet/util/windows/principal.rb +++ b/lib/puppet/util/windows/principal.rb @@ -149,6 +149,7 @@ def self.lookup_account_sid(system_name = nil, sid_bytes) # Sanitize the given account name for lookup to avoid known issues def self.sanitize_account_name(account_name) return account_name unless account_name.start_with?('APPLICATION PACKAGE AUTHORITY\\') + account_name.split('\\').last end private_class_method :sanitize_account_name diff --git a/lib/puppet/util/windows/process.rb b/lib/puppet/util/windows/process.rb index f9566523fac..67c7ace02c3 100644 --- a/lib/puppet/util/windows/process.rb +++ b/lib/puppet/util/windows/process.rb @@ -46,6 +46,7 @@ def wait_process(handle) if GetExitCodeProcess(handle, exit_status_ptr) == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Failed to get child process exit code")) end + exit_status = exit_status_ptr.read_dword # $CHILD_STATUS is not set when calling win32/process Process.create diff --git a/lib/puppet/util/windows/registry.rb b/lib/puppet/util/windows/registry.rb index 6c627bd27de..bb3c832d4de 100644 --- a/lib/puppet/util/windows/registry.rb +++ b/lib/puppet/util/windows/registry.rb @@ -256,6 +256,7 @@ def read(key, name_ptr, *rtype) end rescue IndexError => ex raise if (ex.message !~ /^Memory access .* is out of bounds$/i) + parent_key_name = key.parent ? "#{key.parent.keyname}\\" : "" Puppet.warning _("A value in the registry key %{parent_key_name}%{key} is corrupt or invalid") % { parent_key_name: parent_key_name, key: key.keyname } end diff --git a/lib/puppet/util/windows/security.rb b/lib/puppet/util/windows/security.rb index 768ab69fefb..8ac2d0491dd 100644 --- a/lib/puppet/util/windows/security.rb +++ b/lib/puppet/util/windows/security.rb @@ -174,6 +174,7 @@ def supports_acl?(path) flags_ptr, FFI::Pointer::NULL, 0) == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Failed to get volume information")) end + supported = flags_ptr.read_dword & FILE_PERSISTENT_ACLS == FILE_PERSISTENT_ACLS end diff --git a/lib/puppet/util/windows/service.rb b/lib/puppet/util/windows/service.rb index d19baeb39f4..a46411034e0 100644 --- a/lib/puppet/util/windows/service.rb +++ b/lib/puppet/util/windows/service.rb @@ -28,6 +28,7 @@ def exists?(service_name) end rescue Puppet::Util::Windows::Error => e return false if e.code == ERROR_SERVICE_DOES_NOT_EXIST + raise e end module_function :exists? @@ -111,6 +112,7 @@ def service_state(service_name) if state.nil? raise Puppet::Error.new(_("Unknown Service state '%{current_state}' for '%{service_name}'") % { current_state: state.to_s, service_name: service_name}) end + state end module_function :service_state @@ -138,6 +140,7 @@ def service_start_type(service_name) if start_type.nil? raise Puppet::Error.new(_("Unknown start type '%{start_type}' for '%{service_name}'") % { start_type: start_type.to_s, service_name: service_name}) end + start_type end module_function :service_start_type @@ -253,6 +256,7 @@ def services if success == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Failed to fetch services")) end + # Now that the buffer is populated with services # we pull the data from memory using pointer arithmetic: # the number of services returned by the function is @@ -301,6 +305,7 @@ def open_service(service_name, scm_access, service_access, &block) open_scm(scm_access) do |scm| service = OpenServiceW(scm, wide_string(service_name), service_access) raise Puppet::Util::Windows::Error.new(_("Failed to open a handle to the service")) if service == FFI::Pointer::NULL_HANDLE + result = yield service end @@ -318,6 +323,7 @@ def open_service(service_name, scm_access, service_access, &block) def open_scm(scm_access, &block) scm = OpenSCManagerW(FFI::Pointer::NULL, FFI::Pointer::NULL, scm_access) raise Puppet::Util::Windows::Error.new(_("Failed to open a handle to the service control manager")) if scm == FFI::Pointer::NULL_HANDLE + yield scm ensure CloseServiceHandle(scm) @@ -434,6 +440,7 @@ def query_status(service) if success == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Service query failed")) end + yield status end end @@ -470,6 +477,7 @@ def query_config(service, &block) if success == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Service query failed")) end + yield config end end @@ -513,6 +521,7 @@ def query_config2(service, info_level, &block) if success == FFI::WIN32_FALSE raise Puppet::Util::Windows::Error.new(_("Service query for %{parameter_name} failed") % { parameter_name: SERVICE_CONFIG_TYPES[info_level] } ) end + yield config end end @@ -595,6 +604,7 @@ def wait_on_state_transition(service, initial_state, final_state, timeout) query_status(service) do |status| state = status[:dwCurrentState] return if state == final_state + if state == pending_state Puppet.debug _("The service transitioned to the %{pending_state} state.") % { pending_state: SERVICE_STATES[pending_state] } wait_on_pending_state(service, pending_state, timeout) diff --git a/lib/puppet/util/windows/sid.rb b/lib/puppet/util/windows/sid.rb index 7fea1e58903..656bc1f0fd3 100644 --- a/lib/puppet/util/windows/sid.rb +++ b/lib/puppet/util/windows/sid.rb @@ -117,6 +117,7 @@ def ads_to_principal(ads_object) !ads_object.ole_respond_to?(:objectSID) || !ads_object.ole_respond_to?(:Name) raise Puppet::Error.new("ads_object must be an IAdsUser or IAdsGroup instance") end + octet_string_to_principal(ads_object.objectSID) rescue Puppet::Util::Windows::Error => e # if the error is not a lookup / mapping problem, immediately re-raise diff --git a/lib/puppet/version.rb b/lib/puppet/version.rb index faf73a24304..f566b79adc0 100644 --- a/lib/puppet/version.rb +++ b/lib/puppet/version.rb @@ -62,6 +62,7 @@ module Puppet def self.version version_file = File.join(File.dirname(__FILE__), 'VERSION') return @puppet_version if @puppet_version + @puppet_version = read_version_file(version_file) || PUPPETVERSION end diff --git a/lib/puppet/x509/cert_provider.rb b/lib/puppet/x509/cert_provider.rb index 3bd1ab29c37..c721fd1f695 100644 --- a/lib/puppet/x509/cert_provider.rb +++ b/lib/puppet/x509/cert_provider.rb @@ -58,6 +58,7 @@ def load_cacerts(required: false) if !pem && required raise Puppet::Error, _("The CA certificates are missing from '%{path}'") % { path: @capath } end + pem ? load_cacerts_from_pem(pem) : nil rescue SystemCallError => e raise Puppet::Error.new(_("Failed to load CA certificates from '%{capath}'") % {capath: @capath}, e) @@ -104,6 +105,7 @@ def load_crls(required: false) if !pem && required raise Puppet::Error, _("The CRL is missing from '%{path}'") % { path: @crlpath } end + pem ? load_crls_from_pem(pem) : nil rescue SystemCallError => e raise Puppet::Error.new(_("Failed to load CRLs from '%{crlpath}'") % {crlpath: @crlpath}, e) @@ -212,6 +214,7 @@ def load_private_key(name, required: false, password: nil) if !pem && required raise Puppet::Error, _("The private key is missing from '%{path}'") % { path: path } end + pem ? load_private_key_from_pem(pem, password: password) : nil rescue SystemCallError => e raise Puppet::Error.new(_("Failed to load private key for '%{name}'") % {name: name}, e) @@ -275,6 +278,7 @@ def load_client_cert(name, required: false) if !pem && required raise Puppet::Error, _("The client certificate is missing from '%{path}'") % { path: path } end + pem ? load_client_cert_from_pem(pem) : nil rescue SystemCallError => e raise Puppet::Error.new(_("Failed to load client certificate for '%{name}'") % {name: name}, e) @@ -382,6 +386,7 @@ def load_request_from_pem(pem) # @param name [String] the name associated with the cert related object def to_path(base, name) raise _("Certname %{name} must not contain unprintable or non-ASCII characters") % { name: name.inspect } unless name =~ VALID_CERTNAME + File.join(base, "#{name.downcase}.pem") end diff --git a/util/rspec_grouper b/util/rspec_grouper index b7eab2aa109..5746768c29d 100755 --- a/util/rspec_grouper +++ b/util/rspec_grouper @@ -57,6 +57,7 @@ module Parallel def count_examples(group) return 0 unless group + # Each group can have examples as well as child groups, so recursively traverse group.children.inject(group.examples.count) { |count, g| count + count_examples(g) } end From e7492be7c352aa12efc69a88d24a7cb704204091 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Tue, 19 Dec 2023 13:35:41 -0800 Subject: [PATCH 17/17] Layout/EmptyLineAfterMagicComment This commit enables the Rubocop Layout/EmptyLineAfterMagicComment cop and fixes all offenses. --- .rubocop_todo.yml | 4 ---- lib/hiera/puppet_function.rb | 1 + lib/hiera/scope.rb | 1 + lib/hiera_puppet.rb | 1 + lib/puppet.rb | 1 + lib/puppet/agent.rb | 1 + lib/puppet/agent/disabler.rb | 1 + lib/puppet/agent/locker.rb | 1 + lib/puppet/application.rb | 1 + lib/puppet/application/agent.rb | 1 + lib/puppet/application/apply.rb | 1 + lib/puppet/application/catalog.rb | 1 + lib/puppet/application/config.rb | 1 + lib/puppet/application/describe.rb | 1 + lib/puppet/application/device.rb | 1 + lib/puppet/application/doc.rb | 1 + lib/puppet/application/epp.rb | 1 + lib/puppet/application/face_base.rb | 1 + lib/puppet/application/facts.rb | 1 + lib/puppet/application/filebucket.rb | 1 + lib/puppet/application/generate.rb | 1 + lib/puppet/application/help.rb | 1 + lib/puppet/application/indirection_base.rb | 1 + lib/puppet/application/lookup.rb | 1 + lib/puppet/application/module.rb | 1 + lib/puppet/application/node.rb | 1 + lib/puppet/application/parser.rb | 1 + lib/puppet/application/plugin.rb | 1 + lib/puppet/application/report.rb | 1 + lib/puppet/application/resource.rb | 1 + lib/puppet/application/script.rb | 1 + lib/puppet/application/ssl.rb | 1 + lib/puppet/application_support.rb | 1 + lib/puppet/coercion.rb | 1 + lib/puppet/compilable_resource_type.rb | 1 + lib/puppet/concurrent.rb | 1 + lib/puppet/concurrent/lock.rb | 1 + lib/puppet/concurrent/synchronized.rb | 1 + lib/puppet/concurrent/thread_local_singleton.rb | 1 + lib/puppet/configurer.rb | 1 + lib/puppet/configurer/downloader.rb | 1 + lib/puppet/configurer/fact_handler.rb | 1 + lib/puppet/configurer/plugin_handler.rb | 1 + lib/puppet/confine.rb | 1 + lib/puppet/confine/any.rb | 1 + lib/puppet/confine/boolean.rb | 1 + lib/puppet/confine/exists.rb | 1 + lib/puppet/confine/false.rb | 1 + lib/puppet/confine/feature.rb | 1 + lib/puppet/confine/true.rb | 1 + lib/puppet/confine/variable.rb | 1 + lib/puppet/confine_collection.rb | 1 + lib/puppet/confiner.rb | 1 + lib/puppet/context.rb | 1 + lib/puppet/context/trusted_information.rb | 1 + lib/puppet/daemon.rb | 1 + lib/puppet/data_binding.rb | 1 + lib/puppet/datatypes.rb | 1 + lib/puppet/datatypes/error.rb | 1 + lib/puppet/datatypes/impl/error.rb | 1 + lib/puppet/defaults.rb | 1 + lib/puppet/environments.rb | 1 + lib/puppet/error.rb | 1 + lib/puppet/etc.rb | 1 + lib/puppet/external/dot.rb | 1 + lib/puppet/face.rb | 1 + lib/puppet/face/catalog.rb | 1 + lib/puppet/face/catalog/select.rb | 1 + lib/puppet/face/config.rb | 1 + lib/puppet/face/epp.rb | 1 + lib/puppet/face/facts.rb | 1 + lib/puppet/face/generate.rb | 1 + lib/puppet/face/help.rb | 1 + lib/puppet/face/module.rb | 1 + lib/puppet/face/module/changes.rb | 1 + lib/puppet/face/module/install.rb | 1 + lib/puppet/face/module/uninstall.rb | 1 + lib/puppet/face/node.rb | 1 + lib/puppet/face/node/clean.rb | 1 + lib/puppet/face/parser.rb | 1 + lib/puppet/face/plugin.rb | 1 + lib/puppet/face/report.rb | 1 + lib/puppet/face/resource.rb | 1 + lib/puppet/feature/base.rb | 1 + lib/puppet/feature/bolt.rb | 1 + lib/puppet/feature/cfpropertylist.rb | 1 + lib/puppet/feature/eventlog.rb | 1 + lib/puppet/feature/hiera_eyaml.rb | 1 + lib/puppet/feature/hocon.rb | 1 + lib/puppet/feature/libuser.rb | 1 + lib/puppet/feature/msgpack.rb | 1 + lib/puppet/feature/pe_license.rb | 1 + lib/puppet/feature/pson.rb | 1 + lib/puppet/feature/selinux.rb | 1 + lib/puppet/feature/ssh.rb | 1 + lib/puppet/feature/telnet.rb | 1 + lib/puppet/feature/zlib.rb | 1 + lib/puppet/ffi/posix.rb | 1 + lib/puppet/ffi/posix/constants.rb | 1 + lib/puppet/ffi/posix/functions.rb | 1 + lib/puppet/ffi/windows.rb | 1 + lib/puppet/ffi/windows/api_types.rb | 1 + lib/puppet/ffi/windows/constants.rb | 1 + lib/puppet/ffi/windows/functions.rb | 1 + lib/puppet/ffi/windows/structs.rb | 1 + lib/puppet/file_bucket.rb | 1 + lib/puppet/file_bucket/dipper.rb | 1 + lib/puppet/file_bucket/file.rb | 1 + lib/puppet/file_serving.rb | 1 + lib/puppet/file_serving/base.rb | 1 + lib/puppet/file_serving/configuration.rb | 1 + lib/puppet/file_serving/configuration/parser.rb | 1 + lib/puppet/file_serving/content.rb | 1 + lib/puppet/file_serving/fileset.rb | 1 + lib/puppet/file_serving/http_metadata.rb | 1 + lib/puppet/file_serving/metadata.rb | 1 + lib/puppet/file_serving/mount.rb | 1 + lib/puppet/file_serving/mount/file.rb | 1 + lib/puppet/file_serving/mount/locales.rb | 1 + lib/puppet/file_serving/mount/modules.rb | 1 + lib/puppet/file_serving/mount/pluginfacts.rb | 1 + lib/puppet/file_serving/mount/plugins.rb | 1 + lib/puppet/file_serving/mount/scripts.rb | 1 + lib/puppet/file_serving/mount/tasks.rb | 1 + lib/puppet/file_serving/terminus_helper.rb | 1 + lib/puppet/file_serving/terminus_selector.rb | 1 + lib/puppet/file_system.rb | 1 + lib/puppet/file_system/file_impl.rb | 1 + lib/puppet/file_system/jruby.rb | 1 + lib/puppet/file_system/memory_file.rb | 1 + lib/puppet/file_system/memory_impl.rb | 1 + lib/puppet/file_system/path_pattern.rb | 1 + lib/puppet/file_system/posix.rb | 1 + lib/puppet/file_system/uniquefile.rb | 1 + lib/puppet/file_system/windows.rb | 1 + lib/puppet/forge.rb | 1 + lib/puppet/forge/cache.rb | 1 + lib/puppet/forge/errors.rb | 1 + lib/puppet/forge/repository.rb | 1 + lib/puppet/functions.rb | 1 + lib/puppet/functions/abs.rb | 1 + lib/puppet/functions/alert.rb | 1 + lib/puppet/functions/all.rb | 1 + lib/puppet/functions/annotate.rb | 1 + lib/puppet/functions/any.rb | 1 + lib/puppet/functions/assert_type.rb | 1 + lib/puppet/functions/binary_file.rb | 1 + lib/puppet/functions/break.rb | 1 + lib/puppet/functions/call.rb | 1 + lib/puppet/functions/camelcase.rb | 1 + lib/puppet/functions/capitalize.rb | 1 + lib/puppet/functions/ceiling.rb | 1 + lib/puppet/functions/chomp.rb | 1 + lib/puppet/functions/chop.rb | 1 + lib/puppet/functions/compare.rb | 1 + lib/puppet/functions/contain.rb | 1 + lib/puppet/functions/convert_to.rb | 1 + lib/puppet/functions/crit.rb | 1 + lib/puppet/functions/debug.rb | 1 + lib/puppet/functions/defined.rb | 1 + lib/puppet/functions/dig.rb | 1 + lib/puppet/functions/downcase.rb | 1 + lib/puppet/functions/each.rb | 1 + lib/puppet/functions/emerg.rb | 1 + lib/puppet/functions/empty.rb | 1 + lib/puppet/functions/epp.rb | 1 + lib/puppet/functions/err.rb | 1 + lib/puppet/functions/eyaml_lookup_key.rb | 1 + lib/puppet/functions/filter.rb | 1 + lib/puppet/functions/find_file.rb | 1 + lib/puppet/functions/find_template.rb | 1 + lib/puppet/functions/flatten.rb | 1 + lib/puppet/functions/floor.rb | 1 + lib/puppet/functions/get.rb | 1 + lib/puppet/functions/getvar.rb | 1 + lib/puppet/functions/hiera.rb | 1 + lib/puppet/functions/hiera_array.rb | 1 + lib/puppet/functions/hiera_hash.rb | 1 + lib/puppet/functions/hiera_include.rb | 1 + lib/puppet/functions/hocon_data.rb | 1 + lib/puppet/functions/import.rb | 1 + lib/puppet/functions/include.rb | 1 + lib/puppet/functions/index.rb | 1 + lib/puppet/functions/info.rb | 1 + lib/puppet/functions/inline_epp.rb | 1 + lib/puppet/functions/join.rb | 1 + lib/puppet/functions/json_data.rb | 1 + lib/puppet/functions/keys.rb | 1 + lib/puppet/functions/length.rb | 1 + lib/puppet/functions/lest.rb | 1 + lib/puppet/functions/lookup.rb | 1 + lib/puppet/functions/lstrip.rb | 1 + lib/puppet/functions/map.rb | 1 + lib/puppet/functions/match.rb | 1 + lib/puppet/functions/max.rb | 1 + lib/puppet/functions/min.rb | 1 + lib/puppet/functions/module_directory.rb | 1 + lib/puppet/functions/new.rb | 1 + lib/puppet/functions/next.rb | 1 + lib/puppet/functions/notice.rb | 1 + lib/puppet/functions/reduce.rb | 1 + lib/puppet/functions/regsubst.rb | 1 + lib/puppet/functions/require.rb | 1 + lib/puppet/functions/return.rb | 1 + lib/puppet/functions/reverse_each.rb | 1 + lib/puppet/functions/round.rb | 1 + lib/puppet/functions/rstrip.rb | 1 + lib/puppet/functions/scanf.rb | 1 + lib/puppet/functions/size.rb | 1 + lib/puppet/functions/slice.rb | 1 + lib/puppet/functions/sort.rb | 1 + lib/puppet/functions/split.rb | 1 + lib/puppet/functions/step.rb | 1 + lib/puppet/functions/strftime.rb | 1 + lib/puppet/functions/strip.rb | 1 + lib/puppet/functions/then.rb | 1 + lib/puppet/functions/tree_each.rb | 1 + lib/puppet/functions/type.rb | 1 + lib/puppet/functions/unique.rb | 1 + lib/puppet/functions/unwrap.rb | 1 + lib/puppet/functions/upcase.rb | 1 + lib/puppet/functions/values.rb | 1 + lib/puppet/functions/versioncmp.rb | 1 + lib/puppet/functions/warning.rb | 1 + lib/puppet/functions/with.rb | 1 + lib/puppet/generate/models/type/property.rb | 1 + lib/puppet/generate/models/type/type.rb | 1 + lib/puppet/generate/type.rb | 1 + lib/puppet/gettext/config.rb | 1 + lib/puppet/gettext/module_translations.rb | 1 + lib/puppet/gettext/stubs.rb | 1 + lib/puppet/graph.rb | 1 + lib/puppet/graph/key.rb | 1 + lib/puppet/graph/prioritizer.rb | 1 + lib/puppet/graph/rb_tree_map.rb | 1 + lib/puppet/graph/relationship_graph.rb | 1 + lib/puppet/graph/sequential_prioritizer.rb | 1 + lib/puppet/graph/simple_graph.rb | 1 + lib/puppet/http.rb | 1 + lib/puppet/http/client.rb | 1 + lib/puppet/http/dns.rb | 1 + lib/puppet/http/errors.rb | 1 + lib/puppet/http/external_client.rb | 1 + lib/puppet/http/factory.rb | 1 + lib/puppet/http/pool.rb | 1 + lib/puppet/http/pool_entry.rb | 1 + lib/puppet/http/proxy.rb | 1 + lib/puppet/http/redirector.rb | 1 + lib/puppet/http/resolver.rb | 1 + lib/puppet/http/resolver/server_list.rb | 1 + lib/puppet/http/resolver/settings.rb | 1 + lib/puppet/http/resolver/srv.rb | 1 + lib/puppet/http/response.rb | 1 + lib/puppet/http/response_converter.rb | 1 + lib/puppet/http/response_net_http.rb | 1 + lib/puppet/http/retry_after_handler.rb | 1 + lib/puppet/http/service.rb | 1 + lib/puppet/http/service/ca.rb | 1 + lib/puppet/http/service/compiler.rb | 1 + lib/puppet/http/service/file_server.rb | 1 + lib/puppet/http/service/puppetserver.rb | 1 + lib/puppet/http/service/report.rb | 1 + lib/puppet/http/session.rb | 1 + lib/puppet/http/site.rb | 1 + lib/puppet/indirector.rb | 1 + lib/puppet/indirector/catalog/compiler.rb | 1 + lib/puppet/indirector/catalog/json.rb | 1 + lib/puppet/indirector/catalog/msgpack.rb | 1 + lib/puppet/indirector/catalog/rest.rb | 1 + lib/puppet/indirector/catalog/store_configs.rb | 1 + lib/puppet/indirector/catalog/yaml.rb | 1 + lib/puppet/indirector/code.rb | 1 + lib/puppet/indirector/data_binding/hiera.rb | 1 + lib/puppet/indirector/data_binding/none.rb | 1 + lib/puppet/indirector/direct_file_server.rb | 1 + lib/puppet/indirector/envelope.rb | 1 + lib/puppet/indirector/errors.rb | 1 + lib/puppet/indirector/exec.rb | 1 + lib/puppet/indirector/face.rb | 1 + lib/puppet/indirector/fact_search.rb | 1 + lib/puppet/indirector/facts/facter.rb | 1 + lib/puppet/indirector/facts/json.rb | 1 + lib/puppet/indirector/facts/memory.rb | 1 + lib/puppet/indirector/facts/network_device.rb | 1 + lib/puppet/indirector/facts/rest.rb | 1 + lib/puppet/indirector/facts/store_configs.rb | 1 + lib/puppet/indirector/facts/yaml.rb | 1 + lib/puppet/indirector/file_bucket_file/file.rb | 1 + lib/puppet/indirector/file_bucket_file/rest.rb | 1 + lib/puppet/indirector/file_bucket_file/selector.rb | 1 + lib/puppet/indirector/file_content.rb | 1 + lib/puppet/indirector/file_content/file.rb | 1 + lib/puppet/indirector/file_content/file_server.rb | 1 + lib/puppet/indirector/file_content/rest.rb | 1 + lib/puppet/indirector/file_content/selector.rb | 1 + lib/puppet/indirector/file_metadata.rb | 1 + lib/puppet/indirector/file_metadata/file.rb | 1 + lib/puppet/indirector/file_metadata/file_server.rb | 1 + lib/puppet/indirector/file_metadata/http.rb | 1 + lib/puppet/indirector/file_metadata/rest.rb | 1 + lib/puppet/indirector/file_metadata/selector.rb | 1 + lib/puppet/indirector/file_server.rb | 1 + lib/puppet/indirector/generic_http.rb | 1 + lib/puppet/indirector/hiera.rb | 1 + lib/puppet/indirector/indirection.rb | 1 + lib/puppet/indirector/json.rb | 1 + lib/puppet/indirector/memory.rb | 1 + lib/puppet/indirector/msgpack.rb | 1 + lib/puppet/indirector/node/exec.rb | 1 + lib/puppet/indirector/node/json.rb | 1 + lib/puppet/indirector/node/memory.rb | 1 + lib/puppet/indirector/node/msgpack.rb | 1 + lib/puppet/indirector/node/plain.rb | 1 + lib/puppet/indirector/node/rest.rb | 1 + lib/puppet/indirector/node/store_configs.rb | 1 + lib/puppet/indirector/node/yaml.rb | 1 + lib/puppet/indirector/none.rb | 1 + lib/puppet/indirector/plain.rb | 1 + lib/puppet/indirector/report/json.rb | 1 + lib/puppet/indirector/report/msgpack.rb | 1 + lib/puppet/indirector/report/processor.rb | 1 + lib/puppet/indirector/report/rest.rb | 1 + lib/puppet/indirector/report/yaml.rb | 1 + lib/puppet/indirector/request.rb | 1 + lib/puppet/indirector/resource/ral.rb | 1 + lib/puppet/indirector/resource/store_configs.rb | 1 + lib/puppet/indirector/resource/validator.rb | 1 + lib/puppet/indirector/rest.rb | 1 + lib/puppet/indirector/store_configs.rb | 1 + lib/puppet/indirector/terminus.rb | 1 + lib/puppet/indirector/yaml.rb | 1 + lib/puppet/info_service/class_information_service.rb | 1 + lib/puppet/info_service/plan_information_service.rb | 1 + lib/puppet/info_service/task_information_service.rb | 1 + lib/puppet/interface.rb | 1 + lib/puppet/interface/action.rb | 1 + lib/puppet/interface/action_builder.rb | 1 + lib/puppet/interface/action_manager.rb | 1 + lib/puppet/interface/documentation.rb | 1 + lib/puppet/interface/face_collection.rb | 1 + lib/puppet/interface/option.rb | 1 + lib/puppet/interface/option_builder.rb | 1 + lib/puppet/interface/option_manager.rb | 1 + lib/puppet/loaders.rb | 1 + lib/puppet/metatype/manager.rb | 1 + lib/puppet/module.rb | 1 + lib/puppet/module/plan.rb | 1 + lib/puppet/module/task.rb | 1 + lib/puppet/module_tool.rb | 1 + lib/puppet/module_tool/applications.rb | 1 + lib/puppet/module_tool/applications/application.rb | 1 + lib/puppet/module_tool/applications/checksummer.rb | 1 + lib/puppet/module_tool/applications/installer.rb | 1 + lib/puppet/module_tool/applications/uninstaller.rb | 1 + lib/puppet/module_tool/applications/unpacker.rb | 1 + lib/puppet/module_tool/applications/upgrader.rb | 1 + lib/puppet/module_tool/checksums.rb | 1 + lib/puppet/module_tool/contents_description.rb | 1 + lib/puppet/module_tool/dependency.rb | 1 + lib/puppet/module_tool/errors.rb | 1 + lib/puppet/module_tool/errors/base.rb | 1 + lib/puppet/module_tool/errors/installer.rb | 1 + lib/puppet/module_tool/errors/shared.rb | 1 + lib/puppet/module_tool/errors/uninstaller.rb | 1 + lib/puppet/module_tool/errors/upgrader.rb | 1 + lib/puppet/module_tool/install_directory.rb | 1 + lib/puppet/module_tool/installed_modules.rb | 1 + lib/puppet/module_tool/local_tarball.rb | 1 + lib/puppet/module_tool/metadata.rb | 1 + lib/puppet/module_tool/shared_behaviors.rb | 1 + lib/puppet/module_tool/tar.rb | 1 + lib/puppet/module_tool/tar/gnu.rb | 1 + lib/puppet/module_tool/tar/mini.rb | 1 + lib/puppet/network.rb | 1 + lib/puppet/network/authconfig.rb | 1 + lib/puppet/network/authorization.rb | 1 + lib/puppet/network/client_request.rb | 1 + lib/puppet/network/format.rb | 1 + lib/puppet/network/format_handler.rb | 1 + lib/puppet/network/format_support.rb | 1 + lib/puppet/network/formats.rb | 1 + lib/puppet/network/http.rb | 1 + lib/puppet/network/http/api.rb | 1 + lib/puppet/network/http/api/indirected_routes.rb | 1 + lib/puppet/network/http/api/indirection_type.rb | 1 + lib/puppet/network/http/api/master.rb | 1 + lib/puppet/network/http/api/master/v3.rb | 1 + lib/puppet/network/http/api/master/v3/environments.rb | 1 + lib/puppet/network/http/api/server.rb | 1 + lib/puppet/network/http/api/server/v3.rb | 1 + lib/puppet/network/http/api/server/v3/environments.rb | 1 + lib/puppet/network/http/connection.rb | 1 + lib/puppet/network/http/error.rb | 1 + lib/puppet/network/http/handler.rb | 1 + lib/puppet/network/http/issues.rb | 1 + lib/puppet/network/http/memory_response.rb | 1 + lib/puppet/network/http/response.rb | 1 + lib/puppet/network/http/route.rb | 1 + lib/puppet/network/http_pool.rb | 1 + lib/puppet/network/uri.rb | 1 + lib/puppet/node.rb | 1 + lib/puppet/node/environment.rb | 1 + lib/puppet/node/facts.rb | 1 + lib/puppet/pal/catalog_compiler.rb | 1 + lib/puppet/pal/compiler.rb | 1 + lib/puppet/pal/function_signature.rb | 1 + lib/puppet/pal/json_catalog_encoder.rb | 1 + lib/puppet/pal/pal_api.rb | 1 + lib/puppet/pal/pal_impl.rb | 1 + lib/puppet/pal/plan_signature.rb | 1 + lib/puppet/pal/script_compiler.rb | 1 + lib/puppet/pal/task_signature.rb | 1 + lib/puppet/parameter.rb | 1 + lib/puppet/parameter/boolean.rb | 1 + lib/puppet/parameter/package_options.rb | 1 + lib/puppet/parameter/path.rb | 1 + lib/puppet/parameter/value.rb | 1 + lib/puppet/parameter/value_collection.rb | 1 + lib/puppet/parser.rb | 1 + lib/puppet/parser/ast.rb | 1 + lib/puppet/parser/ast/block_expression.rb | 1 + lib/puppet/parser/ast/branch.rb | 1 + lib/puppet/parser/ast/hostclass.rb | 1 + lib/puppet/parser/ast/leaf.rb | 1 + lib/puppet/parser/ast/node.rb | 1 + lib/puppet/parser/ast/pops_bridge.rb | 1 + lib/puppet/parser/ast/resource.rb | 1 + lib/puppet/parser/ast/resource_instance.rb | 1 + lib/puppet/parser/ast/resourceparam.rb | 1 + lib/puppet/parser/ast/top_level_construct.rb | 1 + lib/puppet/parser/catalog_compiler.rb | 1 + lib/puppet/parser/compiler.rb | 1 + lib/puppet/parser/compiler/catalog_validator.rb | 1 + .../compiler/catalog_validator/relationship_validator.rb | 1 + lib/puppet/parser/e4_parser_adapter.rb | 1 + lib/puppet/parser/files.rb | 1 + lib/puppet/parser/functions.rb | 1 + lib/puppet/parser/functions/assert_type.rb | 1 + lib/puppet/parser/functions/binary_file.rb | 1 + lib/puppet/parser/functions/break.rb | 1 + lib/puppet/parser/functions/contain.rb | 1 + lib/puppet/parser/functions/create_resources.rb | 1 + lib/puppet/parser/functions/defined.rb | 1 + lib/puppet/parser/functions/dig.rb | 1 + lib/puppet/parser/functions/digest.rb | 1 + lib/puppet/parser/functions/each.rb | 1 + lib/puppet/parser/functions/epp.rb | 1 + lib/puppet/parser/functions/fail.rb | 1 + lib/puppet/parser/functions/file.rb | 1 + lib/puppet/parser/functions/filter.rb | 1 + lib/puppet/parser/functions/find_file.rb | 1 + lib/puppet/parser/functions/fqdn_rand.rb | 1 + lib/puppet/parser/functions/generate.rb | 1 + lib/puppet/parser/functions/hiera.rb | 1 + lib/puppet/parser/functions/hiera_array.rb | 1 + lib/puppet/parser/functions/hiera_hash.rb | 1 + lib/puppet/parser/functions/hiera_include.rb | 1 + lib/puppet/parser/functions/include.rb | 1 + lib/puppet/parser/functions/inline_epp.rb | 1 + lib/puppet/parser/functions/inline_template.rb | 1 + lib/puppet/parser/functions/lest.rb | 1 + lib/puppet/parser/functions/lookup.rb | 1 + lib/puppet/parser/functions/map.rb | 1 + lib/puppet/parser/functions/match.rb | 1 + lib/puppet/parser/functions/md5.rb | 1 + lib/puppet/parser/functions/new.rb | 1 + lib/puppet/parser/functions/next.rb | 1 + lib/puppet/parser/functions/realize.rb | 1 + lib/puppet/parser/functions/reduce.rb | 1 + lib/puppet/parser/functions/regsubst.rb | 1 + lib/puppet/parser/functions/require.rb | 1 + lib/puppet/parser/functions/return.rb | 1 + lib/puppet/parser/functions/reverse_each.rb | 1 + lib/puppet/parser/functions/scanf.rb | 1 + lib/puppet/parser/functions/sha1.rb | 1 + lib/puppet/parser/functions/sha256.rb | 1 + lib/puppet/parser/functions/shellquote.rb | 1 + lib/puppet/parser/functions/slice.rb | 1 + lib/puppet/parser/functions/split.rb | 1 + lib/puppet/parser/functions/sprintf.rb | 1 + lib/puppet/parser/functions/step.rb | 1 + lib/puppet/parser/functions/strftime.rb | 1 + lib/puppet/parser/functions/tag.rb | 1 + lib/puppet/parser/functions/tagged.rb | 1 + lib/puppet/parser/functions/template.rb | 1 + lib/puppet/parser/functions/then.rb | 1 + lib/puppet/parser/functions/type.rb | 1 + lib/puppet/parser/functions/versioncmp.rb | 1 + lib/puppet/parser/functions/with.rb | 1 + lib/puppet/parser/parser_factory.rb | 1 + lib/puppet/parser/relationship.rb | 1 + lib/puppet/parser/resource.rb | 1 + lib/puppet/parser/resource/param.rb | 1 + lib/puppet/parser/scope.rb | 1 + lib/puppet/parser/script_compiler.rb | 1 + lib/puppet/parser/templatewrapper.rb | 1 + lib/puppet/parser/type_loader.rb | 1 + lib/puppet/plugins.rb | 1 + lib/puppet/plugins/configuration.rb | 1 + lib/puppet/plugins/syntax_checkers.rb | 1 + lib/puppet/pops.rb | 1 + lib/puppet/pops/adaptable.rb | 1 + lib/puppet/pops/adapters.rb | 1 + lib/puppet/pops/evaluator/access_operator.rb | 1 + lib/puppet/pops/evaluator/callable_signature.rb | 1 + lib/puppet/pops/evaluator/closure.rb | 1 + lib/puppet/pops/evaluator/collector_transformer.rb | 1 + lib/puppet/pops/evaluator/collectors/abstract_collector.rb | 1 + lib/puppet/pops/evaluator/collectors/catalog_collector.rb | 1 + lib/puppet/pops/evaluator/collectors/exported_collector.rb | 1 + lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb | 1 + lib/puppet/pops/evaluator/compare_operator.rb | 1 + lib/puppet/pops/evaluator/deferred_resolver.rb | 1 + lib/puppet/pops/evaluator/epp_evaluator.rb | 1 + lib/puppet/pops/evaluator/evaluator_impl.rb | 1 + lib/puppet/pops/evaluator/external_syntax_support.rb | 1 + lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb | 1 + lib/puppet/pops/evaluator/literal_evaluator.rb | 1 + lib/puppet/pops/evaluator/puppet_proc.rb | 1 + lib/puppet/pops/evaluator/relationship_operator.rb | 1 + lib/puppet/pops/evaluator/runtime3_converter.rb | 1 + lib/puppet/pops/evaluator/runtime3_resource_support.rb | 1 + lib/puppet/pops/evaluator/runtime3_support.rb | 1 + lib/puppet/pops/functions/dispatch.rb | 1 + lib/puppet/pops/functions/dispatcher.rb | 1 + lib/puppet/pops/functions/function.rb | 1 + lib/puppet/pops/issue_reporter.rb | 1 + lib/puppet/pops/issues.rb | 1 + lib/puppet/pops/label_provider.rb | 1 + lib/puppet/pops/loader/base_loader.rb | 1 + lib/puppet/pops/loader/dependency_loader.rb | 1 + lib/puppet/pops/loader/gem_support.rb | 1 + lib/puppet/pops/loader/generic_plan_instantiator.rb | 1 + lib/puppet/pops/loader/loader.rb | 1 + lib/puppet/pops/loader/module_loaders.rb | 1 + lib/puppet/pops/loader/predefined_loader.rb | 1 + lib/puppet/pops/loader/puppet_function_instantiator.rb | 1 + lib/puppet/pops/loader/puppet_plan_instantiator.rb | 1 + .../pops/loader/puppet_resource_type_impl_instantiator.rb | 1 + lib/puppet/pops/loader/ruby_data_type_instantiator.rb | 1 + lib/puppet/pops/loader/ruby_function_instantiator.rb | 1 + lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb | 1 + lib/puppet/pops/loader/runtime3_type_loader.rb | 1 + lib/puppet/pops/loader/simple_environment_loader.rb | 1 + lib/puppet/pops/loader/static_loader.rb | 1 + lib/puppet/pops/loader/task_instantiator.rb | 1 + lib/puppet/pops/loader/type_definition_instantiator.rb | 1 + lib/puppet/pops/loader/typed_name.rb | 1 + lib/puppet/pops/loader/uri_helper.rb | 1 + lib/puppet/pops/loaders.rb | 1 + lib/puppet/pops/lookup.rb | 1 + lib/puppet/pops/lookup/configured_data_provider.rb | 1 + lib/puppet/pops/lookup/context.rb | 1 + lib/puppet/pops/lookup/data_adapter.rb | 1 + lib/puppet/pops/lookup/data_dig_function_provider.rb | 1 + lib/puppet/pops/lookup/data_hash_function_provider.rb | 1 + lib/puppet/pops/lookup/data_provider.rb | 1 + lib/puppet/pops/lookup/environment_data_provider.rb | 1 + lib/puppet/pops/lookup/explainer.rb | 1 + lib/puppet/pops/lookup/function_provider.rb | 1 + lib/puppet/pops/lookup/global_data_provider.rb | 1 + lib/puppet/pops/lookup/hiera_config.rb | 1 + lib/puppet/pops/lookup/interpolation.rb | 1 + lib/puppet/pops/lookup/invocation.rb | 1 + lib/puppet/pops/lookup/key_recorder.rb | 1 + lib/puppet/pops/lookup/location_resolver.rb | 1 + lib/puppet/pops/lookup/lookup_adapter.rb | 1 + lib/puppet/pops/lookup/lookup_key.rb | 1 + lib/puppet/pops/lookup/lookup_key_function_provider.rb | 1 + lib/puppet/pops/lookup/module_data_provider.rb | 1 + lib/puppet/pops/lookup/sub_lookup.rb | 1 + lib/puppet/pops/merge_strategy.rb | 1 + lib/puppet/pops/migration/migration_checker.rb | 1 + lib/puppet/pops/model/ast.rb | 1 + lib/puppet/pops/model/ast_transformer.rb | 1 + lib/puppet/pops/model/factory.rb | 1 + lib/puppet/pops/model/model_label_provider.rb | 1 + lib/puppet/pops/model/model_tree_dumper.rb | 1 + lib/puppet/pops/model/pn_transformer.rb | 1 + lib/puppet/pops/model/tree_dumper.rb | 1 + lib/puppet/pops/parser/epp_parser.rb | 1 + lib/puppet/pops/parser/epp_support.rb | 1 + lib/puppet/pops/parser/evaluating_parser.rb | 1 + lib/puppet/pops/parser/heredoc_support.rb | 1 + lib/puppet/pops/parser/interpolation_support.rb | 1 + lib/puppet/pops/parser/lexer2.rb | 1 + lib/puppet/pops/parser/locatable.rb | 1 + lib/puppet/pops/parser/locator.rb | 1 + lib/puppet/pops/parser/parser_support.rb | 1 + lib/puppet/pops/parser/pn_parser.rb | 1 + lib/puppet/pops/parser/slurp_support.rb | 1 + lib/puppet/pops/patterns.rb | 1 + lib/puppet/pops/pcore.rb | 1 + lib/puppet/pops/pn.rb | 1 + lib/puppet/pops/puppet_stack.rb | 1 + lib/puppet/pops/resource/param.rb | 1 + lib/puppet/pops/resource/resource_type_impl.rb | 1 + lib/puppet/pops/semantic_error.rb | 1 + lib/puppet/pops/serialization.rb | 1 + lib/puppet/pops/serialization/abstract_reader.rb | 1 + lib/puppet/pops/serialization/abstract_writer.rb | 1 + lib/puppet/pops/serialization/deserializer.rb | 1 + lib/puppet/pops/serialization/extension.rb | 1 + lib/puppet/pops/serialization/from_data_converter.rb | 1 + lib/puppet/pops/serialization/instance_reader.rb | 1 + lib/puppet/pops/serialization/instance_writer.rb | 1 + lib/puppet/pops/serialization/json.rb | 1 + lib/puppet/pops/serialization/json_path.rb | 1 + lib/puppet/pops/serialization/object.rb | 1 + lib/puppet/pops/serialization/serializer.rb | 1 + lib/puppet/pops/serialization/time_factory.rb | 1 + lib/puppet/pops/serialization/to_data_converter.rb | 1 + lib/puppet/pops/serialization/to_stringified_converter.rb | 1 + lib/puppet/pops/time/timespan.rb | 1 + lib/puppet/pops/time/timestamp.rb | 1 + lib/puppet/pops/types/annotatable.rb | 1 + lib/puppet/pops/types/annotation.rb | 1 + lib/puppet/pops/types/class_loader.rb | 1 + lib/puppet/pops/types/implementation_registry.rb | 1 + lib/puppet/pops/types/iterable.rb | 1 + lib/puppet/pops/types/p_binary_type.rb | 1 + lib/puppet/pops/types/p_init_type.rb | 1 + lib/puppet/pops/types/p_meta_type.rb | 1 + lib/puppet/pops/types/p_object_type.rb | 1 + lib/puppet/pops/types/p_object_type_extension.rb | 1 + lib/puppet/pops/types/p_runtime_type.rb | 1 + lib/puppet/pops/types/p_sem_ver_range_type.rb | 1 + lib/puppet/pops/types/p_sem_ver_type.rb | 1 + lib/puppet/pops/types/p_sensitive_type.rb | 1 + lib/puppet/pops/types/p_timespan_type.rb | 1 + lib/puppet/pops/types/p_timestamp_type.rb | 1 + lib/puppet/pops/types/p_type_set_type.rb | 1 + lib/puppet/pops/types/p_uri_type.rb | 1 + lib/puppet/pops/types/puppet_object.rb | 1 + lib/puppet/pops/types/recursion_guard.rb | 1 + lib/puppet/pops/types/ruby_generator.rb | 1 + lib/puppet/pops/types/ruby_method.rb | 1 + lib/puppet/pops/types/string_converter.rb | 1 + lib/puppet/pops/types/tree_iterators.rb | 1 + lib/puppet/pops/types/type_acceptor.rb | 1 + lib/puppet/pops/types/type_asserter.rb | 1 + lib/puppet/pops/types/type_calculator.rb | 1 + lib/puppet/pops/types/type_factory.rb | 1 + lib/puppet/pops/types/type_formatter.rb | 1 + lib/puppet/pops/types/type_mismatch_describer.rb | 1 + lib/puppet/pops/types/type_parser.rb | 1 + lib/puppet/pops/types/type_set_reference.rb | 1 + lib/puppet/pops/types/type_with_members.rb | 1 + lib/puppet/pops/types/types.rb | 1 + lib/puppet/pops/utils.rb | 1 + lib/puppet/pops/validation.rb | 1 + lib/puppet/pops/validation/checker4_0.rb | 1 + lib/puppet/pops/validation/tasks_checker.rb | 1 + lib/puppet/pops/validation/validator_factory_4_0.rb | 1 + lib/puppet/pops/visitable.rb | 1 + lib/puppet/pops/visitor.rb | 1 + lib/puppet/property.rb | 1 + lib/puppet/property/boolean.rb | 1 + lib/puppet/property/ensure.rb | 1 + lib/puppet/property/keyvalue.rb | 1 + lib/puppet/property/list.rb | 1 + lib/puppet/property/ordered_list.rb | 1 + lib/puppet/provider.rb | 1 + lib/puppet/provider/aix_object.rb | 1 + lib/puppet/provider/command.rb | 1 + lib/puppet/provider/confine.rb | 1 + lib/puppet/provider/exec.rb | 1 + lib/puppet/provider/exec/posix.rb | 1 + lib/puppet/provider/exec/shell.rb | 1 + lib/puppet/provider/exec/windows.rb | 1 + lib/puppet/provider/file/posix.rb | 1 + lib/puppet/provider/file/windows.rb | 1 + lib/puppet/provider/group/aix.rb | 1 + lib/puppet/provider/group/directoryservice.rb | 1 + lib/puppet/provider/group/groupadd.rb | 1 + lib/puppet/provider/group/ldap.rb | 1 + lib/puppet/provider/group/pw.rb | 1 + lib/puppet/provider/group/windows_adsi.rb | 1 + lib/puppet/provider/ldap.rb | 1 + lib/puppet/provider/nameservice.rb | 1 + lib/puppet/provider/nameservice/directoryservice.rb | 1 + lib/puppet/provider/nameservice/objectadd.rb | 1 + lib/puppet/provider/nameservice/pw.rb | 1 + lib/puppet/provider/package.rb | 1 + lib/puppet/provider/package/aix.rb | 1 + lib/puppet/provider/package/appdmg.rb | 1 + lib/puppet/provider/package/apple.rb | 1 + lib/puppet/provider/package/apt.rb | 1 + lib/puppet/provider/package/aptitude.rb | 1 + lib/puppet/provider/package/aptrpm.rb | 1 + lib/puppet/provider/package/blastwave.rb | 1 + lib/puppet/provider/package/dnf.rb | 1 + lib/puppet/provider/package/dnfmodule.rb | 1 + lib/puppet/provider/package/dpkg.rb | 1 + lib/puppet/provider/package/fink.rb | 1 + lib/puppet/provider/package/freebsd.rb | 1 + lib/puppet/provider/package/gem.rb | 1 + lib/puppet/provider/package/hpux.rb | 1 + lib/puppet/provider/package/macports.rb | 1 + lib/puppet/provider/package/nim.rb | 1 + lib/puppet/provider/package/openbsd.rb | 1 + lib/puppet/provider/package/opkg.rb | 1 + lib/puppet/provider/package/pacman.rb | 1 + lib/puppet/provider/package/pip.rb | 1 + lib/puppet/provider/package/pip2.rb | 1 + lib/puppet/provider/package/pip3.rb | 1 + lib/puppet/provider/package/pkg.rb | 1 + lib/puppet/provider/package/pkgdmg.rb | 1 + lib/puppet/provider/package/pkgin.rb | 1 + lib/puppet/provider/package/pkgng.rb | 1 + lib/puppet/provider/package/pkgutil.rb | 1 + lib/puppet/provider/package/portage.rb | 1 + lib/puppet/provider/package/ports.rb | 1 + lib/puppet/provider/package/portupgrade.rb | 1 + lib/puppet/provider/package/puppet_gem.rb | 1 + lib/puppet/provider/package/puppetserver_gem.rb | 1 + lib/puppet/provider/package/rpm.rb | 1 + lib/puppet/provider/package/rug.rb | 1 + lib/puppet/provider/package/sun.rb | 1 + lib/puppet/provider/package/sunfreeware.rb | 1 + lib/puppet/provider/package/tdnf.rb | 1 + lib/puppet/provider/package/up2date.rb | 1 + lib/puppet/provider/package/urpmi.rb | 1 + lib/puppet/provider/package/windows.rb | 1 + lib/puppet/provider/package/windows/exe_package.rb | 1 + lib/puppet/provider/package/windows/msi_package.rb | 1 + lib/puppet/provider/package/windows/package.rb | 1 + lib/puppet/provider/package/yum.rb | 1 + lib/puppet/provider/package/zypper.rb | 1 + lib/puppet/provider/package_targetable.rb | 1 + lib/puppet/provider/parsedfile.rb | 1 + lib/puppet/provider/service/base.rb | 1 + lib/puppet/provider/service/bsd.rb | 1 + lib/puppet/provider/service/daemontools.rb | 1 + lib/puppet/provider/service/debian.rb | 1 + lib/puppet/provider/service/freebsd.rb | 1 + lib/puppet/provider/service/gentoo.rb | 1 + lib/puppet/provider/service/init.rb | 1 + lib/puppet/provider/service/launchd.rb | 1 + lib/puppet/provider/service/openbsd.rb | 1 + lib/puppet/provider/service/openrc.rb | 1 + lib/puppet/provider/service/openwrt.rb | 1 + lib/puppet/provider/service/rcng.rb | 1 + lib/puppet/provider/service/redhat.rb | 1 + lib/puppet/provider/service/runit.rb | 1 + lib/puppet/provider/service/service.rb | 1 + lib/puppet/provider/service/smf.rb | 1 + lib/puppet/provider/service/src.rb | 1 + lib/puppet/provider/service/systemd.rb | 1 + lib/puppet/provider/service/upstart.rb | 1 + lib/puppet/provider/service/windows.rb | 1 + lib/puppet/provider/user/aix.rb | 1 + lib/puppet/provider/user/directoryservice.rb | 1 + lib/puppet/provider/user/hpux.rb | 1 + lib/puppet/provider/user/ldap.rb | 1 + lib/puppet/provider/user/openbsd.rb | 1 + lib/puppet/provider/user/pw.rb | 1 + lib/puppet/provider/user/user_role_add.rb | 1 + lib/puppet/provider/user/useradd.rb | 1 + lib/puppet/provider/user/windows_adsi.rb | 1 + lib/puppet/reference/configuration.rb | 1 + lib/puppet/reference/function.rb | 1 + lib/puppet/reference/indirection.rb | 1 + lib/puppet/reference/metaparameter.rb | 1 + lib/puppet/reference/providers.rb | 1 + lib/puppet/reference/report.rb | 1 + lib/puppet/reference/type.rb | 1 + lib/puppet/relationship.rb | 1 + lib/puppet/reports.rb | 1 + lib/puppet/reports/http.rb | 1 + lib/puppet/reports/log.rb | 1 + lib/puppet/reports/store.rb | 1 + lib/puppet/resource.rb | 1 + lib/puppet/resource/catalog.rb | 1 + lib/puppet/resource/status.rb | 1 + lib/puppet/resource/type.rb | 1 + lib/puppet/resource/type_collection.rb | 1 + lib/puppet/runtime.rb | 1 + lib/puppet/scheduler.rb | 1 + lib/puppet/scheduler/job.rb | 1 + lib/puppet/scheduler/scheduler.rb | 1 + lib/puppet/scheduler/splay_job.rb | 1 + lib/puppet/scheduler/timer.rb | 1 + lib/puppet/settings.rb | 1 + lib/puppet/settings/alias_setting.rb | 1 + lib/puppet/settings/array_setting.rb | 1 + lib/puppet/settings/autosign_setting.rb | 1 + lib/puppet/settings/base_setting.rb | 1 + lib/puppet/settings/boolean_setting.rb | 1 + lib/puppet/settings/certificate_revocation_setting.rb | 1 + lib/puppet/settings/config_file.rb | 1 + lib/puppet/settings/directory_setting.rb | 1 + lib/puppet/settings/duration_setting.rb | 1 + lib/puppet/settings/enum_setting.rb | 1 + lib/puppet/settings/environment_conf.rb | 1 + lib/puppet/settings/errors.rb | 1 + lib/puppet/settings/file_or_directory_setting.rb | 1 + lib/puppet/settings/file_setting.rb | 1 + lib/puppet/settings/http_extra_headers_setting.rb | 1 + lib/puppet/settings/ini_file.rb | 1 + lib/puppet/settings/integer_setting.rb | 1 + lib/puppet/settings/path_setting.rb | 1 + lib/puppet/settings/port_setting.rb | 1 + lib/puppet/settings/priority_setting.rb | 1 + lib/puppet/settings/server_list_setting.rb | 1 + lib/puppet/settings/string_setting.rb | 1 + lib/puppet/settings/symbolic_enum_setting.rb | 1 + lib/puppet/settings/terminus_setting.rb | 1 + lib/puppet/settings/ttl_setting.rb | 1 + lib/puppet/settings/value_translator.rb | 1 + lib/puppet/ssl.rb | 1 + lib/puppet/ssl/base.rb | 1 + lib/puppet/ssl/certificate.rb | 1 + lib/puppet/ssl/certificate_request.rb | 1 + lib/puppet/ssl/certificate_request_attributes.rb | 1 + lib/puppet/ssl/certificate_signer.rb | 1 + lib/puppet/ssl/digest.rb | 1 + lib/puppet/ssl/error.rb | 1 + lib/puppet/ssl/oids.rb | 1 + lib/puppet/ssl/openssl_loader.rb | 1 + lib/puppet/ssl/ssl_context.rb | 1 + lib/puppet/ssl/ssl_provider.rb | 1 + lib/puppet/ssl/state_machine.rb | 1 + lib/puppet/ssl/verifier.rb | 1 + lib/puppet/syntax_checkers.rb | 1 + lib/puppet/syntax_checkers/base64.rb | 1 + lib/puppet/syntax_checkers/epp.rb | 1 + lib/puppet/syntax_checkers/json.rb | 1 + lib/puppet/syntax_checkers/pp.rb | 1 + lib/puppet/test/test_helper.rb | 1 + lib/puppet/thread_local.rb | 1 + lib/puppet/transaction.rb | 1 + lib/puppet/transaction/additional_resource_generator.rb | 1 + lib/puppet/transaction/event.rb | 1 + lib/puppet/transaction/event_manager.rb | 1 + lib/puppet/transaction/persistence.rb | 1 + lib/puppet/transaction/report.rb | 1 + lib/puppet/transaction/resource_harness.rb | 1 + lib/puppet/trusted_external.rb | 1 + lib/puppet/type.rb | 1 + lib/puppet/type/exec.rb | 1 + lib/puppet/type/file.rb | 1 + lib/puppet/type/file/checksum.rb | 1 + lib/puppet/type/file/checksum_value.rb | 1 + lib/puppet/type/file/content.rb | 1 + lib/puppet/type/file/ctime.rb | 1 + lib/puppet/type/file/data_sync.rb | 1 + lib/puppet/type/file/group.rb | 1 + lib/puppet/type/file/mode.rb | 1 + lib/puppet/type/file/mtime.rb | 1 + lib/puppet/type/file/owner.rb | 1 + lib/puppet/type/file/selcontext.rb | 1 + lib/puppet/type/file/source.rb | 1 + lib/puppet/type/file/target.rb | 1 + lib/puppet/type/file/type.rb | 1 + lib/puppet/type/filebucket.rb | 1 + lib/puppet/type/group.rb | 1 + lib/puppet/type/notify.rb | 1 + lib/puppet/type/package.rb | 1 + lib/puppet/type/resources.rb | 1 + lib/puppet/type/schedule.rb | 1 + lib/puppet/type/service.rb | 1 + lib/puppet/type/stage.rb | 1 + lib/puppet/type/tidy.rb | 1 + lib/puppet/type/user.rb | 1 + lib/puppet/type/whit.rb | 1 + lib/puppet/util.rb | 1 + lib/puppet/util/at_fork.rb | 1 + lib/puppet/util/at_fork/noop.rb | 1 + lib/puppet/util/at_fork/solaris.rb | 1 + lib/puppet/util/autoload.rb | 1 + lib/puppet/util/backups.rb | 1 + lib/puppet/util/character_encoding.rb | 1 + lib/puppet/util/checksums.rb | 1 + lib/puppet/util/classgen.rb | 1 + lib/puppet/util/colors.rb | 1 + lib/puppet/util/command_line.rb | 1 + lib/puppet/util/command_line/puppet_option_parser.rb | 1 + lib/puppet/util/command_line/trollop.rb | 1 + lib/puppet/util/constant_inflector.rb | 1 + lib/puppet/util/diff.rb | 1 + lib/puppet/util/docs.rb | 1 + lib/puppet/util/errors.rb | 1 + lib/puppet/util/execution.rb | 1 + lib/puppet/util/execution_stub.rb | 1 + lib/puppet/util/feature.rb | 1 + lib/puppet/util/file_watcher.rb | 1 + lib/puppet/util/fileparsing.rb | 1 + lib/puppet/util/filetype.rb | 1 + lib/puppet/util/http_proxy.rb | 1 + lib/puppet/util/inifile.rb | 1 + lib/puppet/util/instance_loader.rb | 1 + lib/puppet/util/json.rb | 1 + lib/puppet/util/json_lockfile.rb | 1 + lib/puppet/util/ldap.rb | 1 + lib/puppet/util/ldap/connection.rb | 1 + lib/puppet/util/ldap/generator.rb | 1 + lib/puppet/util/ldap/manager.rb | 1 + lib/puppet/util/libuser.rb | 1 + lib/puppet/util/limits.rb | 1 + lib/puppet/util/lockfile.rb | 1 + lib/puppet/util/log.rb | 1 + lib/puppet/util/log/destination.rb | 1 + lib/puppet/util/log/destinations.rb | 1 + lib/puppet/util/logging.rb | 1 + lib/puppet/util/metaid.rb | 1 + lib/puppet/util/metric.rb | 1 + lib/puppet/util/monkey_patches.rb | 1 + lib/puppet/util/multi_match.rb | 1 + lib/puppet/util/network_device.rb | 1 + lib/puppet/util/network_device/base.rb | 1 + lib/puppet/util/network_device/config.rb | 1 + lib/puppet/util/network_device/transport.rb | 1 + lib/puppet/util/package.rb | 1 + lib/puppet/util/package/version/debian.rb | 1 + lib/puppet/util/package/version/gem.rb | 1 + lib/puppet/util/package/version/pip.rb | 1 + lib/puppet/util/package/version/range.rb | 1 + lib/puppet/util/package/version/range/eq.rb | 1 + lib/puppet/util/package/version/range/gt.rb | 1 + lib/puppet/util/package/version/range/gt_eq.rb | 1 + lib/puppet/util/package/version/range/lt.rb | 1 + lib/puppet/util/package/version/range/lt_eq.rb | 1 + lib/puppet/util/package/version/range/min_max.rb | 1 + lib/puppet/util/package/version/range/simple.rb | 1 + lib/puppet/util/package/version/rpm.rb | 1 + lib/puppet/util/pidlock.rb | 1 + lib/puppet/util/platform.rb | 1 + lib/puppet/util/plist.rb | 1 + lib/puppet/util/posix.rb | 1 + lib/puppet/util/profiler.rb | 1 + lib/puppet/util/profiler/aggregate.rb | 1 + lib/puppet/util/profiler/around_profiler.rb | 1 + lib/puppet/util/profiler/logging.rb | 1 + lib/puppet/util/profiler/object_counts.rb | 1 + lib/puppet/util/profiler/wall_clock.rb | 1 + lib/puppet/util/provider_features.rb | 1 + lib/puppet/util/psych_support.rb | 1 + lib/puppet/util/rdoc.rb | 1 + lib/puppet/util/rdoc/code_objects.rb | 1 + lib/puppet/util/rdoc/generators/puppet_generator.rb | 1 + lib/puppet/util/rdoc/generators/template/puppet/puppet.rb | 1 + lib/puppet/util/rdoc/parser.rb | 1 + lib/puppet/util/rdoc/parser/puppet_parser_core.rb | 1 + lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb | 1 + lib/puppet/util/reference.rb | 1 + lib/puppet/util/resource_template.rb | 1 + lib/puppet/util/retry_action.rb | 1 + lib/puppet/util/rpm_compare.rb | 1 + lib/puppet/util/rubygems.rb | 1 + lib/puppet/util/run_mode.rb | 1 + lib/puppet/util/selinux.rb | 1 + lib/puppet/util/skip_tags.rb | 1 + lib/puppet/util/splayer.rb | 1 + lib/puppet/util/storage.rb | 1 + lib/puppet/util/suidmanager.rb | 1 + lib/puppet/util/symbolic_file_mode.rb | 1 + lib/puppet/util/tag_set.rb | 1 + lib/puppet/util/tagging.rb | 1 + lib/puppet/util/terminal.rb | 1 + lib/puppet/util/user_attr.rb | 1 + lib/puppet/util/warnings.rb | 1 + lib/puppet/util/watched_file.rb | 1 + lib/puppet/util/watcher.rb | 1 + lib/puppet/util/watcher/change_watcher.rb | 1 + lib/puppet/util/watcher/periodic_watcher.rb | 1 + lib/puppet/util/watcher/timer.rb | 1 + lib/puppet/util/windows.rb | 1 + lib/puppet/util/windows/access_control_entry.rb | 1 + lib/puppet/util/windows/access_control_list.rb | 1 + lib/puppet/util/windows/adsi.rb | 1 + lib/puppet/util/windows/com.rb | 1 + lib/puppet/util/windows/daemon.rb | 1 + lib/puppet/util/windows/error.rb | 1 + lib/puppet/util/windows/eventlog.rb | 1 + lib/puppet/util/windows/file.rb | 1 + lib/puppet/util/windows/principal.rb | 1 + lib/puppet/util/windows/process.rb | 1 + lib/puppet/util/windows/registry.rb | 1 + lib/puppet/util/windows/root_certs.rb | 1 + lib/puppet/util/windows/security.rb | 1 + lib/puppet/util/windows/security_descriptor.rb | 1 + lib/puppet/util/windows/service.rb | 1 + lib/puppet/util/windows/sid.rb | 1 + lib/puppet/util/windows/string.rb | 1 + lib/puppet/util/windows/user.rb | 1 + lib/puppet/util/yaml.rb | 1 + lib/puppet/vendor.rb | 1 + lib/puppet/version.rb | 1 + lib/puppet/x509.rb | 1 + lib/puppet/x509/cert_provider.rb | 1 + lib/puppet/x509/pem_store.rb | 1 + lib/puppet_pal.rb | 1 + lib/puppet_x.rb | 1 + util/rspec_grouper | 1 + util/rspec_runner | 1 + 996 files changed, 995 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e7846450031..37e066e96d9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,10 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent: I18n/RailsI18n/DecorateString: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLineAfterMagicComment: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyleAlignWith, Severity. # SupportedStylesAlignWith: keyword, variable, start_of_line diff --git a/lib/hiera/puppet_function.rb b/lib/hiera/puppet_function.rb index 29ee5d422cb..cef4c325c08 100644 --- a/lib/hiera/puppet_function.rb +++ b/lib/hiera/puppet_function.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'hiera_puppet' # Provides the base class for the puppet functions hiera, hiera_array, hiera_hash, and hiera_include. diff --git a/lib/hiera/scope.rb b/lib/hiera/scope.rb index 2bbe7684fa6..c86d9914e59 100644 --- a/lib/hiera/scope.rb +++ b/lib/hiera/scope.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'forwardable' class Hiera class Scope diff --git a/lib/hiera_puppet.rb b/lib/hiera_puppet.rb index e40ee0ac4c2..bd16a3f7747 100644 --- a/lib/hiera_puppet.rb +++ b/lib/hiera_puppet.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Puppet.features.hiera? require 'hiera/scope' require_relative 'puppet' diff --git a/lib/puppet.rb b/lib/puppet.rb index f7f710e53e7..1e52ed8a0f4 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'puppet/version' require_relative 'puppet/concurrent/synchronized' diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index 65c1eb3b9f6..14f8573af2d 100644 --- a/lib/puppet/agent.rb +++ b/lib/puppet/agent.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/application' require_relative '../puppet/error' require_relative '../puppet/util/at_fork' diff --git a/lib/puppet/agent/disabler.rb b/lib/puppet/agent/disabler.rb index bfcf77e7251..7f8be7c6a67 100644 --- a/lib/puppet/agent/disabler.rb +++ b/lib/puppet/agent/disabler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/json_lockfile' # This module is responsible for encapsulating the logic for diff --git a/lib/puppet/agent/locker.rb b/lib/puppet/agent/locker.rb index 6a4c1618593..319db65f180 100644 --- a/lib/puppet/agent/locker.rb +++ b/lib/puppet/agent/locker.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/pidlock' require_relative '../../puppet/error' diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 52c159f22f6..cf84e28ef98 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'optparse' require_relative '../puppet/util/command_line' require_relative '../puppet/util/constant_inflector' diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index 7e7a6f3e4e5..c391441e006 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' require_relative '../../puppet/daemon' require_relative '../../puppet/util/pidlock' diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 960e6259e1b..e992b6abc2f 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' require_relative '../../puppet/configurer' require_relative '../../puppet/util/profiler/aggregate' diff --git a/lib/puppet/application/catalog.rb b/lib/puppet/application/catalog.rb index 847fbee4276..470a0f09097 100644 --- a/lib/puppet/application/catalog.rb +++ b/lib/puppet/application/catalog.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/indirection_base' class Puppet::Application::Catalog < Puppet::Application::IndirectionBase diff --git a/lib/puppet/application/config.rb b/lib/puppet/application/config.rb index e54408cea7a..7ede4e8bcfd 100644 --- a/lib/puppet/application/config.rb +++ b/lib/puppet/application/config.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' class Puppet::Application::Config < Puppet::Application::FaceBase diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index 208e5c67895..e7961423723 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' class Formatter diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb index ed4b7025a9c..50c8e930151 100644 --- a/lib/puppet/application/device.rb +++ b/lib/puppet/application/device.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' require_relative '../../puppet/configurer' require_relative '../../puppet/util/network_device' diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb index 2ceeb6f83c8..58879291467 100644 --- a/lib/puppet/application/doc.rb +++ b/lib/puppet/application/doc.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' class Puppet::Application::Doc < Puppet::Application diff --git a/lib/puppet/application/epp.rb b/lib/puppet/application/epp.rb index 5c29d9f1eac..31fb67e129f 100644 --- a/lib/puppet/application/epp.rb +++ b/lib/puppet/application/epp.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' require_relative '../../puppet/face' diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index dd4cfaf6628..d3514bcf397 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' require_relative '../../puppet/face' require 'optparse' diff --git a/lib/puppet/application/facts.rb b/lib/puppet/application/facts.rb index 2d0413872cc..d34e26337e0 100644 --- a/lib/puppet/application/facts.rb +++ b/lib/puppet/application/facts.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/indirection_base' class Puppet::Application::Facts < Puppet::Application::IndirectionBase diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb index a9a4d550940..b9ab0bea703 100644 --- a/lib/puppet/application/filebucket.rb +++ b/lib/puppet/application/filebucket.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' class Puppet::Application::Filebucket < Puppet::Application diff --git a/lib/puppet/application/generate.rb b/lib/puppet/application/generate.rb index 0b444c75f09..ff8b497c9ba 100644 --- a/lib/puppet/application/generate.rb +++ b/lib/puppet/application/generate.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' # The Generate application. diff --git a/lib/puppet/application/help.rb b/lib/puppet/application/help.rb index 64c8b51d913..6cd85e73cba 100644 --- a/lib/puppet/application/help.rb +++ b/lib/puppet/application/help.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' class Puppet::Application::Help < Puppet::Application::FaceBase diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 98d1fc594a5..2b98abc18cb 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' class Puppet::Application::IndirectionBase < Puppet::Application::FaceBase diff --git a/lib/puppet/application/lookup.rb b/lib/puppet/application/lookup.rb index ba0611a447a..5f7382616aa 100644 --- a/lib/puppet/application/lookup.rb +++ b/lib/puppet/application/lookup.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' require_relative '../../puppet/pops' require_relative '../../puppet/node' diff --git a/lib/puppet/application/module.rb b/lib/puppet/application/module.rb index a5f74faad50..b4a40cea19f 100644 --- a/lib/puppet/application/module.rb +++ b/lib/puppet/application/module.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' class Puppet::Application::Module < Puppet::Application::FaceBase diff --git a/lib/puppet/application/node.rb b/lib/puppet/application/node.rb index d8e2f5f5d08..084fbff7d67 100644 --- a/lib/puppet/application/node.rb +++ b/lib/puppet/application/node.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/indirection_base' class Puppet::Application::Node < Puppet::Application::IndirectionBase diff --git a/lib/puppet/application/parser.rb b/lib/puppet/application/parser.rb index 9d1d39046ad..321a7588711 100644 --- a/lib/puppet/application/parser.rb +++ b/lib/puppet/application/parser.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' require_relative '../../puppet/face' diff --git a/lib/puppet/application/plugin.rb b/lib/puppet/application/plugin.rb index e5455c0abe1..4cbcf7cf672 100644 --- a/lib/puppet/application/plugin.rb +++ b/lib/puppet/application/plugin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/face_base' class Puppet::Application::Plugin < Puppet::Application::FaceBase environment_mode :not_required diff --git a/lib/puppet/application/report.rb b/lib/puppet/application/report.rb index 4f5d4a42115..23935f9a052 100644 --- a/lib/puppet/application/report.rb +++ b/lib/puppet/application/report.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application/indirection_base' class Puppet::Application::Report < Puppet::Application::IndirectionBase diff --git a/lib/puppet/application/resource.rb b/lib/puppet/application/resource.rb index e71c6310876..3f89df9c1b0 100644 --- a/lib/puppet/application/resource.rb +++ b/lib/puppet/application/resource.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' class Puppet::Application::Resource < Puppet::Application diff --git a/lib/puppet/application/script.rb b/lib/puppet/application/script.rb index b64e4890bd8..eb1378a4116 100644 --- a/lib/puppet/application/script.rb +++ b/lib/puppet/application/script.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' require_relative '../../puppet/configurer' require_relative '../../puppet/util/profiler/aggregate' diff --git a/lib/puppet/application/ssl.rb b/lib/puppet/application/ssl.rb index 94f623052d3..0f8179585ff 100644 --- a/lib/puppet/application/ssl.rb +++ b/lib/puppet/application/ssl.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/application' require_relative '../../puppet/ssl/oids' diff --git a/lib/puppet/application_support.rb b/lib/puppet/application_support.rb index 1f38e29f0db..c9efff12552 100644 --- a/lib/puppet/application_support.rb +++ b/lib/puppet/application_support.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'yaml' require_relative '../puppet' diff --git a/lib/puppet/coercion.rb b/lib/puppet/coercion.rb index 0badb4d907a..2b7d9a4f23b 100644 --- a/lib/puppet/coercion.rb +++ b/lib/puppet/coercion.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Various methods used to coerce values into a canonical form. # # @api private diff --git a/lib/puppet/compilable_resource_type.rb b/lib/puppet/compilable_resource_type.rb index 8f40568d9ec..ab1349f08f0 100644 --- a/lib/puppet/compilable_resource_type.rb +++ b/lib/puppet/compilable_resource_type.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet' # The CompilableResourceType module should be either included in a class or used as a class extension # to mark that the instance used as the 'resource type' of a resource instance diff --git a/lib/puppet/concurrent.rb b/lib/puppet/concurrent.rb index 460e66c921e..ea3b38ce138 100644 --- a/lib/puppet/concurrent.rb +++ b/lib/puppet/concurrent.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true + module Puppet::Concurrent end diff --git a/lib/puppet/concurrent/lock.rb b/lib/puppet/concurrent/lock.rb index dafec737758..5a4729a26c6 100644 --- a/lib/puppet/concurrent/lock.rb +++ b/lib/puppet/concurrent/lock.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/concurrent/synchronized' module Puppet diff --git a/lib/puppet/concurrent/synchronized.rb b/lib/puppet/concurrent/synchronized.rb index 57f71f6250a..e9f93e9c300 100644 --- a/lib/puppet/concurrent/synchronized.rb +++ b/lib/puppet/concurrent/synchronized.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Puppet module Concurrent # Including Puppet::Concurrent::Synchronized into a class when running on JRuby diff --git a/lib/puppet/concurrent/thread_local_singleton.rb b/lib/puppet/concurrent/thread_local_singleton.rb index b91b96be137..f792e547790 100644 --- a/lib/puppet/concurrent/thread_local_singleton.rb +++ b/lib/puppet/concurrent/thread_local_singleton.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Puppet module Concurrent module ThreadLocalSingleton diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index bdf3f3f4cce..2ddc43e193d 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # The client for interacting with the puppetmaster config server. require 'timeout' require_relative '../puppet/util' diff --git a/lib/puppet/configurer/downloader.rb b/lib/puppet/configurer/downloader.rb index 05cbbcdb8de..91678d58c15 100644 --- a/lib/puppet/configurer/downloader.rb +++ b/lib/puppet/configurer/downloader.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/configurer' require_relative '../../puppet/resource/catalog' diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index a07a060301e..b3e28d814b4 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/indirector/facts/facter' require_relative '../../puppet/configurer' diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index 403e03400aa..fb9bf311111 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Break out the code related to plugins. This module is # just included into the agent, but having it here makes it # easier to test. diff --git a/lib/puppet/confine.rb b/lib/puppet/confine.rb index a7b1515be4c..1884e53665e 100644 --- a/lib/puppet/confine.rb +++ b/lib/puppet/confine.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # The class that handles testing whether our providers # actually work or not. require_relative '../puppet/util' diff --git a/lib/puppet/confine/any.rb b/lib/puppet/confine/any.rb index 591b652f4b4..44f93c6de5d 100644 --- a/lib/puppet/confine/any.rb +++ b/lib/puppet/confine/any.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class Puppet::Confine::Any < Puppet::Confine def self.summarize(confines) confines.inject(0) { |count, confine| count + confine.summary } diff --git a/lib/puppet/confine/boolean.rb b/lib/puppet/confine/boolean.rb index bef4b6927d7..8749192ff80 100644 --- a/lib/puppet/confine/boolean.rb +++ b/lib/puppet/confine/boolean.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/confine' # Common module for the Boolean confines. It currently diff --git a/lib/puppet/confine/exists.rb b/lib/puppet/confine/exists.rb index 03329684e5f..45752de666b 100644 --- a/lib/puppet/confine/exists.rb +++ b/lib/puppet/confine/exists.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/confine' class Puppet::Confine::Exists < Puppet::Confine diff --git a/lib/puppet/confine/false.rb b/lib/puppet/confine/false.rb index b00d596da69..37496092d33 100644 --- a/lib/puppet/confine/false.rb +++ b/lib/puppet/confine/false.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/confine/boolean' class Puppet::Confine::False < Puppet::Confine diff --git a/lib/puppet/confine/feature.rb b/lib/puppet/confine/feature.rb index ec43c973fb0..c8aedba42a7 100644 --- a/lib/puppet/confine/feature.rb +++ b/lib/puppet/confine/feature.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/confine' class Puppet::Confine::Feature < Puppet::Confine diff --git a/lib/puppet/confine/true.rb b/lib/puppet/confine/true.rb index 848a3f26cd9..e33b2e04f77 100644 --- a/lib/puppet/confine/true.rb +++ b/lib/puppet/confine/true.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/confine/boolean' class Puppet::Confine::True < Puppet::Confine diff --git a/lib/puppet/confine/variable.rb b/lib/puppet/confine/variable.rb index bb6162ed4e2..d03750dbed4 100644 --- a/lib/puppet/confine/variable.rb +++ b/lib/puppet/confine/variable.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/confine' # Require a specific value for a variable, either a Puppet setting diff --git a/lib/puppet/confine_collection.rb b/lib/puppet/confine_collection.rb index 09347eca793..e1d0b2009da 100644 --- a/lib/puppet/confine_collection.rb +++ b/lib/puppet/confine_collection.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Manage a collection of confines, returning a boolean or # helpful information. require_relative '../puppet/confine' diff --git a/lib/puppet/confiner.rb b/lib/puppet/confiner.rb index 1395ea1e420..563808ee0b8 100644 --- a/lib/puppet/confiner.rb +++ b/lib/puppet/confiner.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/confine_collection' # The Confiner module contains methods for managing a Provider's confinement (suitability under given diff --git a/lib/puppet/context.rb b/lib/puppet/context.rb index d857f9aad2d..886bc003bd3 100644 --- a/lib/puppet/context.rb +++ b/lib/puppet/context.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/thread_local' # Puppet::Context is a system for tracking services and contextual information diff --git a/lib/puppet/context/trusted_information.rb b/lib/puppet/context/trusted_information.rb index 679385180f2..5dc685296ac 100644 --- a/lib/puppet/context/trusted_information.rb +++ b/lib/puppet/context/trusted_information.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/trusted_external' # @api private diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index 3c7b8bfa7fb..ff59e9ad2f2 100644 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/application' require_relative '../puppet/scheduler' diff --git a/lib/puppet/data_binding.rb b/lib/puppet/data_binding.rb index 6a4a53009c4..f40ae784be3 100644 --- a/lib/puppet/data_binding.rb +++ b/lib/puppet/data_binding.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/indirector' # A class for managing data lookups diff --git a/lib/puppet/datatypes.rb b/lib/puppet/datatypes.rb index 037c45b9ab2..829b5fe73fa 100644 --- a/lib/puppet/datatypes.rb +++ b/lib/puppet/datatypes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Data types in the Puppet Language can have implementations written in Ruby # and distributed in puppet modules. A data type can be declared together with # its implementation by creating a file in 'lib/puppet/functions/'. diff --git a/lib/puppet/datatypes/error.rb b/lib/puppet/datatypes/error.rb index 4cc48f6efa3..625c7f7f151 100644 --- a/lib/puppet/datatypes/error.rb +++ b/lib/puppet/datatypes/error.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Puppet::DataTypes.create_type('Error') do interface <<-PUPPET type_parameters => { diff --git a/lib/puppet/datatypes/impl/error.rb b/lib/puppet/datatypes/impl/error.rb index 9067836a12d..aab3dc24793 100644 --- a/lib/puppet/datatypes/impl/error.rb +++ b/lib/puppet/datatypes/impl/error.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class Puppet::DataTypes::Error attr_reader :msg, :kind, :issue_code, :details alias message msg diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 897bb795755..00a6e906813 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/util/platform' module Puppet diff --git a/lib/puppet/environments.rb b/lib/puppet/environments.rb index ef3c8d800d9..52fbd8425af 100644 --- a/lib/puppet/environments.rb +++ b/lib/puppet/environments.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/concurrent/synchronized' # @api private diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb index 3625dedf09f..d080c60a494 100644 --- a/lib/puppet/error.rb +++ b/lib/puppet/error.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Puppet # The base class for all Puppet errors. It can wrap another exception class Error < RuntimeError diff --git a/lib/puppet/etc.rb b/lib/puppet/etc.rb index 963d5e6e42d..23a75683cc5 100644 --- a/lib/puppet/etc.rb +++ b/lib/puppet/etc.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/util/character_encoding' # Wrapper around Ruby Etc module allowing us to manage encoding in a single # place. diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb index 42c5956f3e0..33335de1b02 100644 --- a/lib/puppet/external/dot.rb +++ b/lib/puppet/external/dot.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # rdot.rb # # diff --git a/lib/puppet/face.rb b/lib/puppet/face.rb index fa418b760ee..309def6d011 100644 --- a/lib/puppet/face.rb +++ b/lib/puppet/face.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # The public name of this feature is 'face', but we have hidden all the # plumbing over in the 'interfaces' namespace to make clear the distinction # between the two. diff --git a/lib/puppet/face/catalog.rb b/lib/puppet/face/catalog.rb index 0f0677db01f..3a7ea1a975b 100644 --- a/lib/puppet/face/catalog.rb +++ b/lib/puppet/face/catalog.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/indirector/face' Puppet::Indirector::Face.define(:catalog, '0.0.1') do diff --git a/lib/puppet/face/catalog/select.rb b/lib/puppet/face/catalog/select.rb index 2c14a8eb077..53bdfd83f59 100644 --- a/lib/puppet/face/catalog/select.rb +++ b/lib/puppet/face/catalog/select.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Select and show a list of resources of a given type. Puppet::Face.define(:catalog, '0.0.1') do action :select do diff --git a/lib/puppet/face/config.rb b/lib/puppet/face/config.rb index a8101d92193..9ce2ff09306 100644 --- a/lib/puppet/face/config.rb +++ b/lib/puppet/face/config.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/face' require_relative '../../puppet/settings/ini_file' diff --git a/lib/puppet/face/epp.rb b/lib/puppet/face/epp.rb index d9ad057cb46..56130e6d5c3 100644 --- a/lib/puppet/face/epp.rb +++ b/lib/puppet/face/epp.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/face' require_relative '../../puppet/pops' require_relative '../../puppet/parser/files' diff --git a/lib/puppet/face/facts.rb b/lib/puppet/face/facts.rb index e1e0ac7921e..d59cc970305 100644 --- a/lib/puppet/face/facts.rb +++ b/lib/puppet/face/facts.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/indirector/face' require_relative '../../puppet/node/facts' diff --git a/lib/puppet/face/generate.rb b/lib/puppet/face/generate.rb index a6b22a7f2e1..f1ac1457987 100644 --- a/lib/puppet/face/generate.rb +++ b/lib/puppet/face/generate.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/face' require_relative '../../puppet/generate/type' diff --git a/lib/puppet/face/help.rb b/lib/puppet/face/help.rb index bcc77c57f34..0d062ca7272 100644 --- a/lib/puppet/face/help.rb +++ b/lib/puppet/face/help.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/face' require_relative '../../puppet/application/face_base' require_relative '../../puppet/util/constant_inflector' diff --git a/lib/puppet/face/module.rb b/lib/puppet/face/module.rb index c30c13194aa..486d8be9999 100644 --- a/lib/puppet/face/module.rb +++ b/lib/puppet/face/module.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/face' require_relative '../../puppet/module_tool' require_relative '../../puppet/util/colors' diff --git a/lib/puppet/face/module/changes.rb b/lib/puppet/face/module/changes.rb index 743c3f5ac24..bea0bba9c49 100644 --- a/lib/puppet/face/module/changes.rb +++ b/lib/puppet/face/module/changes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Puppet::Face.define(:module, '1.0.0') do action(:changes) do summary _("Show modified files of an installed module.") diff --git a/lib/puppet/face/module/install.rb b/lib/puppet/face/module/install.rb index 780a8cd9192..d1f499bb397 100644 --- a/lib/puppet/face/module/install.rb +++ b/lib/puppet/face/module/install.rb @@ -1,5 +1,6 @@ # encoding: UTF-8 # frozen_string_literal: true + require_relative '../../../puppet/forge' require_relative '../../../puppet/module_tool/install_directory' require 'pathname' diff --git a/lib/puppet/face/module/uninstall.rb b/lib/puppet/face/module/uninstall.rb index db17083bd1c..7da7befbd16 100644 --- a/lib/puppet/face/module/uninstall.rb +++ b/lib/puppet/face/module/uninstall.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Puppet::Face.define(:module, '1.0.0') do action(:uninstall) do summary _("Uninstall a puppet module.") diff --git a/lib/puppet/face/node.rb b/lib/puppet/face/node.rb index 16b1adf44ee..49a18dabe33 100644 --- a/lib/puppet/face/node.rb +++ b/lib/puppet/face/node.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/indirector/face' Puppet::Indirector::Face.define(:node, '0.0.1') do copyright "Puppet Inc.", 2011 diff --git a/lib/puppet/face/node/clean.rb b/lib/puppet/face/node/clean.rb index 993e38db9d1..3f817136f3f 100644 --- a/lib/puppet/face/node/clean.rb +++ b/lib/puppet/face/node/clean.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Puppet::Face.define(:node, '0.0.1') do action(:clean) do summary _("Clean up signed certs, cached facts, node objects, and reports for a node stored by the puppetmaster") diff --git a/lib/puppet/face/parser.rb b/lib/puppet/face/parser.rb index 76458df462f..902b0188163 100644 --- a/lib/puppet/face/parser.rb +++ b/lib/puppet/face/parser.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/face' require_relative '../../puppet/parser' diff --git a/lib/puppet/face/plugin.rb b/lib/puppet/face/plugin.rb index ee4b2426ab0..78dcd336f2d 100644 --- a/lib/puppet/face/plugin.rb +++ b/lib/puppet/face/plugin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/face' require_relative '../../puppet/configurer/plugin_handler' diff --git a/lib/puppet/face/report.rb b/lib/puppet/face/report.rb index a166e3055f5..19cfef5710d 100644 --- a/lib/puppet/face/report.rb +++ b/lib/puppet/face/report.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/indirector/face' Puppet::Indirector::Face.define(:report, '0.0.1') do diff --git a/lib/puppet/face/resource.rb b/lib/puppet/face/resource.rb index 364d2f6e2ab..3a7a29c0a34 100644 --- a/lib/puppet/face/resource.rb +++ b/lib/puppet/face/resource.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/indirector/face' Puppet::Indirector::Face.define(:resource, '0.0.1') do diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb index d8f1647148f..c37eda00af6 100644 --- a/lib/puppet/feature/base.rb +++ b/lib/puppet/feature/base.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' # Add the simple features, all in one file. diff --git a/lib/puppet/feature/bolt.rb b/lib/puppet/feature/bolt.rb index 7bfbf3e14cd..e202d5d8add 100644 --- a/lib/puppet/feature/bolt.rb +++ b/lib/puppet/feature/bolt.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add(:bolt, :libs => ['bolt']) diff --git a/lib/puppet/feature/cfpropertylist.rb b/lib/puppet/feature/cfpropertylist.rb index 2abf98406b8..a66c634f41f 100644 --- a/lib/puppet/feature/cfpropertylist.rb +++ b/lib/puppet/feature/cfpropertylist.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add(:cfpropertylist, :libs => ['cfpropertylist']) diff --git a/lib/puppet/feature/eventlog.rb b/lib/puppet/feature/eventlog.rb index 28ee44dadb1..07c256cbe65 100644 --- a/lib/puppet/feature/eventlog.rb +++ b/lib/puppet/feature/eventlog.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' if Puppet::Util::Platform.windows? diff --git a/lib/puppet/feature/hiera_eyaml.rb b/lib/puppet/feature/hiera_eyaml.rb index 887475e30b0..167319fdd38 100644 --- a/lib/puppet/feature/hiera_eyaml.rb +++ b/lib/puppet/feature/hiera_eyaml.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add(:hiera_eyaml, :libs => ['hiera/backend/eyaml/parser/parser']) diff --git a/lib/puppet/feature/hocon.rb b/lib/puppet/feature/hocon.rb index 039dac2d73b..2dd7295b8fa 100644 --- a/lib/puppet/feature/hocon.rb +++ b/lib/puppet/feature/hocon.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add(:hocon, :libs => ['hocon']) diff --git a/lib/puppet/feature/libuser.rb b/lib/puppet/feature/libuser.rb index 109058e1663..bb793453391 100644 --- a/lib/puppet/feature/libuser.rb +++ b/lib/puppet/feature/libuser.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' require_relative '../../puppet/util/libuser' diff --git a/lib/puppet/feature/msgpack.rb b/lib/puppet/feature/msgpack.rb index 5284c230f91..0dd2f0d162d 100644 --- a/lib/puppet/feature/msgpack.rb +++ b/lib/puppet/feature/msgpack.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add(:msgpack, :libs => ["msgpack"]) diff --git a/lib/puppet/feature/pe_license.rb b/lib/puppet/feature/pe_license.rb index 96f7644ae52..2cf9e0a47ec 100644 --- a/lib/puppet/feature/pe_license.rb +++ b/lib/puppet/feature/pe_license.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' #Is the pe license library installed providing the ability to read licenses. diff --git a/lib/puppet/feature/pson.rb b/lib/puppet/feature/pson.rb index 031732f20ed..4a2511b6d12 100644 --- a/lib/puppet/feature/pson.rb +++ b/lib/puppet/feature/pson.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' # PSON is deprecated, use JSON instead diff --git a/lib/puppet/feature/selinux.rb b/lib/puppet/feature/selinux.rb index ce1e9321e7a..bcfc4087465 100644 --- a/lib/puppet/feature/selinux.rb +++ b/lib/puppet/feature/selinux.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add(:selinux, :libs => ["selinux"]) diff --git a/lib/puppet/feature/ssh.rb b/lib/puppet/feature/ssh.rb index 3c9635c9142..49ca36f4cb6 100644 --- a/lib/puppet/feature/ssh.rb +++ b/lib/puppet/feature/ssh.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add(:ssh, :libs => %{net/ssh}) diff --git a/lib/puppet/feature/telnet.rb b/lib/puppet/feature/telnet.rb index 26115495a7a..71add4df6d6 100644 --- a/lib/puppet/feature/telnet.rb +++ b/lib/puppet/feature/telnet.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' Puppet.features.add :telnet do diff --git a/lib/puppet/feature/zlib.rb b/lib/puppet/feature/zlib.rb index 6a9b9873dbc..a2a4e2824e8 100644 --- a/lib/puppet/feature/zlib.rb +++ b/lib/puppet/feature/zlib.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/feature' # We want this to load if possible, but it's not automatically diff --git a/lib/puppet/ffi/posix.rb b/lib/puppet/ffi/posix.rb index 8c8185527c7..1fd2c91d851 100644 --- a/lib/puppet/ffi/posix.rb +++ b/lib/puppet/ffi/posix.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'ffi' module Puppet diff --git a/lib/puppet/ffi/posix/constants.rb b/lib/puppet/ffi/posix/constants.rb index 3f43d1570f5..c36f2d8b198 100644 --- a/lib/puppet/ffi/posix/constants.rb +++ b/lib/puppet/ffi/posix/constants.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/ffi/posix' module Puppet::FFI::POSIX diff --git a/lib/puppet/ffi/posix/functions.rb b/lib/puppet/ffi/posix/functions.rb index b4eef0f8fa6..5688451720a 100644 --- a/lib/puppet/ffi/posix/functions.rb +++ b/lib/puppet/ffi/posix/functions.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/ffi/posix' module Puppet::FFI::POSIX diff --git a/lib/puppet/ffi/windows.rb b/lib/puppet/ffi/windows.rb index 037e2cd7dc9..2d63264a580 100644 --- a/lib/puppet/ffi/windows.rb +++ b/lib/puppet/ffi/windows.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'ffi' module Puppet diff --git a/lib/puppet/ffi/windows/api_types.rb b/lib/puppet/ffi/windows/api_types.rb index 6fa26104aac..fc6485f89e3 100644 --- a/lib/puppet/ffi/windows/api_types.rb +++ b/lib/puppet/ffi/windows/api_types.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/ffi/windows' require_relative '../../../puppet/util/windows/string' diff --git a/lib/puppet/ffi/windows/constants.rb b/lib/puppet/ffi/windows/constants.rb index 6d12503691a..fc4a4ab15ae 100644 --- a/lib/puppet/ffi/windows/constants.rb +++ b/lib/puppet/ffi/windows/constants.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/ffi/windows' module Puppet::FFI::Windows diff --git a/lib/puppet/ffi/windows/functions.rb b/lib/puppet/ffi/windows/functions.rb index 89d3e04e835..b9b9c1be270 100644 --- a/lib/puppet/ffi/windows/functions.rb +++ b/lib/puppet/ffi/windows/functions.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/ffi/windows' module Puppet::FFI::Windows diff --git a/lib/puppet/ffi/windows/structs.rb b/lib/puppet/ffi/windows/structs.rb index 7254eb3cebf..c37eb88acd3 100644 --- a/lib/puppet/ffi/windows/structs.rb +++ b/lib/puppet/ffi/windows/structs.rb @@ -1,5 +1,6 @@ # coding: utf-8 # frozen_string_literal: true + require_relative '../../../puppet/ffi/windows' module Puppet::FFI::Windows diff --git a/lib/puppet/file_bucket.rb b/lib/puppet/file_bucket.rb index 27c7e4c3f83..f7c11e5e032 100644 --- a/lib/puppet/file_bucket.rb +++ b/lib/puppet/file_bucket.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # stub module Puppet::FileBucket class BucketError < RuntimeError; end diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index 82250d012ff..6186d4d067b 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'pathname' require_relative '../../puppet/file_bucket' require_relative '../../puppet/file_bucket/file' diff --git a/lib/puppet/file_bucket/file.rb b/lib/puppet/file_bucket/file.rb index d3778b6b1ab..1053e55d6d1 100644 --- a/lib/puppet/file_bucket/file.rb +++ b/lib/puppet/file_bucket/file.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_bucket' require_relative '../../puppet/indirector' require_relative '../../puppet/util/checksums' diff --git a/lib/puppet/file_serving.rb b/lib/puppet/file_serving.rb index ad951a03c7d..dc1536c72e5 100644 --- a/lib/puppet/file_serving.rb +++ b/lib/puppet/file_serving.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Just a stub class. class Puppet::FileServing # :nodoc: end diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 2abc679f8e5..7ac9f5efca4 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_serving' require_relative '../../puppet/util' diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index 57e05f53d55..d6549f8ab46 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet' require_relative '../../puppet/file_serving' require_relative '../../puppet/file_serving/mount' diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb index 85f9d694d67..18eed7551ef 100644 --- a/lib/puppet/file_serving/configuration/parser.rb +++ b/lib/puppet/file_serving/configuration/parser.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/file_serving/configuration' require_relative '../../../puppet/util/watched_file' diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index 088cf663d7c..c938768aa7a 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/indirector' require_relative '../../puppet/file_serving' require_relative '../../puppet/file_serving/base' diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index b0ca063e0f3..aab1a3573e0 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'find' require_relative '../../puppet/file_serving' require_relative '../../puppet/file_serving/metadata' diff --git a/lib/puppet/file_serving/http_metadata.rb b/lib/puppet/file_serving/http_metadata.rb index 6d198fb6352..5c9a4bfb7bf 100644 --- a/lib/puppet/file_serving/http_metadata.rb +++ b/lib/puppet/file_serving/http_metadata.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_serving/metadata' # Simplified metadata representation, suitable for the information diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 0d57438b2e5..23c71a7753d 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet' require_relative '../../puppet/indirector' require_relative '../../puppet/file_serving' diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index d85c55ae372..64a33187aff 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/logging' require_relative '../../puppet/file_serving' require_relative '../../puppet/file_serving/metadata' diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index b64607cb77e..d71094b830b 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/file_serving/mount' class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount diff --git a/lib/puppet/file_serving/mount/locales.rb b/lib/puppet/file_serving/mount/locales.rb index eb1e1bb2932..a2b44066cf2 100644 --- a/lib/puppet/file_serving/mount/locales.rb +++ b/lib/puppet/file_serving/mount/locales.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/file_serving/mount' # Find files in the modules' locales directories. diff --git a/lib/puppet/file_serving/mount/modules.rb b/lib/puppet/file_serving/mount/modules.rb index b13c73dc24f..bd982011d7c 100644 --- a/lib/puppet/file_serving/mount/modules.rb +++ b/lib/puppet/file_serving/mount/modules.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/file_serving/mount' # This is the modules-specific mount: it knows how to search through diff --git a/lib/puppet/file_serving/mount/pluginfacts.rb b/lib/puppet/file_serving/mount/pluginfacts.rb index eb7837d89fe..14455984cfb 100644 --- a/lib/puppet/file_serving/mount/pluginfacts.rb +++ b/lib/puppet/file_serving/mount/pluginfacts.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/file_serving/mount' # Find files in the modules' pluginfacts directories. diff --git a/lib/puppet/file_serving/mount/plugins.rb b/lib/puppet/file_serving/mount/plugins.rb index 78d7462c9ca..c7d32c09764 100644 --- a/lib/puppet/file_serving/mount/plugins.rb +++ b/lib/puppet/file_serving/mount/plugins.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/file_serving/mount' # Find files in the modules' plugins directories. diff --git a/lib/puppet/file_serving/mount/scripts.rb b/lib/puppet/file_serving/mount/scripts.rb index 746f235dec0..ad5aa5ea97c 100644 --- a/lib/puppet/file_serving/mount/scripts.rb +++ b/lib/puppet/file_serving/mount/scripts.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'puppet/file_serving/mount' class Puppet::FileServing::Mount::Scripts < Puppet::FileServing::Mount diff --git a/lib/puppet/file_serving/mount/tasks.rb b/lib/puppet/file_serving/mount/tasks.rb index e344a758d16..14035f3f00e 100644 --- a/lib/puppet/file_serving/mount/tasks.rb +++ b/lib/puppet/file_serving/mount/tasks.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../../puppet/file_serving/mount' class Puppet::FileServing::Mount::Tasks < Puppet::FileServing::Mount diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb index 3b29ebf8ece..be1f7c58c7e 100644 --- a/lib/puppet/file_serving/terminus_helper.rb +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_serving' require_relative '../../puppet/file_serving/fileset' diff --git a/lib/puppet/file_serving/terminus_selector.rb b/lib/puppet/file_serving/terminus_selector.rb index c03d04a03e5..0fbb051e2a7 100644 --- a/lib/puppet/file_serving/terminus_selector.rb +++ b/lib/puppet/file_serving/terminus_selector.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_serving' # This module is used to pick the appropriate terminus diff --git a/lib/puppet/file_system.rb b/lib/puppet/file_system.rb index 85068cf3d5f..0c6dd4a2704 100644 --- a/lib/puppet/file_system.rb +++ b/lib/puppet/file_system.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Puppet::FileSystem require_relative '../puppet/util' require_relative 'file_system/path_pattern' diff --git a/lib/puppet/file_system/file_impl.rb b/lib/puppet/file_system/file_impl.rb index 969a895ecc5..6150217e1cf 100644 --- a/lib/puppet/file_system/file_impl.rb +++ b/lib/puppet/file_system/file_impl.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Abstract implementation of the Puppet::FileSystem # class Puppet::FileSystem::FileImpl diff --git a/lib/puppet/file_system/jruby.rb b/lib/puppet/file_system/jruby.rb index 3458488ba90..cd8366a0e01 100644 --- a/lib/puppet/file_system/jruby.rb +++ b/lib/puppet/file_system/jruby.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_system/posix' class Puppet::FileSystem::JRuby < Puppet::FileSystem::Posix diff --git a/lib/puppet/file_system/memory_file.rb b/lib/puppet/file_system/memory_file.rb index 30bd800622d..27805f0b5e0 100644 --- a/lib/puppet/file_system/memory_file.rb +++ b/lib/puppet/file_system/memory_file.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # An in-memory file abstraction. Commonly used with Puppet::FileSystem::File#overlay # @api private class Puppet::FileSystem::MemoryFile diff --git a/lib/puppet/file_system/memory_impl.rb b/lib/puppet/file_system/memory_impl.rb index 9ee6f746596..f2cc71b0093 100644 --- a/lib/puppet/file_system/memory_impl.rb +++ b/lib/puppet/file_system/memory_impl.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class Puppet::FileSystem::MemoryImpl def initialize(*files) @files = files + all_children_of(files) diff --git a/lib/puppet/file_system/path_pattern.rb b/lib/puppet/file_system/path_pattern.rb index 6755ba427fa..cd16c1c2498 100644 --- a/lib/puppet/file_system/path_pattern.rb +++ b/lib/puppet/file_system/path_pattern.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'pathname' require_relative '../../puppet/error' diff --git a/lib/puppet/file_system/posix.rb b/lib/puppet/file_system/posix.rb index 40f0872b396..07fe60cd50a 100644 --- a/lib/puppet/file_system/posix.rb +++ b/lib/puppet/file_system/posix.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class Puppet::FileSystem::Posix < Puppet::FileSystem::FileImpl def binread(path) path.binread diff --git a/lib/puppet/file_system/uniquefile.rb b/lib/puppet/file_system/uniquefile.rb index a19a5a98108..b076df56996 100644 --- a/lib/puppet/file_system/uniquefile.rb +++ b/lib/puppet/file_system/uniquefile.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_system' require 'delegate' require 'tmpdir' diff --git a/lib/puppet/file_system/windows.rb b/lib/puppet/file_system/windows.rb index 0c2ea2de1b2..f28ca8e6d41 100644 --- a/lib/puppet/file_system/windows.rb +++ b/lib/puppet/file_system/windows.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/file_system/posix' require_relative '../../puppet/util/windows' diff --git a/lib/puppet/forge.rb b/lib/puppet/forge.rb index 0e44c532d01..12ac34ab093 100644 --- a/lib/puppet/forge.rb +++ b/lib/puppet/forge.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../puppet/vendor' Puppet::Vendor.load_vendored diff --git a/lib/puppet/forge/cache.rb b/lib/puppet/forge/cache.rb index 8ac2fa52074..bc5675f65ae 100644 --- a/lib/puppet/forge/cache.rb +++ b/lib/puppet/forge/cache.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'uri' require_relative '../../puppet/forge' diff --git a/lib/puppet/forge/errors.rb b/lib/puppet/forge/errors.rb index 69551a201cf..18732ed5a93 100644 --- a/lib/puppet/forge/errors.rb +++ b/lib/puppet/forge/errors.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/util/json' require_relative '../../puppet/error' require_relative '../../puppet/forge' diff --git a/lib/puppet/forge/repository.rb b/lib/puppet/forge/repository.rb index 307b9e5ea1b..9203201ff54 100644 --- a/lib/puppet/forge/repository.rb +++ b/lib/puppet/forge/repository.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative '../../puppet/ssl/openssl_loader' require 'digest/sha1' require 'uri' diff --git a/lib/puppet/functions.rb b/lib/puppet/functions.rb index d784c603285..cad6970d080 100644 --- a/lib/puppet/functions.rb +++ b/lib/puppet/functions.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Functions in the puppet language can be written in Ruby and distributed in # puppet modules. The function is written by creating a file in the module's # `lib/puppet/functions/` directory, where `` is diff --git a/lib/puppet/functions/abs.rb b/lib/puppet/functions/abs.rb index 816761114ac..c00157fff06 100644 --- a/lib/puppet/functions/abs.rb +++ b/lib/puppet/functions/abs.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Returns the absolute value of a Numeric value, for example -34.56 becomes # 34.56. Takes a single `Integer` or `Float` value as an argument. # diff --git a/lib/puppet/functions/alert.rb b/lib/puppet/functions/alert.rb index c5cefd28dac..82ca82c9296 100644 --- a/lib/puppet/functions/alert.rb +++ b/lib/puppet/functions/alert.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Logs a message on the server at level `alert`. Puppet::Functions.create_function(:alert, Puppet::Functions::InternalFunction) do # @param values The values to log. diff --git a/lib/puppet/functions/all.rb b/lib/puppet/functions/all.rb index e4efe6ffd89..1b6d8375c84 100644 --- a/lib/puppet/functions/all.rb +++ b/lib/puppet/functions/all.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Runs a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) # repeatedly using each value in a data structure until the lambda returns a non "truthy" value which # makes the function return `false`, or if the end of the iteration is reached, `true` is returned. diff --git a/lib/puppet/functions/annotate.rb b/lib/puppet/functions/annotate.rb index e96afcb6f25..ce3f9d2ff3e 100644 --- a/lib/puppet/functions/annotate.rb +++ b/lib/puppet/functions/annotate.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Handles annotations on objects. The function can be used in four different ways. # # With two arguments, an `Annotation` type and an object, the function returns the annotation diff --git a/lib/puppet/functions/any.rb b/lib/puppet/functions/any.rb index ebfeea809fe..296a6044336 100644 --- a/lib/puppet/functions/any.rb +++ b/lib/puppet/functions/any.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Runs a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) # repeatedly using each value in a data structure until the lambda returns a "truthy" value which # makes the function return `true`, or if the end of the iteration is reached, false is returned. diff --git a/lib/puppet/functions/assert_type.rb b/lib/puppet/functions/assert_type.rb index 2ed3e062ba9..9b862c792a3 100644 --- a/lib/puppet/functions/assert_type.rb +++ b/lib/puppet/functions/assert_type.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Returns the given value if it is of the given # [data type](https://puppet.com/docs/puppet/latest/lang_data.html), or # otherwise either raises an error or executes an optional two-parameter diff --git a/lib/puppet/functions/binary_file.rb b/lib/puppet/functions/binary_file.rb index d4225ac9d5b..6cfe8374710 100644 --- a/lib/puppet/functions/binary_file.rb +++ b/lib/puppet/functions/binary_file.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Loads a binary file from a module or file system and returns its contents as a `Binary`. # The argument to this function should be a `/` # reference, which will load `` from a module's `files` diff --git a/lib/puppet/functions/break.rb b/lib/puppet/functions/break.rb index abca3db3821..1a6a8f6c8c1 100644 --- a/lib/puppet/functions/break.rb +++ b/lib/puppet/functions/break.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Breaks an innermost iteration as if it encountered an end of input. # This function does not return to the caller. # diff --git a/lib/puppet/functions/call.rb b/lib/puppet/functions/call.rb index 3b59f91c913..0d17370cfee 100644 --- a/lib/puppet/functions/call.rb +++ b/lib/puppet/functions/call.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Calls an arbitrary Puppet function by name. # # This function takes one mandatory argument and one or more optional arguments: diff --git a/lib/puppet/functions/camelcase.rb b/lib/puppet/functions/camelcase.rb index 690e8f5a067..4dfe6e70dbb 100644 --- a/lib/puppet/functions/camelcase.rb +++ b/lib/puppet/functions/camelcase.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Creates a Camel Case version of a String # # This function is compatible with the stdlib function with the same name. diff --git a/lib/puppet/functions/capitalize.rb b/lib/puppet/functions/capitalize.rb index b3d3177b9e6..b8507f402ca 100644 --- a/lib/puppet/functions/capitalize.rb +++ b/lib/puppet/functions/capitalize.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Capitalizes the first character of a String, or the first character of every String in an Iterable value (such as an Array). # # This function is compatible with the stdlib function with the same name. diff --git a/lib/puppet/functions/ceiling.rb b/lib/puppet/functions/ceiling.rb index 345b10d65a3..a46f507510f 100644 --- a/lib/puppet/functions/ceiling.rb +++ b/lib/puppet/functions/ceiling.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Returns the smallest `Integer` greater or equal to the argument. # Takes a single numeric value as an argument. # diff --git a/lib/puppet/functions/chomp.rb b/lib/puppet/functions/chomp.rb index 045adeaa924..a7b909e7ba4 100644 --- a/lib/puppet/functions/chomp.rb +++ b/lib/puppet/functions/chomp.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Returns a new string with the record separator character(s) removed. # The record separator is the line ending characters `\r` and `\n`. # diff --git a/lib/puppet/functions/chop.rb b/lib/puppet/functions/chop.rb index 68efccfe4ed..210937aafeb 100644 --- a/lib/puppet/functions/chop.rb +++ b/lib/puppet/functions/chop.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Returns a new string with the last character removed. # If the string ends with `\r\n`, both characters are removed. Applying chop to an empty # string returns an empty string. If you wish to merely remove record diff --git a/lib/puppet/functions/compare.rb b/lib/puppet/functions/compare.rb index c17cac7d6e3..6a322677743 100644 --- a/lib/puppet/functions/compare.rb +++ b/lib/puppet/functions/compare.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Compares two values and returns -1, 0 or 1 if first value is smaller, equal or larger than the second value. # The compare function accepts arguments of the data types `String`, `Numeric`, `Timespan`, `Timestamp`, and `Semver`, # such that: diff --git a/lib/puppet/functions/contain.rb b/lib/puppet/functions/contain.rb index e4d9bd36042..dea0ae79ac8 100644 --- a/lib/puppet/functions/contain.rb +++ b/lib/puppet/functions/contain.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Makes one or more classes be contained inside the current class. # If any of these classes are undeclared, they will be declared as if # there were declared with the `include` function. diff --git a/lib/puppet/functions/convert_to.rb b/lib/puppet/functions/convert_to.rb index bf19fae65dd..c21af06dc3c 100644 --- a/lib/puppet/functions/convert_to.rb +++ b/lib/puppet/functions/convert_to.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # The `convert_to(value, type)` is a convenience function that does the same as `new(type, value)`. # The difference in the argument ordering allows it to be used in chained style for # improved readability "left to right". diff --git a/lib/puppet/functions/crit.rb b/lib/puppet/functions/crit.rb index ed43adeb788..e71cdcf51b7 100644 --- a/lib/puppet/functions/crit.rb +++ b/lib/puppet/functions/crit.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Logs a message on the server at level `crit`. Puppet::Functions.create_function(:crit, Puppet::Functions::InternalFunction) do # @param values The values to log. diff --git a/lib/puppet/functions/debug.rb b/lib/puppet/functions/debug.rb index 2533f7a068f..2a643890dc2 100644 --- a/lib/puppet/functions/debug.rb +++ b/lib/puppet/functions/debug.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Logs a message on the server at level `debug`. Puppet::Functions.create_function(:debug, Puppet::Functions::InternalFunction) do # @param values The values to log. diff --git a/lib/puppet/functions/defined.rb b/lib/puppet/functions/defined.rb index 1a33b1f298f..1d07d914c74 100644 --- a/lib/puppet/functions/defined.rb +++ b/lib/puppet/functions/defined.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Determines whether a given class or resource type is defined and returns a Boolean # value. You can also use `defined` to determine whether a specific resource is defined, # or whether a variable has a value (including `undef`, as opposed to the variable never diff --git a/lib/puppet/functions/dig.rb b/lib/puppet/functions/dig.rb index 26fbac3ff08..5cc2781a5b5 100644 --- a/lib/puppet/functions/dig.rb +++ b/lib/puppet/functions/dig.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Returns a value for a sequence of given keys/indexes into a structure, such as # an array or hash. # diff --git a/lib/puppet/functions/downcase.rb b/lib/puppet/functions/downcase.rb index a052387af92..98fb9fb1b4e 100644 --- a/lib/puppet/functions/downcase.rb +++ b/lib/puppet/functions/downcase.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Converts a String, Array or Hash (recursively) into lower case. # # This function is compatible with the stdlib function with the same name. diff --git a/lib/puppet/functions/each.rb b/lib/puppet/functions/each.rb index 2f42fdde9e1..a7c1ebda4a5 100644 --- a/lib/puppet/functions/each.rb +++ b/lib/puppet/functions/each.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Runs a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) # repeatedly using each value in a data structure, then returns the values unchanged. # diff --git a/lib/puppet/functions/emerg.rb b/lib/puppet/functions/emerg.rb index d1c9d8eb672..716db8d7ea6 100644 --- a/lib/puppet/functions/emerg.rb +++ b/lib/puppet/functions/emerg.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Logs a message on the server at level `emerg`. Puppet::Functions.create_function(:emerg, Puppet::Functions::InternalFunction) do # @param values The values to log. diff --git a/lib/puppet/functions/empty.rb b/lib/puppet/functions/empty.rb index 4e4c1f91edb..1560a29877d 100644 --- a/lib/puppet/functions/empty.rb +++ b/lib/puppet/functions/empty.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Returns `true` if the given argument is an empty collection of values. # # This function can answer if one of the following is empty: diff --git a/lib/puppet/functions/epp.rb b/lib/puppet/functions/epp.rb index 95af8050df4..4abe3dd7885 100644 --- a/lib/puppet/functions/epp.rb +++ b/lib/puppet/functions/epp.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Evaluates an Embedded Puppet (EPP) template file and returns the rendered text # result as a String. # diff --git a/lib/puppet/functions/err.rb b/lib/puppet/functions/err.rb index 9d202ac54e5..c507fcf17b8 100644 --- a/lib/puppet/functions/err.rb +++ b/lib/puppet/functions/err.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Logs a message on the server at level `err`. Puppet::Functions.create_function(:err, Puppet::Functions::InternalFunction) do # @param values The values to log. diff --git a/lib/puppet/functions/eyaml_lookup_key.rb b/lib/puppet/functions/eyaml_lookup_key.rb index e76c837f90b..a4de064d53f 100644 --- a/lib/puppet/functions/eyaml_lookup_key.rb +++ b/lib/puppet/functions/eyaml_lookup_key.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # The `eyaml_lookup_key` is a hiera 5 `lookup_key` data provider function. # See [the configuration guide documentation](https://puppet.com/docs/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-hiera-eyaml) for # how to use this function. diff --git a/lib/puppet/functions/filter.rb b/lib/puppet/functions/filter.rb index 33170afa141..4582934abff 100644 --- a/lib/puppet/functions/filter.rb +++ b/lib/puppet/functions/filter.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) # to every value in a data structure and returns an array or hash containing any elements # for which the lambda evaluates to a truthy value (not `false` or `undef`). diff --git a/lib/puppet/functions/find_file.rb b/lib/puppet/functions/find_file.rb index 9ede5310a04..e930adfd37a 100644 --- a/lib/puppet/functions/find_file.rb +++ b/lib/puppet/functions/find_file.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Finds an existing file from a module and returns its path. # # This function accepts an argument that is a String as a `/` diff --git a/lib/puppet/functions/find_template.rb b/lib/puppet/functions/find_template.rb index 58730373184..127ad090aa4 100644 --- a/lib/puppet/functions/find_template.rb +++ b/lib/puppet/functions/find_template.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Finds an existing template from a module and returns its path. # # This function accepts an argument that is a String as a `/