Merge pull request #16497 from issyl0/rubocop-new-rules-style-array-intersect

Fix RuboCop `Style/ArrayIntersect` offenses
This commit is contained in:
Issy Long 2024-01-19 13:00:30 +00:00 committed by GitHub
commit bc5e422815
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 6 additions and 8 deletions

View File

@ -459,8 +459,6 @@ Performance/MapCompact:
Enabled: false Enabled: false
Style/ArgumentsForwarding: Style/ArgumentsForwarding:
Enabled: false Enabled: false
Style/ArrayIntersect:
Enabled: false
Style/HashSyntax: Style/HashSyntax:
EnforcedShorthandSyntax: either EnforcedShorthandSyntax: either
Style/RedundantFreeze: Style/RedundantFreeze:

View File

@ -374,7 +374,7 @@ module Cask
define_method(klass.dsl_key) do |*args, **kwargs| define_method(klass.dsl_key) do |*args, **kwargs|
T.bind(self, DSL) T.bind(self, DSL)
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) && 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.") raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.")
end end

View File

@ -232,7 +232,7 @@ module Homebrew
return false if no_cleanup_formula.blank? return false if no_cleanup_formula.blank?
@skip_clean_formulae ||= no_cleanup_formula.split(",") @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 end
def self.periodic_clean_due? def self.periodic_clean_due?

View File

@ -703,7 +703,7 @@ module Homebrew
return unless coreutils.any_version_installed? return unless coreutils.any_version_installed?
gnubin = %W[#{coreutils.opt_libexec}/gnubin #{coreutils.libexec}/gnubin] gnubin = %W[#{coreutils.opt_libexec}/gnubin #{coreutils.libexec}/gnubin]
return if (paths & gnubin).empty? return unless paths.intersect?(gnubin)
<<~EOS <<~EOS
Putting non-prefixed coreutils in your path can cause GMP builds to fail. Putting non-prefixed coreutils in your path can cause GMP builds to fail.

View File

@ -96,7 +96,7 @@ module Homebrew
gnubin = %W[#{findutils.opt_libexec}/gnubin #{findutils.libexec}/gnubin] gnubin = %W[#{findutils.opt_libexec}/gnubin #{findutils.libexec}/gnubin]
default_names = Tab.for_name("findutils").with? "default-names" default_names = Tab.for_name("findutils").with? "default-names"
return if !default_names && (paths & gnubin).empty? return if !default_names && !paths.intersect?(gnubin)
<<~EOS <<~EOS
Putting non-prefixed findutils in your path can cause python builds to fail. Putting non-prefixed findutils in your path can cause python builds to fail.

View File

@ -33,7 +33,7 @@ module RuboCop
# NOTE: Solving the first problem here might solve the second one too # NOTE: Solving the first problem here might solve the second one too
# so we don't show both of them at the same time. # 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) offending_node(service_node)
problem "Service blocks require `run` or `name` to be defined." problem "Service blocks require `run` or `name` to be defined."
elsif !method_calls.key?(:run) elsif !method_calls.key?(:run)

View File

@ -217,7 +217,7 @@ RSpec.configure do |config|
@__stdin = $stdin.clone @__stdin = $stdin.clone
begin 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) $stdout.reopen(File::NULL)
$stderr.reopen(File::NULL) $stderr.reopen(File::NULL)
else else