From b9fe631d6eff1b074e129297dc4d6d9b70045f17 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 6 Sep 2024 19:06:55 +0200 Subject: [PATCH] rubocop: autofix --- lib/beaker/dsl/helpers/host_helpers.rb | 22 +++++++++++----------- lib/beaker/dsl/patterns.rb | 4 ++-- lib/beaker/dsl/structure.rb | 10 +++++----- lib/beaker/host/aix/group.rb | 8 ++++---- lib/beaker/host/aix/user.rb | 8 ++++---- lib/beaker/host/mac/group.rb | 4 ++-- lib/beaker/host/mac/user.rb | 4 ++-- lib/beaker/host/pswindows/group.rb | 8 ++++---- lib/beaker/host/pswindows/user.rb | 8 ++++---- lib/beaker/host/unix/group.rb | 8 ++++---- lib/beaker/host/unix/user.rb | 8 ++++---- lib/beaker/host/windows/group.rb | 8 ++++---- lib/beaker/host/windows/user.rb | 8 ++++---- lib/beaker/shared/repetition.rb | 4 ++-- lib/beaker/tasks/rake_task.rb | 4 ++-- spec/beaker/platform_spec.rb | 2 +- 16 files changed, 59 insertions(+), 59 deletions(-) diff --git a/lib/beaker/dsl/helpers/host_helpers.rb b/lib/beaker/dsl/helpers/host_helpers.rb index 302aa1882..87558a47b 100644 --- a/lib/beaker/dsl/helpers/host_helpers.rb +++ b/lib/beaker/dsl/helpers/host_helpers.rb @@ -118,8 +118,8 @@ def on(host, command, opts = {}, &block) # # @return [Result] An object representing the outcome of *command*. # @raise [FailTest] Raises an exception if *command* obviously fails. - def shell(command, opts = {}, &block) - on(default, command, opts, &block) + def shell(command, opts = {}, &) + on(default, command, opts, &) end # Move a file from a remote to a local path @@ -307,7 +307,7 @@ def execute_powershell_script_on(hosts, powershell_script, opts = {}) # @param [Proc] block Additional tests to run after script has executed # # @return [Result] Returns the result of the underlying SCP operation. - def run_script_on(host, script, opts = {}, &block) + def run_script_on(host, script, opts = {}, &) # this is unsafe as it uses the File::SEPARATOR will be set to that # of the coordinator node. This works for us because we use cygwin # which will properly convert the paths. Otherwise this would not @@ -317,13 +317,13 @@ def run_script_on(host, script, opts = {}, &block) remote_path = File.join("", "tmp", File.basename(script)) scp_to host, script, remote_path - on host, remote_path, opts, &block + on(host, remote_path, opts, &) end # Move a local script to default host and execute it # @see #run_script_on - def run_script(script, opts = {}, &block) - run_script_on(default, script, opts, &block) + def run_script(script, opts = {}, &) + run_script_on(default, script, opts, &) end # Install a package on a host @@ -515,8 +515,8 @@ def file_contents_on(host, file_path) # @param [Proc] block Additional actions or assertions. # @!macro common_opts # - def curl_on(host, cmd, opts = {}, &block) - on host, "curl --tlsv1 %s" % cmd, opts, &block + def curl_on(host, cmd, opts = {}, &) + on(host, "curl --tlsv1 %s" % cmd, opts, &) end def curl_with_retries(_desc, host, url, desired_exit_codes, max_retries = 60, retry_interval = 1) @@ -547,7 +547,7 @@ def curl_with_retries(_desc, host, url, desired_exit_codes, max_retries = 60, re # @option opts [Boolean] :verbose (false) # # @return [Result] Result object of the last command execution - def retry_on(host, command, opts = {}, &block) + def retry_on(host, command, opts = {}, &) option_exit_codes = opts[:desired_exit_codes] option_max_retries = opts[:max_retries].to_i option_retry_interval = opts[:retry_interval].to_f @@ -562,11 +562,11 @@ def retry_on(host, command, opts = {}, &block) logger.debug " Trying command #{max_retries} times." logger.debug ".", add_newline = false - result = on host, command, { :accept_all_exit_codes => true, :silent => !verbose }, &block + result = on(host, command, { :accept_all_exit_codes => true, :silent => !verbose }, &) num_retries = 0 until desired_exit_codes.include?(result.exit_code) sleep retry_interval - result = on host, command, { :accept_all_exit_codes => true, :silent => !verbose }, &block + result = on(host, command, { :accept_all_exit_codes => true, :silent => !verbose }, &) num_retries += 1 logger.debug ".", add_newline = false if (num_retries > max_retries) diff --git a/lib/beaker/dsl/patterns.rb b/lib/beaker/dsl/patterns.rb index a854f059c..eba7d1f3d 100644 --- a/lib/beaker/dsl/patterns.rb +++ b/lib/beaker/dsl/patterns.rb @@ -22,7 +22,7 @@ module Patterns # # @return [Array, Result, nil] An array of results, a result object, or nil. # Check {Beaker::Shared::HostManager#run_block_on} for more details on this. - def block_on hosts_or_filter, opts = {}, &block + def block_on(hosts_or_filter, opts = {}, &) block_hosts = nil if defined? hosts block_hosts = hosts @@ -33,7 +33,7 @@ def block_on hosts_or_filter, opts = {}, &block else block_hosts = hosts_or_filter end - run_block_on block_hosts, filter, opts, &block + run_block_on(block_hosts, filter, opts, &) end end end diff --git a/lib/beaker/dsl/structure.rb b/lib/beaker/dsl/structure.rb index 63db723be..dea89fe30 100644 --- a/lib/beaker/dsl/structure.rb +++ b/lib/beaker/dsl/structure.rb @@ -107,10 +107,10 @@ def manual_step step_name # @param [String] manual_test_name The name of the test to be logged. # @param [Proc] block The actions to be performed during this test. # - def manual_test manual_test_name, &block + def manual_test(manual_test_name, &) if @options.has_key?(:exec_manual_tests) && @options[:exec_manual_tests] == true # here the option is set so we run the test as normal - test_name manual_test_name, &block + test_name(manual_test_name, &) else # here no option was set so we log the test name and skip it test_name manual_test_name @@ -261,13 +261,13 @@ def expect_failure(explanation) # targets for this tests case. # @raise [SkipTest] Raises skip test if there are no valid hosts for # this test case after confinement. - def confine(type, criteria, host_array = nil, &block) + def confine(type, criteria, host_array = nil, &) hosts_to_modify = Array(host_array || hosts) hosts_not_modified = hosts - hosts_to_modify # we aren't examining these hosts case type when :except hosts_to_modify = if criteria and (not criteria.empty?) - hosts_to_modify - select_hosts(criteria, hosts_to_modify, &block) + hosts_not_modified + hosts_to_modify - select_hosts(criteria, hosts_to_modify, &) + hosts_not_modified else # confining to all hosts *except* provided array of hosts hosts_not_modified @@ -278,7 +278,7 @@ def confine(type, criteria, host_array = nil, &block) end when :to if criteria and (not criteria.empty?) - hosts_to_modify = select_hosts(criteria, hosts_to_modify, &block) + hosts_not_modified + hosts_to_modify = select_hosts(criteria, hosts_to_modify, &) + hosts_not_modified else # confining to only hosts in provided array of hosts end diff --git a/lib/beaker/host/aix/group.rb b/lib/beaker/host/aix/group.rb index 8cfa20457..f2905e759 100644 --- a/lib/beaker/host/aix/group.rb +++ b/lib/beaker/host/aix/group.rb @@ -26,11 +26,11 @@ def group_gid(name) end end - def group_present(name, &block) - execute("if ! lsgroup #{name}; then mkgroup #{name}; fi", {}, &block) + def group_present(name, &) + execute("if ! lsgroup #{name}; then mkgroup #{name}; fi", {}, &) end - def group_absent(name, &block) - execute("if lsgroup #{name}; then rmgroup #{name}; fi", {}, &block) + def group_absent(name, &) + execute("if lsgroup #{name}; then rmgroup #{name}; fi", {}, &) end end diff --git a/lib/beaker/host/aix/user.rb b/lib/beaker/host/aix/user.rb index 405d15ea1..87202c0d2 100644 --- a/lib/beaker/host/aix/user.rb +++ b/lib/beaker/host/aix/user.rb @@ -23,11 +23,11 @@ def user_get(name) end end - def user_present(name, &block) - execute("if ! lsuser #{name}; then mkuser #{name}; fi", {}, &block) + def user_present(name, &) + execute("if ! lsuser #{name}; then mkuser #{name}; fi", {}, &) end - def user_absent(name, &block) - execute("if lsuser #{name}; then rmuser #{name}; fi", {}, &block) + def user_absent(name, &) + execute("if lsuser #{name}; then rmuser #{name}; fi", {}, &) end end diff --git a/lib/beaker/host/mac/group.rb b/lib/beaker/host/mac/group.rb index 906922593..056d54dae 100644 --- a/lib/beaker/host/mac/group.rb +++ b/lib/beaker/host/mac/group.rb @@ -83,8 +83,8 @@ def group_present(name) # # @param [String] name Name of the group # @param [Proc] block Additional actions or insertions - def group_absent(name, &block) - execute("if dscl . -list /Groups/#{name}; then dscl . -delete /Groups/#{name}; fi", {}, &block) + def group_absent(name, &) + execute("if dscl . -list /Groups/#{name}; then dscl . -delete /Groups/#{name}; fi", {}, &) end # Gives the next gid not used on the system diff --git a/lib/beaker/host/mac/user.rb b/lib/beaker/host/mac/user.rb index 8b292adde..bb21d08da 100644 --- a/lib/beaker/host/mac/user.rb +++ b/lib/beaker/host/mac/user.rb @@ -66,8 +66,8 @@ def user_present(name) # # @param [String] name Name of the user # @param [Proc] block Additional actions or insertions - def user_absent(name, &block) - execute("if dscl . -list /Users/#{name}; then dscl . -delete /Users/#{name}; fi", {}, &block) + def user_absent(name, &) + execute("if dscl . -list /Users/#{name}; then dscl . -delete /Users/#{name}; fi", {}, &) end # Gives the next uid not used on the system diff --git a/lib/beaker/host/pswindows/group.rb b/lib/beaker/host/pswindows/group.rb index 98ea04eda..1ff157f45 100644 --- a/lib/beaker/host/pswindows/group.rb +++ b/lib/beaker/host/pswindows/group.rb @@ -27,11 +27,11 @@ def group_gid(_name) raise NotImplementedError, "Can't retrieve group gid on a Windows host" end - def group_present(name, &block) - execute("net localgroup /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def group_present(name, &) + execute("net localgroup /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end - def group_absent(name, &block) - execute("net localgroup /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def group_absent(name, &) + execute("net localgroup /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end end diff --git a/lib/beaker/host/pswindows/user.rb b/lib/beaker/host/pswindows/user.rb index ae60aefeb..0cbdd5431 100644 --- a/lib/beaker/host/pswindows/user.rb +++ b/lib/beaker/host/pswindows/user.rb @@ -23,11 +23,11 @@ def user_get(name) end end - def user_present(name, &block) - execute("net user /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def user_present(name, &) + execute("net user /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end - def user_absent(name, &block) - execute("net user /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def user_absent(name, &) + execute("net user /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end end diff --git a/lib/beaker/host/unix/group.rb b/lib/beaker/host/unix/group.rb index e49ad3141..d4c75d80c 100644 --- a/lib/beaker/host/unix/group.rb +++ b/lib/beaker/host/unix/group.rb @@ -31,11 +31,11 @@ def group_gid(name) end end - def group_present(name, &block) - execute("if ! getent group #{name}; then groupadd #{name}; fi", {}, &block) + def group_present(name, &) + execute("if ! getent group #{name}; then groupadd #{name}; fi", {}, &) end - def group_absent(name, &block) - execute("if getent group #{name}; then groupdel #{name}; fi", {}, &block) + def group_absent(name, &) + execute("if getent group #{name}; then groupdel #{name}; fi", {}, &) end end diff --git a/lib/beaker/host/unix/user.rb b/lib/beaker/host/unix/user.rb index ab2e44a6e..e4627893b 100644 --- a/lib/beaker/host/unix/user.rb +++ b/lib/beaker/host/unix/user.rb @@ -23,11 +23,11 @@ def user_get(name) end end - def user_present(name, &block) - execute("if ! getent passwd #{name}; then useradd #{name}; fi", {}, &block) + def user_present(name, &) + execute("if ! getent passwd #{name}; then useradd #{name}; fi", {}, &) end - def user_absent(name, &block) - execute("if getent passwd #{name}; then userdel #{name}; fi", {}, &block) + def user_absent(name, &) + execute("if getent passwd #{name}; then userdel #{name}; fi", {}, &) end end diff --git a/lib/beaker/host/windows/group.rb b/lib/beaker/host/windows/group.rb index c0a2616c7..ad2590600 100644 --- a/lib/beaker/host/windows/group.rb +++ b/lib/beaker/host/windows/group.rb @@ -27,11 +27,11 @@ def group_gid(_name) raise NotImplementedError, "Can't retrieve group gid on a Windows host" end - def group_present(name, &block) - execute("net localgroup /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def group_present(name, &) + execute("net localgroup /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end - def group_absent(name, &block) - execute("net localgroup /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def group_absent(name, &) + execute("net localgroup /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end end diff --git a/lib/beaker/host/windows/user.rb b/lib/beaker/host/windows/user.rb index 66dd66fef..e3177785d 100644 --- a/lib/beaker/host/windows/user.rb +++ b/lib/beaker/host/windows/user.rb @@ -23,11 +23,11 @@ def user_get(name) end end - def user_present(name, &block) - execute("net user /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def user_present(name, &) + execute("net user /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end - def user_absent(name, &block) - execute("net user /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block) + def user_absent(name, &) + execute("net user /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &) end end diff --git a/lib/beaker/shared/repetition.rb b/lib/beaker/shared/repetition.rb index aa95dee1d..5e0094540 100644 --- a/lib/beaker/shared/repetition.rb +++ b/lib/beaker/shared/repetition.rb @@ -1,9 +1,9 @@ module Beaker module Shared module Repetition - def repeat_for seconds, &block + def repeat_for(seconds, &) # do not peg CPU if &block takes less than 1 second - repeat_for_and_wait seconds, 1, &block + repeat_for_and_wait(seconds, 1, &) end def repeat_for_and_wait seconds, wait diff --git a/lib/beaker/tasks/rake_task.rb b/lib/beaker/tasks/rake_task.rb index 3b241cb9a..de7e656c2 100644 --- a/lib/beaker/tasks/rake_task.rb +++ b/lib/beaker/tasks/rake_task.rb @@ -29,14 +29,14 @@ class RakeTask < ::Rake::TaskLib # Sets up the predefine task checking # @param args [Array] First argument is always the name of the task # if no additonal arguments are defined such as parameters it will default to [:hosts,:type] - def initialize(*args, &task_block) + def initialize(*args, &) super @name = args.shift || 'beaker:test' args = %i[hosts type] if args.empty? @acceptance_root = DEFAULT_ACCEPTANCE_ROOT @options_file = nil - define(args, &task_block) + define(args, &) end private diff --git a/spec/beaker/platform_spec.rb b/spec/beaker/platform_spec.rb index 502c9f274..08984a4af 100644 --- a/spec/beaker/platform_spec.rb +++ b/spec/beaker/platform_spec.rb @@ -140,7 +140,7 @@ module Beaker if YAML.respond_to?(:unsafe_load) YAML.unsafe_load(YAML.dump(platform)) else - YAML.load(YAML.dump(platform)) # rubocop:disable Security/YAMLLoad + YAML.load(YAML.dump(platform)) end end