Commit 93a6134e authored by intrigeri's avatar intrigeri
Browse files

Rubocop: fix Style/ConditionalAssignment offenses

Initially done via --auto-correct, then manually linted the resulting
code (that would otherwise introduce a bunch of offenses).
parent d5c2ddbb
......@@ -63,24 +63,6 @@ Naming/AccessorMethodName:
- 'features/step_definitions/ssh.rb'
- 'features/support/helpers/vm_helper.rb'
# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'features/step_definitions/browser.rb'
- 'features/step_definitions/checks.rb'
- 'features/step_definitions/chutney.rb'
- 'features/step_definitions/common_steps.rb'
- 'features/step_definitions/mac_spoofing.rb'
- 'features/step_definitions/pidgin.rb'
- 'features/step_definitions/thunderbird.rb'
- 'features/support/helpers/misc_helpers.rb'
- 'features/support/helpers/opencv.rb'
- 'features/support/hooks.rb'
- 'vagrant/Vagrantfile'
# Offense count: 22
Style/Documentation:
Exclude:
......
......@@ -99,11 +99,11 @@ When /^I open the address "([^"]*)" in the (.*)$/ do |address, browser|
@screen.wait_vanish(info[:browser_stop_button_image], 3)
open_address.call
end
if browser == 'Tor Browser'
retry_method = method(:retry_tor)
else
retry_method = proc { |p, &b| retry_action(10, recovery_proc: p, &b) }
end
retry_method = if browser == 'Tor Browser'
method(:retry_tor)
else
proc { |p, &b| retry_action(10, recovery_proc: p, &b) }
end
open_address.call
retry_method.call(recovery_on_failure) do
@screen.wait_vanish(info[:browser_stop_button_image], 120)
......
......@@ -104,11 +104,7 @@ Then /^the support documentation page opens in Tor Browser$/ do
expected_heading = 'Search the documentation'
end
step "\"#{expected_title}\" has loaded in the Tor Browser"
if $language == 'German'
browser_name = 'Tor-Browser'
else
browser_name = 'Tor Browser'
end
browser_name = $language == 'German' ? 'Tor-Browser' : 'Tor Browser'
try_for(60) do
@torbrowser
.child(expected_title + " - #{browser_name}", roleName: 'frame')
......
......@@ -174,11 +174,7 @@ end
def chutney_onionservice_redir(remote_address, remote_port)
redir_unit_name = 'tails-test-suite-redir.service'
if ENV['USER'] == 'root'
bus = '--system'
else
bus = '--user'
end
bus = ENV['USER'] == 'root' ? '--system' : '--user'
kill_redir = proc do
begin
if system('/bin/systemctl', bus, '--quiet', 'is-active', redir_unit_name)
......
......@@ -797,11 +797,11 @@ When /^I (can|cannot) save the current page as "([^"]+[.]html)" to the (.*) dire
end
When /^I can print the current page as "([^"]+[.]pdf)" to the (default downloads|persistent Tor Browser) directory$/ do |output_file, output_dir|
if output_dir == 'persistent Tor Browser'
output_dir = "/home/#{LIVE_USER}/Persistent/Tor Browser"
else
output_dir = "/home/#{LIVE_USER}/Tor Browser"
end
output_dir = if output_dir == 'persistent Tor Browser'
"/home/#{LIVE_USER}/Persistent/Tor Browser"
else
"/home/#{LIVE_USER}/Tor Browser"
end
@screen.press('ctrl', 'p')
print_dialog = @torbrowser.child('Print', roleName: 'dialog')
print_dialog.child('Print to File', 'table cell').click
......@@ -881,11 +881,11 @@ When /^I open a page on the LAN web server in the (.*)$/ do |browser|
end
Given /^I wait (?:between (\d+) and )?(\d+) seconds$/ do |min, max|
if min
time = rand(max.to_i - min.to_i + 1) + min.to_i
else
time = max.to_i
end
time = if min
rand(max.to_i - min.to_i + 1) + min.to_i
else
max.to_i
end
puts "Slept for #{time} seconds"
sleep(time)
end
......
......@@ -102,11 +102,11 @@ When /^I hotplug a network device( and wait for it to be initialized)?$/ do |wai
# XXX:Buster: when we stop supporting the test suite on Stretch
# hosts, let's remove this workaround related to #14819 and just
# settle on a device that works on all supported platforms.
if cmd_helper('lsb_release --short --codename').chomp == 'stretch'
device = 'virtio'
else
device = 'pcnet'
end
device = if cmd_helper('lsb_release --short --codename').chomp == 'stretch'
'virtio'
else
'pcnet'
end
debug_log("Hotplugging a '#{device}' network device")
xml = <<-XML
<interface type='network'>
......
......@@ -184,13 +184,13 @@ When /^I join some empty multi-user chat$/ do
@screen.wait('PidginJoinChatWindow.png', 10).click
click_mid_right_edge('PidginJoinChatRoomLabel.png')
account = xmpp_account('Tails_account')
if account.key?('chat_room') && \
!account['chat_room'].nil? && \
!account['chat_room'].empty?
chat_room = account['chat_room']
else
chat_room = random_alnum_string(10, 15)
end
chat_room = if account.key?('chat_room') && \
!account['chat_room'].nil? && \
!account['chat_room'].empty?
account['chat_room']
else
random_alnum_string(10, 15)
end
@screen.type(chat_room)
# We will need the conference server later, when starting the bot.
......@@ -241,16 +241,8 @@ def configured_pidgin_accounts
port = e.elements["settings/setting[@name='port']"].text
username_element = e.elements["settings/setting[@name='username']"]
realname_elemenet = e.elements["settings/setting[@name='realname']"]
if username_element
nickname = username_element.text
else
nickname = nil
end
if realname_elemenet
real_name = realname_elemenet.text
else
real_name = nil
end
nickname = username_element ? username_element.text : nil
real_name = realname_elemenet ? realname_elemenet.text : nil
accounts[network] = {
'name' => account_name,
'network' => network,
......
......@@ -176,11 +176,11 @@ When /^I accept the (?:autoconfiguration wizard's|manual) configuration$/ do
end
When /^I select the autoconfiguration wizard's (IMAP|POP3) choice$/ do |protocol|
if protocol == 'IMAP'
choice = 'IMAP (remote folders)'
else
choice = 'POP3 (keep mail on your computer)'
end
choice = if protocol == 'IMAP'
'IMAP (remote folders)'
else
'POP3 (keep mail on your computer)'
end
thunderbird_wizard.child(choice, roleName: 'radio button').click
@protocol = protocol
end
......
......@@ -55,11 +55,11 @@ def try_for(timeout, **options)
# XXX: The commit that introduced this version check can be
# reverted when we drop support for running the test suite on
# Debian Stretch.
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4')
elapsed = ('%.2f' % elapsed).chomp('.00').chomp('.0').chomp('0')
else
elapsed = elapsed.ceil(2)
end
elapsed = if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4')
('%.2f' % elapsed).chomp('.00').chomp('.0').chomp('0')
else
elapsed.ceil(2)
end
debug_log("try_for: attempt #{attempts} (#{elapsed}s elapsed " \
"of #{timeout}s)...") if options[:log]
if yield
......
......@@ -4,11 +4,11 @@ class OpenCVInternalError < StandardError
end
module OpenCV
if cmd_helper('lsb_release --short --codename').chomp == 'stretch'
@python = 'python2.7'
else
@python = 'python3'
end
@python = if cmd_helper('lsb_release --short --codename').chomp == 'stretch'
'python2.7'
else
'python3'
end
def self.matchTemplate(image, screen, sensitivity, show_match)
assert(sensitivity < 1.0)
......
......@@ -210,11 +210,11 @@ Before('@product') do |scenario|
err: ['/dev/null', 'w'],])
@video_capture_pid = capture.pid
end
if $config['IMAGE_BUMPING_MODE']
@screen = ImageBumpingScreen.new
else
@screen = Screen.new
end
@screen = if $config['IMAGE_BUMPING_MODE']
ImageBumpingScreen.new
else
Screen.new
end
# English will be assumed if this is not overridden
$language = ''
@os_loader = 'MBR'
......
......@@ -37,11 +37,7 @@ Vagrant.configure('2') do |config|
domain.management_network_guest_ipv6 = 'no'
domain.connect_via_ssh = false
domain.machine_arch = 'x86_64'
if ENV['TAILS_BUILD_MACHINE_TYPE']
domain.machine_type = ENV['TAILS_BUILD_MACHINE_TYPE']
else
domain.machine_type = 'q35'
end
domain.machine_type = ENV['TAILS_BUILD_MACHINE_TYPE'] || 'q35'
if ENV['TAILS_BUILD_CPU_MODEL']
domain.cpu_mode = 'custom'
domain.cpu_model = ENV['TAILS_BUILD_CPU_MODEL']
......
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