diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d7beb5c9365..d6f6bd063ad 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -652,11 +652,6 @@ Style/OptionalBooleanParameter: Style/PreferredHashMethods: Enabled: false -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Enabled: false - # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit diff --git a/lib/hiera/scope.rb b/lib/hiera/scope.rb index 2d419c0bca8..726b0405c39 100644 --- a/lib/hiera/scope.rb +++ b/lib/hiera/scope.rb @@ -77,11 +77,11 @@ def compiler def find_hostclass(scope) if scope.source and scope.source.type == :hostclass - return scope.source.name.downcase + scope.source.name.downcase elsif scope.parent - return find_hostclass(scope.parent) + find_hostclass(scope.parent) else - return nil + nil end end private :find_hostclass diff --git a/lib/hiera_puppet.rb b/lib/hiera_puppet.rb index 94dd92c88a5..fa48532e60e 100644 --- a/lib/hiera_puppet.rb +++ b/lib/hiera_puppet.rb @@ -47,7 +47,7 @@ def parse_args(args) default = args[1] override = args[2] - return [key, default, override] + [key, default, override] end def hiera diff --git a/lib/puppet.rb b/lib/puppet.rb index b7a06508d44..40f990a52b5 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -75,9 +75,9 @@ def self.replace_settings_object(new_settings) # @api public def self.[](param) if param == :debug - return Puppet::Util::Log.level == :debug + Puppet::Util::Log.level == :debug else - return @@settings[param] + @@settings[param] end end diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 0f6d24a7f28..92ca1f4640d 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -254,14 +254,14 @@ def find(application_name) raise Puppet::Error, _("Unable to load application class '%{class_name}' from file 'puppet/application/%{application_name}.rb'") % { class_name: class_name, application_name: application_name } end - return clazz + clazz end # Given the fully qualified name of a class, attempt to get the class instance. # @param [String] class_name the fully qualified name of the class to try to load # @return [Class] the Class instance, or nil? if it could not be loaded. def try_load_class(class_name) - return const_defined?(class_name) ? const_get(class_name) : nil + const_defined?(class_name) ? const_get(class_name) : nil end private :try_load_class diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index 7e2969878f7..1b11c9fa0d8 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -44,9 +44,9 @@ def scrub(text) # indent from every line. if text =~ /^(\s+)/ indent = ::Regexp.last_match(1) - return text.gsub(/^#{indent}/, '') + text.gsub(/^#{indent}/, '') else - return text + text end end end diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb index 073a6172790..b6da159d96b 100644 --- a/lib/puppet/application/doc.rb +++ b/lib/puppet/application/doc.rb @@ -122,7 +122,7 @@ def handle_unknown(opt, arg) end def run_command - return [:rdoc].include?(options[:mode]) ? send(options[:mode]) : other + [:rdoc].include?(options[:mode]) ? send(options[:mode]) : other end def rdoc diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index 8e81025c070..b3a7363db52 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -164,7 +164,7 @@ def find_global_settings_argument(item) pattern.match item and return object end end - return nil # nothing found. + nil # nothing found. end def find_application_argument(item) @@ -181,7 +181,7 @@ def find_application_argument(item) } end end - return nil # not found + nil # not found end def setup diff --git a/lib/puppet/application/ssl.rb b/lib/puppet/application/ssl.rb index 4434163bac5..00c665ab795 100644 --- a/lib/puppet/application/ssl.rb +++ b/lib/puppet/application/ssl.rb @@ -234,7 +234,7 @@ def download_cert(ssl_context) cert rescue Puppet::HTTP::ResponseError => e if e.response.code == 404 - return nil + nil else raise Puppet::Error.new(_("Failed to download certificate: %{message}") % { message: e.message }, e) end diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index dc340305be5..cea6c5c2500 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -505,7 +505,7 @@ def run_internal(options) true rescue => detail Puppet.log_exception(detail, _("Failed to apply catalog: %{detail}") % { detail: detail }) - return nil + nil ensure execute_postrun_command or return nil # rubocop:disable Lint/EnsureReturn end @@ -675,12 +675,12 @@ def resubmit_facts puppet.put_facts(facts.name, facts: facts, environment: Puppet.lookup(:current_environment).name.to_s) - return true + true rescue => detail Puppet.log_exception(detail, _("Failed to submit facts: %{detail}") % { detail: detail }) - return false + false end private @@ -722,7 +722,7 @@ def retrieve_catalog_from_cache(query_options) result rescue => detail Puppet.log_exception(detail, _("Could not retrieve catalog from cache: %{detail}") % { detail: detail }) - return nil + nil end def retrieve_new_catalog(facts, query_options) @@ -744,7 +744,7 @@ def retrieve_new_catalog(facts, query_options) result rescue StandardError => detail Puppet.log_exception(detail, _("Could not retrieve catalog from remote server: %{detail}") % { detail: detail }) - return nil + nil end def download_plugins(remote_environment_for_plugins) diff --git a/lib/puppet/configurer/downloader.rb b/lib/puppet/configurer/downloader.rb index 52928f8eccd..61c05e44420 100644 --- a/lib/puppet/configurer/downloader.rb +++ b/lib/puppet/configurer/downloader.rb @@ -86,6 +86,6 @@ def default_arguments defargs[:owner] = Process.uid defargs[:group] = Process.gid end - return defargs + defargs end end diff --git a/lib/puppet/confine.rb b/lib/puppet/confine.rb index 752d6452c37..003a54169da 100644 --- a/lib/puppet/confine.rb +++ b/lib/puppet/confine.rb @@ -75,7 +75,7 @@ def valid? end end - return true + true ensure reset end diff --git a/lib/puppet/confiner.rb b/lib/puppet/confiner.rb index bc696e2fd02..f4d1dc4492f 100644 --- a/lib/puppet/confiner.rb +++ b/lib/puppet/confiner.rb @@ -43,6 +43,6 @@ def confine_collection # @api public # def suitable?(short = true) - return(short ? confine_collection.valid? : confine_collection.summary) + (short ? confine_collection.valid? : confine_collection.summary) end end diff --git a/lib/puppet/environments.rb b/lib/puppet/environments.rb index a3c4d829d66..29536d529e0 100644 --- a/lib/puppet/environments.rb +++ b/lib/puppet/environments.rb @@ -194,7 +194,7 @@ def self.real_path(dir) if Puppet::FileSystem.symlink?(dir) && Puppet[:versioned_environment_dirs] dir = Pathname.new Puppet::FileSystem.expand_path(Puppet::FileSystem.readlink(dir)) end - return dir + dir end # @!macro loader_search_paths diff --git a/lib/puppet/face/help.rb b/lib/puppet/face/help.rb index adcdce764b1..cfd71c902fc 100644 --- a/lib/puppet/face/help.rb +++ b/lib/puppet/face/help.rb @@ -95,7 +95,7 @@ def render_face_man(facename) end def render_application_help(applicationname) - return Puppet::Application[applicationname].help + Puppet::Application[applicationname].help rescue StandardError, LoadError => detail message = [] message << _('Could not load help for the application %{application_name}.') % { application_name: applicationname } @@ -107,7 +107,7 @@ def render_application_help(applicationname) def render_face_help(facename, actionname, version) face, action = load_face_help(facename, actionname, version) - return template_for(face, action).result(binding) + template_for(face, action).result(binding) rescue StandardError, LoadError => detail message = [] message << _('Could not load help for the face %{face_name}.') % { face_name: facename } @@ -141,7 +141,7 @@ def erb(name) template = (Pathname(__FILE__).dirname + "help" + name) erb = Puppet::Util.create_erb(template.read) erb.filename = template.to_s - return erb + erb end # Return a list of applications that are not simply just stubs for Faces. @@ -213,7 +213,7 @@ def horribly_extract_summary_from(appname) return md[1] end end - return '' + '' end # This should absolutely be a private method, but for some reason it appears # that you can't use the 'private' keyword inside of a Face definition. diff --git a/lib/puppet/face/node/clean.rb b/lib/puppet/face/node/clean.rb index 3f817136f3f..0be63f74bf4 100644 --- a/lib/puppet/face/node/clean.rb +++ b/lib/puppet/face/node/clean.rb @@ -104,6 +104,6 @@ def type_is_ensurable(resource) return true if type && type.arguments.keys.include?('ensure') end - return false + false end end diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index 1de5c23296e..31312e8cccd 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -52,7 +52,7 @@ def backup(file) Puppet::FileBucket::File.indirection.save(file_bucket_file, dest_path) end - return file_bucket_file.checksum_data + file_bucket_file.checksum_data rescue => detail message = _("Could not back up %{file}: %{detail}") % { file: file, detail: detail } Puppet.log_exception(detail, message) @@ -152,9 +152,9 @@ def restore(file, sum) Puppet.err _("Could not find file with checksum %{sum}") % { sum: sum } return nil end - return newsum + newsum else - return nil + nil end end diff --git a/lib/puppet/file_bucket/file.rb b/lib/puppet/file_bucket/file.rb index 329c0706976..4c92bc585ee 100644 --- a/lib/puppet/file_bucket/file.rb +++ b/lib/puppet/file_bucket/file.rb @@ -102,7 +102,7 @@ def checksum_data(base_method) def to_binary # This is not so horrible as for FileContent, but still possible to mutate the content that the # checksum is based on... so semi horrible... - return @contents; + @contents; end end diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 78363f7cfdb..6e55c05a1c1 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -13,9 +13,9 @@ class Puppet::FileServing::Base # Does our file exist? def exist? stat - return true + true rescue - return false + false end # Return the full path to our file. Fails if there's no path set. diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index c5442f3515f..cc771050f50 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -74,7 +74,7 @@ def split_path(request) path = path.gsub(%r{/+}, "/") end - return mount, path + [mount, path] end def umount(name) diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 6edfec97f84..ab1bd6937c3 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -80,7 +80,7 @@ def initialize(stat, path, source_permissions) :group => 'S-1-0-0', :mode => 0o644 }.each do |method, default_value| define_method method do - return default_value + default_value end end end diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 6454e0c8bcf..73f860f9d10 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -40,9 +40,9 @@ def find(short_file, request) # Return the path as appropriate, expanding as necessary. def path(node = nil) if expandable? - return expand(@path, node) + expand(@path, node) else - return @path + @path end end diff --git a/lib/puppet/file_system/memory_impl.rb b/lib/puppet/file_system/memory_impl.rb index f2cc71b0093..a909a90e65e 100644 --- a/lib/puppet/file_system/memory_impl.rb +++ b/lib/puppet/file_system/memory_impl.rb @@ -74,7 +74,7 @@ def open(path, *args, &block) if block_given? yield handle else - return handle + handle end end diff --git a/lib/puppet/file_system/windows.rb b/lib/puppet/file_system/windows.rb index 988d6245b04..ca4c8b6a5c3 100644 --- a/lib/puppet/file_system/windows.rb +++ b/lib/puppet/file_system/windows.rb @@ -36,7 +36,7 @@ def expand_path(path, dir_string = nil) end def exist?(path) - return Puppet::Util::Windows::File.exist?(path) + Puppet::Util::Windows::File.exist?(path) end def symlink(path, dest, options = {}) diff --git a/lib/puppet/forge.rb b/lib/puppet/forge.rb index e51b611b8dd..9fad982ae5e 100644 --- a/lib/puppet/forge.rb +++ b/lib/puppet/forge.rb @@ -114,7 +114,7 @@ def fetch(input) uri = decode_uri(response['pagination']['next']) end - return releases + releases end def make_http_request(*args) @@ -161,7 +161,7 @@ def install(dir) # Return the Pathname object representing the directory where the # module release archive was unpacked the to. - return module_dir + module_dir ensure staging_dir.rmtree if staging_dir.exist? end diff --git a/lib/puppet/forge/cache.rb b/lib/puppet/forge/cache.rb index c004ce4fa60..17d91422d41 100644 --- a/lib/puppet/forge/cache.rb +++ b/lib/puppet/forge/cache.rb @@ -38,7 +38,7 @@ def retrieve(url) # Return contents of file at the given URI's +uri+. def read_retrieve(uri) - return uri.read + uri.read end # Return Pathname for repository's cache directory, create it if needed. diff --git a/lib/puppet/forge/repository.rb b/lib/puppet/forge/repository.rb index a18be50fea3..fcf23afb9ea 100644 --- a/lib/puppet/forge/repository.rb +++ b/lib/puppet/forge/repository.rb @@ -69,7 +69,7 @@ def forge_authorization # repository at +release+ (e.g. "myuser-mymodule"). def retrieve(release) path = @host.chomp('/') + release - return cache.retrieve(path) + cache.retrieve(path) end # Return the URI string for this repository. @@ -80,7 +80,7 @@ def to_s # Return the cache key for this repository, this a hashed string based on # the URI. def cache_key - return @cache_key ||= [ + @cache_key ||= [ @host.to_s.gsub(/[^[:alnum:]]+/, '_').sub(/_$/, ''), Digest::SHA1.hexdigest(@host.to_s) ].join('-').freeze diff --git a/lib/puppet/functions.rb b/lib/puppet/functions.rb index ac0b72d6c5e..c033f058f67 100644 --- a/lib/puppet/functions.rb +++ b/lib/puppet/functions.rb @@ -748,7 +748,7 @@ def call(scope, *args, &block) # this is the scope.function_xxx(...) call return scope.send(self.class.method3x, mapped_args) end - return result.value + result.value rescue Puppet::Pops::Evaluator::Next => jumper begin throw :next, jumper.value diff --git a/lib/puppet/functions/compare.rb b/lib/puppet/functions/compare.rb index 9f5c8afb1f3..accce889ae7 100644 --- a/lib/puppet/functions/compare.rb +++ b/lib/puppet/functions/compare.rb @@ -115,7 +115,7 @@ def on_error(a, b, *ignore_case) if a.class != b.class # TRANSLATORS 'compare' is a name - return _("compare(): Can only compare values of the same type (or for Timestamp/Timespan also against Numeric). Got %{type_a} and %{type_b}") % { + _("compare(): Can only compare values of the same type (or for Timestamp/Timespan also against Numeric). Got %{type_a} and %{type_b}") % { type_a: type_label(a), type_b: type_label(b) } end diff --git a/lib/puppet/functions/get.rb b/lib/puppet/functions/get.rb index 33c89572461..6fe21373542 100644 --- a/lib/puppet/functions/get.rb +++ b/lib/puppet/functions/get.rb @@ -138,7 +138,7 @@ def get_from_value(value, navigation, default_value = nil, &block) begin result = call_function('dig', value, *segments) - return result.nil? ? default_value : result + result.nil? ? default_value : result rescue Puppet::ErrorWithData => e if block_given? yield(e.error_data) diff --git a/lib/puppet/functions/new.rb b/lib/puppet/functions/new.rb index 424cde559a8..9ffe34b841f 100644 --- a/lib/puppet/functions/new.rb +++ b/lib/puppet/functions/new.rb @@ -994,7 +994,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 + block_given? ? yield(result) : result end def new_function_for_type(t) diff --git a/lib/puppet/gettext/config.rb b/lib/puppet/gettext/config.rb index 9581566eaf0..e9a9bcfb508 100644 --- a/lib/puppet/gettext/config.rb +++ b/lib/puppet/gettext/config.rb @@ -43,9 +43,9 @@ def self.gettext_loaded? # @return [String] the active locale def self.current_locale if gettext_loaded? - return FastGettext.default_locale + FastGettext.default_locale else - return 'en' + 'en' end end @@ -55,7 +55,7 @@ def self.current_locale def self.loaded_text_domains return [] if @gettext_disabled || !gettext_loaded? - return FastGettext.translation_repositories.keys + FastGettext.translation_repositories.keys end # @api private @@ -191,11 +191,11 @@ def self.copy_default_translations(domain_name) # @return [String] path to the config, or nil if not found def self.puppet_locale_path if Puppet::FileSystem.exist?(LOCAL_PATH) - return LOCAL_PATH + LOCAL_PATH elsif Puppet::Util::Platform.windows? && Puppet::FileSystem.exist?(WINDOWS_PATH) - return WINDOWS_PATH + WINDOWS_PATH elsif !Puppet::Util::Platform.windows? && Puppet::FileSystem.exist?(POSIX_PATH) - return POSIX_PATH + POSIX_PATH else nil end @@ -207,9 +207,9 @@ def self.puppet_locale_path # @return [Symbol] :mo if in a package structure, :po otherwise def self.translation_mode(conf_path) if WINDOWS_PATH == conf_path || POSIX_PATH == conf_path - return :mo + :mo else - return :po + :po end end @@ -239,7 +239,7 @@ def self.load_translations(project_name, locale_dir, file_format, text_domain = end add_repository_to_domain(project_name, locale_dir, file_format, text_domain) - return true + true end # @api private diff --git a/lib/puppet/graph/rb_tree_map.rb b/lib/puppet/graph/rb_tree_map.rb index 2c75718261d..cf757c933cf 100644 --- a/lib/puppet/graph/rb_tree_map.rb +++ b/lib/puppet/graph/rb_tree_map.rb @@ -329,7 +329,7 @@ def delete_recursive(node, key) node.right, result = delete_recursive(node.right, key) end end - return node.fixup, result + [node.fixup, result] end def delete_min_recursive(node) @@ -342,7 +342,7 @@ def delete_min_recursive(node) end node.left, result = delete_min_recursive(node.left) - return node.fixup, result + [node.fixup, result] end def delete_max_recursive(node) @@ -356,16 +356,16 @@ def delete_max_recursive(node) end node.right, result = delete_max_recursive(node.right) - return node.fixup, result + [node.fixup, result] end 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) - when 1 then return get_recursive(node.right, key) + when 0 then node + when -1 then get_recursive(node.left, key) + when 1 then get_recursive(node.right, key) end end diff --git a/lib/puppet/graph/simple_graph.rb b/lib/puppet/graph/simple_graph.rb index a050b365df1..308ae18d6cd 100644 --- a/lib/puppet/graph/simple_graph.rb +++ b/lib/puppet/graph/simple_graph.rb @@ -223,7 +223,7 @@ def paths_in_cycle(cycle, max_paths = 1) end end - return found.sort + found.sort end # @return [Array] array of dependency cycles (arrays) @@ -268,7 +268,7 @@ def write_cycles_to_graph(cycles) filename = File.join(Puppet[:graphdir], "cycles.dot") # DOT files are assumed to be UTF-8 by default - http://www.graphviz.org/doc/info/lang.html File.open(filename, "w:UTF-8") { |f| f.puts graph } - return filename + filename end # Add a new vertex to the graph. diff --git a/lib/puppet/http/dns.rb b/lib/puppet/http/dns.rb index 833165dcf07..4e148b8c363 100644 --- a/lib/puppet/http/dns.rb +++ b/lib/puppet/http/dns.rb @@ -118,7 +118,7 @@ def weight(record) # @param [String] service_name the service whose TTL we want # @return [Integer] the TTL for this service, in seconds def ttl(service_name) - return @record_cache[service_name].ttl + @record_cache[service_name].ttl end # Checks if the cached entry for the given service has expired. @@ -128,9 +128,9 @@ def ttl(service_name) def expired?(service_name) entry = @record_cache[service_name] if entry - return Time.now > (entry.resolution_time + entry.ttl) + Time.now > (entry.resolution_time + entry.ttl) else - return true + true end end diff --git a/lib/puppet/http/proxy.rb b/lib/puppet/http/proxy.rb index 0d3bb23d574..e1d642a751e 100644 --- a/lib/puppet/http/proxy.rb +++ b/lib/puppet/http/proxy.rb @@ -24,7 +24,7 @@ def self.http_proxy_env rescue URI::InvalidURIError return nil end - return nil + nil end # The documentation around the format of the no_proxy variable seems @@ -68,7 +68,7 @@ def self.no_proxy?(dest) end end - return false + false end def self.http_proxy_host @@ -82,7 +82,7 @@ def self.http_proxy_host return nil end - return Puppet.settings[:http_proxy_host] + Puppet.settings[:http_proxy_host] end def self.http_proxy_port @@ -92,7 +92,7 @@ def self.http_proxy_port return env.port end - return Puppet.settings[:http_proxy_port] + Puppet.settings[:http_proxy_port] end def self.http_proxy_user @@ -106,7 +106,7 @@ def self.http_proxy_user return nil end - return Puppet.settings[:http_proxy_user] + Puppet.settings[:http_proxy_user] end def self.http_proxy_password @@ -120,7 +120,7 @@ def self.http_proxy_password return nil end - return Puppet.settings[:http_proxy_password] + Puppet.settings[:http_proxy_password] end def self.no_proxy @@ -134,6 +134,6 @@ def self.no_proxy return nil end - return Puppet.settings[:no_proxy] + Puppet.settings[:no_proxy] end end diff --git a/lib/puppet/http/resolver.rb b/lib/puppet/http/resolver.rb index 5b9164ec5c2..85200b7084a 100644 --- a/lib/puppet/http/resolver.rb +++ b/lib/puppet/http/resolver.rb @@ -42,9 +42,9 @@ def resolve(session, name, ssl_context: nil, canceled_handler: nil) # @api public def check_connection?(session, service, ssl_context: nil) service.connect(ssl_context: ssl_context) - return true + true rescue Puppet::HTTP::ConnectionError => e Puppet.log_exception(e, "Connection to #{service.url} failed, trying next route: #{e.message}") - return false + false end end diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 15e1f7e4a6a..0ef64b3e304 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -120,9 +120,9 @@ def convert_wire_facts(facts, format) when 'pson' # We unescape here because the corresponding code in Puppet::Configurer::FactHandler encodes with Puppet::Util.uri_query_encode # PSON is deprecated, but continue to accept from older agents - return Puppet::Node::Facts.convert_from('pson', CGI.unescape(facts)) + Puppet::Node::Facts.convert_from('pson', CGI.unescape(facts)) when 'application/json' - return Puppet::Node::Facts.convert_from('json', CGI.unescape(facts)) + Puppet::Node::Facts.convert_from('json', CGI.unescape(facts)) else raise ArgumentError, _("Unsupported facts format") end @@ -156,24 +156,23 @@ def get_content_uri(metadata, source, environment_path) source_as_uri = URI.parse(Puppet::Util.uri_encode(source)) server = source_as_uri.host port = ":#{source_as_uri.port}" if source_as_uri.port - return "puppet://#{server}#{port}/#{path}" + "puppet://#{server}#{port}/#{path}" end # Helper method to decide if a file resource's metadata can be inlined. # Also used to profile/log reasons for not inlining. def inlineable?(resource, sources) - case - when resource[:ensure] == 'absent' + if resource[:ensure] == 'absent' # TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining) - return Puppet::Util::Profiler.profile(_("Not inlining absent resource"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :absent]) { false } - when sources.empty? + Puppet::Util::Profiler.profile(_("Not inlining absent resource"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :absent]) { false } + elsif sources.empty? # TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining) - return Puppet::Util::Profiler.profile(_("Not inlining resource without sources"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :no_sources]) { false } - when !(sources.all? { |source| source =~ /^puppet:/ }) + Puppet::Util::Profiler.profile(_("Not inlining resource without sources"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :no_sources]) { false } + elsif !(sources.all? { |source| source =~ /^puppet:/ }) # TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining) - return Puppet::Util::Profiler.profile(_("Not inlining unsupported source scheme"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :unsupported_scheme]) { false } + Puppet::Util::Profiler.profile(_("Not inlining unsupported source scheme"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :unsupported_scheme]) { false } else - return true + true end end diff --git a/lib/puppet/indirector/exec.rb b/lib/puppet/indirector/exec.rb index a851c2dbdff..6e8a47218cf 100644 --- a/lib/puppet/indirector/exec.rb +++ b/lib/puppet/indirector/exec.rb @@ -25,9 +25,9 @@ def find(request) if output =~ /\A\s*\Z/ # all whitespace Puppet.debug { "Empty response for #{name} from #{self.name} terminus" } - return nil + nil else - return output + output end end diff --git a/lib/puppet/indirector/face.rb b/lib/puppet/indirector/face.rb index 8593c581aa9..5db462ae6d3 100644 --- a/lib/puppet/indirector/face.rb +++ b/lib/puppet/indirector/face.rb @@ -53,7 +53,7 @@ def call_indirection_method(method, key, options) raise RuntimeError, message, detail.backtrace end - return result + result end action :destroy do diff --git a/lib/puppet/indirector/fact_search.rb b/lib/puppet/indirector/fact_search.rb index 772e5f614ad..a1a4c44a3e0 100644 --- a/lib/puppet/indirector/fact_search.rb +++ b/lib/puppet/indirector/fact_search.rb @@ -9,7 +9,7 @@ def node_matches?(facts, options) return false unless node_matches_option?(type, name, operator, value, facts) end - return true + true end def node_matches_option?(type, name, operator, value, facts) diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb index 72eb127eb4b..d0cd2d0ea88 100644 --- a/lib/puppet/indirector/file_bucket_file/file.rb +++ b/lib/puppet/indirector/file_bucket_file/file.rb @@ -31,7 +31,7 @@ def find(request) 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)) + diff(Puppet::FileSystem.path_string(contents_file), Puppet::FileSystem.path_string(other_contents_file)) else # TRANSLATORS "FileBucket" should not be translated Puppet.info _("FileBucket read %{checksum}") % { checksum: checksum } @@ -88,7 +88,7 @@ def list(request) msg += "#{chksum} #{date} #{filename}\n" } } - return model.new(msg) + model.new(msg) end def head(request) @@ -137,7 +137,7 @@ def path_match(file_handle, files_original_path) file_handle.each_line do |line| return true if line.chomp == files_original_path end - return false + false end # @param bucket_file [Puppet::FileBucket::File] IO object representing diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 6e4e01960ce..d1f354bbcde 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -311,7 +311,7 @@ def search(key, options = {}) instance.expiration ||= expiration end - return result + result end end diff --git a/lib/puppet/indirector/json.rb b/lib/puppet/indirector/json.rb index 7e8989834d9..658e14a9f39 100644 --- a/lib/puppet/indirector/json.rb +++ b/lib/puppet/indirector/json.rb @@ -66,7 +66,7 @@ def load_json_from_file(file, key) end begin - return from_json(json) + from_json(json) rescue => detail raise Puppet::Error, _("Could not parse JSON data for %{name} %{key}: %{detail}") % { name: indirection.name, key: key, detail: detail }, detail.backtrace end diff --git a/lib/puppet/indirector/msgpack.rb b/lib/puppet/indirector/msgpack.rb index 17599669e64..8ba5a8f2272 100644 --- a/lib/puppet/indirector/msgpack.rb +++ b/lib/puppet/indirector/msgpack.rb @@ -71,7 +71,7 @@ def load_msgpack_from_file(file, key) end begin - return from_msgpack(msgpack) + from_msgpack(msgpack) rescue => detail raise Puppet::Error, _("Could not parse MessagePack data for %{indirection} %{key}: %{detail}") % { indirection: indirection.name, key: key, detail: detail }, detail.backtrace end diff --git a/lib/puppet/indirector/none.rb b/lib/puppet/indirector/none.rb index 3e51a26617c..0fd9f67906e 100644 --- a/lib/puppet/indirector/none.rb +++ b/lib/puppet/indirector/none.rb @@ -5,6 +5,6 @@ # A none terminus type, meant to always return nil class Puppet::Indirector::None < Puppet::Indirector::Terminus def find(request) - return nil + nil end end diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 5cb884ebe6a..f436450ca92 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -140,7 +140,7 @@ def to_hash end def description - return(uri || "/#{indirection_name}/#{key}") + uri || "/#{indirection_name}/#{key}" end def remote? diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index c2efff32efc..85b900f7e36 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -11,7 +11,7 @@ def find(request) return nil unless Puppet::FileSystem.exist?(file) begin - return load_file(file) + load_file(file) rescue Puppet::Util::Yaml::YamlLoadError => detail raise Puppet::Error, _("Could not parse YAML data for %{indirection} %{request}: %{detail}") % { indirection: indirection.name, request: request.key, detail: detail }, detail.backtrace end diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb index f6beb8c040b..0e26070de87 100644 --- a/lib/puppet/interface.rb +++ b/lib/puppet/interface.rb @@ -67,7 +67,7 @@ def define(name, version, &block) face.instance_eval(&block) if block_given? - return face + face end # Retrieves a face by name and version. Use `:current` for the diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index fee77af055e..c08090cc1eb 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -42,7 +42,7 @@ def initialize(face, name) def __dup_and_rebind_to(to) bound_version = dup bound_version.instance_variable_set(:@face, to) - return bound_version + bound_version end def to_s() "#{@face}##{@name}" end @@ -88,7 +88,7 @@ def when_rendering(type) return @when_rendering[alt].bind(@face) if @when_rendering.has_key? alt # Guess not, nothing to run. - return nil + nil end # @api private @@ -394,7 +394,7 @@ def validate_and_clean(original) end # All done. - return result + result end ######################################################################## diff --git a/lib/puppet/interface/action_manager.rb b/lib/puppet/interface/action_manager.rb index e51d5616640..13c1e13ec41 100644 --- a/lib/puppet/interface/action_manager.rb +++ b/lib/puppet/interface/action_manager.rb @@ -71,7 +71,7 @@ def get_action(name) result = @actions[name.to_sym] = found.__dup_and_rebind_to(self) end end - return result + result end # Retrieves the default action for the face diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb index 3bf86cb7e9f..d131eb8ba23 100644 --- a/lib/puppet/interface/face_collection.rb +++ b/lib/puppet/interface/face_collection.rb @@ -40,7 +40,7 @@ def self.get_action_for_face(name, action_name, version) end end - return action + action end # get face from memory, without loading. @@ -51,7 +51,7 @@ def self.get_face(name, pattern) versions = @faces[name].keys - [:current] range = pattern.is_a?(SemanticPuppet::Version) ? SemanticPuppet::VersionRange.new(pattern, pattern) : SemanticPuppet::VersionRange.parse(pattern) found = find_matching(range, versions) - return @faces[name][found] + @faces[name][found] end def self.find_matching(range, versions) @@ -105,7 +105,7 @@ def self.load_face(name, version) safely_require name, version end - return get_face(name, version) + get_face(name, version) end def self.safely_require(name, version = nil) diff --git a/lib/puppet/interface/option_manager.rb b/lib/puppet/interface/option_manager.rb index 3790f2c55be..d1b22be2524 100644 --- a/lib/puppet/interface/option_manager.rb +++ b/lib/puppet/interface/option_manager.rb @@ -34,7 +34,7 @@ def walk_inheritance_tree(start, sym) elsif self.class.respond_to?(sym) result = self.class.send(sym) + result end - return result + result end # Declare that this app can take a specific option, and provide the @@ -77,7 +77,7 @@ def add_option(option) @options_hash[name] = option end - return option + option end # @api private @@ -98,7 +98,7 @@ def get_option(name, with_inherited_options = true) end end - return result + result end # @api private diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index dab21ef29ea..0f6e600caa6 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -46,21 +46,21 @@ def self.is_module_directory?(name, path) fullpath = File.join(path, name) return false unless Puppet::FileSystem.directory?(fullpath) - return is_module_directory_name?(name) + 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 + 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 + false end # @api private @@ -96,7 +96,7 @@ def puppetversion=(something) # @deprecated The puppetversion module metadata field is no longer used. def validate_puppet_version - return + nil end def has_metadata? @@ -116,7 +116,7 @@ def has_metadata? return false end - return true + true end # A method for returning a given file of a given type. @@ -135,7 +135,7 @@ def has_metadata? return nil unless Puppet::FileSystem.exist?(full_path) - return full_path + full_path end # Return the base directory for the given type @@ -171,9 +171,9 @@ def task_file(name) end if Puppet::FileSystem.exist?(full_path) - return full_path + full_path else - return nil + nil end end @@ -204,9 +204,9 @@ def plan_file(name) end if Puppet::FileSystem.exist?(full_path) - return full_path + full_path else - return nil + nil end end @@ -336,7 +336,7 @@ def locale_directory # @return true if the module has a directory for the locale, false # false otherwise def has_translations?(locale) - return Puppet::FileSystem.exist?(File.join(locale_directory, locale)) + Puppet::FileSystem.exist?(File.join(locale_directory, locale)) end def has_external_facts? diff --git a/lib/puppet/module/plan.rb b/lib/puppet/module/plan.rb index 7b311cf48b8..c1a04eb6e04 100644 --- a/lib/puppet/module/plan.rb +++ b/lib/puppet/module/plan.rb @@ -59,7 +59,7 @@ def initialize(plan_name, module_name) def self.is_plan_name?(name) return true if name =~ /^[a-z][a-z0-9_]*$/ - return false + false end # Determine whether a plan file has a legal name and extension @@ -77,7 +77,7 @@ def self.is_plans_filename?(path) return [false, _("Plan name cannot be a Puppet data type, but was '%{name}'") % { name: name }] end - return [true] + [true] end # Executables list should contain the full path of all possible implementation files @@ -159,7 +159,7 @@ def self.new_with_files(pup_module, name, plan_files) # Abstracted here so we can add support for subdirectories later def self.plan_name_from_path(path) - return File.basename(path, '.*') + File.basename(path, '.*') end private_class_method :plan_name_from_path end diff --git a/lib/puppet/module/task.rb b/lib/puppet/module/task.rb index fc669674a7b..bc0d04d4fdc 100644 --- a/lib/puppet/module/task.rb +++ b/lib/puppet/module/task.rb @@ -55,7 +55,7 @@ def initialize(task_name, module_name) def self.is_task_name?(name) return true if name =~ /^[a-z][a-z0-9_]*$/ - return false + false end def self.is_tasks_file?(path) @@ -70,7 +70,7 @@ def self.is_tasks_filename?(path) FORBIDDEN_EXTENSIONS.each do |ext| return false if path.end_with?(ext) end - return true + true end def self.get_file_details(path, mod) @@ -281,7 +281,7 @@ def self.new_with_files(pup_module, name, task_files, module_executables) # Abstracted here so we can add support for subdirectories later def self.task_name_from_path(path) - return File.basename(path, '.*') + File.basename(path, '.*') end private_class_method :task_name_from_path end diff --git a/lib/puppet/module_tool.rb b/lib/puppet/module_tool.rb index 1d52cb3e5bf..ea1a0f204ad 100644 --- a/lib/puppet/module_tool.rb +++ b/lib/puppet/module_tool.rb @@ -35,7 +35,7 @@ def self.artifact?(path) def self.username_and_modname_from(full_module_name) matcher = full_module_name.match(FULL_MODULE_NAME_PATTERN) if matcher - return matcher.captures + matcher.captures else raise ArgumentError, _("Not a valid full name: %{full_module_name}") % { full_module_name: full_module_name } end @@ -87,7 +87,7 @@ def self.format_tree(nodes, level = 0) str << branch end - return str + str end def self.build_tree(mods, dir) diff --git a/lib/puppet/module_tool/applications/application.rb b/lib/puppet/module_tool/applications/application.rb index c04f1ddaff3..8ce2d28995a 100644 --- a/lib/puppet/module_tool/applications/application.rb +++ b/lib/puppet/module_tool/applications/application.rb @@ -64,7 +64,7 @@ def metadata(require_metadata = false) Puppet.warning _("A Modulefile was found in the root directory of the module. This file will be ignored and can safely be removed.") end - return @metadata + @metadata end def load_metadata! @@ -84,7 +84,7 @@ def parse_filename(filename) raise ArgumentError, _("Invalid version format: %{version} (Semantic Versions are acceptable: http://semver.org)") % { version: version } end - return { + { :module_name => module_name, :author => author, :dir_name => shortname, diff --git a/lib/puppet/module_tool/applications/installer.rb b/lib/puppet/module_tool/applications/installer.rb index 195ef60a977..ff37ce2ff7f 100644 --- a/lib/puppet/module_tool/applications/installer.rb +++ b/lib/puppet/module_tool/applications/installer.rb @@ -290,7 +290,7 @@ def build_install_graph(release, installed, graphed = []) previous = installed_modules[release.name] previous = previous.version if previous - return { + { :release => release, :name => release.name, :path => release.install_dir.to_s, diff --git a/lib/puppet/module_tool/applications/unpacker.rb b/lib/puppet/module_tool/applications/unpacker.rb index 12839034f43..49052690127 100644 --- a/lib/puppet/module_tool/applications/unpacker.rb +++ b/lib/puppet/module_tool/applications/unpacker.rb @@ -38,7 +38,7 @@ def run # Return the Pathname object representing the directory where the # module release archive was unpacked the to. - return module_dir + module_dir end # @api private diff --git a/lib/puppet/module_tool/applications/upgrader.rb b/lib/puppet/module_tool/applications/upgrader.rb index 90af3094d2b..b4c4ef230dc 100644 --- a/lib/puppet/module_tool/applications/upgrader.rb +++ b/lib/puppet/module_tool/applications/upgrader.rb @@ -271,7 +271,7 @@ def build_install_graph(release, installed, graphed = []) end end - return { + { :release => release, :name => release.name, :path => release.install_dir, diff --git a/lib/puppet/module_tool/checksums.rb b/lib/puppet/module_tool/checksums.rb index a0b8bcfeee3..e447d515c04 100644 --- a/lib/puppet/module_tool/checksums.rb +++ b/lib/puppet/module_tool/checksums.rb @@ -19,7 +19,7 @@ def initialize(path) # Return checksum for the +Pathname+. def checksum(pathname) - return Digest::MD5.hexdigest(Puppet::FileSystem.binread(pathname)) + Digest::MD5.hexdigest(Puppet::FileSystem.binread(pathname)) end # Return checksums for object's +Pathname+, generate if it's needed. @@ -36,7 +36,7 @@ def data end end end - return @data + @data end alias :to_data_hash :data diff --git a/lib/puppet/module_tool/metadata.rb b/lib/puppet/module_tool/metadata.rb index 6ca5ff45ce4..56eaa32ce38 100644 --- a/lib/puppet/module_tool/metadata.rb +++ b/lib/puppet/module_tool/metadata.rb @@ -58,7 +58,7 @@ def update(data) merge_dependencies(data) if data['dependencies'] @data.merge!(data) - return self + self end # Validates the name and version_requirement for a dependency, then creates @@ -156,7 +156,7 @@ def process_source(data) data['issues_url'] ||= @data['issues_url'] || source_uri.to_s.sub(%r{/*$}, '') + '/issues' end rescue URI::Error - return + nil end # Validates and parses the dependencies. diff --git a/lib/puppet/module_tool/shared_behaviors.rb b/lib/puppet/module_tool/shared_behaviors.rb index c55e283f5d0..cf582c54226 100644 --- a/lib/puppet/module_tool/shared_behaviors.rb +++ b/lib/puppet/module_tool/shared_behaviors.rb @@ -60,14 +60,14 @@ def implicit_version(mod) return :latest end - return :best + :best end def annotated_version(mod, versions) if versions.empty? - return implicit_version(mod) + implicit_version(mod) else - return "#{implicit_version(mod)}: #{versions.last}" + "#{implicit_version(mod)}: #{versions.last}" end end @@ -158,7 +158,7 @@ def resolve_constraints(dependencies, source = [{ :name => :you }], seen = {}, a deps = @remote["#{mod[:module]}@#{mod[:version][:vstring]}"].sort_by(&:first) mod[:dependencies] = resolve_constraints(deps, source + [{ :name => mod[:module], :version => mod[:version][:vstring] }], seen, :install) end unless @ignore_dependencies - return dependencies + dependencies end def download_tarballs(graph, default_path, forge) diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb index 23835fa9227..076eb932b85 100644 --- a/lib/puppet/network/format.rb +++ b/lib/puppet/network/format.rb @@ -111,6 +111,6 @@ def required_method_present?(name, klass, type) method = send(name) - return(type == :class ? klass.respond_to?(method) : klass.method_defined?(method)) + (type == :class ? klass.respond_to?(method) : klass.method_defined?(method)) end end diff --git a/lib/puppet/network/http/api/indirected_routes.rb b/lib/puppet/network/http/api/indirected_routes.rb index 36f95c1b892..3d0055ffb57 100644 --- a/lib/puppet/network/http/api/indirected_routes.rb +++ b/lib/puppet/network/http/api/indirected_routes.rb @@ -248,7 +248,7 @@ def indirection_method(http_method, indirection) end def self.pluralize(indirection) - return(indirection == "status" ? "statuses" : indirection + "s") + (indirection == "status" ? "statuses" : indirection + "s") end private_class_method :pluralize diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 6ea626dd0a2..b90c62b2e62 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -107,14 +107,10 @@ def respond_with_http_error(response, exception) def find_route_or_raise(request) route = @routes.find { |r| r.matches?(request) } - if route - return route - else - raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new( - _("No route for %{request} %{path}") % { request: request.method, path: request.path }, - HANDLER_NOT_FOUND - ) - end + route || raise(Puppet::Network::HTTP::Error::HTTPNotFoundError.new( + _("No route for %{request} %{path}") % { request: request.method, path: request.path }, + HANDLER_NOT_FOUND + )) end def set_puppet_version_header(response) diff --git a/lib/puppet/network/http/route.rb b/lib/puppet/network/http/route.rb index c9af539ad2e..aa9f8c57716 100644 --- a/lib/puppet/network/http/route.rb +++ b/lib/puppet/network/http/route.rb @@ -28,39 +28,39 @@ def initialize(path_matcher) def get(*handlers) @method_handlers[:GET] = handlers - return self + self end def head(*handlers) @method_handlers[:HEAD] = handlers - return self + self end def options(*handlers) @method_handlers[:OPTIONS] = handlers - return self + self end def post(*handlers) @method_handlers[:POST] = handlers - return self + self end def put(*handlers) @method_handlers[:PUT] = handlers - return self + self end def delete(*handlers) @method_handlers[:DELETE] = handlers - return self + self end def any(*handlers) @method_handlers.each do |method, _registered_handlers| @method_handlers[method] = handlers end - return self + self end def chain(*routes) @@ -76,7 +76,7 @@ def matches?(request) Puppet.debug { "Did not match path (#{request.routing_path.inspect})" } end - return false + false end def process(request, response) diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index d5568c59394..54a3bc5fd7a 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -87,10 +87,10 @@ def initialize(name, modulepath, manifest, config_version) # parameters (:modulepath, :manifest, :config_version) # @return [Puppet::Node::Environment] def override_with(env_params) - return self.class.create(name, - env_params[:modulepath] || modulepath, - env_params[:manifest] || manifest, - env_params[:config_version] || config_version) + self.class.create(name, + env_params[:modulepath] || modulepath, + env_params[:manifest] || manifest, + env_params[:config_version] || config_version) end # Creates a new Puppet::Node::Environment instance, overriding :manifest, @@ -537,10 +537,10 @@ def self.split_path(path_string) end def ==(other) - return true if other.is_a?(Puppet::Node::Environment) && - name == other.name && - full_modulepath == other.full_modulepath && - manifest == other.manifest + true if other.is_a?(Puppet::Node::Environment) && + name == other.name && + full_modulepath == other.full_modulepath && + manifest == other.manifest end alias eql? == @@ -623,7 +623,7 @@ def perform_initial_import # # @return [Puppet::Parser::AST::Hostclass] def empty_parse_result - return Puppet::Parser::AST::Hostclass.new('') + Puppet::Parser::AST::Hostclass.new('') end # A None subclass to make it easier to trace the NONE environment when debugging. diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index 33f0145bc02..9f4db03ec40 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -395,9 +395,9 @@ def noop # @api private def pathbuilder if @resource - return [@resource.pathbuilder, name] + [@resource.pathbuilder, name] else - return [name] + [name] end end diff --git a/lib/puppet/parameter/value.rb b/lib/puppet/parameter/value.rb index c217d147db5..6ded772d7b8 100644 --- a/lib/puppet/parameter/value.rb +++ b/lib/puppet/parameter/value.rb @@ -57,9 +57,9 @@ def initialize(name) # def match?(value) if regex? - return true if name =~ value.to_s + true if name =~ value.to_s else - return(name == convert(value) ? true : @aliases.include?(convert(value))) + (name == convert(value) ? true : @aliases.include?(convert(value))) end end diff --git a/lib/puppet/parameter/value_collection.rb b/lib/puppet/parameter/value_collection.rb index cf27c80818b..8e25e3921f5 100644 --- a/lib/puppet/parameter/value_collection.rb +++ b/lib/puppet/parameter/value_collection.rb @@ -103,12 +103,12 @@ def munge(value) instance = match?(value) if instance if instance.regex? - return value + value else - return instance.name + instance.name end else - return value + value end end diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb index 4e05819563e..be82a5339c9 100644 --- a/lib/puppet/parser/ast.rb +++ b/lib/puppet/parser/ast.rb @@ -29,7 +29,7 @@ def safeevaluate(scope) # We duplicate code here, rather than using exceptwrap, because this # is called so many times during parsing. - return evaluate(scope) + evaluate(scope) rescue Puppet::Pops::Evaluator::PuppetStopIteration => detail raise detail # # Only deals with StopIteration from the break() function as a general diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index 6119a01a258..6384829efad 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -20,7 +20,7 @@ def instantiate(modname) end end end - return all_types + all_types end def code diff --git a/lib/puppet/parser/ast/pops_bridge.rb b/lib/puppet/parser/ast/pops_bridge.rb index 3217afd002e..87ceab951e7 100644 --- a/lib/puppet/parser/ast/pops_bridge.rb +++ b/lib/puppet/parser/ast/pops_bridge.rb @@ -59,7 +59,7 @@ def children class ExpressionSupportingReturn < Expression def evaluate(scope) - return catch(:return) do + catch(:return) do return catch(:next) do return super(scope) end diff --git a/lib/puppet/parser/ast/resourceparam.rb b/lib/puppet/parser/ast/resourceparam.rb index efe8b5fd96a..868f4c35e5c 100644 --- a/lib/puppet/parser/ast/resourceparam.rb +++ b/lib/puppet/parser/ast/resourceparam.rb @@ -17,7 +17,7 @@ def each # Return the parameter and the value. def evaluate(scope) value = @value.safeevaluate(scope) - return Puppet::Parser::Resource::Param.new( + Puppet::Parser::Resource::Param.new( :name => @param, :value => value.nil? ? :undef : value, :source => scope.source, diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 77462683b6e..b623f3b7bf8 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -150,9 +150,9 @@ def initialize(type, title, attributes, with_defaults = true) # Is this resource modeling an isomorphic resource type? def isomorphic? if builtin_type? - return resource_type.isomorphic? + resource_type.isomorphic? else - return true + true end end diff --git a/lib/puppet/parser/resource/param.rb b/lib/puppet/parser/resource/param.rb index 5210e9f2781..cb4032219bd 100644 --- a/lib/puppet/parser/resource/param.rb +++ b/lib/puppet/parser/resource/param.rb @@ -32,6 +32,6 @@ def to_s def self.from_param(param, value) new_param = param.dup new_param.value = value - return new_param + new_param end end diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index ca7386e4f54..4d3436d264b 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -625,7 +625,7 @@ def lookup_qualified_variable(fqn, options) end end # report with leading '::' by using empty class_name - return handle_not_found('', fqn, options) + handle_not_found('', fqn, options) end # @api private diff --git a/lib/puppet/parser/script_compiler.rb b/lib/puppet/parser/script_compiler.rb index 7d82531ae6c..53f57b7edd7 100644 --- a/lib/puppet/parser/script_compiler.rb +++ b/lib/puppet/parser/script_compiler.rb @@ -118,6 +118,6 @@ def newscope(parent, options = {}) def evaluate_main @loaders.pre_load program = @loaders.load_main_manifest - return program.nil? ? nil : Puppet::Pops::Parser::EvaluatingParser.singleton.evaluator.evaluate(program, @topscope) + program.nil? ? nil : Puppet::Pops::Parser::EvaluatingParser.singleton.evaluator.evaluate(program, @topscope) end end diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb index 874190bc91f..f4d0ff6b763 100644 --- a/lib/puppet/parser/type_loader.rb +++ b/lib/puppet/parser/type_loader.rb @@ -78,14 +78,14 @@ def try_load_fqname(type, fqname) # preserves existing behaviours. end # Nothing found. - return nil + nil end def parse_file(file) Puppet.debug { "importing '#{file}' in environment #{environment}" } parser = Puppet::Parser::ParserFactory.parser parser.file = file - return parser.parse + parser.parse end private diff --git a/lib/puppet/pops/evaluator/access_operator.rb b/lib/puppet/pops/evaluator/access_operator.rb index fd34f448040..eb09455666a 100644 --- a/lib/puppet/pops/evaluator/access_operator.rb +++ b/lib/puppet/pops/evaluator/access_operator.rb @@ -665,7 +665,7 @@ def access_PResourceType(o, scope, keys) Types::PResourceType.new(type_name, t == :no_title ? nil : t) end # returns single type if request was for a single entity, else an array of types (possibly empty) - return result_type_array ? result : result.pop + result_type_array ? result : result.pop end NS = '::' @@ -725,7 +725,7 @@ def access_PClassType(o, scope, keys) end # returns single type as type, else an array of types - return result_type_array ? result : result.pop + result_type_array ? result : result.pop end end end diff --git a/lib/puppet/pops/evaluator/collector_transformer.rb b/lib/puppet/pops/evaluator/collector_transformer.rb index 61dae6df873..cbdf43fa202 100644 --- a/lib/puppet/pops/evaluator/collector_transformer.rb +++ b/lib/puppet/pops/evaluator/collector_transformer.rb @@ -182,19 +182,19 @@ def match_AccessExpression(o, scope) def match_AndExpression(o, scope) left_match = match(o.left_expr, scope) right_match = match(o.right_expr, scope) - return [left_match, 'and', right_match] + [left_match, 'and', right_match] end def match_OrExpression(o, scope) left_match = match(o.left_expr, scope) right_match = match(o.right_expr, scope) - return [left_match, 'or', right_match] + [left_match, 'or', right_match] end def match_ComparisonExpression(o, scope) left_match = match(o.left_expr, scope) right_match = match(o.right_expr, scope) - return [left_match, o.operator.to_s, right_match] + [left_match, o.operator.to_s, right_match] end def match_VariableExpression(o, scope) diff --git a/lib/puppet/pops/evaluator/compare_operator.rb b/lib/puppet/pops/evaluator/compare_operator.rb index c5f0dff3e60..5429581f3bd 100644 --- a/lib/puppet/pops/evaluator/compare_operator.rb +++ b/lib/puppet/pops/evaluator/compare_operator.rb @@ -183,15 +183,15 @@ def include_Array(a, b, scope) end # Always set match data, a "not found" should not keep old match data visible set_match_data(matched, scope) # creates ephemeral - return !!matched + !!matched when String, SemanticPuppet::Version a.any? { |element| match(b, element, scope) } when Types::PAnyType a.each { |element| return true if b.instance?(element) } - return false + false else a.each { |element| return true if equals(element, b) } - return false + false end end diff --git a/lib/puppet/pops/evaluator/evaluator_impl.rb b/lib/puppet/pops/evaluator/evaluator_impl.rb index 2b9baa6e64f..3c8a3562f03 100644 --- a/lib/puppet/pops/evaluator/evaluator_impl.rb +++ b/lib/puppet/pops/evaluator/evaluator_impl.rb @@ -747,7 +747,7 @@ def eval_Program(o, scope) file = o.locator.file line = 0 # Add stack frame for "top scope" logic. See Puppet::Pops::PuppetStack - return Puppet::Pops::PuppetStack.stack(file, line, self, 'evaluate', [o.body, scope]) + Puppet::Pops::PuppetStack.stack(file, line, self, 'evaluate', [o.body, scope]) # evaluate(o.body, scope) rescue Puppet::Pops::Evaluator::PuppetStopIteration => ex # breaking out of a file level program is not allowed diff --git a/lib/puppet/pops/functions/function.rb b/lib/puppet/pops/functions/function.rb index c8cf5a574be..bbf76dac77b 100644 --- a/lib/puppet/pops/functions/function.rb +++ b/lib/puppet/pops/functions/function.rb @@ -43,7 +43,7 @@ def call(scope, *args, &block) result = catch(:return) do return self.class.dispatcher.dispatch(self, scope, args, &block) end - return result.value + result.value rescue Puppet::Pops::Evaluator::Next => jumper begin throw :next, jumper.value diff --git a/lib/puppet/pops/loader/loader.rb b/lib/puppet/pops/loader/loader.rb index 56f105798c0..e28b61f4e8e 100644 --- a/lib/puppet/pops/loader/loader.rb +++ b/lib/puppet/pops/loader/loader.rb @@ -54,7 +54,7 @@ def initialize(loader_name, environment) # @yieldreturn [Boolean] `true` to keep the entry, `false` to discard it. # @return [Array] the list of names of discovered values def discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_AUTHORITY, &block) - return EMPTY_ARRAY + EMPTY_ARRAY end # Produces the value associated with the given name if already loaded, or available for loading diff --git a/lib/puppet/pops/loader/module_loaders.rb b/lib/puppet/pops/loader/module_loaders.rb index 1a3dd37bb31..1c635a37985 100644 --- a/lib/puppet/pops/loader/module_loaders.rb +++ b/lib/puppet/pops/loader/module_loaders.rb @@ -82,7 +82,7 @@ def self.pcore_resource_type_loader_from(parent_loader, loaders, environment_pat class EmptyLoader < BaseLoader def find(typed_name) - return nil + nil end def private_loader diff --git a/lib/puppet/pops/lookup/data_dig_function_provider.rb b/lib/puppet/pops/lookup/data_dig_function_provider.rb index 937b273ed16..d2abe6c8e92 100644 --- a/lib/puppet/pops/lookup/data_dig_function_provider.rb +++ b/lib/puppet/pops/lookup/data_dig_function_provider.rb @@ -92,7 +92,7 @@ def instantiate_backend(lookup_invocation) require 'hiera/backend' require "hiera/backend/#{backend_name.downcase}_backend" backend = Hiera::Backend.const_get("#{backend_name.capitalize}_backend").new - return backend.method(:lookup).arity == 4 ? Hiera::Backend::Backend1xWrapper.new(backend) : backend + backend.method(:lookup).arity == 4 ? Hiera::Backend::Backend1xWrapper.new(backend) : backend rescue LoadError => e lookup_invocation.report_text { "Unable to load backend '#{backend_name}': #{e.message}" } throw :no_such_key diff --git a/lib/puppet/pops/model/ast_transformer.rb b/lib/puppet/pops/model/ast_transformer.rb index 9ccb275b877..c79fc10dacc 100644 --- a/lib/puppet/pops/model/ast_transformer.rb +++ b/lib/puppet/pops/model/ast_transformer.rb @@ -91,11 +91,11 @@ def hostname_Array(o) end def hostname_LiteralValue(o) - return o.value + o.value end def hostname_QualifiedName(o) - return o.value + o.value end def hostname_LiteralNumber(o) @@ -103,7 +103,7 @@ def hostname_LiteralNumber(o) end def hostname_LiteralDefault(o) - return 'default' + 'default' end def hostname_LiteralRegularExpression(o) diff --git a/lib/puppet/pops/model/factory.rb b/lib/puppet/pops/model/factory.rb index 3f92900dc0f..11032163d4e 100644 --- a/lib/puppet/pops/model/factory.rb +++ b/lib/puppet/pops/model/factory.rb @@ -648,7 +648,7 @@ def self.set_resource_form(expr, form) return false unless expr.instance_of?(self) && expr.model_class <= AbstractResource expr['form'] = form - return true + true end # Returns symbolic information about an expected shape of a resource expression given the LHS of a resource expr. diff --git a/lib/puppet/pops/parser/epp_parser.rb b/lib/puppet/pops/parser/epp_parser.rb index e70899920af..804f34c5e09 100644 --- a/lib/puppet/pops/parser/epp_parser.rb +++ b/lib/puppet/pops/parser/epp_parser.rb @@ -43,7 +43,7 @@ def _parse # rescue => except # raise Puppet::ParseError.new(except.message, @lexer.file, @lexer.line, @lexer.pos, except) end - return main + main ensure @lexer.clear @namestack = [] diff --git a/lib/puppet/pops/parser/locator.rb b/lib/puppet/pops/parser/locator.rb index b91e4fb6e1d..0d469a33a36 100644 --- a/lib/puppet/pops/parser/locator.rb +++ b/lib/puppet/pops/parser/locator.rb @@ -163,7 +163,7 @@ def ary_bsearch_i(ary, value) return nil if low == ary.length return nil unless satisfied - return low + low end def hash @@ -192,7 +192,7 @@ def line_for_offset(offset) # If not found it is after last # clear cache @prev_offset = @prev_line = nil - return line_index.size + line_index.size end end diff --git a/lib/puppet/pops/parser/parser_support.rb b/lib/puppet/pops/parser/parser_support.rb index 0f6bdca2687..4dbf04f7948 100644 --- a/lib/puppet/pops/parser/parser_support.rb +++ b/lib/puppet/pops/parser/parser_support.rb @@ -241,7 +241,7 @@ def _parse @yydebug = false main = yyparse(@lexer, :scan) end - return main + main ensure @lexer.clear @namestack = [] diff --git a/lib/puppet/pops/types/ruby_generator.rb b/lib/puppet/pops/types/ruby_generator.rb index e3cc3a10797..861e92fbe99 100644 --- a/lib/puppet/pops/types/ruby_generator.rb +++ b/lib/puppet/pops/types/ruby_generator.rb @@ -64,7 +64,7 @@ def create_class(obj) class_body(key, EMPTY_ARRAY, class_def) cls = Class.new(parent_class) cls.class_eval(class_def) - cls.define_singleton_method(:_pcore_type) { return key } + cls.define_singleton_method(:_pcore_type) { key } key.implementation_class = cls end hash[key] = cls diff --git a/lib/puppet/pops/types/string_converter.rb b/lib/puppet/pops/types/string_converter.rb index a2f18d60f95..f633a986e8e 100644 --- a/lib/puppet/pops/types/string_converter.rb +++ b/lib/puppet/pops/types/string_converter.rb @@ -47,7 +47,7 @@ def breaks? end def padding - return ' ' * 2 * level + ' ' * 2 * level end end @@ -1136,7 +1136,7 @@ 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") + Format.new("%s") end private :get_format end diff --git a/lib/puppet/pops/types/type_factory.rb b/lib/puppet/pops/types/type_factory.rb index 7cc44253b0c..b76698a9f83 100644 --- a/lib/puppet/pops/types/type_factory.rb +++ b/lib/puppet/pops/types/type_factory.rb @@ -313,7 +313,7 @@ def self.scalar_data # @api public # def self.all_callables - return PCallableType::DEFAULT + PCallableType::DEFAULT end # Produces a Callable type with one signature without support for a block diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb index 5e67ff44c39..41885f2d006 100644 --- a/lib/puppet/pops/types/types.rb +++ b/lib/puppet/pops/types/types.rb @@ -737,7 +737,7 @@ def self.register_ptype(loader, ir) end def instance?(o, guard = nil) - return o.instance_of?(String) || o.is_a?(Integer) || o.is_a?(Float) || o.is_a?(TrueClass) || o.is_a?(FalseClass) + o.instance_of?(String) || o.is_a?(Integer) || o.is_a?(Float) || o.is_a?(TrueClass) || o.is_a?(FalseClass) end DEFAULT = PScalarDataType.new diff --git a/lib/puppet/pops/validation/checker4_0.rb b/lib/puppet/pops/validation/checker4_0.rb index 472e7ade9ca..691a6ce629c 100644 --- a/lib/puppet/pops/validation/checker4_0.rb +++ b/lib/puppet/pops/validation/checker4_0.rb @@ -620,7 +620,7 @@ def namespace_for_file(file) # If a file comes from a module, but isn't in the right place, always error names = dir_to_names(relative_path) - return adapter.file_to_namespace[file] = (names == BAD_MODULE_FILE ? BAD_MODULE_FILE : names.join("::").freeze) + adapter.file_to_namespace[file] = (names == BAD_MODULE_FILE ? BAD_MODULE_FILE : names.join("::").freeze) end def initial_manifest?(path, manifest_setting) @@ -647,7 +647,7 @@ def is_parent_dir_of?(parent_dir, child_dir) parent_dir_path = Pathname.new(parent_dir) clean_parent = parent_dir_path.cleanpath.to_s + File::SEPARATOR - return child_dir.start_with?(clean_parent) + child_dir.start_with?(clean_parent) end private :is_parent_dir_of? diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb index 1bad9a6b61a..f5f50db26df 100644 --- a/lib/puppet/property.rb +++ b/lib/puppet/property.rb @@ -204,11 +204,11 @@ def call_provider(value) # def change_to_s(current_value, newvalue) if current_value == :absent - return "defined '#{name}' as #{should_to_s(newvalue)}" + "defined '#{name}' as #{should_to_s(newvalue)}" elsif newvalue == :absent or newvalue == [:absent] - return "undefined '#{name}' from #{is_to_s(current_value)}" + "undefined '#{name}' from #{is_to_s(current_value)}" else - return "#{name} changed #{is_to_s(current_value)} to #{should_to_s(newvalue)}" + "#{name} changed #{is_to_s(current_value)} to #{should_to_s(newvalue)}" end rescue Puppet::Error raise @@ -231,11 +231,11 @@ def event_name name == :ensure or return (name.to_s + "_changed").to_sym - return (resource.type.to_s + case value - when :present; "_created" - when :absent; "_removed" - else "_changed" - end).to_sym + (resource.type.to_s + case value + when :present; "_created" + when :absent; "_removed" + else "_changed" + end).to_sym end # Produces an event describing a change of this property. @@ -331,14 +331,14 @@ def insync?(is) # # This does mean that property equality is not commutative, and will not # work unless the `is` value is carefully arranged to match the should. - return (is == @should or is == @should.map(&:to_s)) + (is == @should or is == @should.map(&:to_s)) # When we stop being idiots about this, and actually have meaningful # semantics, this version is the thing we actually want to do. # # return is.zip(@should).all? {|a, b| property_matches?(a, b) } else - return @should.any? { |want| property_matches?(is, want) } + @should.any? { |want| property_matches?(is, want) } end end @@ -527,9 +527,9 @@ def should devfail "should for #{self.class.name} on #{resource.name} is not an array" unless @should.is_a?(Array) if match_all? - return @should.collect { |val| unmunge(val) } + @should.collect { |val| unmunge(val) } else - return unmunge(@should[0]) + unmunge(@should[0]) end end diff --git a/lib/puppet/property/ensure.rb b/lib/puppet/property/ensure.rb index 739b32ec5b8..a227145916c 100644 --- a/lib/puppet/property/ensure.rb +++ b/lib/puppet/property/ensure.rb @@ -53,11 +53,11 @@ def self.inherited(sub) def change_to_s(currentvalue, newvalue) if currentvalue == :absent || currentvalue.nil? - return _("created") + _("created") elsif newvalue == :absent - return _("removed") + _("removed") else - return _('%{name} changed %{is} to %{should}') % { name: name, is: is_to_s(currentvalue), should: should_to_s(newvalue) } + _('%{name} changed %{is} to %{should}') % { name: name, is: is_to_s(currentvalue), should: should_to_s(newvalue) } end rescue Puppet::Error raise @@ -88,9 +88,9 @@ def retrieve raise Puppet::DevError, _("No ability to determine if %{name} exists") % { name: @resource.class.name } end if result - return :present + :present else - return :absent + :absent end end diff --git a/lib/puppet/property/keyvalue.rb b/lib/puppet/property/keyvalue.rb index 45d146c5657..28933aae67b 100644 --- a/lib/puppet/property/keyvalue.rb +++ b/lib/puppet/property/keyvalue.rb @@ -110,9 +110,9 @@ def retrieve # ok, some 'convention' if the keyvalue property is named properties, provider should implement a properties method key_hash = provider.send(name) if provider if key_hash && key_hash != :absent - return key_hash + key_hash else - return :absent + :absent end end diff --git a/lib/puppet/property/list.rb b/lib/puppet/property/list.rb index 895e478cad4..ded51d0bb01 100644 --- a/lib/puppet/property/list.rb +++ b/lib/puppet/property/list.rb @@ -48,9 +48,9 @@ def retrieve # ok, some 'convention' if the list property is named groups, provider should implement a groups method tmp = provider.send(name) if provider if tmp && tmp != :absent - return tmp.instance_of?(Array) ? tmp : tmp.split(delimiter) + tmp.instance_of?(Array) ? tmp : tmp.split(delimiter) else - return :absent + :absent end end diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb index 7b8c7d05341..a0996576f51 100644 --- a/lib/puppet/provider.rb +++ b/lib/puppet/provider.rb @@ -290,7 +290,7 @@ def self.some_default_match(defaultlist) def self.fact_match(fact, values) fact_val = Puppet.runtime[:facter].value(fact).to_s.downcase if fact_val.empty? - return false + false else values = [values] unless values.is_a?(Array) values.any? do |value| @@ -536,7 +536,7 @@ def initialize(resource = nil) def name n = @property_hash[:name] if n - return n + n elsif resource resource.name else @@ -579,7 +579,7 @@ def <=>(other) return nil unless other.is_a? Puppet::Provider # Otherwise, order by the providers class name. - return self.class.name <=> other.class.name + self.class.name <=> other.class.name end # @comment Document prefetch here as it does not exist anywhere else (called from transaction if implemented) diff --git a/lib/puppet/provider/exec.rb b/lib/puppet/provider/exec.rb index 85137f8a90e..a0e28750adc 100644 --- a/lib/puppet/provider/exec.rb +++ b/lib/puppet/provider/exec.rb @@ -82,7 +82,7 @@ def run(command, check = false) # Return output twice as processstatus was returned before, but only exitstatus was ever called. # Output has the exitstatus on it so it is returned instead. This is here twice as changing this # would result in a change to the underlying API. - return output, output + [output, output] end def extractexe(command) diff --git a/lib/puppet/provider/file/posix.rb b/lib/puppet/provider/file/posix.rb index b64a72f50a9..445dbb13cbf 100644 --- a/lib/puppet/provider/file/posix.rb +++ b/lib/puppet/provider/file/posix.rb @@ -27,9 +27,9 @@ def uid2name(id) end if user.uid == "" - return nil + nil else - return user.name + user.name end end @@ -51,9 +51,9 @@ def gid2name(id) end if group.gid == "" - return nil + nil else - return group.name + group.name end end @@ -132,9 +132,9 @@ def group=(should) def mode stat = resource.stat if stat - return (stat.mode & 0o07777).to_s(8).rjust(4, '0') + (stat.mode & 0o07777).to_s(8).rjust(4, '0') else - return :absent + :absent end end diff --git a/lib/puppet/provider/group/directoryservice.rb b/lib/puppet/provider/group/directoryservice.rb index becbf1cfca7..25ca91027e4 100644 --- a/lib/puppet/provider/group/directoryservice.rb +++ b/lib/puppet/provider/group/directoryservice.rb @@ -14,10 +14,11 @@ def members_insync?(current, should) return false unless current + if current == :absent - return should.empty? + should.empty? else - return current.sort.uniq == should.sort.uniq + current.sort.uniq == should.sort.uniq end end end diff --git a/lib/puppet/provider/group/windows_adsi.rb b/lib/puppet/provider/group/windows_adsi.rb index 0125e3347ba..2e169b8ed05 100644 --- a/lib/puppet/provider/group/windows_adsi.rb +++ b/lib/puppet/provider/group/windows_adsi.rb @@ -57,7 +57,7 @@ def members_to_s(users) resource.debug("#{sid.domain}\\#{account} (#{sid.sid})") sid.domain ? "#{sid.domain}\\#{account}" : account end - return users.join(',') + users.join(',') end def member_valid?(user_name) diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb index cae8da94911..382494b9e8b 100644 --- a/lib/puppet/provider/nameservice.rb +++ b/lib/puppet/provider/nameservice.rb @@ -108,15 +108,15 @@ def autogen(field) field = field.intern id_generators = { :user => :uid, :group => :gid } if id_generators[@resource.class.name] == field - return self.class.autogen_id(field, @resource.class.name) + self.class.autogen_id(field, @resource.class.name) else value = self.class.autogen_default(field) if value - return value + value elsif respond_to?("autogen_#{field}") - return send("autogen_#{field}") + send("autogen_#{field}") else - return nil + nil end end end diff --git a/lib/puppet/provider/package/aix.rb b/lib/puppet/provider/package/aix.rb index 2a2a485b202..2f046fd20ca 100644 --- a/lib/puppet/provider/package/aix.rb +++ b/lib/puppet/provider/package/aix.rb @@ -137,9 +137,9 @@ def self.pkglist(hash = {}) end if hash[:pkgname] - return list.shift + list.shift else - return list + list end end @@ -153,11 +153,11 @@ def latest upd = latest_info unless upd.nil? - return (upd[:version]).to_s + (upd[:version]).to_s else raise Puppet::DevError, _("Tried to get latest on a missing package") if properties[:ensure] == :absent - return properties[:ensure] + properties[:ensure] end end diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index 0442c73812b..4da9ed3f9d2 100644 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -189,10 +189,10 @@ def latest output = aptcache :policy, @resource[:name] if output =~ /Candidate:\s+(\S+)\s/ - return Regexp.last_match(1) + Regexp.last_match(1) else err _("Could not find latest version") - return nil + nil end end diff --git a/lib/puppet/provider/package/aptrpm.rb b/lib/puppet/provider/package/aptrpm.rb index 3047b071bfa..81edfaa1e06 100644 --- a/lib/puppet/provider/package/aptrpm.rb +++ b/lib/puppet/provider/package/aptrpm.rb @@ -67,7 +67,7 @@ def latest end # Get the latest and greatest version number - return available_versions.pop + available_versions.pop else err _("Could not match string") end diff --git a/lib/puppet/provider/package/blastwave.rb b/lib/puppet/provider/package/blastwave.rb index b8f11491bef..8eec34e2873 100644 --- a/lib/puppet/provider/package/blastwave.rb +++ b/lib/puppet/provider/package/blastwave.rb @@ -50,12 +50,12 @@ def self.blastlist(hash) end if hash[:justme] - return list[0] + list[0] else list.reject! { |h| h[:ensure] == :absent } - return list + list end end @@ -76,10 +76,10 @@ def self.blastsplit(line) # Use the name method, so it works with subclasses. hash[:provider] = name - return hash + hash else Puppet.warning _("Cannot match %{line}") % { line: line } - return nil + nil end end diff --git a/lib/puppet/provider/package/dnfmodule.rb b/lib/puppet/provider/package/dnfmodule.rb index 22eaea7cdee..8d58d2fdd8f 100644 --- a/lib/puppet/provider/package/dnfmodule.rb +++ b/lib/puppet/provider/package/dnfmodule.rb @@ -113,7 +113,7 @@ def insync?(is) end return true if pkg end - return false + false end def enable(args = @resource[:name]) diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index 4ce85cddf33..f91b5df5cc0 100644 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -81,7 +81,7 @@ def self.parse_line(line, regex = self::FIELDS_REGEX) Puppet.debug("Failed to match dpkg-query line #{line.inspect}") end - return hash + hash end public diff --git a/lib/puppet/provider/package/fink.rb b/lib/puppet/provider/package/fink.rb index c12b53cf9e7..b4e857ba3dd 100644 --- a/lib/puppet/provider/package/fink.rb +++ b/lib/puppet/provider/package/fink.rb @@ -52,10 +52,10 @@ def latest output = aptcache :policy, @resource[:name] if output =~ /Candidate:\s+(\S+)\s/ - return Regexp.last_match(1) + Regexp.last_match(1) else err _("Could not find latest version") - return nil + nil end end diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index d41ab27a93c..c0a46c1a4e9 100644 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -126,9 +126,9 @@ def self.gemlist(options) end if options[:justme] - return list.shift + list.shift else - return list + list end end diff --git a/lib/puppet/provider/package/macports.rb b/lib/puppet/provider/package/macports.rb index c1bf2198a45..79e904d9b3f 100644 --- a/lib/puppet/provider/package/macports.rb +++ b/lib/puppet/provider/package/macports.rb @@ -76,7 +76,7 @@ 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 + result end def latest diff --git a/lib/puppet/provider/package/nim.rb b/lib/puppet/provider/package/nim.rb index da2eef685f0..6c84a3a5e85 100644 --- a/lib/puppet/provider/package/nim.rb +++ b/lib/puppet/provider/package/nim.rb @@ -271,11 +271,11 @@ def determine_latest_version(showres_output, package_name) if packages[package_name].count == 1 version = packages[package_name].keys[0] - return packages[package_name][version], nil + [packages[package_name][version], nil] else versions = packages[package_name].keys latest_version = (versions.sort { |a, b| Puppet::Util::Package.versioncmp(b, a) })[0] - return packages[package_name][latest_version], latest_version + [packages[package_name][latest_version], latest_version] end end diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb index f39794f9938..6e05ef03934 100644 --- a/lib/puppet/provider/package/openbsd.rb +++ b/lib/puppet/provider/package/openbsd.rb @@ -56,9 +56,9 @@ def self.instances } end - return packages + packages rescue Puppet::ExecutionFailure - return nil + nil end end @@ -95,7 +95,7 @@ def latest if output =~ /^#{resource[:name]}-(\d[^-]*)-?(\w*) \(installed\)$/ debug "Package is already the latest available" - return version + version else match = /^(.*)-(\d[^-]*)-?(\w*)$/.match(output) debug "Latest available for #{resource[:name]}: #{match[2]}" @@ -109,9 +109,9 @@ def latest # The locally installed package may actually be newer than what a mirror # has. Log it at debug, but ignore it otherwise. debug "Package #{resource[:name]} #{version} newer then available #{match[2]}" - return version + version else - return match[2] + match[2] end end end @@ -222,15 +222,15 @@ def get_version raise Puppet::Error, _("%{version} is not available for this package") % { version: version } end rescue Puppet::ExecutionFailure - return nil + nil end def query # Search for the version info if pkginfo(@resource[:name]) =~ /Information for (inst:)?#{@resource[:name]}-(\S+)/ - return { :ensure => Regexp.last_match(2) } + { :ensure => Regexp.last_match(2) } else - return nil + nil end end diff --git a/lib/puppet/provider/package/opkg.rb b/lib/puppet/provider/package/opkg.rb index 84769e42c6c..e2524ba6673 100644 --- a/lib/puppet/provider/package/opkg.rb +++ b/lib/puppet/provider/package/opkg.rb @@ -31,7 +31,7 @@ def self.instances end packages rescue Puppet::ExecutionFailure - return nil + nil end def latest @@ -69,7 +69,7 @@ def query nil rescue Puppet::ExecutionFailure - return { + { :ensure => :purged, :status => 'missing', :name => @resource[:name], diff --git a/lib/puppet/provider/package/pacman.rb b/lib/puppet/provider/package/pacman.rb index de604ca1bfe..abfa24849cf 100644 --- a/lib/puppet/provider/package/pacman.rb +++ b/lib/puppet/provider/package/pacman.rb @@ -141,7 +141,7 @@ def latest begin if pacman_check output = pacman "-Sp", "--print-format", "%v", resource_name - return output.chomp + output.chomp else output = yaourt "-Qma", resource_name output.split("\n").each do |line| diff --git a/lib/puppet/provider/package/pip.rb b/lib/puppet/provider/package/pip.rb index cb56abd31ee..7c00c73b7b7 100644 --- a/lib/puppet/provider/package/pip.rb +++ b/lib/puppet/provider/package/pip.rb @@ -116,7 +116,7 @@ def query self.class.instances(command).each do |pkg| return pkg.properties if @resource[:name].casecmp(pkg.name).zero? end - return nil + nil end # Return latest version available for current package diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb index 5127a793e77..ec9bfb29f5d 100644 --- a/lib/puppet/provider/package/pkgdmg.rb +++ b/lib/puppet/provider/package/pkgdmg.rb @@ -137,9 +137,9 @@ def self.installpkgdmg(source, name) def query if Puppet::FileSystem.exist?("/var/db/.puppet_pkgdmg_installed_#{@resource[:name]}") Puppet.debug "/var/db/.puppet_pkgdmg_installed_#{@resource[:name]} found" - return { :name => @resource[:name], :ensure => :present } + { :name => @resource[:name], :ensure => :present } else - return nil + nil end end diff --git a/lib/puppet/provider/package/pkgin.rb b/lib/puppet/provider/package/pkgin.rb index f3e1d2408e7..97f50312a57 100644 --- a/lib/puppet/provider/package/pkgin.rb +++ b/lib/puppet/provider/package/pkgin.rb @@ -79,7 +79,7 @@ def latest package = parse_pkgsearch_line.detect { |p| p[:status] == '<' } return properties[:ensure] unless package - return package[:ensure] + package[:ensure] end def update diff --git a/lib/puppet/provider/package/pkgng.rb b/lib/puppet/provider/package/pkgng.rb index 4194504130c..0abc5a12ea4 100644 --- a/lib/puppet/provider/package/pkgng.rb +++ b/lib/puppet/provider/package/pkgng.rb @@ -76,9 +76,9 @@ def self.instances packages << new(hash) end - return packages + packages rescue Puppet::ExecutionFailure - return [] + [] end end diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index d94fe57ab89..8ca4809da66 100644 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -105,11 +105,11 @@ def self.parse_pkglist(output, hash = {}) # Single queries may have been for an alias so return the name requested if list.any? list[-1][:name] = hash[:justme] - return list[-1] + list[-1] end else list.reject! { |h| h[:ensure] == :absent } - return list + list end end @@ -142,10 +142,10 @@ def self.pkgsplit(line) # Use the name method, so it works with subclasses. hash[:provider] = name - return hash + hash else Puppet.warning _("Cannot match %{line}") % { line: line } - return nil + nil end end diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb index f12c6040402..b7b273b6187 100644 --- a/lib/puppet/provider/package/portage.rb +++ b/lib/puppet/provider/package/portage.rb @@ -58,7 +58,7 @@ def self.instances packages << new(package) end - return packages + packages rescue Puppet::ExecutionFailure => detail raise Puppet::Error, detail end diff --git a/lib/puppet/provider/package/portupgrade.rb b/lib/puppet/provider/package/portupgrade.rb index cb1d38a20db..763866bd6b5 100644 --- a/lib/puppet/provider/package/portupgrade.rb +++ b/lib/puppet/provider/package/portupgrade.rb @@ -75,7 +75,7 @@ def self.instances } # return the packages array of hashes - return packages + packages end ######## Installation sub command @@ -97,7 +97,7 @@ def install end # No return code required, so do nil to be clean - return nil + nil end ######## Latest subcommand (returns the latest version available, or current version if installed is latest) @@ -126,24 +126,24 @@ def latest case comparison when "=", ">" Puppet.debug "portupgrade.latest() - Installed package is latest (#{installedversion})" - return installedversion + installedversion when "<" # "portpkg-1.7_5 < needs updating (port has 1.14)" # "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg') if otherdata =~ /\(port has (\S+)\)/ newversion = Regexp.last_match(1) Puppet.debug "portupgrade.latest() - Installed version needs updating to (#{newversion})" - return newversion + newversion else Puppet.debug "portupgrade.latest() - Unable to determine new version from (#{otherdata})" - return installedversion + installedversion end when "?", "!", "#" Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (#{output})" - return installedversion + installedversion else Puppet.debug "portupgrade.latest() - Unknown code from portversion output (#{output})" - return installedversion + installedversion end elsif output =~ /^\*\* No matching package / @@ -181,10 +181,10 @@ def query # If more details are required, then we can do another pkg_info # query here and parse out that output and add to the hash # return the hash to the caller - return hash + hash else Puppet.debug "portupgrade.query() - package (#{@resource[:name]}) not installed" - return nil + nil end end diff --git a/lib/puppet/provider/package/puppetserver_gem.rb b/lib/puppet/provider/package/puppetserver_gem.rb index 3e8212a5dde..1482d2e9993 100644 --- a/lib/puppet/provider/package/puppetserver_gem.rb +++ b/lib/puppet/provider/package/puppetserver_gem.rb @@ -74,9 +74,9 @@ def self.gemlist(options) .map { |set| gemsplit(set) } if options[:justme] - return gem_list.shift + gem_list.shift else - return gem_list + gem_list end end diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb index 0e71cee4fd7..6065f72983d 100644 --- a/lib/puppet/provider/package/rpm.rb +++ b/lib/puppet/provider/package/rpm.rb @@ -216,7 +216,7 @@ def self.nevra_to_hash(line) Puppet.debug("Failed to match rpm line #{line}") end - return hash + hash end # @param line [String] multiple lines of rpm package query information @@ -250,6 +250,6 @@ def self.nevra_to_multiversion_hash(multiline) return list[0] end - return list + list end end diff --git a/lib/puppet/provider/package/rug.rb b/lib/puppet/provider/package/rug.rb index 31531eb5a65..fed8816b1cd 100644 --- a/lib/puppet/provider/package/rug.rb +++ b/lib/puppet/provider/package/rug.rb @@ -36,11 +36,11 @@ def latest output = rug "list-updates" if output =~ /#{Regexp.escape @resource[:name]}\s*\|\s*([^\s|]+)/ - return Regexp.last_match(1) + Regexp.last_match(1) else # rug didn't find updates, pretend the current # version is the latest - return @property_hash[:ensure] + @property_hash[:ensure] end end diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb index ca9b91d3060..f2d20393fea 100644 --- a/lib/puppet/provider/package/sun.rb +++ b/lib/puppet/provider/package/sun.rb @@ -81,7 +81,7 @@ def info2hash(device = nil) # 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 } rescue Puppet::ExecutionFailure - return { :ensure => :absent } + { :ensure => :absent } end end diff --git a/lib/puppet/provider/package/up2date.rb b/lib/puppet/provider/package/up2date.rb index 90ccd5405b5..69d5fca0a40 100644 --- a/lib/puppet/provider/package/up2date.rb +++ b/lib/puppet/provider/package/up2date.rb @@ -25,11 +25,11 @@ def latest output = up2date "--showall" if output =~ /^#{Regexp.escape @resource[:name]}-(\d+.*)\.\w+/ - return Regexp.last_match(1) + Regexp.last_match(1) else # up2date didn't find updates, pretend the current # version is the latest - return @property_hash[:ensure] + @property_hash[:ensure] end end diff --git a/lib/puppet/provider/package/urpmi.rb b/lib/puppet/provider/package/urpmi.rb index e536cbdc11c..cb1a88c3228 100644 --- a/lib/puppet/provider/package/urpmi.rb +++ b/lib/puppet/provider/package/urpmi.rb @@ -34,11 +34,11 @@ def latest output = urpmq "-S", @resource[:name] if output =~ /^#{Regexp.escape @resource[:name]}\s+:\s+.*\(\s+(\S+)\s+\)/ - return Regexp.last_match(1) + Regexp.last_match(1) else # urpmi didn't find updates, pretend the current # version is the latest - return @resource[:ensure] + @resource[:ensure] end end diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 06447d2951e..7b2b206514c 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -336,14 +336,14 @@ def latest unless upd.nil? # FIXME: there could be more than one update for a package # because of multiarch - return "#{upd[:epoch]}:#{upd[:version]}-#{upd[:release]}" + "#{upd[:epoch]}:#{upd[:version]}-#{upd[:release]}" else # Yum didn't find updates, pretend the current version is the latest 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 + version end end diff --git a/lib/puppet/provider/package/zypper.rb b/lib/puppet/provider/package/zypper.rb index 5054d58a0ea..f5690d31c8b 100644 --- a/lib/puppet/provider/package/zypper.rb +++ b/lib/puppet/provider/package/zypper.rb @@ -151,10 +151,10 @@ def install # What's the latest package version available? def latest - return self.class.latest_package_version(@resource[:name]) || - # zypper didn't find updates, pretend the current - # version is the latest - @property_hash[:ensure] + self.class.latest_package_version(@resource[:name]) || + # zypper didn't find updates, pretend the current + # version is the latest + @property_hash[:ensure] end def update diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb index 3a553b20c9e..09e9dfa6093 100644 --- a/lib/puppet/provider/parsedfile.rb +++ b/lib/puppet/provider/parsedfile.rb @@ -325,13 +325,13 @@ def self.retrieve(path) text = target_object(path).read if text.nil? or text == "" # there is no file - return [] + [] else # Set the target, for logging. old = @target begin @target = path - return parse(text) + parse(text) rescue Puppet::Error => detail detail.file = @target if detail.respond_to?(:file=) raise detail diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb index 3476397affd..796e1135369 100644 --- a/lib/puppet/provider/service/base.rb +++ b/lib/puppet/provider/service/base.rb @@ -74,17 +74,17 @@ def status # Explicitly calling exitstatus to facilitate testing if status.exitstatus == 0 - return :running + :running else - return :stopped + :stopped end else pid = getpid if pid debug "PID is #{pid}" - return :running + :running else - return :stopped + :stopped end end end @@ -102,12 +102,7 @@ def start # The command used to start. Generated if the 'binary' argument # is passed. def startcmd - if @resource[:binary] - return @resource[:binary] - else - raise Puppet::Error, - "Services must specify a start command or a binary" - end + @resource[:binary] || raise(Puppet::Error, "Services must specify a start command or a binary") end # Stop the service. If a 'stop' parameter is specified, it @@ -130,7 +125,7 @@ def stop rescue Puppet::ExecutionFailure @resource.fail Puppet::Error, "Could not kill #{name}, PID #{pid}: #{output}", $! end - return true + true end end diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb index 8c90c8f0e06..046ce959a7d 100644 --- a/lib/puppet/provider/service/daemontools.rb +++ b/lib/puppet/provider/service/daemontools.rb @@ -141,10 +141,10 @@ def enabled? case status when :running # obviously if the daemon is running then it is enabled - return :true + :true else # the service is enabled if it is linked - return Puppet::FileSystem.symlink?(service) ? :true : :false + Puppet::FileSystem.symlink?(service) ? :true : :false end end diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb index d9466904115..013f41c6dc8 100644 --- a/lib/puppet/provider/service/debian.rb +++ b/lib/puppet/provider/service/debian.rb @@ -42,7 +42,7 @@ def enabled? # 106 is the exit status when the policy layer supplies a fallback action # See x-man-page://invoke-rc.d if [104, 106].include?(status.exitstatus) - return :true + :true elsif [101, 105].include?(status.exitstatus) # 101 is action not allowed, which means we have to do the check manually. # 105 is unknown, which generally means the initscript does not support query @@ -50,12 +50,12 @@ def enabled? # For those that do not, perform the checks manually # http://www.debian.org/doc/debian-policy/ch-opersys.html if get_start_link_count >= 4 - return :true + :true else - return :false + :false end else - return :false + :false end end diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb index 82ae10ab9c5..c787484eafa 100644 --- a/lib/puppet/provider/service/gentoo.rb +++ b/lib/puppet/provider/service/gentoo.rb @@ -33,9 +33,9 @@ def enabled? # If it's enabled then it will print output showing service | runlevel if output =~ /^\s*#{@resource[:name]}\s*\|\s*(boot|default)/ - return :true + :true else - return :false + :false end end diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index 57d736ab095..7a40868cea7 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -165,12 +165,12 @@ def self.jobsearch(label = nil) if label if by_label.has_key? label - return { label => by_label[label] } + { label => by_label[label] } else # try refreshing the map, in case a plist has been added in the interim by_label = make_label_to_path_map(true) if by_label.has_key? label - return { label => by_label[label] } + { label => by_label[label] } else raise Puppet::Error, "Unable to find launchd plist for job: #{label}" end @@ -248,7 +248,7 @@ def plist_from_label(label) # status mechanism and fall back to the base provider status method. def status if @resource && ((@resource[:hasstatus] == :false) || (@resource[:status])) - return super + super elsif @property_hash[:status].nil? # property_hash was flushed so the service changed status service_name = @resource[:name] diff --git a/lib/puppet/provider/service/openbsd.rb b/lib/puppet/provider/service/openbsd.rb index 7910d614b16..616b61ccc66 100644 --- a/lib/puppet/provider/service/openbsd.rb +++ b/lib/puppet/provider/service/openbsd.rb @@ -47,7 +47,7 @@ def self.instances end instances rescue Puppet::ExecutionFailure - return nil + nil end end @@ -57,10 +57,10 @@ def enabled? if output.exitstatus == 1 debug("Is disabled") - return :false + :false else debug("Is enabled") - return :true + :true end end @@ -80,7 +80,7 @@ def disable def running? output = execute([command(:rcctl), "check", @resource[:name]], :failonfail => false, :combine => false, :squelch => false).chomp - return true if output =~ /\(ok\)/ + true if output =~ /\(ok\)/ end # Uses the wrapper to prevent failure when the service is not running; diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb index ff73132d385..1d03f0607d5 100644 --- a/lib/puppet/provider/service/smf.rb +++ b/lib/puppet/provider/service/smf.rb @@ -216,13 +216,13 @@ def status case state when "online" - return :running + :running when "offline", "disabled", "uninitialized" - return :stopped + :stopped when "maintenance" - return :maintenance + :maintenance when "degraded" - return :degraded + :degraded when "legacy_run" raise Puppet::Error, "Cannot manage legacy services through SMF" diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb index 7bb3175613f..60c090b884e 100644 --- a/lib/puppet/provider/service/src.rb +++ b/lib/puppet/provider/service/src.rb @@ -142,6 +142,6 @@ def status end rescue Puppet::ExecutionFailure => detail debug(detail.message) - return :stopped + :stopped end end diff --git a/lib/puppet/provider/service/systemd.rb b/lib/puppet/provider/service/systemd.rb index 78284f49754..c83dfb7d539 100644 --- a/lib/puppet/provider/service/systemd.rb +++ b/lib/puppet/provider/service/systemd.rb @@ -39,9 +39,9 @@ def self.instances Puppet.debug("#{m[0]} marked as bad by `systemctl`. It is recommended to be further checked.") if m[1] == "bad" i << new(:name => m[0]) end - return i + i rescue Puppet::ExecutionFailure - return [] + [] end # Static services cannot be enabled or disabled manually. Indirect services @@ -55,11 +55,11 @@ def enabled_insync?(current) current == @resource[:enable] else Puppet.debug("Unable to enable or disable static service #{@resource[:name]}") - return true + true end when 'indirect' Puppet.debug("Service #{@resource[:name]} is in 'indirect' state and cannot be enabled/disabled") - return true + true else current == @resource[:enable] end @@ -122,7 +122,7 @@ def enabled? return ret if ret end - return :false + :false end # This method is required for Debian systems due to the way the SysVInit-Systemd @@ -133,7 +133,7 @@ def enabled? def debian_enabled? status = execute(["/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start"], :failonfail => false) if [104, 106].include?(status.exitstatus) - return :true + :true elsif [101, 105].include?(status.exitstatus) # 101 is action not allowed, which means we have to do the check manually. # 105 is unknown, which generally means the initscript does not support query @@ -141,12 +141,12 @@ def debian_enabled? # For those that do not, perform the checks manually # http://www.debian.org/doc/debian-policy/ch-opersys.html if get_start_link_count >= 4 - return :true + :true else - return :false + :false end else - return :false + :false end end @@ -170,12 +170,12 @@ def status if exist? status = service_command(:status, false) if status.exitstatus == 0 - return :running + :running else - return :stopped + :stopped end else - return :absent + :absent end end diff --git a/lib/puppet/provider/service/upstart.rb b/lib/puppet/provider/service/upstart.rb index 8dfbd02bd79..39597b3544c 100644 --- a/lib/puppet/provider/service/upstart.rb +++ b/lib/puppet/provider/service/upstart.rb @@ -186,9 +186,9 @@ def status output = status_exec(@resource[:name].split) if output =~ %r{start/} - return :running + :running else - return :stopped + :stopped end end @@ -213,9 +213,9 @@ def version_is_post_0_9_0 def enabled_pre_0_6_7?(script_text) # Upstart version < 0.6.7 means no manual stanza. if script_text.match(START_ON) - return :true + :true else - return :false + :false end end diff --git a/lib/puppet/provider/user/aix.rb b/lib/puppet/provider/user/aix.rb index 43eb9f6ba6e..287f32bd06f 100644 --- a/lib/puppet/provider/user/aix.rb +++ b/lib/puppet/provider/user/aix.rb @@ -75,7 +75,7 @@ def expires_to_expiry(provider, expires) month = match_obj[1] day = match_obj[2] year = match_obj[-1] - return "20#{year}-#{month}-#{day}" + "20#{year}-#{month}-#{day}" end # We do some validation before-hand to ensure the value's an Array, diff --git a/lib/puppet/provider/user/hpux.rb b/lib/puppet/provider/user/hpux.rb index f8e4c7c3250..ff3358a321a 100644 --- a/lib/puppet/provider/user/hpux.rb +++ b/lib/puppet/provider/user/hpux.rb @@ -76,7 +76,7 @@ def password debug "No trusted computing user file #{file_name} found." end else - return ent.passwd + ent.passwd end end @@ -84,11 +84,7 @@ def trusted # Check to see if the HP-UX box is running in trusted compute mode # UID for root should always be 0 trusted_sys = exec_getprpw('root', '-m uid') - if trusted_sys.chomp == "uid=0" - return true - else - return false - end + trusted_sys.chomp == "uid=0" end def exec_getprpw(user, opts) diff --git a/lib/puppet/provider/user/windows_adsi.rb b/lib/puppet/provider/user/windows_adsi.rb index 3b985fca0c3..07424eb7d85 100644 --- a/lib/puppet/provider/user/windows_adsi.rb +++ b/lib/puppet/provider/user/windows_adsi.rb @@ -81,7 +81,7 @@ def groups_to_s(groups) resource.debug("#{sid.domain}\\#{account} (#{sid.sid})") "#{sid.domain}\\#{account}" end - return groups.join(',') + groups.join(',') end def create diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 4c7bb40a3a3..be3cc93a51c 100644 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -48,11 +48,9 @@ def initialize(source, target, options = {}) # of :NONE comes from. def match?(event) if self.event.nil? or event == :NONE or self.event == :NONE - return false - elsif self.event == :ALL_EVENTS or event == self.event - return true + false else - return false + self.event == :ALL_EVENTS or event == self.event end end diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index f56c8b83d7a..3e907a61137 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -475,7 +475,7 @@ def to_hiera_hash res['ensure'] = value if value res.merge!(params.sort.to_h) - return { h['title'] => res } + { h['title'] => res } end # Convert our resource to Puppet code. @@ -671,7 +671,7 @@ def parse_title # resource should fail here. raise Puppet::Error, _("No set of title patterns matched the title \"%{title}\".") % { title: title } else - return { :name => title.to_s } + { :name => title.to_s } end end end diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 7a554bf5718..12cc6e72b53 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -93,7 +93,7 @@ def title_key_for_ref(ref) else a = [nil, nil] end - return a + a end def add_resource_before(other, *resources) diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index d329d9fff25..4129ef4e5de 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -56,7 +56,7 @@ def child_of?(klass) return true if override return false unless parent - return(klass == parent_type ? true : parent_type.child_of?(klass)) + (klass == parent_type ? true : parent_type.child_of?(klass)) end # Now evaluate the code associated with this class or definition. @@ -376,7 +376,7 @@ def namesplit(fullname) ary = fullname.split(DOUBLE_COLON) n = ary.pop || "" ns = ary.join(DOUBLE_COLON) - return ns, n + [ns, n] end def parent_scope(scope, klass) diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index b162b073ae5..f1b48bc3753 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -679,15 +679,15 @@ def parse_config_files(require_config = true) def main_config_file if explicit_config_file? - return self[:config] + self[:config] else - return File.join(Puppet::Util::RunMode[:server].conf_dir, config_file_name) + File.join(Puppet::Util::RunMode[:server].conf_dir, config_file_name) end end private :main_config_file def user_config_file - return File.join(Puppet::Util::RunMode[:user].conf_dir, config_file_name) + File.join(Puppet::Util::RunMode[:user].conf_dir, config_file_name) end private :user_config_file @@ -706,7 +706,7 @@ def config_file_name # This just means that the setting wasn't explicitly set on the command line, so we will ignore it and # fall through to the default name. end - return self.class.default_config_file_name + self.class.default_config_file_name end private :config_file_name @@ -1109,7 +1109,7 @@ def to_config end end - return str + str end # Convert to a parseable manifest @@ -1247,9 +1247,9 @@ def value_sym(param, environment = nil, bypass_interpolation = false) # in {https://projects.puppetlabs.com/issues/16637 #16637} def which_configuration_file if explicit_config_file? or Puppet.features.root? then - return main_config_file + main_config_file else - return user_config_file + user_config_file end end @@ -1379,7 +1379,7 @@ def value_sets_for(environment, mode) # Read the file in. # @api private def read_file(file) - return Puppet::FileSystem.read(file, :encoding => 'utf-8') + Puppet::FileSystem.read(file, :encoding => 'utf-8') end # Private method for internal test use only; allows to do a comprehensive clear of all settings between tests. @@ -1407,12 +1407,12 @@ def explicit_config_file? # get an exception. # - return true if self[:config] + true if self[:config] rescue InterpolationError # This means we failed to interpolate, which means that they didn't # explicitly specify either :config or :confdir... so we'll fall out to # the default value. - return false + false end private :explicit_config_file? diff --git a/lib/puppet/settings/base_setting.rb b/lib/puppet/settings/base_setting.rb index 75ca4d6dcba..ebbdf09df7c 100644 --- a/lib/puppet/settings/base_setting.rb +++ b/lib/puppet/settings/base_setting.rb @@ -146,7 +146,7 @@ def default(check_application_defaults_first = false) end return default_value unless check_application_defaults_first - return @settings.value(name, :application_defaults, true) || default_value + @settings.value(name, :application_defaults, true) || default_value end # Convert the object to a config statement. diff --git a/lib/puppet/settings/boolean_setting.rb b/lib/puppet/settings/boolean_setting.rb index 34a6e2429d6..16ff8326846 100644 --- a/lib/puppet/settings/boolean_setting.rb +++ b/lib/puppet/settings/boolean_setting.rb @@ -21,8 +21,8 @@ def optparse_args def munge(value) case value - when true, "true"; return true - when false, "false"; return false + when true, "true"; true + when false, "false"; false else raise Puppet::Settings::ValidationError, _("Invalid value '%{value}' for boolean parameter: %{name}") % { value: value.inspect, name: @name } end diff --git a/lib/puppet/settings/environment_conf.rb b/lib/puppet/settings/environment_conf.rb index 49ee488941d..5814f91174a 100644 --- a/lib/puppet/settings/environment_conf.rb +++ b/lib/puppet/settings/environment_conf.rb @@ -161,7 +161,7 @@ def self.validate(path_to_conf_file, config) valid = false end - return valid + valid end private_class_method :validate diff --git a/lib/puppet/settings/value_translator.rb b/lib/puppet/settings/value_translator.rb index 1c2533bff55..4d74e6d38ac 100644 --- a/lib/puppet/settings/value_translator.rb +++ b/lib/puppet/settings/value_translator.rb @@ -4,13 +4,13 @@ class Puppet::Settings::ValueTranslator def [](value) # Handle different data types correctly - return case value - when /^false$/i; false - when /^true$/i; true - when true; true - when false; false - else - value.gsub(/^["']|["']$/, '').sub(/\s+$/, '') - end + case value + when /^false$/i; false + when /^true$/i; true + when true; true + when false; false + else + value.gsub(/^["']|["']$/, '').sub(/\s+$/, '') + end end end diff --git a/lib/puppet/ssl/certificate_request_attributes.rb b/lib/puppet/ssl/certificate_request_attributes.rb index 5346f8f25b1..eafecde511b 100644 --- a/lib/puppet/ssl/certificate_request_attributes.rb +++ b/lib/puppet/ssl/certificate_request_attributes.rb @@ -35,6 +35,6 @@ def load return true end - return false + false end end diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb index 5528950c16a..49706857dda 100644 --- a/lib/puppet/transaction/event_manager.rb +++ b/lib/puppet/transaction/event_manager.rb @@ -155,14 +155,14 @@ def process_callback(resource, callback, events) add_callback_status_event(resource, callback, message, "success") end - return true + true rescue => detail resource_error_message = _("Failed to call %{callback}: %{detail}") % { callback: callback, detail: detail } resource.err(resource_error_message) transaction.resource_status(resource).failed_to_restart = true transaction.resource_status(resource).fail_with_event(resource_error_message) resource.log_exception(detail) - return false + false end def add_callback_status_event(resource, callback, message, status) diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index cfde9f73ec4..e6797599b51 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -275,7 +275,7 @@ def self.handle_param_options(name, options) define_method(name.to_s + "?") do val = self[name] if val == :true or val == true - return true + true end end end @@ -662,7 +662,7 @@ def [](name) # not the current value. obj.value else - return nil + nil end end @@ -933,9 +933,9 @@ def properties # @return [Boolean] true, if this type's name is isomorphic with the object def self.isomorphic? if defined?(@isomorphic) - return @isomorphic + @isomorphic else - return true + true end end @@ -965,7 +965,7 @@ def managed? end } end - return @managed + @managed end ############################### @@ -1115,7 +1115,7 @@ def currentpropvalues # is the first property, which is important for skipping 'retrieve' on # all the properties if the resource is absent. ensure_state = false - return properties.each_with_object({}) do |property, prophash| + properties.each_with_object({}) do |property, prophash| if property.name == :ensure ensure_state = property.retrieve prophash[property] = ensure_state diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb index e8a343f1e22..94e60a20507 100644 --- a/lib/puppet/type/component.rb +++ b/lib/puppet/type/component.rb @@ -47,9 +47,9 @@ def pathbuilder end p = parent if p - return [p.pathbuilder, myname] + [p.pathbuilder, myname] else - return [myname] + [myname] end end diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 207853535d7..daaa0d88d1a 100644 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -131,9 +131,9 @@ def retrieve # value, which causes us to be treated as in_sync?, which means we # don't actually execute anything. I think. --daniel 2011-03-10 if @resource.check_all_attributes - return :notrun + :notrun else - return should + should end end @@ -675,9 +675,9 @@ def check_all_attributes(refreshing = false) def output if property(:returns).nil? - return nil + nil else - return property(:returns).output + property(:returns).output end end diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 536524a6883..d74d9b650ae 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -465,7 +465,7 @@ def self.[](path) end def self.instances - return [] + [] end # Determine the user to write files as. @@ -616,12 +616,12 @@ def pathbuilder # Remove the parent file name list = parent.pathbuilder list.pop # remove the parent's path info - return list << ref + list << ref else - return super + super end else - return [ref] + [ref] end end @@ -810,9 +810,9 @@ def remove_existing(should) case current_type when "directory" - return remove_directory(wanted_type) + remove_directory(wanted_type) when "link", "file", "fifo", "socket" - return remove_file(current_type, wanted_type) + remove_file(current_type, wanted_type) else # Including: “blockSpecial”, “characterSpecial”, “unknown” self.fail _("Could not remove files of type %{current_type}") % { current_type: current_type } diff --git a/lib/puppet/type/file/checksum_value.rb b/lib/puppet/type/file/checksum_value.rb index 1a9f3b63670..f72d3e2acb9 100644 --- a/lib/puppet/type/file/checksum_value.rb +++ b/lib/puppet/type/file/checksum_value.rb @@ -26,7 +26,7 @@ def insync?(is) def property_matches?(current, desired) return true if super(current, desired) - return date_matches?(resource.parameter(:checksum).value, current, desired) + date_matches?(resource.parameter(:checksum).value, current, desired) end def retrieve diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index c1a018ef124..24bce1c7aae 100644 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -79,11 +79,11 @@ def change_to_s(currentvalue, newvalue) newvalue = tmp end if currentvalue == :absent - return "defined content as '#{newvalue}'" + "defined content as '#{newvalue}'" elsif newvalue == :absent - return "undefined content from '#{currentvalue}'" + "undefined content from '#{currentvalue}'" else - return "content changed '#{currentvalue}' to '#{newvalue}'" + "content changed '#{currentvalue}' to '#{newvalue}'" end end @@ -119,7 +119,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) + date_matches?(checksum_type, current, desired) end def retrieve diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 7dea5889819..760ac0f3791 100644 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -165,20 +165,20 @@ def insync?(currentvalue) end if should == :present - return !(currentvalue.nil? or currentvalue == :absent) + !(currentvalue.nil? or currentvalue == :absent) else - return super(currentvalue) + super(currentvalue) end end def retrieve stat = @resource.stat if stat - return stat.ftype.intern + stat.ftype.intern elsif should == :false - return :false + :false else - return :absent + :absent end end diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb index 0ff700756ef..d2283c24765 100644 --- a/lib/puppet/type/file/mode.rb +++ b/lib/puppet/type/file/mode.rb @@ -132,9 +132,9 @@ def insync?(currentvalue) stat = @resource.stat if stat && stat.ftype == "link" && @resource[:links] != :follow debug _("Not managing symlink mode") - return true + true else - return super(currentvalue) + super(currentvalue) end end diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index d97bfd1226c..15242d2ef41 100644 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -130,9 +130,9 @@ def self.normalize(source) def change_to_s(currentvalue, newvalue) # newvalue = "{md5}#{@metadata.checksum}" if resource.property(:ensure).retrieve == :absent - return "creating from source #{metadata.source} with contents #{metadata.checksum}" + "creating from source #{metadata.source} with contents #{metadata.checksum}" else - return "replacing from source #{metadata.source} with contents #{metadata.checksum}" + "replacing from source #{metadata.source} with contents #{metadata.checksum}" end end diff --git a/lib/puppet/type/file/target.rb b/lib/puppet/type/file/target.rb index d90036dc581..973e5ddf9fa 100644 --- a/lib/puppet/type/file/target.rb +++ b/lib/puppet/type/file/target.rb @@ -64,11 +64,11 @@ def mklink def insync?(currentvalue) if [:nochange, :notlink].include?(should) or @resource.recurse? - return true + true elsif !@resource.replace? and Puppet::FileSystem.exist?(@resource[:path]) - return true + true else - return super(currentvalue) + super(currentvalue) end end @@ -76,12 +76,12 @@ def retrieve stat = @resource.stat if stat if stat.ftype == "link" - return Puppet::FileSystem.readlink(@resource[:path]) + Puppet::FileSystem.readlink(@resource[:path]) else - return :notlink + :notlink end else - return :absent + :absent end end end diff --git a/lib/puppet/type/notify.rb b/lib/puppet/type/notify.rb index a581c30a301..81bda653f90 100644 --- a/lib/puppet/type/notify.rb +++ b/lib/puppet/type/notify.rb @@ -19,7 +19,7 @@ def sync else Puppet.send(@resource[:loglevel], message) end - return + nil end def retrieve diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 114b4052fd9..aa88180bdc7 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -100,9 +100,9 @@ def check(resource) @checkmethod ||= "#{self[:name]}_check" @hascheck ||= respond_to?(@checkmethod) if @hascheck - return send(@checkmethod, resource) + send(@checkmethod, resource) else - return true + true end end diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index 42e61d024b6..55c110fe176 100644 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -255,10 +255,10 @@ def match?(previous, now) when :number method = ScheduleMethods[value] if method.is_a?(Proc) - return method.call(previous, now) + method.call(previous, now) else # We negate it, because if they're equal we don't run - return now.send(method) != previous.send(method) + now.send(method) != previous.send(method) end when :distance scale = ScheduleScales[value] @@ -267,7 +267,7 @@ def match?(previous, now) # than the unit of time, we match. We divide the scale # by the repeat, so that we'll repeat that often within # the scale. - return (now.to_i - previous.to_i) >= (scale / @resource[:repeat]) + (now.to_i - previous.to_i) >= (scale / @resource[:repeat]) end end end diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index c2dfa055757..48c62ac7bb8 100644 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -110,7 +110,7 @@ def tidy?(path, stat) basename = File.basename(path) flags = File::FNM_DOTMATCH | File::FNM_PATHNAME - return(value.find { |pattern| File.fnmatch(pattern, basename, flags) } ? true : false) + (value.find { |pattern| File.fnmatch(pattern, basename, flags) } ? true : false) end end @@ -139,7 +139,7 @@ def tidy?(path, stat) def convert(unit, multi) num = AgeConvertors[unit] if num - return num * multi + num * multi else self.fail _("Invalid age unit '%{unit}'") % { unit: unit } end @@ -181,7 +181,7 @@ def convert(unit, multi) if num result = multi num.times do result *= 1024 end - return result + result else self.fail _("Invalid size unit '%{unit}'") % { unit: unit } end @@ -260,9 +260,9 @@ def retrieve # Our ensure property knows how to retrieve everything for us. obj = @parameters[:ensure] if obj - return obj.retrieve + obj.retrieve else - return {} + {} end end @@ -329,10 +329,10 @@ def matches?(path) basename = File.basename(path) flags = File::FNM_DOTMATCH | File::FNM_PATHNAME if self[:matches].find { |pattern| File.fnmatch(pattern, basename, flags) } - return true + true else debug "No specified patterns match #{path}, not tidying" - return false + false end end @@ -371,10 +371,10 @@ def stat(path) Puppet::FileSystem.lstat(path) rescue Errno::ENOENT debug _("File does not exist") - return nil + nil rescue Errno::EACCES # TRANSLATORS "stat" is a program name and should not be translated warning _("Could not stat; permission denied") - return nil + nil end end diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index b211abe424f..bb44e2e1408 100644 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -93,12 +93,12 @@ module Puppet def retrieve if provider.exists? if provider.respond_to?(:is_role?) and provider.is_role? - return :role + :role else - return :present + :present end else - return :absent + :absent end end diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index e697aa6056a..06c7b11815d 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -190,7 +190,7 @@ def benchmark(*args) yield } object.send(level, msg % { seconds: "%0.2f" % seconds }) - return seconds + seconds else yield end diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index 180f21d5ec2..fb86b5fb609 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -81,7 +81,7 @@ def load_file(name, env) begin mark_loaded(name, file) Kernel.load file - return true + true rescue SystemExit, NoMemoryError raise rescue Exception => detail diff --git a/lib/puppet/util/backups.rb b/lib/puppet/util/backups.rb index e96caeeb68e..528dbcbe973 100644 --- a/lib/puppet/util/backups.rb +++ b/lib/puppet/util/backups.rb @@ -13,7 +13,7 @@ def perform_backup(file = nil) file ||= self[:path] return true unless Puppet::FileSystem.exist?(file) - return(bucket ? perform_backup_with_bucket(file) : perform_backup_with_backuplocal(file, self[:backup])) + (bucket ? perform_backup_with_bucket(file) : perform_backup_with_backuplocal(file, self[:backup])) end private @@ -44,7 +44,7 @@ def perform_backup_with_backuplocal(fileobj, backup) # N.B. cp_r works on both files and directories FileUtils.cp_r(file, bfile, :preserve => true) - return true + true rescue => detail # since they said they want a backup, let's error out # if we couldn't make one @@ -83,6 +83,6 @@ def remove_backup(newfile) def backup_file_with_filebucket(f) sum = bucket.backup(f) info _("Filebucketed %{f} to %{filebucket} with sum %{sum}") % { f: f, filebucket: bucket.name, sum: sum } - return sum + sum end end diff --git a/lib/puppet/util/character_encoding.rb b/lib/puppet/util/character_encoding.rb index 5093fc24550..2ebf4b5d021 100644 --- a/lib/puppet/util/character_encoding.rb +++ b/lib/puppet/util/character_encoding.rb @@ -26,7 +26,7 @@ def convert_to_utf_8(string) } end # String is already valid UTF-8 - noop - return string_copy + string_copy else # If the string comes to us as BINARY encoded, we don't know what it # started as. However, to encode! we need a starting place, and our @@ -34,7 +34,7 @@ def convert_to_utf_8(string) # So set external_encoding to default_external before we try to # transcode to UTF-8. string_copy.force_encoding(Encoding.default_external) if original_encoding == Encoding::BINARY - return string_copy.encode(Encoding::UTF_8) + string_copy.encode(Encoding::UTF_8) end rescue EncodingError => detail # Set the encoding on our copy back to its original if we modified it @@ -46,7 +46,7 @@ def convert_to_utf_8(string) Puppet.debug { _("%{error}: %{value} cannot be transcoded by Puppet.") % { error: detail.inspect, value: string.dump } } - return string_copy + string_copy end end @@ -68,14 +68,15 @@ def override_encoding_to_utf_8(string) string_copy = string.dup original_encoding = string_copy.encoding return string_copy if original_encoding == Encoding::UTF_8 + if string_copy.force_encoding(Encoding::UTF_8).valid_encoding? - return string_copy + string_copy else Puppet.debug { _("%{value} is not valid UTF-8 and result of overriding encoding would be invalid.") % { value: string.dump } } # Set copy back to its original encoding before returning - return string_copy.force_encoding(original_encoding) + string_copy.force_encoding(original_encoding) end end end diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index 3de345e4fa3..c6db6f8b233 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -230,9 +230,9 @@ def handle_record_line(line, record) if ret ret[:record_type] = record.name - return ret + ret else - return nil + nil end end @@ -346,7 +346,7 @@ def to_line(details) end case record.type - when :text; return details[:line] + when :text; details[:line] else return record.to_line(details) if record.respond_to?(:to_line) @@ -358,9 +358,9 @@ def to_line(details) if regex == true regex = /\s+$/ end - return line.sub(regex, '') + line.sub(regex, '') else - return line + line end end end @@ -368,9 +368,9 @@ def to_line(details) # Whether to add a trailing separator to the file. Defaults to true def trailing_separator if defined?(@trailing_separator) - return @trailing_separator + @trailing_separator else - return true + true end end @@ -378,11 +378,9 @@ def valid_attr?(type, attr) type = type.intern record = record_type(type) if record && record.fields.include?(attr.intern) - return true - elsif attr.intern == :ensure - return true + true else - false + attr.intern == :ensure end end diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index 616e608dc97..a8c9bdbc075 100644 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -40,9 +40,9 @@ def self.newfiletype(name, &block) val = real_read @loaded = Time.now if val - return val.gsub(/# HEADER.*\n/, '') + val.gsub(/# HEADER.*\n/, '') else - return "" + "" end rescue Puppet::Error raise @@ -57,7 +57,7 @@ def self.newfiletype(name, &block) define_method(:write) do |text| val = real_write(text) @synced = Time.now - return val + val rescue Puppet::Error raise rescue => detail @@ -110,7 +110,7 @@ def read # being explicitly preserved Puppet::FileSystem.read(@path, :encoding => Encoding.default_external) else - return nil + nil end end @@ -202,11 +202,11 @@ def read rescue => detail case detail.to_s when /no crontab for/ - return "" + "" when /are not allowed to/ Puppet.debug _("The %{path} user is not authorized to use cron. Their crontab file is treated as empty in case Puppet authorizes them in the middle of the run (by, for example, modifying the cron.deny or cron.allow files).") % { path: @path } - return "" + "" else raise FileReadError, _("Could not read crontab for %{path}: %{detail}") % { path: @path, detail: detail }, detail.backtrace end @@ -245,9 +245,9 @@ def write(text) # does not think I should be allowed to set the @path to my own user name def cmdbase if @uid == Puppet::Util::SUIDManager.uid || Puppet.runtime[:facter].value('os.name') == "HP-UX" - return "crontab" + "crontab" else - return "crontab -u #{@path}" + "crontab -u #{@path}" end end end @@ -267,11 +267,11 @@ def read rescue => detail case detail.to_s when /can't open your crontab/ - return "" + "" when /you are not authorized to use cron/ Puppet.debug _("The %{path} user is not authorized to use cron. Their crontab file is treated as empty in case Puppet authorizes them in the middle of the run (by, for example, modifying the cron.deny or cron.allow files).") % { path: @path } - return "" + "" else raise FileReadError, _("Could not read crontab for %{path}: %{detail}") % { path: @path, detail: detail }, detail.backtrace end @@ -318,11 +318,11 @@ def read rescue => detail case detail.to_s when /open.*in.*directory/ - return "" + "" when /not.*authorized.*cron/ Puppet.debug _("The %{path} user is not authorized to use cron. Their crontab file is treated as empty in case Puppet authorizes them in the middle of the run (by, for example, modifying the cron.deny or cron.allow files).") % { path: @path } - return "" + "" else raise FileReadError, _("Could not read crontab for %{path}: %{detail}") % { path: @path, detail: detail }, detail.backtrace end diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb index 4e6509bb358..98a4655ce68 100644 --- a/lib/puppet/util/inifile.rb +++ b/lib/puppet/util/inifile.rb @@ -73,7 +73,7 @@ def []=(key, value) # exists, return nil def [](key) entry = find_entry(key) - return(entry.nil? ? nil : entry[1]) + (entry.nil? ? nil : entry[1]) end # Format the section as text in the way it should be diff --git a/lib/puppet/util/ldap/manager.rb b/lib/puppet/util/ldap/manager.rb index 3d7156aca00..f1a08e85a61 100644 --- a/lib/puppet/util/ldap/manager.rb +++ b/lib/puppet/util/ldap/manager.rb @@ -109,7 +109,7 @@ def entry2provider(entry) # Create our normal search filter. def filter - return(objectclasses.length == 1 ? "objectclass=#{objectclasses[0]}" : "(&(objectclass=" + objectclasses.join(")(objectclass=") + "))") + (objectclasses.length == 1 ? "objectclass=#{objectclasses[0]}" : "(&(objectclass=" + objectclasses.join(")(objectclass=") + "))") end # Find the associated entry for a resource. Returns a hash, minus @@ -213,7 +213,7 @@ def search(sfilter = nil) result << entry2provider(entry) end end - return(result.empty? ? nil : result) + (result.empty? ? nil : result) end # Update the ldap entry with the desired state. diff --git a/lib/puppet/util/lockfile.rb b/lib/puppet/util/lockfile.rb index 256c5cf2342..c57df408637 100644 --- a/lib/puppet/util/lockfile.rb +++ b/lib/puppet/util/lockfile.rb @@ -51,7 +51,7 @@ def locked? # was locked. # @return [String] the data object. def lock_data - return File.read(@file_path) if file_locked? + File.read(@file_path) if file_locked? end # Private, internal utility method for encapsulating the logic about diff --git a/lib/puppet/util/log/destination.rb b/lib/puppet/util/log/destination.rb index f1452f412b2..2b90d2cd602 100644 --- a/lib/puppet/util/log/destination.rb +++ b/lib/puppet/util/log/destination.rb @@ -32,9 +32,9 @@ def self.match?(obj) def name if defined?(@name) - return @name + @name else - return self.class.name + self.class.name end end diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index 21c522b249e..903783e78c8 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -36,9 +36,9 @@ def to_data_hash def [](name) value = @values.find { |v| v[0] == name } if value - return value[2] + value[2] else - return 0 + 0 end end diff --git a/lib/puppet/util/pidlock.rb b/lib/puppet/util/pidlock.rb index 3001ab6357a..7753d1816f9 100644 --- a/lib/puppet/util/pidlock.rb +++ b/lib/puppet/util/pidlock.rb @@ -25,7 +25,7 @@ def lock def unlock if mine? - return @lockfile.unlock + @lockfile.unlock else false end diff --git a/lib/puppet/util/plist.rb b/lib/puppet/util/plist.rb index a9f3b9ddb9d..387ffcfe388 100644 --- a/lib/puppet/util/plist.rb +++ b/lib/puppet/util/plist.rb @@ -51,7 +51,7 @@ def read_plist_file(file_path) Puppet.warning(message) end end - return nil + nil end # Read plist text using the CFPropertyList gem. diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index 1f4f3570bb1..71cb241d6af 100644 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -87,10 +87,10 @@ def get_posix_field(space, field, id) end begin - return Etc.send(method, id).send(field) + Etc.send(method, id).send(field) rescue NoMethodError, ArgumentError # ignore it; we couldn't find the object - return nil + nil end end @@ -128,8 +128,8 @@ def search_posix_field(type, field, id) # Determine what the field name is for users and groups. def idfield(space) case space.intern - when :gr, :group; return :gid - when :pw, :user, :passwd; return :uid + when :gr, :group; :gid + when :pw, :user, :passwd; :uid else raise ArgumentError, _("Can only handle users and groups") end @@ -138,8 +138,8 @@ def idfield(space) # Determine what the method is to get users and groups by id def methodbyid(space) case space.intern - when :gr, :group; return :getgrgid - when :pw, :user, :passwd; return :getpwuid + when :gr, :group; :getgrgid + when :pw, :user, :passwd; :getpwuid else raise ArgumentError, _("Can only handle users and groups") end @@ -148,8 +148,8 @@ def methodbyid(space) # Determine what the method is to get users and groups by name def methodbyname(space) case space.intern - when :gr, :group; return :getgrnam - when :pw, :user, :passwd; return :getpwnam + when :gr, :group; :getgrnam + when :pw, :user, :passwd; :getpwnam else raise ArgumentError, _("Can only handle users and groups") end @@ -194,13 +194,13 @@ def get_posix_value(location, id_field, field) if id == check_value_id Puppet.debug("Multiple entries found for resource: '#{location}' with #{id_field}: #{id}") - return id + id else Puppet.debug("The value retrieved: '#{check_value}' is different than the required state: '#{field}', searching in all entries") - return search_posix_field(location, id_field, field) + search_posix_field(location, id_field, field) end else - return id + id end end end diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb index 44185d978f2..bd2677c07bc 100644 --- a/lib/puppet/util/provider_features.rb +++ b/lib/puppet/util/provider_features.rb @@ -23,12 +23,12 @@ class ProviderFeature # @return [Boolean] whether all requirements for this feature are met or not. def available?(obj) if methods - return !!methods_available?(obj) + !!methods_available?(obj) else # In this case, the provider has to declare support for this # feature, and that's been checked before we ever get to the # method checks. - return false + false end end diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb index b6e268c11a8..bba7d138783 100644 --- a/lib/puppet/util/reference.rb +++ b/lib/puppet/util/reference.rb @@ -71,9 +71,9 @@ def self.references(environment) def doc if defined?(@doc) - return "#{@name} - #{@doc}" + "#{@name} - #{@doc}" else - return @title + @title end end diff --git a/lib/puppet/util/rpm_compare.rb b/lib/puppet/util/rpm_compare.rb index 4d4d13465c2..a10b7977015 100644 --- a/lib/puppet/util/rpm_compare.rb +++ b/lib/puppet/util/rpm_compare.rb @@ -141,7 +141,7 @@ def rpm_parse_evr(full_version) version = full_version release = nil end - return { :epoch => epoch, :version => version, :release => release, :arch => architecture } + { :epoch => epoch, :version => version, :release => release, :arch => architecture } end # this method is a native implementation of the @@ -152,7 +152,7 @@ def compare_values(s1, s2) return 1 if !s1.nil? && s2.nil? return -1 if s1.nil? && !s2.nil? - return rpmvercmp(s1, s2) + rpmvercmp(s1, s2) end # how rpm compares two package versions: @@ -190,8 +190,6 @@ def rpm_compare_evr(should, is) # This should NOT be triggered if we're trying to ensure latest. return 0 if should_hash[:release].nil? - rc = compare_values(should_hash[:release], is_hash[:release]) - - return rc + compare_values(should_hash[:release], is_hash[:release]) end end diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index 7597fa52c28..44976924059 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -142,10 +142,10 @@ def set_selinux_context(file, value, component = false) retval = Selinux.lsetfilecon(file, context) if retval == 0 - return true + true else Puppet.warning _("Failed to set SELinux context %{context} on %{file}") % { context: context, file: file } - return false + false end end @@ -294,7 +294,7 @@ def find_fs(path) end # Should never be reached... - return mounts['/'] + mounts['/'] end ## diff --git a/lib/puppet/util/symbolic_file_mode.rb b/lib/puppet/util/symbolic_file_mode.rb index 52421c4ba90..2701c59d3cd 100644 --- a/lib/puppet/util/symbolic_file_mode.rb +++ b/lib/puppet/util/symbolic_file_mode.rb @@ -19,7 +19,7 @@ def valid_symbolic_mode?(value) return true if value =~ /^0?[0-7]{1,4}$/ return true if value =~ /^([ugoa]*[-=+][-=+rstwxXugo]*)(,[ugoa]*[-=+][-=+rstwxXugo]*)*$/ - return false + false end def display_mode(value) @@ -146,12 +146,10 @@ def symbolic_mode_to_int(modification, to_mode = 0, is_a_directory = false) raise Puppet::Error, _("%{error}%{rest} in symbolic mode %{modification}") % { error: e, rest: rest, modification: modification.inspect }, e.backtrace end - result = - final_mode['s'] << 9 | + final_mode['s'] << 9 | final_mode['u'] << 6 | final_mode['g'] << 3 | final_mode['o'] << 0 - return result end end end diff --git a/lib/puppet/util/terminal.rb b/lib/puppet/util/terminal.rb index 38e40294d2a..02a2a33f009 100644 --- a/lib/puppet/util/terminal.rb +++ b/lib/puppet/util/terminal.rb @@ -11,8 +11,8 @@ def self.width result = %x(stty size 2>/dev/null).split[1] || %x(tput cols 2>/dev/null).split[0] end - return (result || '80').to_i + (result || '80').to_i rescue - return 80 + 80 end end diff --git a/lib/puppet/util/windows/adsi.rb b/lib/puppet/util/windows/adsi.rb index 375665a28b0..61f31346c32 100644 --- a/lib/puppet/util/windows/adsi.rb +++ b/lib/puppet/util/windows/adsi.rb @@ -165,7 +165,7 @@ def parse_name(name) domain = matches[0][1] || '.' account = matches[0][2] - return account, domain + [account, domain] end # returns Puppet::Util::Windows::SID::Principal[] diff --git a/lib/puppet/util/windows/monkey_patches/process.rb b/lib/puppet/util/windows/monkey_patches/process.rb index fccde3f1ab0..3ab9c0ba75c 100644 --- a/lib/puppet/util/windows/monkey_patches/process.rb +++ b/lib/puppet/util/windows/monkey_patches/process.rb @@ -197,7 +197,7 @@ def setpriority(kind, int, int_priority) FFI::WIN32.CloseHandle(handle) end - return 0 + 0 end private diff --git a/lib/puppet/util/windows/user.rb b/lib/puppet/util/windows/user.rb index a90a0cf5c41..4e55e0d8d64 100644 --- a/lib/puppet/util/windows/user.rb +++ b/lib/puppet/util/windows/user.rb @@ -13,7 +13,7 @@ def admin? # if Vista or later, check for unrestricted process token elevated_supported = Puppet::Util::Windows::Process.supports_elevated_security? - return elevated_supported ? Puppet::Util::Windows::Process.elevated_security? : true + elevated_supported ? Puppet::Util::Windows::Process.elevated_security? : true end module_function :admin? @@ -84,7 +84,7 @@ def password_is?(name, password, domain = '.') ERROR_ACCOUNT_DISABLED, ] - return authenticated_error_codes.include?(detail.code) + authenticated_error_codes.include?(detail.code) end module_function :password_is?