Commit c0f19f06 authored by intrigeri's avatar intrigeri
Browse files

Rubocop: fix Style/RaiseArgs offenses

Changes generated with:

`rubocop --only Style/RaiseArgs --auto-correct`
parent e19dc5df
......@@ -458,24 +458,6 @@ Style/Proc:
- 'features/support/helpers/misc_helpers.rb'
- 'features/support/helpers/storage_helper.rb'
# Offense count: 23
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
Exclude:
- 'features/step_definitions/build.rb'
- 'features/step_definitions/common_steps.rb'
- 'features/step_definitions/torified_gnupg.rb'
- 'features/support/env.rb'
- 'features/support/helpers/dogtail.rb'
- 'features/support/helpers/firewall_helper.rb'
- 'features/support/helpers/misc_helpers.rb'
- 'features/support/helpers/opencv.rb'
- 'features/support/helpers/remote_shell.rb'
- 'features/support/helpers/screen.rb'
- 'features/support/helpers/vm_helper.rb'
# Offense count: 95
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
......
......@@ -37,7 +37,7 @@ end
Given /^the last version mentioned in debian\/changelog is ([[:alnum:]~.]+)$/ do |version|
last = `dpkg-parsechangelog | awk '/^Version: / { print $2 }'`.strip
raise StandardError.new('dpkg-parsechangelog failed.') if $CHILD_STATUS != 0
raise StandardError, 'dpkg-parsechangelog failed.' if $CHILD_STATUS != 0
if last != version
fatal_system "debchange -v '#{version}' 'New upstream release'"
......@@ -100,7 +100,7 @@ end
When /^I successfully run "?([[:alnum:] -]+)"?$/ do |command|
@output = `#{File.expand_path("../../../auto/scripts/#{command}", __FILE__)}`
raise StandardError.new("#{command} failed. Exit code: #{$CHILD_STATUS}") if $CHILD_STATUS != 0
raise StandardError, "#{command} failed. Exit code: #{$CHILD_STATUS}" if $CHILD_STATUS != 0
end
When /^I run "?([[:alnum:] -]+)"?$/ do |command|
......
......@@ -382,7 +382,7 @@ Given /^the time has synced$/ do
File.open("#{$config['TMPDIR']}/log.htpdate", 'w') do |file|
file.write($vm.execute('cat /var/log/htpdate.log').stdout)
end
raise TimeSyncingError.new('Time syncing failed')
raise TimeSyncingError, 'Time syncing failed'
end
end
......
......@@ -11,9 +11,7 @@ end
def check_for_seahorse_error
if @screen.exists('GnomeCloseButton.png')
raise OpenPGPKeyserverCommunicationError.new(
"Found GnomeCloseButton.png' on the screen"
)
raise OpenPGPKeyserverCommunicationError, "Found GnomeCloseButton.png' on the screen"
end
end
......@@ -166,9 +164,7 @@ Then /^I synchronize keys in Seahorse$/ do
change_of_status?
end
check_for_seahorse_error
raise OpenPGPKeyserverCommunicationError.new(
'Seahorse crashed with a segfault.'
) unless $vm.has_process?('seahorse')
raise OpenPGPKeyserverCommunicationError, 'Seahorse crashed with a segfault.' unless $vm.has_process?('seahorse')
end
end
......
......@@ -11,7 +11,7 @@ Encoding.default_internal = Encoding::UTF_8
def fatal_system(str, *args)
unless system(str, *args)
raise StandardError.new("Command exited with #{$CHILD_STATUS}")
raise StandardError, "Command exited with #{$CHILD_STATUS}"
end
end
......
......@@ -82,7 +82,7 @@ module Dogtail
code = code.join("\n") if code.class == Array
c = RemoteShell::PythonCommand.new($vm, code, user: @opts[:user])
if c.failure?
raise Failure.new("The Dogtail script raised: #{c.exception}")
raise Failure, "The Dogtail script raised: #{c.exception}"
end
return c
......
......@@ -29,9 +29,7 @@ def pcap_connections_helper(pcap_file, **opts)
# packetfu cannot parse RARP, see #16825.
next
else
raise FirewallAssertionFailedError.new(
'Found something that is not an ethernet packet'
)
raise FirewallAssertionFailedError, 'Found something that is not an ethernet packet'
end
end
sport = nil
......@@ -59,9 +57,7 @@ def pcap_connections_helper(pcap_file, **opts)
ip_packet = PacketFu::ARPPacket.parse(p)
protocol = 'arp'
else
raise FirewallAssertionFailedError.new(
'Found something that cannot be parsed'
)
raise FirewallAssertionFailedError, 'Found something that cannot be parsed'
end
next if opts[:ignore_dhcp] &&
......@@ -106,10 +102,8 @@ def assert_all_connections(pcap_file, **opts, &block)
good = all.find_all(&block)
bad = all - good
unless bad.empty?
raise FirewallAssertionFailedError.new(
"Unexpected connections were made:\n" +
raise FirewallAssertionFailedError, "Unexpected connections were made:\n" +
bad.map { |e| " #{e}" } .join("\n")
)
end
end
......
......@@ -110,7 +110,7 @@ rescue unique_timeout_exception
msg += "\nLast ignored exception was: " +
"#{last_exception.class}: #{last_exception}"
end
raise exc_class.new(msg)
raise exc_class, msg
end
class TorFailure < StandardError
......@@ -172,11 +172,9 @@ def retry_action(max_retries, options = {}, &block)
options[:recovery_proc].call if options[:recovery_proc]
retries += 1
else
raise MaxRetriesFailure.new(
"#{options[:operation_name]} failed (despite retrying " +
raise MaxRetriesFailure, "#{options[:operation_name]} failed (despite retrying " +
"#{max_retries} times) with\n" +
"#{e.class}: #{e.message}"
)
end
end
end
......@@ -200,7 +198,7 @@ rescue Timeout::Error
file.write($vm.file_content('/tmp/tor.journal'))
file.write($vm.file_content('/var/log/tor/log'))
end
raise TorBootstrapFailure.new('Tor failed to bootstrap')
raise TorBootstrapFailure, 'Tor failed to bootstrap'
end
def convert_bytes_mod(unit)
......
......@@ -31,7 +31,7 @@ module OpenCV
when 1
return nil
else
raise OpenCVInternalError.new(out)
raise OpenCVInternalError, out
end
end
end
......@@ -37,9 +37,9 @@ module RemoteShell
if status != 'success'
if (status == 'error') && (rest.class == Array) && (rest.size == 1)
msg = rest.first
raise ServerFailure.new(msg.to_s)
raise ServerFailure, msg.to_s
else
raise ServerFailure.new("Uncaught exception: #{status}: #{rest}")
raise ServerFailure, "Uncaught exception: #{status}: #{rest}"
end
end
return rest
......@@ -147,7 +147,7 @@ module RemoteShell
debug_log("opening file #{path} in '#{mode}' mode")
ret = RemoteShell.communicate(vm, 'file_' + mode, path, *args, **opts)
if ret.size != 1
raise ServerFailure.new("expected 1 value but got #{ret.size}")
raise ServerFailure, "expected 1 value but got #{ret.size}"
end
debug_log("#{mode} complete")
......
......@@ -118,7 +118,7 @@ class Screen
debug_log("Screen: trying to find #{image}") if opts[:log]
p = match_screen(image, opts[:sensitivity], false)
if p.nil?
raise FindFailed.new("cannot find #{image} on the screen")
raise FindFailed, "cannot find #{image} on the screen"
end
m = Match.new(image, self, *p)
......@@ -133,7 +133,7 @@ class Screen
return real_find(pattern, **opts.clone.update(log: false))
end
rescue Timeout::Error
raise FindFailed.new("cannot find #{pattern} on the screen")
raise FindFailed, "cannot find #{pattern} on the screen"
end
def find(pattern, **opts)
......@@ -158,7 +158,7 @@ class Screen
debug_log("Screen: #{pattern} has vanished") if opts[:log]
return nil
rescue Timeout::Error
raise FindFailed.new("can still find #{pattern} on the screen")
raise FindFailed, "can still find #{pattern} on the screen"
end
def find_any(patterns, **opts)
......@@ -175,8 +175,8 @@ class Screen
end
end
# If we've reached this point, none of the patterns could be found.
raise FindFailed.new("can not find any of the patterns #{patterns} " +
'on the screen')
raise FindFailed, "can not find any of the patterns #{patterns} " +
'on the screen'
end
def exists_any(*args, **opts)
......@@ -192,8 +192,8 @@ class Screen
return find_any(patterns, **opts.clone.update(log: false))
end
rescue Timeout::Error
raise FindFailed.new("can not find any of the patterns #{patterns} " +
'on the screen')
raise FindFailed, "can not find any of the patterns #{patterns} " +
'on the screen'
end
def press(*sequence, **opts)
......
......@@ -454,7 +454,7 @@ class VM
begin
assert_vmcommand_success(p)
rescue Test::Unit::AssertionFailedError => e
raise ExecutionFailedInVM.new(e)
raise ExecutionFailedInVM, e
end
return p
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment