Skip to content

Commit

Permalink
Merge pull request #7399 from MikeMcQuaid/uses_from_macos_updates
Browse files Browse the repository at this point in the history
rubocops/uses_from_macos: update list.
  • Loading branch information
MikeMcQuaid committed Apr 20, 2020
2 parents 9eed1e4 + cddc67b commit f074e3a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
48 changes: 39 additions & 9 deletions Library/Homebrew/rubocops/uses_from_macos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,72 @@ module Cop
module FormulaAudit
# This cop audits `uses_from_macos` dependencies in formulae
class UsesFromMacos < FormulaCop
ALLOWED_USES_FROM_MACOS_DEPS = %w[
# Generate with:
# brew ruby -e 'puts Formula.select {|f| f.keg_only_reason&.provided_by_macos? }.map(&:name).sort.join("\n")'
# Not done at runtime as its too slow and RuboCop doesn't have access.
PROVIDED_BY_MACOS_FORMULAE = %w[
apr
bc
bison
bzip2
cups
curl
dyld-headers
expat
expect
file-formula
flex
groff
gcore
gnu-getopt
icu4c
krb5
libarchive
libedit
libffi
libiconv
libpcap
libressl
libxml2
libxslt
llvm
lsof
m4
ncompress
ncurses
net-snmp
openldap
openssl@1.1
perl
php
openlibm
pod2man
rpcgen
ruby
sqlite
ssh-copy-id
swift
tcl-tk
texinfo
unifdef
unzip
vim
xz
zip
zlib
zsh
].freeze

# These formulae aren't keg_only :provided_by_macos but are provided by
# macOS (or very similarly e.g. OpenSSL where system provides LibreSSL)
# TODO: consider making some of these keg-only.
ALLOWED_USES_FROM_MACOS_DEPS = (PROVIDED_BY_MACOS_FORMULAE + %w[
bash
expect
groff
openssl
openssl@1.1
perl
php
python
python@3
vim
xz
zsh
]).freeze

def audit_formula(_node, _class_node, _parent_class_node, body_node)
find_method_with_args(body_node, :uses_from_macos, /^"(.+)"/).each do |method|
dep = if parameters(method).first.class == RuboCop::AST::StrNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
shared_examples "formulae exist" do |array|
array.each do |f|
it "#{f} formula exists" do
formula_path = Pathname("#{HOMEBREW_LIBRARY_PATH}/../Taps/homebrew/homebrew-core/Formula/#{f}.rb")
expect(formula_path.exist?).to be true
core_tap = Pathname("#{HOMEBREW_LIBRARY_PATH}/../Taps/homebrew/homebrew-core")
formula_path = core_tap/"Formula/#{f}.rb"
alias_path = core_tap/"Aliases/#{f}"
expect(formula_path.exist? || alias_path.exist?).to be true
end
end
end

0 comments on commit f074e3a

Please sign in to comment.