Cleanup after adding os specific rubocop

- Change name of rubocop warning
- Disable linting on remaining offending lines
- Add todos to move lines with disabled linting
  checks to extend/os in the future
This commit is contained in:
apainintheneck 2022-11-21 22:14:04 -08:00
parent d48859a9ce
commit c477b9aab3
10 changed files with 24 additions and 11 deletions

View File

@ -57,7 +57,7 @@ FormulaAuditStrict:
Homebrew/MoveToExtendOS:
Exclude:
- "Homebrew/{extend,test}/**/*"
- "Homebrew/{extend,test,requirements}/**/*"
- "Taps/**/*"
- "Homebrew/os.rb"

View File

@ -68,7 +68,8 @@ module Cask
zap: nil,
dry_run: nil
)
odie "Installing casks is supported only on macOS" unless OS.mac?
# TODO: Refactor and move to extend/os
odie "Installing casks is supported only on macOS" unless OS.mac? # rubocop:disable Homebrew/MoveToExtendOS
options = {
verbose: verbose,

View File

@ -293,7 +293,8 @@ module Homebrew
end
def migrate_gcc_dependents_if_needed
return if OS.mac?
# TODO: Refactor and move to extend/os
return if OS.mac? # rubocop:disable Homebrew/MoveToExtendOS
return if Settings.read("gcc-rpaths.fixed") == "true"
Formula.installed.each do |formula|

View File

@ -4,7 +4,8 @@
require "simulate_system"
module Homebrew
DEFAULT_PREFIX, DEFAULT_REPOSITORY = if OS.mac? && Hardware::CPU.arm?
# TODO: Refactor and move to extend/os
DEFAULT_PREFIX, DEFAULT_REPOSITORY = if OS.mac? && Hardware::CPU.arm? # rubocop:disable Homebrew/MoveToExtendOS
[HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY]
elsif Homebrew::SimulateSystem.simulating_or_running_on_linux?
[HOMEBREW_LINUX_DEFAULT_PREFIX, HOMEBREW_LINUX_DEFAULT_REPOSITORY]

View File

@ -247,7 +247,8 @@ module Homebrew
"--pax-option", "globexthdr.name=/GlobalHead.%n,exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime"
].freeze
return ["tar", gnutar_args].freeze if OS.linux?
# TODO: Refactor and move to extend/os
return ["tar", gnutar_args].freeze if OS.linux? # rubocop:disable Homebrew/MoveToExtendOS
# Use gnu-tar on macOS as it can be set up for reproducibility better than libarchive.
begin
@ -275,6 +276,8 @@ module Homebrew
ignores << %r{#{cellar_regex}/#{go_regex}/[\d.]+/libexec}
end
# TODO: Refactor and move to extend/os
# rubocop:disable Homebrew/MoveToExtendOS
ignores << case f.name
# On Linux, GCC installation can be moved so long as the whole directory tree is moved together:
# https://gcc-help.gcc.gnu.narkive.com/GnwuCA7l/moving-gcc-from-the-installation-path-is-it-allowed.
@ -284,6 +287,7 @@ module Homebrew
when Version.formula_optionally_versioned_regex(:binutils)
%r{#{cellar_regex}/binutils} if OS.linux?
end
# rubocop:enable Homebrew/MoveToExtendOS
ignores.compact
end
@ -409,7 +413,8 @@ module Homebrew
# Set the times for reproducible bottles.
if file.symlink?
# Need to make symlink permissions consistent on macOS and Linux
File.lchmod 0777, file if OS.mac?
# TODO: Refactor and move to extend/os
File.lchmod 0777, file if OS.mac? # rubocop:disable Homebrew/MoveToExtendOS
File.lutime(tab.source_modified_time, tab.source_modified_time, file)
else
file.utime(tab.source_modified_time, tab.source_modified_time)

View File

@ -157,6 +157,8 @@ module Homebrew
--require spec_helper
]
# TODO: Refactor and move to extend/os
# rubocop:disable Homebrew/MoveToExtendOS
unless OS.mac?
bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask"
files = files.grep_v(%r{^test/(os/mac|cask)(/.*|_spec\.rb)$})
@ -166,6 +168,7 @@ module Homebrew
bundle_args << "--tag" << "~needs_linux"
files = files.grep_v(%r{^test/os/linux(/.*|_spec\.rb)$})
end
# rubocop:enable Homebrew/MoveToExtendOS
puts "Randomized with seed #{seed}"

View File

@ -65,7 +65,8 @@ module Homebrew
tags = if (HOMEBREW_REPOSITORY/".git/shallow").exist?
safe_system "git", "fetch", "--tags", "--depth=1"
Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
elsif OS.linux?
# TODO: Refactor and move to extend/os
elsif OS.linux? # rubocop:disable Homebrew/MoveToExtendOS
Utils.popen_read("git tag --list | sort -rV")
end
end

View File

@ -319,7 +319,8 @@ module FormulaCellarChecks
def check_binary_arches(formula)
return unless formula.prefix.directory?
# There is no `binary_executable_or_library_files` method for the generic OS
return if !OS.mac? && !OS.linux?
# TODO: Refactor and move to extend/os
return if !OS.mac? && !OS.linux? # rubocop:disable Homebrew/MoveToExtendOS
keg = Keg.new(formula.prefix)
mismatches = {}

View File

@ -8,7 +8,7 @@ module RuboCop
#
# @api private
class MoveToExtendOS < Base
MSG = "Move calls to `OS.linux?` and `OS.mac?` to `extend/os`."
MSG = "Move `OS.linux?` and `OS.mac?` calls to `extend/os`."
def_node_matcher :os_check?, <<~PATTERN
(send (const nil? :OS) {:mac? | :linux?})

View File

@ -9,14 +9,14 @@ describe RuboCop::Cop::Homebrew::MoveToExtendOS do
it "registers an offense when using `OS.linux?`" do
expect_offense(<<~RUBY)
OS.linux?
^^^^^^^^^ Move calls to `OS.linux?` and `OS.mac?` to `extend/os`.
^^^^^^^^^ Move `OS.linux?` and `OS.mac?` calls to `extend/os`.
RUBY
end
it "registers an offense when using `OS.mac?`" do
expect_offense(<<~RUBY)
OS.mac?
^^^^^^^ Move calls to `OS.linux?` and `OS.mac?` to `extend/os`.
^^^^^^^ Move `OS.linux?` and `OS.mac?` calls to `extend/os`.
RUBY
end
end