rubocops/resource_requires_dependencies: check sym_type?

Avoid running `#value` on unsupported types by selecting only symbol
nodes as we only care about `:build` value.

Signed-off-by: Michael Cho <michael@michaelcho.dev>
This commit is contained in:
Michael Cho 2024-04-05 10:03:35 -04:00
parent ad196e057b
commit 747e95b159
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85

View File

@ -27,8 +27,8 @@ module RuboCop
uses_from_macos_or_depends_on = (uses_from_macos_nodes + depends_on_nodes).filter_map do |node|
if (dep = node.arguments.first).hash_type?
dep_types = dep.values.first
dep_types = dep_types.array_type? ? dep_types.values.map(&:value) : [dep_types.value]
dep.keys.first.str_content if dep_types.include?(:build)
dep_types = dep_types.array_type? ? dep_types.values : [dep_types]
dep.keys.first.str_content if dep_types.select(&:sym_type?).map(&:value).include?(:build)
else
dep.str_content
end