Skip to content

Commit

Permalink
rubocops/uses_from_macos: audit when depends_on :linux
Browse files Browse the repository at this point in the history
  • Loading branch information
cho-m committed Dec 21, 2023
1 parent 4a8d9ce commit 728f57a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Library/Homebrew/rubocops/uses_from_macos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ class UsesFromMacos < FormulaCop
def audit_formula(_node, _class_node, _parent_class_node, body_node)
return if body_node.nil?

find_method_with_args(body_node, :uses_from_macos, /^"(.+)"/).each do |method|
uses_from_macos_nodes = find_method_with_args(body_node, :uses_from_macos, /^"(.+)"/)
return if uses_from_macos_nodes.blank?

problem "`uses_from_macos` should not be used when Linux is required." if depends_on?(:linux)

uses_from_macos_nodes.each do |method|
dep = if parameters(method).first.instance_of?(RuboCop::AST::StrNode)
parameters(method).first
elsif parameters(method).first.instance_of?(RuboCop::AST::HashNode)
Expand Down

0 comments on commit 728f57a

Please sign in to comment.