From 0e27dc25640e945ba997de4d316223e8b180f206 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 18 Jan 2024 14:11:43 +0000 Subject: [PATCH] Fix RuboCop `Style/ArrayIntersect` offenses --- Library/.rubocop.yml | 2 -- Library/Homebrew/cask/dsl.rb | 2 +- Library/Homebrew/cleanup.rb | 2 +- Library/Homebrew/diagnostic.rb | 2 +- Library/Homebrew/extend/os/mac/diagnostic.rb | 2 +- Library/Homebrew/rubocops/service.rb | 2 +- Library/Homebrew/test/spec_helper.rb | 2 +- 7 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 617d074a00bdd..853abc9ca2b79 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -457,8 +457,6 @@ Performance/MapCompact: Enabled: false Style/ArgumentsForwarding: Enabled: false -Style/ArrayIntersect: - Enabled: false Style/HashSyntax: EnforcedShorthandSyntax: either Style/RedundantFreeze: diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index bf875e07aaf29..d139d90b5b62c 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -374,7 +374,7 @@ def disable!(date:, because:) define_method(klass.dsl_key) do |*args, **kwargs| T.bind(self, DSL) if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) && - (artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any? + artifacts.map(&:class).intersect?(ACTIVATABLE_ARTIFACT_CLASSES) raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.") end diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index b92b6f02f5897..19348c6a4cd60 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -232,7 +232,7 @@ def self.skip_clean_formula?(formula) return false if no_cleanup_formula.blank? @skip_clean_formulae ||= no_cleanup_formula.split(",") - @skip_clean_formulae.include?(formula.name) || (@skip_clean_formulae & formula.aliases).present? + @skip_clean_formulae.include?(formula.name) || @skip_clean_formulae.intersect?(formula.aliases) end def self.periodic_clean_due? diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index f0bec7ee802d4..99630fe1f7412 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -703,7 +703,7 @@ def check_for_non_prefixed_coreutils return unless coreutils.any_version_installed? gnubin = %W[#{coreutils.opt_libexec}/gnubin #{coreutils.libexec}/gnubin] - return if (paths & gnubin).empty? + return unless paths.intersect?(gnubin) <<~EOS Putting non-prefixed coreutils in your path can cause GMP builds to fail. diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index f3d43a7db0015..0e74b6da65c4b 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -96,7 +96,7 @@ def check_for_non_prefixed_findutils gnubin = %W[#{findutils.opt_libexec}/gnubin #{findutils.libexec}/gnubin] default_names = Tab.for_name("findutils").with? "default-names" - return if !default_names && (paths & gnubin).empty? + return if !default_names && !paths.intersect?(gnubin) <<~EOS Putting non-prefixed findutils in your path can cause python builds to fail. diff --git a/Library/Homebrew/rubocops/service.rb b/Library/Homebrew/rubocops/service.rb index 29065b26aa26a..4560cbb4a693a 100644 --- a/Library/Homebrew/rubocops/service.rb +++ b/Library/Homebrew/rubocops/service.rb @@ -33,7 +33,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) # NOTE: Solving the first problem here might solve the second one too # so we don't show both of them at the same time. - if (method_calls.keys & REQUIRED_METHOD_CALLS).empty? + if !method_calls.keys.intersect?(REQUIRED_METHOD_CALLS) offending_node(service_node) problem "Service blocks require `run` or `name` to be defined." elsif !method_calls.key?(:run) diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 3b1765157098e..6af17fcd03854 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -217,7 +217,7 @@ def find_files @__stdin = $stdin.clone begin - if (example.metadata.keys & [:focus, :byebug]).empty? && !ENV.key?("HOMEBREW_VERBOSE_TESTS") + if !example.metadata.keys.intersect?([:focus, :byebug]) && !ENV.key?("HOMEBREW_VERBOSE_TESTS") $stdout.reopen(File::NULL) $stderr.reopen(File::NULL) else