diff --git a/Library/Homebrew/cask/macos.rb b/Library/Homebrew/cask/macos.rb index be2693b239..1587de3456 100644 --- a/Library/Homebrew/cask/macos.rb +++ b/Library/Homebrew/cask/macos.rb @@ -378,8 +378,7 @@ module OS "~/Library/Widgets", "~/Library/Workflows", ] - .map { |path| Pathname(path.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path } - .to_set + .to_set { |path| Pathname(path.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path } .union(SYSTEM_DIRS) .freeze private_constant :UNDELETABLE_PATHS diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index e134256d74..16201b3cb0 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -307,11 +307,7 @@ module Homebrew def cleanup_logs return unless HOMEBREW_LOGS.directory? - logs_days = if days > CLEANUP_DEFAULT_DAYS - CLEANUP_DEFAULT_DAYS - else - days - end + logs_days = [days, CLEANUP_DEFAULT_DAYS].min HOMEBREW_LOGS.subdirs.each do |dir| cleanup_path(dir) { dir.rmtree } if dir.prune?(logs_days) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index acce289519..b217588e57 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -105,7 +105,7 @@ class AbstractDownloadStrategy def chdir(&block) entries = Dir["*"] - raise "Empty archive" if entries.length.zero? + raise "Empty archive" if entries.empty? if entries.length != 1 yield diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index e1829e32a6..62b2692c43 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -188,7 +188,7 @@ module Stdenv # @private sig { params(map: T::Hash[Symbol, String]).void } - def set_cpu_cflags(map = Hardware::CPU.optimization_flags) # rubocop:disable Naming/AccessorMethodName + def set_cpu_cflags(map = Hardware::CPU.optimization_flags) set_cpu_flags(CC_FLAG_VARS, map) end diff --git a/Library/Homebrew/ignorable.rb b/Library/Homebrew/ignorable.rb index 4ede76f392..5aeeb4dc02 100644 --- a/Library/Homebrew/ignorable.rb +++ b/Library/Homebrew/ignorable.rb @@ -48,10 +48,8 @@ module Ignorable def self.unhook_raise Object.class_eval do # False positive - https://github.com/rubocop/rubocop/issues/5022 - # rubocop:disable Lint/DuplicateMethods alias_method :raise, :original_raise alias_method :fail, :original_raise - # rubocop:enable Lint/DuplicateMethods undef :original_raise end end diff --git a/Library/Homebrew/test/pathname_spec.rb b/Library/Homebrew/test/pathname_spec.rb index 4e5e8d4faa..0611260c7f 100644 --- a/Library/Homebrew/test/pathname_spec.rb +++ b/Library/Homebrew/test/pathname_spec.rb @@ -95,7 +95,7 @@ describe Pathname do it "preserves permissions" do File.open(file, "w", 0100777) {} file.atomic_write("CONTENT") - expect(file.stat.mode.to_s(8)).to eq((0100777 & ~File.umask).to_s(8)) + expect(file.stat.mode.to_s(8)).to eq((~File.umask & 0100777).to_s(8)) end it "preserves default permissions" do diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index f758c1a78c..b71b58a1e9 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -46,10 +46,8 @@ module UnpackStrategy def bom tries = 0 result = loop do - # rubocop:disable Style/AsciiComments # We need to use `find` here instead of Ruby in order to properly handle # file names containing special characters, such as “e” + “´” vs. “é”. - # rubocop:enable Style/AsciiComments r = system_command("find", args: [".", "-print0"], chdir: self, print_stderr: false) tries += 1 diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 93e23254b6..56ea25f353 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -354,7 +354,7 @@ module Utils return "The #{url_type} #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end - lenratio = (100 * https_content.length / http_content.length).to_i + lenratio = (https_content.length * 100 / http_content.length).to_i return unless (90..110).cover?(lenratio) "The #{url_type} #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser."