Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RuboCop Style/ArrayIntersect offenses #16497

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,6 @@ Performance/MapCompact:
Enabled: false
Style/ArgumentsForwarding:
Enabled: false
Style/ArrayIntersect:
Enabled: false
Style/HashSyntax:
EnforcedShorthandSyntax: either
Style/RedundantFreeze:
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
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)

Check warning on line 235 in Library/Homebrew/cleanup.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cleanup.rb#L235

Added line #L235 was not covered by tests
end

def self.periodic_clean_due?
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/os/mac/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/rubocops/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down