Skip to content

Conversation

@svogt0511
Copy link
Contributor

@svogt0511 svogt0511 commented Jul 25, 2025

Note: hsh_to_spdx was was already implementing that behavior that around line 1309 of lib/bolognese/utils.rb.

Purpose

related to : https://github.com/orgs/datacite/projects/28/views/21?pane=issue&itemId=111924271&issue=datacite%7Cproduct-backlog%7C335

Approach

It fixes a failing test in lupo.

Open Questions and Pre-Merge TODOs

Learning

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

Reviewer, please remember our guidelines:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

@svogt0511 svogt0511 self-assigned this Jul 25, 2025
@svogt0511 svogt0511 requested a review from Copilot July 25, 2025 22:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes inconsistent handling of the "rightsUri" field in the hsh_to_spdx method by accepting both "rightsUri" and "rightsURI" variations. The change addresses a failing test in Lupo by ensuring the method can handle both camelCase and PascalCase variations of the rights URI field name.

Key Changes

  • Modified the license lookup logic to check for both "rightsUri" and "rightsURI" field names

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.
@jrhoads
Copy link
Contributor

jrhoads commented Oct 16, 2025

@svogt0511 and @codycooperross This looks pretty much complete. Should we update it and get it out soon?

@codycooperross
Copy link
Contributor

Not sure I remember what this is addressing, but feel free, @svogt0511

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants