From 75bc603418320ffbff9746e914e1e22d538d0934 Mon Sep 17 00:00:00 2001 From: Maximilian Downey Twiss Date: Fri, 6 Jun 2025 21:04:01 +1000 Subject: [PATCH] Run rubocop 1.76.0 on tree (#11998) --- .pre-commit-config.yaml | 2 +- .rubocop.yml | 15 ++++++++++----- commands/check.rb | 4 ++-- lib/buildsystems/pip.rb | 12 ++++++------ lib/buildsystems/qmake.rb | 2 +- lib/downloader.rb | 8 ++++---- lib/misc_functions.rb | 2 +- packages/binutils.rb | 2 +- packages/elfutils.rb | 2 +- packages/gdb.rb | 2 +- packages/graphicsmagick.rb | 2 +- packages/libdovi.rb | 2 +- packages/ruby.rb | 2 +- 13 files changed, 31 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c68ce141..8239e7d60 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ # These pre-commit hooks mirror the Github CI, so running them locally will catch errors earlier. repos: - repo: https://github.com/rubocop/rubocop - rev: v1.74.0 + rev: v1.76.0 hooks: - id: rubocop - repo: https://github.com/syntaqx/git-hooks diff --git a/.rubocop.yml b/.rubocop.yml index a058d7792..eadd9e9e6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -108,14 +108,19 @@ Naming/ClassAndModuleCamelCase: Exclude: - 'packages/*' +# If there is meaningful information to convey about the contents of a heredoc, a comment is the best way to do it. +# Forcing unique names for all heredoc delimiters does not improve documentation in the vast majority of cases. +Naming/HeredocDelimiterNaming: + Enabled: false + +# Many predicate methods (methods returning either true or false) are made more readable by having an ? at the end, but not all. +# A manual inspection should suffice to determine which is which. +Naming/PredicateMethod: + Enabled: false + # We allow all caps variables to mirror our constants, so things like @ARCH_LDFLAGS are allowed. Naming/VariableName: EnforcedStyle: snake_case # Allow variable names which are in all caps (with optional numbers and underscores) AllowedPatterns: - '^@?[A-Z0-9_]+$' - -# If there is meaningful information to convey about the contents of a heredoc, a comment is the best way to do it. -# Forcing unique names for all heredoc delimiters does not improve documentation in the vast majority of cases. -Naming/HeredocDelimiterNaming: - Enabled: false diff --git a/commands/check.rb b/commands/check.rb index 5897e60b8..156445f09 100644 --- a/commands/check.rb +++ b/commands/check.rb @@ -25,11 +25,11 @@ class Command system "rubocop -c #{File.join(CREW_LOCAL_REPO_ROOT, '.rubocop.yml')} -A #{local_package}", exception: true else puts 'The configuration file for rubocop in .rubocop.yml, from the rubocop-chromebrew gem, was not found.'.lightred - puts 'To install rubocop-chromebrew, run the following command: '.lightred + "crew #{PackageUtils.installed?('ruby_rubocop_chromebrew') ? 're' : ''}install ruby_rubocop_chromebrew".lightblue + puts 'To install rubocop-chromebrew, run the following command: '.lightred + "crew #{'re' if PackageUtils.installed?('ruby_rubocop_chromebrew')}install ruby_rubocop_chromebrew".lightblue end else puts "Rubocop is not installed, and thus will not be used to sanitize #{local_package}".lightred - puts 'To install Rubocop, run the following command: '.lightred + "crew #{PackageUtils.installed?('ruby_rubocop') ? 're' : ''}install ruby_rubocop".lightblue + puts 'To install Rubocop, run the following command: '.lightred + "crew #{'re' if PackageUtils.installed?('ruby_rubocop')}install ruby_rubocop".lightblue end to_copy = force diff --git a/lib/buildsystems/pip.rb b/lib/buildsystems/pip.rb index d58aa83cb..cdddb777e 100644 --- a/lib/buildsystems/pip.rb +++ b/lib/buildsystems/pip.rb @@ -73,7 +73,7 @@ class Pip < Package @py_pkg_deps.each do |pip_dep| @cleaned_py_dep = pip_dep[/[^;]+/] puts "——Installing: #{@cleaned_py_dep}".gray - system "PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 python3 -s -m pip install #{@pip_resume_retries} #{prerelease? ? '--pre' : ''} --ignore-installed -U \"#{@cleaned_py_dep}\" | grep -v 'Requirement already satisfied'", exception: false + system "PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 python3 -s -m pip install #{@pip_resume_retries} #{'--pre' if prerelease?} --ignore-installed -U \"#{@cleaned_py_dep}\" | grep -v 'Requirement already satisfied'", exception: false end end puts "Installing #{@py_pkg} python module. This may take a while...".lightblue @@ -81,7 +81,7 @@ class Pip < Package # Build wheel if pip install fails, since that implies a wheel isn't available. puts "Trying to install #{@py_pkg}==#{@py_pkg_chromebrew_version}" if CREW_DEBUG - Kernel.system "PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 MAKEFLAGS=-j#{CREW_NPROC} #{@pip_pre_configure_options} python3 -s -m pip install #{@pip_resume_retries} --no-warn-conflicts --force-reinstall #{prerelease? ? '--pre' : ''} --no-deps --ignore-installed -U --only-binary :all: #{@py_pkg}==#{@py_pkg_chromebrew_version}" + Kernel.system "PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 MAKEFLAGS=-j#{CREW_NPROC} #{@pip_pre_configure_options} python3 -s -m pip install #{@pip_resume_retries} --no-warn-conflicts --force-reinstall #{'--pre' if prerelease?} --no-deps --ignore-installed -U --only-binary :all: #{@py_pkg}==#{@py_pkg_chromebrew_version}" get_pip_info(@py_pkg) pip_hard_reinstall unless @py_pkg_chromebrew_version == @pip_pkg_version if CREW_DEBUG @@ -92,16 +92,16 @@ class Pip < Package puts "A wheel for #{@py_pkg}==#{@py_pkg_chromebrew_version} was found!".lightblue else puts "A wheel for #{@py_pkg}==#{@py_pkg_chromebrew_version} was unavailable, so we will build a wheel.".orange - system "PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 python3 -m pip install #{@pip_resume_retries} #{prerelease? ? '--pre' : ''} --force-reinstall --upgrade '#{@py_pkg}==#{@py_pkg_chromebrew_version}'" unless prerelease? + system "PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 python3 -m pip install #{@pip_resume_retries} #{'--pre' if prerelease?} --force-reinstall --upgrade '#{@py_pkg}==#{@py_pkg_chromebrew_version}'" unless prerelease? # Assume all pip non-SKIP sources are git. @pip_wheel = if @source_url == 'SKIP' - `PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 MAKEFLAGS=-j#{CREW_NPROC} #{@pip_pre_configure_options} python3 -m pip wheel #{prerelease? ? '--pre' : ''} -w #{@pip_cache_dir} #{@py_pkg}==#{@py_pkg_version}`[/(?<=filename=)(.*)*?(\S+)/, 0] + `PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 MAKEFLAGS=-j#{CREW_NPROC} #{@pip_pre_configure_options} python3 -m pip wheel #{'--pre' if prerelease?} -w #{@pip_cache_dir} #{@py_pkg}==#{@py_pkg_version}`[/(?<=filename=)(.*)*?(\S+)/, 0] else - `PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 MAKEFLAGS=-j#{CREW_NPROC} #{@pip_pre_configure_options} python3 -m pip wheel #{prerelease? ? '--pre' : ''} -w #{@pip_cache_dir} git+#{source_url}`[/(?<=filename=)(.*)*?(\S+)/, 0] + `PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 MAKEFLAGS=-j#{CREW_NPROC} #{@pip_pre_configure_options} python3 -m pip wheel #{'--pre' if prerelease?} -w #{@pip_cache_dir} git+#{source_url}`[/(?<=filename=)(.*)*?(\S+)/, 0] end puts "@pip_wheel is #{@pip_wheel}" if CREW_DEBUG FileUtils.install File.join(@pip_cache_dir, @pip_wheel), @pip_cache_dest_dir - Kernel.system "python3 -m pip install #{prerelease? ? '--pre' : ''} --force-reinstall --upgrade #{File.join(@pip_cache_dir, @pip_wheel)}" + Kernel.system "python3 -m pip install #{'--pre' if prerelease?} --force-reinstall --upgrade #{File.join(@pip_cache_dir, @pip_wheel)}" # Check the just-installed package... if get_pip_info(@py_pkg) puts "Note that #{@py_pkg}==#{@pip_pkg_version} is installed, which is different from the #{@py_pkg_chromebrew_version}. Please update the package file.".lightpurple if @py_pkg_chromebrew_version != @pip_pkg_version diff --git a/lib/buildsystems/qmake.rb b/lib/buildsystems/qmake.rb index 459e40e08..d421e94b8 100644 --- a/lib/buildsystems/qmake.rb +++ b/lib/buildsystems/qmake.rb @@ -9,7 +9,7 @@ class Qmake < Package extend ReportBuildsystemMethods print_buildsystem_methods - system "QMAKE_CXX='g++ #{ARCH == 'x86_64' && Gem::Version.new(LIBC_VERSION.to_s) >= Gem::Version.new('2.35') ? File.join(CREW_LIB_PREFIX, 'libC.so.6').to_s : ''}' qmake" + system "QMAKE_CXX='g++ #{File.join(CREW_LIB_PREFIX, 'libC.so.6').to_s if ARCH == 'x86_64' && Gem::Version.new(LIBC_VERSION.to_s) >= Gem::Version.new('2.35')}' qmake" system 'make' @qmake_build_extras&.call end diff --git a/lib/downloader.rb b/lib/downloader.rb index c3d890e50..9fac75986 100644 --- a/lib/downloader.rb +++ b/lib/downloader.rb @@ -74,10 +74,10 @@ def downloader(url, sha256sum, filename = File.basename(url), verbose: false) FileUtils.rm_f filename warn 'Checksum mismatch :/ Try again?'.lightred, <<~EOT - #{''} - Filename: #{filename.lightblue} - Expected checksum (SHA256): #{sha256sum.green} - Calculated checksum (SHA256): #{calc_sha256sum.red} + + Filename: #{filename.lightblue} + Expected checksum (SHA256): #{sha256sum.green} + Calculated checksum (SHA256): #{calc_sha256sum.red} EOT exit 2 diff --git a/lib/misc_functions.rb b/lib/misc_functions.rb index 4ff76f08a..632b9c383 100644 --- a/lib/misc_functions.rb +++ b/lib/misc_functions.rb @@ -70,7 +70,7 @@ class MiscFunctions else "#{time_minutes} min, " end - time_seconds_string = "#{time_seconds} second#{time_seconds == 1 ? '' : 's'}" + time_seconds_string = "#{time_seconds} second#{'s' unless time_seconds == 1}" return time_hour_string + time_minutes_string + time_seconds_string end diff --git a/packages/binutils.rb b/packages/binutils.rb index 8efef5f72..4885d47fb 100644 --- a/packages/binutils.rb +++ b/packages/binutils.rb @@ -62,7 +62,7 @@ class Binutils < Package --enable-shared \ --enable-threads \ --enable-vtable-verify \ - #{ARCH == 'i686' || ARCH == 'x86_64' ? '--disable-gprofng' : ''} \ + #{'--disable-gprofng' if ARCH == 'i686' || ARCH == 'x86_64'} \ --with-bugurl=https://github.com/chromebrew/chromebrew/issues/new \ --with-lib-path=#{CREW_LIB_PREFIX} \ --with-pic \ diff --git a/packages/elfutils.rb b/packages/elfutils.rb index c94185e7c..7923a9dfb 100644 --- a/packages/elfutils.rb +++ b/packages/elfutils.rb @@ -30,7 +30,7 @@ class Elfutils < Autotools # -D_FORTIFY_SOURCE=0 needed due to -O3 optimization. autotools_pre_configure_options "CFLAGS+=' -Wno-error -D_FORTIFY_SOURCE=0' CXXFLAGS+=' -Wno-error -D_FORTIFY_SOURCE=0'" - autotools_configure_options "#{ARCH == 'i686' ? '--disable-libdebuginfod --disable-debuginfod' : ''} --enable-maintainer-mode --program-prefix='eu-'" + autotools_configure_options "#{'--disable-libdebuginfod --disable-debuginfod' if ARCH == 'i686'} --enable-maintainer-mode --program-prefix='eu-'" def self.patch downloader 'https://raw.githubusercontent.com/openwrt/openwrt/refs/heads/main/package/libs/elfutils/patches/009-fix-null-dereference-with-lto.patch', 'bd81d483ed5474fd7e87a27e4c961bf8670f76c45f5fe9a273cb2f11d8f44ffc' diff --git a/packages/gdb.rb b/packages/gdb.rb index 807a92e86..4d3fc8e1d 100644 --- a/packages/gdb.rb +++ b/packages/gdb.rb @@ -58,7 +58,7 @@ class Gdb < Autotools --with-system-gdbinit=#{CREW_PREFIX}/etc/gdb/gdbinit \ --with-system-readline \ --with-system-zlib \ - #{ARCH == 'i686' ? '' : '--with-x'}" + #{'--with-x' unless ARCH == 'i686'}" def self.install system "make -C gdb DESTDIR=#{CREW_DEST_DIR} install" diff --git a/packages/graphicsmagick.rb b/packages/graphicsmagick.rb index ecfe7abf2..31094aa66 100644 --- a/packages/graphicsmagick.rb +++ b/packages/graphicsmagick.rb @@ -130,7 +130,7 @@ class Graphicsmagick < Package --enable-static=no \ --with-modules \ --with-perl \ - #{%w[x86_64 aarch64 armv7l].include?(ARCH) ? '--with-x' : ''} \ + #{'--with-x' if %w[x86_64 aarch64 armv7l].include?(ARCH)} \ --with-xml" system 'make' end diff --git a/packages/libdovi.rb b/packages/libdovi.rb index 0c8c982df..400c3ba87 100644 --- a/packages/libdovi.rb +++ b/packages/libdovi.rb @@ -27,7 +27,7 @@ class Libdovi < Package def self.build Dir.chdir('dolby_vision') do - system "#{ARCH == 'x86_64' ? 'RUSTFLAGS="-C target-cpu=x86-64-v3"' : ''} cargo build --release" + system "#{'RUSTFLAGS="-C target-cpu=x86-64-v3"' if ARCH == 'x86_64'} cargo build --release" end end diff --git a/packages/ruby.rb b/packages/ruby.rb index 85baa94a2..21b3bcd69 100644 --- a/packages/ruby.rb +++ b/packages/ruby.rb @@ -47,7 +47,7 @@ class Ruby < Package LD=mold \ ./configure #{CREW_CONFIGURE_OPTIONS} \ --enable-shared \ - #{ARCH == 'x86_64' ? '--enable-yjit' : ''} \ + #{'--enable-yjit' if ARCH == 'x86_64'} \ --disable-fortify-source" system "MAKEFLAGS='--jobs #{CREW_NPROC}' make" end