Skip to content

Commit

Permalink
fix: auto-correct Layout/OddElseLayout
Browse files Browse the repository at this point in the history
This error started appearing in a new version of rubocop. It is
auto-correctable, so auto-correct it
  • Loading branch information
doudou committed Nov 12, 2021
1 parent 8c64813 commit b713882
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 37 deletions.
42 changes: 28 additions & 14 deletions lib/autobuild/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,44 @@ def self.msys?

SHELL_VAR_EXPANSION =
if windows? then "%%%s%%".freeze
else "$%s".freeze
else
"$%s".freeze
end
SHELL_SET_COMMAND =
if windows? then "set %s=%s".freeze
else "%s=\"%s\"".freeze
else
"%s=\"%s\"".freeze
end
SHELL_CONDITIONAL_SET_COMMAND =
if windows? then "set %s=%s".freeze
else "if test -z \"$%1$s\"; then\n %1$s=\"%3$s\"\n"\
else
"if test -z \"$%1$s\"; then\n %1$s=\"%3$s\"\n"\
"else\n %1$s=\"%2$s\"\nfi".freeze
end
SHELL_UNSET_COMMAND = "unset %s".freeze
SHELL_EXPORT_COMMAND =
if windows? then "set %s".freeze
else "export %s".freeze
else
"export %s".freeze
end
SHELL_SOURCE_SCRIPT =
if windows? then "%s".freeze
else '. "%s"'.freeze
else
'. "%s"'.freeze
end

LIBRARY_PATH =
if macos? then 'DYLD_LIBRARY_PATH'.freeze
elsif windows? then 'PATH'.freeze
else 'LD_LIBRARY_PATH'.freeze
else
'LD_LIBRARY_PATH'.freeze
end

LIBRARY_SUFFIX =
if macos? then 'dylib'
elsif windows? then 'dll'
else 'so'
else
'so'
end

ORIGINAL_ENV = Hash.new
Expand Down Expand Up @@ -211,7 +218,8 @@ def inherit?(name = nil)
if @inherit
if name
@inherited_variables.include?(name)
else true
else
true
end
end
end
Expand Down Expand Up @@ -245,7 +253,8 @@ def inherit(*names)
flag =
if !names.last.respond_to?(:to_str)
names.pop
else true
else
true
end

if flag
Expand Down Expand Up @@ -342,7 +351,8 @@ def value(name, options = Hash.new)
inherited_environment[name] || []
elsif inheritance_mode == :keep && inherit?(name)
["$#{name}"]
else []
else
[]
end

value = []
Expand Down Expand Up @@ -439,7 +449,8 @@ def source_before(file = nil, shell: 'sh')
if file
@source_before << { file: file, shell: shell }
source_before(shell: shell) # for backwards compatibility
else @source_before.select { |pair| pair[:shell] == shell }
else
@source_before.select { |pair| pair[:shell] == shell }
.map { |item| item[:file] }
end
end
Expand All @@ -457,7 +468,8 @@ def source_after(file = nil, shell: 'sh')
if file
@source_after << { file: file, shell: shell }
source_after(shell: shell) # for backwards compatibility
else @source_after.select { |pair| pair[:shell] == shell }
else
@source_after.select { |pair| pair[:shell] == shell }
.map { |item| item[:file] }
end
end
Expand Down Expand Up @@ -542,7 +554,8 @@ def self.environment_from_export(export, base_env = ENV)
with_inheritance = with_inheritance.map do |value|
if value == variable_expansion
base_env[name]
else value
else
value
end
end
result[name] = with_inheritance.join(File::PATH_SEPARATOR)
Expand Down Expand Up @@ -604,7 +617,8 @@ def arch_size
@arch_size ||=
if RbConfig::CONFIG['host_cpu'] =~ /64/
64
else 32
else
32
end
@arch_size
end
Expand Down
3 changes: 2 additions & 1 deletion lib/autobuild/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def to_s
target_name =
if target.respond_to?(:name)
target.name
else target.to_str
else
target.to_str
end

if target && phase
Expand Down
3 changes: 2 additions & 1 deletion lib/autobuild/import/archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ def checkout(package, options = Hash.new) # :nodoc:

if mode == Zip
main_dir = if @options[:no_subdirectory] then package.srcdir
else base_dir
else
base_dir
end

FileUtils.mkdir_p base_dir
Expand Down
12 changes: 8 additions & 4 deletions lib/autobuild/import/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def default_alternates
@default_alternates = cache_dirs.map do |path|
File.join(File.expand_path(path), '%s')
end
else Array.new
else
Array.new
end
end
end
Expand Down Expand Up @@ -764,7 +765,8 @@ def has_commit?(package, commit_id)
rescue SubcommandFailed => e
if e.status == 1
false
else raise
else
raise
end
end

Expand All @@ -775,7 +777,8 @@ def has_branch?(package, branch_name)
rescue SubcommandFailed => e
if e.status == 1
false
else raise
else
raise
end
end

Expand Down Expand Up @@ -1020,7 +1023,8 @@ def update_alternates(package)
File.readlines(alternates_path)
.map(&:strip)
.find_all { |l| !l.empty? }
else Array.new
else
Array.new
end

alternates = each_alternate_path(package).map do |path|
Expand Down
3 changes: 2 additions & 1 deletion lib/autobuild/import/svn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def svn_info(package)
# Try svn upgrade and info again
run_svn(package, 'upgrade', retry: false)
svninfo = run_svn(package, 'info')
else raise
else
raise
end
end

Expand Down
6 changes: 4 additions & 2 deletions lib/autobuild/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ def perform_update(package, only_local = false)
message = Autobuild.color('interrupted', :red)
if last_error
raise last_error
else raise
else
raise
end
rescue ::Exception => e
message = Autobuild.color('update failed', :red)
Expand Down Expand Up @@ -410,7 +411,8 @@ def perform_checkout(package, **options)
execute_post_hooks(package)
rescue Interrupt
if last_error then raise last_error
else raise
else
raise
end
rescue ::Exception => e
last_error = e
Expand Down
6 changes: 4 additions & 2 deletions lib/autobuild/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def installstamp
def update?
if @update.nil?
Autobuild.do_update
else @update
else
@update
end
end

Expand Down Expand Up @@ -492,7 +493,8 @@ def process_formatting_string(msg, *prefix_style)
suffix << token.gsub(/%s/, name)
elsif suffix.empty?
prefix << token
else suffix << token
else
suffix << token
end
end
if suffix.empty?
Expand Down
3 changes: 2 additions & 1 deletion lib/autobuild/packages/autotools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ def prepare
varname, = o.split("=").first
if (current_flag = testflags.find { |fl| fl =~ /^#{varname}=/ })
current_flag != o
else false
else
false
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/autobuild/packages/cmake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ def configure
def show_make_messages?
if !@show_make_messages.nil?
@show_make_messages
else CMake.show_make_messages?
else
CMake.show_make_messages?
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/autobuild/parallel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def push(task, base_priority = 1)
if task.respond_to?(:package)
started_packages[task.package] ||= -started_packages.size
queue[task] = started_packages[task.package]
else queue[task] = base_priority
else
queue[task] = base_priority
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/autobuild/progress_display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def group_messages(messages)
groups.last[1] = (current_group.first..group_end_index)
groups << [prefix, [idx, other_idx]]
grouping = true
else break
else
break
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions lib/autobuild/reporting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def self.report(on_package_failures: default_report_on_package_failures)
# :exit if debug is false, or :raise if it is true
def self.default_report_on_package_failures
if Autobuild.debug then :raise
else :exit
else
:exit
end
end

Expand Down Expand Up @@ -163,7 +164,8 @@ def self.report_finish_on_error(errors,
raise interrupted_by if interrupted_by

e = if errors.size == 1 then errors.first
else CompositeException.new(errors)
else
CompositeException.new(errors)
end
raise e
elsif %i[report_silent report].include?(on_package_failures)
Expand Down
14 changes: 10 additions & 4 deletions lib/autobuild/subcommand.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def self.run(target, phase, *command)
end
logdir = if target.respond_to?(:logdir)
target.logdir
else Autobuild.logdir
else
Autobuild.logdir
end

if target.respond_to?(:working_directory)
Expand All @@ -288,7 +289,8 @@ def self.run(target, phase, *command)

open_flag = if Autobuild.keep_oldlogs then 'a'
elsif Autobuild.registered_logfile?(logname) then 'a'
else 'w'
else
'w'
end
open_flag << ":BINARY"

Expand Down Expand Up @@ -318,9 +320,12 @@ def self.run(target, phase, *command)
logfile.sync = true

begin
# close_others: false is needed because some code (e.g.
# orogen/make) implicitly pass FDs to the child
pid = spawn(
env, *command,
chdir: chdir, in: inread, out: outwrite, err: outwrite
chdir: chdir, in: inread, out: outwrite, err: outwrite,
close_others: false
)
rescue StandardError => e
raise Failed.new(nil, false), e.message
Expand Down Expand Up @@ -398,7 +403,8 @@ def self.run(target, phase, *command)
logname, e.status, subcommand_output
)
error.retry = if e.retry?.nil? then options[:retry]
else e.retry?
else
e.retry?
end
error.phase = phase
raise error, e.message
Expand Down
6 changes: 4 additions & 2 deletions lib/autobuild/test_utility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def initialize(name, package, install_on_error: true)
def coverage_enabled?
if @coverage_enabled.nil?
TestUtility.coverage_enabled?
else @coverage_enabled
else
@coverage_enabled
end
end

Expand Down Expand Up @@ -53,7 +54,8 @@ def coverage_source_dir
if @coverage_source_dir
relative = if package.respond_to?(:builddir)
package.builddir
else package.srcdir
else
package.srcdir
end
File.expand_path(@coverage_source_dir, relative)
end
Expand Down

0 comments on commit b713882

Please sign in to comment.