Skip to content

Commit

Permalink
allow for a different rightsholder and funder in description
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Jun 20, 2024
1 parent 108765d commit 4fb3665
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions R/check_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,46 @@ Please send a pull request if you need support for this license.",
check_authors <- function(this_desc, org) {
assert_that(inherits(org, "organisation"))
authors <- this_desc$get_authors()
stopifnot(
"TO DO: handle funder not equal to rightsholder" =
(is.na(org$get_rightsholder) && is.na(org$get_funder)) ||
(org$get_rightsholder == org$get_funder)
)
rightsholder <- person(
given = org$get_rightsholder, role = c("cph", "fnd"), email = org$get_email
email <- c(NULL, org$get_email[!is.na(org$get_email)])
if (!is.na(org$get_rightsholder)) {
if (!is.na(org$get_funder)) {
if (org$get_rightsholder == org$get_funder) {
rightsholder <- person(
given = org$get_rightsholder, role = c("cph", "fnd"), email = email
)
funder <- NULL
} else {
rightsholder <- person(
given = org$get_rightsholder, role = "cph", email = email

Check warning on line 304 in R/check_description.R

View check run for this annotation

Codecov / codecov/patch

R/check_description.R#L303-L304

Added lines #L303 - L304 were not covered by tests
)
funder <- person(given = org$get_funder, role = "fnd")

Check warning on line 306 in R/check_description.R

View check run for this annotation

Codecov / codecov/patch

R/check_description.R#L306

Added line #L306 was not covered by tests
}
} else {
rightsholder <- person(
given = org$get_rightsholder, role = "cph", email = email

Check warning on line 310 in R/check_description.R

View check run for this annotation

Codecov / codecov/patch

R/check_description.R#L309-L310

Added lines #L309 - L310 were not covered by tests
)
funder <- NULL

Check warning on line 312 in R/check_description.R

View check run for this annotation

Codecov / codecov/patch

R/check_description.R#L312

Added line #L312 was not covered by tests
}
} else if (!is.na(org$get_funder)) {
rightsholder <- NULL
funder <- person(given = org$get_funder, role = "fnd")

Check warning on line 316 in R/check_description.R

View check run for this annotation

Codecov / codecov/patch

R/check_description.R#L314-L316

Added lines #L314 - L316 were not covered by tests
}

problems <- c(
sprintf(
"`%s` must be listed as copyright holder and use `%s` as email.",
org$get_rightsholder, org$get_email
)[
!is.null(rightsholder) && !is.na(org$get_rightsholder) &&
!rightsholder %in% authors
],
sprintf(
"`%s` must be listed as funder without email.",
org$get_funder
)[!is.null(funder) && !is.na(org$get_funder) && !funder %in% authors]
)
problems <- sprintf(
"`%s` must be listed as copyright holder and funder and use `%s` as email.",
org$get_rightsholder, org$get_email
)[!is.na(org$get_rightsholder) && !rightsholder %in% authors]
authors <- authors[!authors %in% rightsholder]
authors <- authors[!authors %in% funder]
vapply(
authors, FUN.VALUE = vector(mode = "list", length = 1L),
FUN = function(author) {
Expand Down

0 comments on commit 4fb3665

Please sign in to comment.