rubocops/cask: Skip string interpolations when determining inner stanzas

- Otherwise syntax like this, where `#{arch}` is an interpolation,
  causes an offense:

```ruby
cask "transcribe" do
  arch arm: "_arm"

  on_catalina :or_older do
    version "8.75.2"
    sha256 "f01781100cd3b9987c8f8892145a2eaa358df07b92e10e26f30b6a877f5b352c"

    url "https://www.seventhstring.com/xscribe/downmo/transcribe#{version.no_dots}.dmg"

    livecheck_version = "10"
  end
  on_big_sur :or_newer do
    livecheck_version = "11"

    version "9.21"
    sha256 :no_check

    url "https://www.seventhstring.com/xscribe/transcribe#{arch}.dmg"
  end
  [...]
end
```

```
Casks/transcribe.rb:2:3: C: Cask/NoOverrides: Do not use a top-level arch stanza as the default. Add it to an on_{system} block instead.
Use :or_older or :or_newer to specify a range of macOS versions.

  arch arm: "_arm"
  ^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected
```
This commit is contained in:
Issy Long 2023-03-21 00:03:50 +00:00
parent e04101007f
commit c337dc4c81
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -40,6 +40,8 @@ module RuboCop
node.child_nodes.each do |child| node.child_nodes.each do |child|
child.each_node(:send) do |send_node| child.each_node(:send) do |send_node|
# Skip string interpolations (`:begin` inside `:dstr`).
next if send_node.begin_type? && send_node.parent_node.dstr_type?
next if ON_SYSTEM_METHODS.include?(send_node.method_name) next if ON_SYSTEM_METHODS.include?(send_node.method_name)
names.add(send_node.method_name) names.add(send_node.method_name)