Commit e40ae3c5 authored by intrigeri's avatar intrigeri
Browse files

Rubocop: fix Style/RedundantReturn offenses

Changes generated with:

`rubocop --only Style/RedundantReturn --auto-correct`
parent b3a7db00
......@@ -439,12 +439,6 @@ Style/MutableConstant:
- 'features/support/helpers/screen.rb'
- 'vagrant/lib/tails_build_settings.rb'
# Offense count: 95
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false
# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
......
......@@ -88,7 +88,7 @@ def capture_command(*args)
'%{status}: %{stderr}',
stderr: stderr, status: proc_status.exitstatus)
end
return stdout, stderr
[stdout, stderr]
end
def git_helper(*args)
......@@ -102,9 +102,9 @@ def git_helper(*args)
status = e.status
end
if question
return status.zero?
status.zero?
else
return stdout.chomp
stdout.chomp
end
end
......@@ -156,11 +156,11 @@ def vm_state
out, = capture_vagrant('status')
status_line = out.split("\n")[2]
if status_line['not created']
return :not_created
:not_created
elsif status_line['shutoff']
return :poweroff
:poweroff
elsif status_line['running']
return :running
:running
else
raise 'could not determine VM state'
end
......@@ -353,7 +353,7 @@ def list_artifacts
'-o -name tails-build-env.list').first
stdout.split("\n")
rescue VagrantCommandError
return Array.new
Array.new
end
def remove_artifacts
......
......@@ -69,7 +69,7 @@ def parse_argv!
req_nr_parameters = options['skip-packages'] ? 2 : 4
assert_equal(req_nr_parameters, parameters.size,
"You must pass exactly #{req_nr_parameters} parameters")
return [options, parameters]
[options, parameters]
end
# From a .build-manifest, from its list of packages, generate a
......@@ -119,7 +119,7 @@ def canonicalize_relationship(orig_entry)
entry[field] = entry[field].arrayify
end
return entry
entry
rescue Exception => e
warn 'Problematic entry:'
warn YAML.dump([orig_entry])
......@@ -139,7 +139,7 @@ def read_relationship_file_as_impact_map(relationship_file)
impact_map.deep_merge({ page => source_files })
end
end
return impact_map
impact_map
end
# Given the "documentation impact map" and the "old" and "new" state,
......@@ -236,7 +236,7 @@ def find_impacted_docs(impact_map,
end
end
end
return impacted_docs
impacted_docs
end
# Main
......
......@@ -44,7 +44,7 @@ def page_meta_date_is_ok?(path)
success = false
end
end
return success
success
end
def po_file_meta_date_is_ok?(path)
......@@ -74,7 +74,7 @@ def po_file_meta_date_is_ok?(path)
end
end
end
return success
success
end
# Main
......
......@@ -63,7 +63,7 @@ def xul_application_info(application)
else
raise "Invalid browser or XUL application: #{application}"
end
return {
{
:user => user,
:cmd_regex => cmd_regex,
:chroot => chroot,
......
def shipped_openpgp_keys
shipped_gpg_keys = $vm.execute_successfully('gpg --batch --with-colons --fingerprint --list-key', :user => LIVE_USER).stdout
openpgp_fingerprints = shipped_gpg_keys.scan(/^fpr:::::::::([A-Z0-9]+):$/).flatten
return openpgp_fingerprints
openpgp_fingerprints
end
Then /^the OpenPGP keys shipped with Tails will be valid for the next (\d+) months$/ do |months|
......@@ -159,7 +159,7 @@ def get_seccomp_status(process)
assert($vm.has_process?(process), "Process #{process} not running.")
pid = $vm.pidof(process)[0]
status = $vm.file_content("/proc/#{pid}/status")
return status.match(/^Seccomp:\s+([0-9])/)[1].chomp.to_i
status.match(/^Seccomp:\s+([0-9])/)[1].chomp.to_i
end
def get_apparmor_status(pid)
......@@ -167,9 +167,9 @@ def get_apparmor_status(pid)
if apparmor_status.include?(')')
# matches something like /usr/sbin/cupsd (enforce)
# and only returns what's in the parentheses
return apparmor_status.match(/[^\s]+\s+\((.+)\)$/)[1].chomp
apparmor_status.match(/[^\s]+\s+\((.+)\)$/)[1].chomp
else
return apparmor_status
apparmor_status
end
end
......
......@@ -203,5 +203,5 @@ def chutney_onionservice_redir(remote_address, remote_port)
"#{remote_address}:#{remote_port}"
)
add_after_scenario_hook { kill_redir.call }
return $chutney_onionservice_job
$chutney_onionservice_job
end
......@@ -754,7 +754,7 @@ end
def pulseaudio_sink_inputs
pa_info = $vm.execute_successfully('pacmd info', :user => LIVE_USER).stdout
sink_inputs_line = pa_info.match(/^\d+ sink input\(s\) available\.$/)[0]
return sink_inputs_line.match(/^\d+/)[0].to_i
sink_inputs_line.match(/^\d+/)[0].to_i
end
When /^(no|\d+) application(?:s?) (?:is|are) playing audio(?:| after (\d+) seconds)$/ do |nb, wait_time|
......@@ -997,7 +997,7 @@ def size_of_shared_disk_for(files)
disk_size = files.map { |f| File.new(f).size } .inject(0, :+)
# Let's add some extra space for filesystem overhead etc.
disk_size += [convert_to_bytes(1, 'MiB'), (disk_size * 0.15).ceil].max
return disk_size
disk_size
end
def share_host_files(files)
......@@ -1019,7 +1019,7 @@ def share_host_files(files)
partition = dev + '1'
$vm.execute_successfully("mount #{partition} #{mount_dir}")
$vm.execute_successfully("chmod -R a+rX '#{mount_dir}'")
return mount_dir
mount_dir
end
def mount_USB_drive(disk, **fs_options)
......@@ -1044,7 +1044,7 @@ def mount_USB_drive(disk, **fs_options)
@tmp_filesystem_disk = disk
@tmp_filesystem_options = fs_options
@tmp_filesystem_partition = partition
return @tmp_usb_drive_mount_dir
@tmp_usb_drive_mount_dir
end
When(/^I plug and mount a (\d+) MiB USB drive with an? (.*)$/) do |size_MiB, fs|
......
......@@ -14,7 +14,7 @@ def udev_watchdog_monitored_device
$vm.execute_successfully(
"readlink -f /dev/block/'#{monitored_device_id}'"
).stdout.chomp
return monitored_device
monitored_device
end
Given /^udev-watchdog is monitoring the correct device$/ do
......@@ -22,11 +22,11 @@ Given /^udev-watchdog is monitoring the correct device$/ do
end
def used_ram_in_MiB
return $vm.execute_successfully("free -m | awk '/^Mem:/ { print $3 }'").stdout.chomp.to_i
$vm.execute_successfully("free -m | awk '/^Mem:/ { print $3 }'").stdout.chomp.to_i
end
def detected_ram_in_MiB
return $vm.execute_successfully("free -m | awk '/^Mem:/ { print $2 }'").stdout.chomp.to_i
$vm.execute_successfully("free -m | awk '/^Mem:/ { print $2 }'").stdout.chomp.to_i
end
def pattern_coverage_in_guest_ram(reference_memory_b)
......@@ -55,7 +55,7 @@ def pattern_coverage_in_guest_ram(reference_memory_b)
coverage = patterns_b.to_f / reference_memory_b
puts "Pattern coverage: #{'%.3f' % (coverage * 100)}% (#{patterns_m} MiB " +
"out of #{reference_memory_m} MiB reference memory)"
return coverage
coverage
end
Given /^I prepare Tails for memory erasure tests$/ do
......@@ -104,7 +104,7 @@ When /^I kill the allocating process$/ do
end
def avail_space_in_mountpoint_kB(mountpoint)
return $vm.execute_successfully(
$vm.execute_successfully(
"df --output=avail '#{mountpoint}'"
).stdout.split("\n")[1].to_i
end
......
......@@ -15,7 +15,7 @@ def xmpp_account(account_name, required_options = [])
EOF
)
end
return account
account
end
def wait_and_focus(img, window, time = 10)
......@@ -263,7 +263,7 @@ def configured_pidgin_accounts
}
end
return accounts
accounts
end
def chan_image(account, channel, image)
......@@ -275,18 +275,18 @@ def chan_image(account, channel, image)
},
},
}
return images[account][channel][image] + '.png'
images[account][channel][image] + '.png'
end
def default_chan(account)
chans = {
'conference.riseup.net' => 'tails',
}
return chans[account]
chans[account]
end
def pidgin_otr_keys
return $vm.file_content("/home/#{LIVE_USER}/.purple/otr.private_key")
$vm.file_content("/home/#{LIVE_USER}/.purple/otr.private_key")
end
When /^I open Pidgin's account manager window$/ do
......
......@@ -66,7 +66,7 @@ end
def get_free_tcp_port
server = TCPServer.new('127.0.0.1', 0)
return server.addr[1]
server.addr[1]
ensure
server.close
end
......
......@@ -24,7 +24,7 @@ def iptables_rules_parse(iptables, chain, table)
iptables_chains_parse(iptables, table) do |name, _, rules|
return rules if name == chain
end
return nil
nil
end
def iptables_rules(chain, table = 'filter')
......@@ -46,7 +46,7 @@ def ip4tables_packet_counter_sum(**filters)
pkts += rule.attribute('packet-count').to_s.to_i
end
end
return pkts
pkts
end
def try_xml_element_text(element, xpath, default = nil)
......
......@@ -75,7 +75,7 @@ Then /^the Unsafe Browser has only Firefox's default bookmarks configured$/ do
end
end
end
return mozilla_uris_counter
mozilla_uris_counter
end
mozilla_uris_counter = check_bookmarks_helper(dump['children'])
......
......@@ -31,7 +31,7 @@ def create_veracrypt_keyfile()
keyfile = Tempfile.create('veracrypt-keyfile', $config['TMPDIR'])
keyfile << 'asdf'
keyfile.close
return keyfile.path
keyfile.path
end
def reply_prompt(r_f, w_f, prompt_re, answer)
......
......@@ -53,7 +53,7 @@ def current_branch
cmd = 'git rev-parse --symbolic-full-name --abbrev-ref HEAD'.split
branch = cmd_helper(cmd).strip
assert_not_equal('HEAD', branch, "We are in 'detached HEAD' state")
return branch
branch
end
# In order: if git HEAD is tagged, return its name; if a branch is
......
......@@ -55,6 +55,6 @@ class ChatBot
end
end
assert_equal(1, ret, "This shouldn't happen")
return true
true
end
end
......@@ -85,7 +85,7 @@ module Dogtail
raise Failure, "The Dogtail script raised: #{c.exception}"
end
return c
c
end
def child?(*args)
......@@ -97,9 +97,9 @@ module Dogtail
def exist?
run('dogtail.config.searchCutoffCount = 0')
run(@find_code)
return true
true
rescue
return false
false
ensure
run('dogtail.config.searchCutoffCount = 20')
end
......@@ -177,7 +177,7 @@ module Dogtail
"print(len(#{nodes_var}))",
]
size = run(find_script_lines).stdout.chomp.to_i
return size.times.map do |i|
size.times.map do |i|
Node.new("#{nodes_var}[#{i}]", **@opts)
end
end
......
......@@ -216,19 +216,19 @@ def convert_bytes_mod(unit)
else
raise "invalid memory unit '#{unit}'"
end
return mod
mod
end
def convert_to_bytes(size, unit)
return (size * convert_bytes_mod(unit)).to_i
(size * convert_bytes_mod(unit)).to_i
end
def convert_to_MiB(size, unit)
return (size * convert_bytes_mod(unit) / (2**20)).to_i
(size * convert_bytes_mod(unit) / (2**20)).to_i
end
def convert_from_bytes(size, unit)
return size.to_f / convert_bytes_mod(unit).to_f
size.to_f / convert_bytes_mod(unit).to_f
end
def cmd_helper(cmd, env = {})
......@@ -259,7 +259,7 @@ def all_tor_hosts
end
end
end
return nodes
nodes
end
def allowed_hosts_under_tor_enforcement
......@@ -278,7 +278,7 @@ def get_free_space(machine, path)
raise "Unsupported machine type #{machine} passed."
end
output = free.split("\n").last
return output.match(/[^\s]\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+.*/)[1].chomp.to_i
output.match(/[^\s]\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+.*/)[1].chomp.to_i
end
def random_string_from_set(set, min_len, max_len)
......@@ -395,9 +395,9 @@ end
def ffmpeg
if cmd_helper('lsb_release --short --codename').chomp == 'stretch'
return 'avconv'
'avconv'
else
return 'ffmpeg'
'ffmpeg'
end
end
......@@ -407,7 +407,7 @@ end
def popen_wait(*args, **opts)
p = IO.popen(*args, **opts)
Process.wait(p.pid)
return p
p
ensure
# If popen is run inside a Timeout::timeout() block we might abort
# while the subprocess is still running and before the above wait()
......
......@@ -27,9 +27,9 @@ module OpenCV
out = p.readlines.join("\n")
case $CHILD_STATUS.exitstatus
when 0
return out.chomp.split.map { |s| s.to_i }
out.chomp.split.map { |s| s.to_i }
when 1
return nil
nil
else
raise OpenCVInternalError, out
end
......
......@@ -71,7 +71,7 @@ module RemoteShell
debug_log("Remote shell: #{type}ing as #{opts[:user]}: #{cmd}")
ret = RemoteShell.communicate(vm, 'sh_' + type, opts[:user], cmd, **opts)
debug_log("Remote shell: #{type} returned: #{ret}") unless opts[:spawn]
return ret
ret
end
attr_reader :cmd, :returncode, :stdout, :stderr
......@@ -82,11 +82,11 @@ module RemoteShell
end
def success?
return @returncode.zero?
@returncode.zero?
end
def failure?
return !success?
!success?
end
def to_s
......@@ -113,7 +113,7 @@ module RemoteShell
vm, 'python_execute', opts[:user], code, **opts
)
debug_log('execution complete')
return ret
ret
end
attr_reader :code, :exception, :stdout, :stderr
......@@ -124,11 +124,11 @@ module RemoteShell
end
def success?
return @exception.nil?
@exception.nil?
end
def failure?
return !success?
!success?
end
def to_s
......@@ -151,7 +151,7 @@ module RemoteShell
end
debug_log("#{mode} complete")
return ret.first
ret.first
end
attr_reader :vm, :path
......
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