Skip to content

Commit

Permalink
rubocop: autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Sep 6, 2024
1 parent d627817 commit b9fe631
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 59 deletions.
22 changes: 11 additions & 11 deletions lib/beaker/dsl/helpers/host_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/beaker/dsl/patterns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Patterns
#
# @return [Array<Result>, 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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/beaker/dsl/structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/beaker/host/aix/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/beaker/host/aix/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/beaker/host/mac/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/beaker/host/mac/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/beaker/host/pswindows/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/beaker/host/pswindows/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/beaker/host/unix/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/beaker/host/unix/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/beaker/host/windows/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/beaker/host/windows/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/beaker/shared/repetition.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/beaker/tasks/rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/beaker/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b9fe631

Please sign in to comment.