From e9cd6972c6a3d08d8cd183d3f5ec978cccac4820 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 11 Nov 2021 11:02:58 -0300 Subject: [PATCH] fix: auto-correct Layout/OddElseLayout This error started appearing in a new version of rubocop. It is auto-correctable, so auto-correct it --- lib/autobuild/environment.rb | 42 +++++++++++++++++++---------- lib/autobuild/exceptions.rb | 3 ++- lib/autobuild/import/archive.rb | 3 ++- lib/autobuild/import/git.rb | 12 ++++++--- lib/autobuild/import/svn.rb | 3 ++- lib/autobuild/importer.rb | 6 +++-- lib/autobuild/package.rb | 6 +++-- lib/autobuild/packages/autotools.rb | 3 ++- lib/autobuild/packages/cmake.rb | 3 ++- lib/autobuild/parallel.rb | 3 ++- lib/autobuild/progress_display.rb | 3 ++- lib/autobuild/reporting.rb | 6 +++-- lib/autobuild/subcommand.rb | 9 ++++--- lib/autobuild/test_utility.rb | 6 +++-- 14 files changed, 72 insertions(+), 36 deletions(-) diff --git a/lib/autobuild/environment.rb b/lib/autobuild/environment.rb index f704e159..597dae9a 100644 --- a/lib/autobuild/environment.rb +++ b/lib/autobuild/environment.rb @@ -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 @@ -211,7 +218,8 @@ def inherit?(name = nil) if @inherit if name @inherited_variables.include?(name) - else true + else + true end end end @@ -245,7 +253,8 @@ def inherit(*names) flag = if !names.last.respond_to?(:to_str) names.pop - else true + else + true end if flag @@ -342,7 +351,8 @@ def value(name, options = Hash.new) inherited_environment[name] || [] elsif inheritance_mode == :keep && inherit?(name) ["$#{name}"] - else [] + else + [] end value = [] @@ -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 @@ -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 @@ -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) @@ -604,7 +617,8 @@ def arch_size @arch_size ||= if RbConfig::CONFIG['host_cpu'] =~ /64/ 64 - else 32 + else + 32 end @arch_size end diff --git a/lib/autobuild/exceptions.rb b/lib/autobuild/exceptions.rb index 56ca03c7..017df130 100644 --- a/lib/autobuild/exceptions.rb +++ b/lib/autobuild/exceptions.rb @@ -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 diff --git a/lib/autobuild/import/archive.rb b/lib/autobuild/import/archive.rb index 3c4dba02..c7f842c4 100644 --- a/lib/autobuild/import/archive.rb +++ b/lib/autobuild/import/archive.rb @@ -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 diff --git a/lib/autobuild/import/git.rb b/lib/autobuild/import/git.rb index f8d90bd3..023272e3 100644 --- a/lib/autobuild/import/git.rb +++ b/lib/autobuild/import/git.rb @@ -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 @@ -764,7 +765,8 @@ def has_commit?(package, commit_id) rescue SubcommandFailed => e if e.status == 1 false - else raise + else + raise end end @@ -775,7 +777,8 @@ def has_branch?(package, branch_name) rescue SubcommandFailed => e if e.status == 1 false - else raise + else + raise end end @@ -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| diff --git a/lib/autobuild/import/svn.rb b/lib/autobuild/import/svn.rb index c758c761..85941ff0 100644 --- a/lib/autobuild/import/svn.rb +++ b/lib/autobuild/import/svn.rb @@ -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 diff --git a/lib/autobuild/importer.rb b/lib/autobuild/importer.rb index afa2209c..b45fd390 100644 --- a/lib/autobuild/importer.rb +++ b/lib/autobuild/importer.rb @@ -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) @@ -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 diff --git a/lib/autobuild/package.rb b/lib/autobuild/package.rb index 4af1188c..6fffe1fd 100644 --- a/lib/autobuild/package.rb +++ b/lib/autobuild/package.rb @@ -119,7 +119,8 @@ def installstamp def update? if @update.nil? Autobuild.do_update - else @update + else + @update end end @@ -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? diff --git a/lib/autobuild/packages/autotools.rb b/lib/autobuild/packages/autotools.rb index 0a9ff0f2..ab6baadd 100644 --- a/lib/autobuild/packages/autotools.rb +++ b/lib/autobuild/packages/autotools.rb @@ -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 diff --git a/lib/autobuild/packages/cmake.rb b/lib/autobuild/packages/cmake.rb index d3fae24b..debc4f87 100644 --- a/lib/autobuild/packages/cmake.rb +++ b/lib/autobuild/packages/cmake.rb @@ -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 diff --git a/lib/autobuild/parallel.rb b/lib/autobuild/parallel.rb index f654c6fc..fde431ac 100644 --- a/lib/autobuild/parallel.rb +++ b/lib/autobuild/parallel.rb @@ -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 diff --git a/lib/autobuild/progress_display.rb b/lib/autobuild/progress_display.rb index 20fc634d..5365bdd7 100644 --- a/lib/autobuild/progress_display.rb +++ b/lib/autobuild/progress_display.rb @@ -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 diff --git a/lib/autobuild/reporting.rb b/lib/autobuild/reporting.rb index 8f034116..bc95bfe0 100644 --- a/lib/autobuild/reporting.rb +++ b/lib/autobuild/reporting.rb @@ -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 @@ -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) diff --git a/lib/autobuild/subcommand.rb b/lib/autobuild/subcommand.rb index b8da93e8..40690b7f 100644 --- a/lib/autobuild/subcommand.rb +++ b/lib/autobuild/subcommand.rb @@ -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) @@ -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" @@ -398,7 +400,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 diff --git a/lib/autobuild/test_utility.rb b/lib/autobuild/test_utility.rb index f00a4ea4..c1ebaad6 100644 --- a/lib/autobuild/test_utility.rb +++ b/lib/autobuild/test_utility.rb @@ -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 @@ -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