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

Return hashes from yarn dependency_url guard clauses #425

Merged
merged 1 commit into from
Dec 3, 2021
Merged
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
8 changes: 4 additions & 4 deletions lib/licensed/sources/yarn/v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ def dependency_urls
.map(&:strip)
.map(&JSON.method(:parse))
.find { |json| json["type"] == "table" }
return [] if table.nil?
return {} if table.nil?

head = table.dig("data", "head")
return [] if head.nil?
return {} if head.nil?

name_index = head.index YARN_NAME_HEAD
version_index = head.index YARN_VERSION_HEAD
url_index = head.index YARN_URL_HEAD
return [] if name_index.nil? || version_index.nil? || url_index.nil?
return {} if name_index.nil? || version_index.nil? || url_index.nil?

body = table.dig("data", "body")
return [] if body.nil?
return {} if body.nil?

body.each_with_object({}) do |row, hsh|
id = "#{row[name_index]}@#{row[version_index]}"
Expand Down