Clean up rubocop configuration pt.1 (#11566)

This commit is contained in:
Maximilian Downey Twiss
2025-03-18 09:42:05 +11:00
committed by GitHub
parent 2799fade10
commit 0c86288d24
15 changed files with 78 additions and 75 deletions

View File

@@ -3,7 +3,7 @@
require 'etc'
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
CREW_VERSION ||= '1.57.8' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
CREW_VERSION ||= '1.57.9' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
# Kernel architecture.
KERN_ARCH ||= Etc.uname[:machine]
@@ -61,7 +61,7 @@ else
end
# Use sane minimal defaults if in container and no override specified.
CREW_KERNEL_VERSION ||= \
CREW_KERNEL_VERSION ||=
if CREW_IN_CONTAINER && ENV.fetch('CREW_KERNEL_VERSION', nil).nil?
ARCH.eql?('i686') ? '3.8' : '5.10'
else
@@ -106,7 +106,7 @@ CREW_FORCE ||= ARGV.intersect?(%w[-f --force]) unless defined?(CREW_FORCE)
CREW_VERBOSE ||= ARGV.intersect?(%w[-v --verbose]) unless defined?(CREW_VERBOSE)
# Set CREW_NPROC from environment variable, `distcc -j`, or `nproc`.
CREW_NPROC ||= \
CREW_NPROC ||=
if File.file?("#{CREW_PREFIX}/bin/distcc")
ENV.fetch('CREW_NPROC', `distcc -j`.chomp)
else
@@ -139,7 +139,7 @@ CREW_BRANCH ||= ENV.fetch('CREW_BRANCH', 'master') unless defined?(CREW_BRANCH)
USER ||= Etc.getlogin unless defined?(USER)
unless defined?(CHROMEOS_RELEASE)
CHROMEOS_RELEASE = \
CHROMEOS_RELEASE =
if File.exist?('/etc/lsb-release')
File.read('/etc/lsb-release')[/CHROMEOS_RELEASE_CHROME_MILESTONE||=(.+)/, 1]
else
@@ -168,7 +168,7 @@ CREW_DOWNLOADER_RETRY ||= ENV.fetch('CREW_DOWNLOADER_RETRY', 3).to_i unless defi
CREW_HIDE_PROGBAR = ENV.fetch('CREW_HIDE_PROGBAR', false) unless defined?(CREW_HIDE_PROGBAR)
# set certificate file location for lib/downloader.rb
SSL_CERT_FILE ||= \
SSL_CERT_FILE ||=
if ENV['SSL_CERT_FILE'] && File.exist?(ENV['SSL_CERT_FILE'])
ENV['SSL_CERT_FILE']
elsif File.exist?("#{CREW_PREFIX}/etc/ssl/certs/ca-certificates.crt")
@@ -177,7 +177,7 @@ SSL_CERT_FILE ||= \
'/etc/ssl/certs/ca-certificates.crt'
end
SSL_CERT_DIR ||= \
SSL_CERT_DIR ||=
if ENV['SSL_CERT_DIR'] && Dir.exist?(ENV['SSL_CERT_DIR'])
ENV['SSL_CERT_DIR']
elsif Dir.exist?("#{CREW_PREFIX}/etc/ssl/certs")
@@ -211,7 +211,7 @@ CREW_COMMON_FNO_LTO_FLAGS ||= "#{CREW_CORE_FLAGS} -fno-lto"
CREW_LDFLAGS ||= "-flto=auto #{CREW_LINKER_FLAGS}"
CREW_FNO_LTO_LDFLAGS ||= '-fno-lto'
CREW_ENV_OPTIONS_HASH ||= \
CREW_ENV_OPTIONS_HASH ||=
if CREW_DISABLE_ENV_OPTIONS
{ 'CREW_DISABLE_ENV_OPTIONS' => '1' }
else

View File

@@ -115,7 +115,7 @@ class ConvenienceFunctions
def self.unset_default_browser(browser_name, browser_binary)
Dir.chdir("#{CREW_PREFIX}/bin") do
if File.exist?('x-www-browser') && File.symlink?('x-www-browser') && \
if File.exist?('x-www-browser') && File.symlink?('x-www-browser') &&
File.realpath('x-www-browser') == "#{CREW_PREFIX}/share/#{browser_name.downcase}/#{browser_binary}"
FileUtils.rm "#{CREW_PREFIX}/bin/x-www-browser"
end

View File

@@ -29,7 +29,7 @@ module DebUtils
end
# read file meta
name, _modtime, _uid, _gid, mode, size, end_char = \
name, _modtime, _uid, _gid, mode, size, end_char =
line.scan(/(.{16})(.{12})(.{6})(.{6})(.{8})(.{10})(.{1})/).flatten.map(&:strip)
# remove slash suffix from filename (if any)

View File

@@ -24,7 +24,7 @@ rescue RuntimeError => e
end
end
def downloader(url, sha256sum, filename = File.basename(url), verbose = false)
def downloader(url, sha256sum, filename = File.basename(url), verbose: false)
# downloader: wrapper for all Chromebrew downloaders (`net/http`,`curl`...)
# Usage: downloader <url>, <sha256sum>, <filename::optional>, <verbose::optional>
#
@@ -39,13 +39,13 @@ def downloader(url, sha256sum, filename = File.basename(url), verbose = false)
if CREW_USE_CURL || !ENV['CREW_DOWNLOADER'].to_s.empty?
# force using external downloader if either CREW_USE_CURL or ENV['CREW_DOWNLOADER'] is set
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
external_downloader(uri, filename, verbose)
external_downloader(uri, filename, verbose: verbose)
else
case uri.scheme
when 'http', 'https'
# use net/http if the url protocol is http(s)://
puts "http_downloader(#{uri}, #{filename}, #{verbose})" if verbose
http_downloader(uri, filename, verbose)
http_downloader(uri, filename, verbose: verbose)
when 'file'
# use FileUtils to copy if it is a local file (the url protocol is file://)
if File.exist?(uri.path)
@@ -56,7 +56,7 @@ def downloader(url, sha256sum, filename = File.basename(url), verbose = false)
else
# use external downloader (curl by default) if the url protocol is not http(s):// or file://
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
external_downloader(uri, filename, verbose)
external_downloader(uri, filename, verbose: verbose)
end
end
@@ -88,10 +88,10 @@ rescue StandardError => e
# fallback to curl if error occurred
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
external_downloader(uri, filename, verbose)
external_downloader(uri, filename, verbose: verbose)
end
def http_downloader(uri, filename = File.basename(url), verbose = false)
def http_downloader(uri, filename = File.basename(url), verbose: false)
# http_downloader: Downloader based on net/http library
ssl_error_retry = 0
@@ -119,7 +119,7 @@ def http_downloader(uri, filename = File.basename(url), verbose = false)
redirect_uri.scheme ||= uri.scheme
redirect_uri.host ||= uri.host
return send(__method__, redirect_uri, filename, verbose)
return send(__method__, redirect_uri, filename, verbose: verbose)
else
abort "Download of #{uri} failed with error #{response.code}: #{response.msg}".lightred
end
@@ -167,7 +167,7 @@ rescue OpenSSL::SSL::SSLError
ssl_error_retry <= 3 ? retry : raise
end
def external_downloader(uri, filename = File.basename(url), verbose = false)
def external_downloader(uri, filename = File.basename(url), verbose: false)
# external_downloader: wrapper for external downloaders in CREW_DOWNLOADER (curl by default)
# default curl cmdline, CREW_DOWNLOADER should be in this format also

View File

@@ -143,9 +143,9 @@ class Package
deps = pkg_obj.dependencies
# Append buildessential to deps if building from source is needed/specified.
if ((include_build_deps == true) || ((include_build_deps == 'auto') && is_source)) && \
!pkg_obj.no_compile_needed? && \
!exclude_buildessential && \
if ((include_build_deps == true) || ((include_build_deps == 'auto') && is_source)) &&
!pkg_obj.no_compile_needed? &&
!exclude_buildessential &&
!@checked_list.keys.include?('buildessential')
deps = { 'buildessential' => [[:build]] }.merge(deps)
@@ -155,8 +155,8 @@ class Package
expanded_deps = deps.uniq.map do |dep, (dep_tags, ver_check)|
# Check build dependencies only if building from source is needed/specified.
# Do not recursively find :build based build dependencies.
next unless (include_build_deps == true && @crew_current_package == pkg_obj.name) || \
((include_build_deps == 'auto') && is_source && @crew_current_package == pkg_obj.name) || \
next unless (include_build_deps == true && @crew_current_package == pkg_obj.name) ||
((include_build_deps == 'auto') && is_source && @crew_current_package == pkg_obj.name) ||
!dep_tags.include?(:build)
# Overwrite tags if parent dependency is a build dependency.

View File

@@ -94,6 +94,7 @@ class Selector
# discard any input in the input buffer
$stdin.read_nonblock(1024)
rescue IO::WaitReadable
# We wait here for reading as per https://docs.ruby-lang.org/en/master/IO.html#method-c-select
ensure
Thread.current[:input] = $stdin.getc
end