Skip to content
Open
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion lib/bolognese/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ def name_to_spdx(name)

def hsh_to_spdx(hsh)
spdx = resource_json(:spdx).fetch("licenses")
license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) }
license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsUri"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) }
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expression l["seeAlso"].first is called three times in this condition chain. Consider extracting it to a variable to avoid repeated array access and potential nil errors if seeAlso is empty.

Suggested change
license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsUri"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) }
license = spdx.find do |l|
see_also_first = l["seeAlso"].first
l["licenseId"].casecmp?(hsh["rightsIdentifier"]) ||
see_also_first == normalize_cc_url(hsh["rightsUri"]) ||
see_also_first == normalize_cc_url(hsh["rightsURI"]) ||
l["name"] == hsh["rights"] ||
see_also_first == normalize_cc_url(hsh["rights"])
end

Copilot uses AI. Check for mistakes.

if license
{
Expand Down