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

version 0.3.7 #132

Merged
merged 23 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c9ea106
allow code owners
ThierryO Jun 4, 2024
54ddd32
bump package version
ThierryO Jun 4, 2024
0828fcb
fix URL in README
ThierryO Jun 4, 2024
2d703ff
handle citation where the rightsholder are not set
ThierryO Jun 17, 2024
108765d
allow multiple communities in DESCRIPTION
ThierryO Jun 19, 2024
4fb3665
allow for a different rightsholder and funder in description
ThierryO Jun 19, 2024
51cc84f
Update organisation_class.R
wlangera Jun 20, 2024
e95f7b4
upgrade to Roxygen 7.3.2
ThierryO Jul 12, 2024
72aa964
setup_package() uses existing Language when set. Otherwise set it to …
ThierryO Jul 12, 2024
b316675
update documentation
ThierryO Jul 14, 2024
07c6d20
Merge pull request #133 from inbo/wlangera-patch-1
ThierryO Jul 14, 2024
6437ea0
add alt text to logo
ThierryO Jul 13, 2024
865d84b
improve error message in case of a missing checklist.yml
ThierryO Jul 13, 2024
6f5a189
install the matching version of roxygen2 before checking a package in…
ThierryO Jul 14, 2024
5d65cc6
checklist summary() displays only the unstaged changes
ThierryO Jul 14, 2024
12b7058
Make sure the licenses start with a level one heading
ThierryO Jul 16, 2024
d82f04d
improve README
ThierryO Jul 16, 2024
368b6cf
add set_license()
ThierryO Jul 17, 2024
87acb14
check_license() overwrites wrong LICENSE.md
ThierryO Jul 17, 2024
0f94a56
make the directory exists before writing to it #138
ThierryO Jul 18, 2024
7639962
update pkgdown
ThierryO Jul 19, 2024
867835b
update NEWS and bump package version to 0.4.0
ThierryO Jul 19, 2024
f6ec490
avoid duplicated spelling issue markers
ThierryO Jul 19, 2024
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 .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code",
"version": "0.3.6",
"version": "0.4.0",
"license": "GPL-3.0",
"upload_type": "software",
"description": "<p>An opinionated set of rules for R packages and R source code projects.<\/p>",
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ identifiers:
value: 10.5281/zenodo.4028303
- type: url
value: https://inbo.github.io/checklist/
version: 0.3.6
version: 0.4.0
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: checklist
Title: A Thorough and Strict Set of Checks for R Packages and Source Code
Version: 0.3.6
Version: 0.4.0
Authors@R: c(
person("Thierry", "Onkelinx", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")),
Expand Down Expand Up @@ -59,5 +59,5 @@ Config/checklist/keywords: quality control; documentation; publication
Encoding: UTF-8
Language: en-GB
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
SystemRequirements: Pandoc (>= 1.17.2)
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
maintainer="Thierry Onkelinx <[email protected]>"

## for apt to be noninteractive
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true

## Install nano
RUN apt-get update \
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### GNU GENERAL PUBLIC LICENSE
# GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export(organisation)
export(prepare_ghpages)
export(read_checklist)
export(read_organisation)
export(set_license)
export(set_tag)
export(setup_package)
export(setup_project)
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# checklist 0.4.0

* Updated `README.md`.
* Improved support for `organisation`.
* Add `set_license()`.
* `check_filename()` allows a `CODEOWNERS` file.
* The checklist summary displays the unstaged git changes.
* The GitHub Action on packages installs the `roxygen2` version listed in the
`DESCRIPTION` of the package it checks.

# checklist 0.3.6

* Add an `organisation` class to store organisation rules different from those
Expand Down
59 changes: 43 additions & 16 deletions R/check_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@
official <- official[-3]
current <- current[-3]
}
problems <- c(
problems,
"LICENSE.md doesn't match the version in the checklist package"[
(length(current) != length(official)) || any(current != official)
]
if ((length(current) != length(official)) || any(current != official)) {
problems <- c(
problems, "LICENSE.md doesn't match the version in the checklist package"

Check warning on line 278 in R/check_description.R

View check run for this annotation

Codecov / codecov/patch

R/check_description.R#L277-L278

Added lines #L277 - L278 were not covered by tests
)
set_license(x)

Check warning on line 280 in R/check_description.R

View check run for this annotation

Codecov / codecov/patch

R/check_description.R#L280

Added line #L280 was not covered by tests
}
x$add_error(
errors = problems,
item = "license", keep = FALSE
Expand All @@ -291,19 +291,46 @@
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
2 changes: 1 addition & 1 deletion R/check_filename.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ check_filename <- function(x = ".") {
paste(
c(
"\\.[a-zA-Z]+ignore", "\\.Rprofile", "\\.[a-zA-Z]+\\.(json|yml)",
"CITATION", "DESCRIPTION", "NAMESPACE", "CITATION\\.cff",
"CITATION", "CODEOWNERS", "DESCRIPTION", "NAMESPACE", "CITATION\\.cff",
"README\\.R?md", "NEWS\\.md",
"CODE_OF_CONDUCT\\.md", "CONTRIBUTING\\.md", "LICENSE(\\.md)?",
"SUPPORT\\.md", "SECURITY\\.md", "FUNDING\\.yml",
Expand Down
2 changes: 1 addition & 1 deletion R/check_spelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ rstudio_source_markers <- function(issues) { # nocov start
"`%s` not found in the dictionary or wordlist for %s.", issues$message,
issues$language
)
issues <- issues[order(issues$file, issues$line, issues$column), ]
issues <- unique(issues[order(issues$file, issues$line, issues$column), ])
issues$file <- as.character(issues$file)
# request source markers
rstudioapi::callFun(
Expand Down
3 changes: 2 additions & 1 deletion R/citation_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ description_communities <- function(communities, org) {
)
}
list(
meta = list(community = communities), warnings = character(0)
meta = list(community = split_community(communities)),
warnings = character(0)
)
}
15 changes: 11 additions & 4 deletions R/citation_meta_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,20 @@ validate_citation <- function(meta) {
rightsholder_id <- roles$contributor[roles$role == "copyright holder"]
funder_id <- roles$contributor[roles$role == "funder"]
notes <- c(
"no rightsholder listed"[
!is.na(org$get_rightsholder) && length(rightsholder_id) == 0
],
"no funder listed"[!is.na(org$get_funder) && length(funder_id) == 0],
sprintf("rightsholder differs from `%s`", org$get_rightsholder)[
!is.na(org$get_rightsholder) &&
authors$given[authors$id == rightsholder_id] != org$get_rightsholder
!is.na(org$get_rightsholder) && length(rightsholder_id) >= 1 &&
!any(
authors$given[authors$id %in% rightsholder_id] %in%
org$get_rightsholder
)
],
sprintf("funder differs from `%s`", org$get_funder)[
!is.na(org$get_funder) &&
authors$given[authors$id == funder_id] != org$get_funder
!is.na(org$get_funder) && length(funder_id) >= 1 &&
!any(org$get_funder %in% authors$given[authors$id == funder_id])
]
)
errors <- c(
Expand Down
18 changes: 1 addition & 17 deletions R/create_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,7 @@ create_package <- function(
git_add("README.Rmd", repo = repo)

# add LICENSE.md
license_file <- path(path, "LICENSE.md")
switch(
license, "GPL-3" = path("generic_template", "gplv3.md"),
"MIT" = path("generic_template", "mit.md")
) |>
system.file(package = "checklist") |>
file_copy(license_file)
if (license == "MIT") {
paste0("YEAR: ", format(Sys.Date(), "%Y")) |>
c(sprintf("COPYRIGHT HOLDER: %s", org$get_rightsholder)) |>
writeLines(path(path, "LICENSE"))
git_add("LICENSE", repo = repo)
mit <- readLines(license_file)
mit[3] <- gsub("<YEAR>", format(Sys.Date(), "%Y"), mit[3])
mit[3] <- gsub("<COPYRIGHT HOLDER>", org$get_rightsholder, mit[3])
writeLines(mit, license_file)
}
set_license(x)
git_add("LICENSE.md", repo = repo)

# Add code of conduct
Expand Down
4 changes: 3 additions & 1 deletion R/default_organisation.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#' @family both
default_organisation <- function(org = organisation$new()) {
assert_that(inherits(org, "organisation"))
R_user_dir("checklist", which = "config") |>
target <- R_user_dir("checklist", which = "config")
dir_create(target)
target |>
path("organisation.yml") |>
write_yaml(x = org$template)
return(invisible(NULL))
Expand Down
5 changes: 3 additions & 2 deletions R/organisation_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ organisation <- R6Class(
#' - `rightsholder`: the rightsholder.
#' Defaults to `"Research Institute for Nature and Forest (INBO)"`.
#' Set to `NA_character_` in case you don't want to set a rightsholder.
#' - `organisation`: a named list with one or more organisation defaults.
#' - `organisation`: a named list with one or more organisation default
#' rules.
#' The names of the element must match the e-mail domain name of the
#' organisation.
#' Every element should be a named list containing ´affiliation` and
#' Every element should be a named list containing `affiliation` and
#' `orcid`.
#' `affiliation` is a character vector with the approved organisation
#' names in one or more languages.
Expand Down
7 changes: 6 additions & 1 deletion R/read_checklist.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ read_checklist <- function(x = ".") {
}
assert_that(
is_file(checklist_file),
msg = sprintf("no checklist.yml found `%s` or its parents", x)
msg = paste(
"No checklist.yml found at `%1$s` or its parents.",
"\nRun `checklist::setup_package(\"%1$s\")` or",
"`checklist::setup_project(\"%1$s\")`."
) |>
sprintf(path_real(x))
)

# read existing check list file
Expand Down
51 changes: 51 additions & 0 deletions R/set_license.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#' Set the proper license
#' @inheritParams read_checklist
#' @family setup
#' @export
#' @importFrom assertthat assert_that
#' @importFrom desc description
#' @importFrom fs file_copy file_exists path
set_license <- function(x = ".") {
x <- read_checklist(x = x)
license_file <- path(x$get_path, "LICENSE.md")
if (x$package) {
assert_that(
file_exists(path(x$get_path, "DESCRIPTION")),
msg = sprintf("No `DESCRIPTION` file found at %s", x$get_path)
)
this_desc <- description$new(file = path(x$get_path, "DESCRIPTION"))
assert_that(
this_desc$has_fields("License"),
msg = "`DESCRIPTION` has no `License`field."
)
switch(
this_desc$get_field("License"),
"GPL-3" = path("generic_template", "gplv3.md"),
"MIT" = path("generic_template", "mit.md"),
"MIT + file LICENSE" = path("generic_template", "mit.md"),
stop(
sprintf("`%s` license is not available", this_desc$get_field("License"))
)
) |>
system.file(package = "checklist") |>
file_copy(license_file, overwrite = TRUE)
if (!grepl("^MIT", this_desc$get_field("License"))) {
return(invisible(NULL))
}
this_desc$get_author(role = "cph") |>
format(include = c("given", "family")) |>
paste(collapse = ", ") -> cph
paste0("YEAR: ", format(Sys.Date(), "%Y")) |>
c(sprintf("COPYRIGHT HOLDER: %s", cph)) |>
writeLines(path(x$get_path, "LICENSE"))
mit <- readLines(license_file)
mit[3] <- gsub("<YEAR>", format(Sys.Date(), "%Y"), mit[3])
mit[3] <- gsub("<COPYRIGHT HOLDER>", cph, mit[3])
writeLines(mit, license_file)
return(invisible(NULL))
}
path("generic_template", "cc_by_4_0.md") |>
system.file(package = "checklist") |>
file_copy(license_file, overwrite = TRUE)
return(invisible(NULL))
}
11 changes: 10 additions & 1 deletion R/setup_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@

# add checklist.yml
if (!file_exists(path(path, "checklist.yml"))) {
x <- checklist$new(x = path, language = "en-GB", package = TRUE)
if (descript$has_fields("Language")) {
x <- checklist$new(
x = path, language = descript$get_field("Language"), package = TRUE
)
} else {
x <- checklist$new(x = path, language = "en-GB", package = TRUE)
descript$set("Language", "en-GB")
path(x$get_path, "DESCRIPTION") |>
descript$write()

Check warning on line 46 in R/setup_package.R

View check run for this annotation

Codecov / codecov/patch

R/setup_package.R#L43-L46

Added lines #L43 - L46 were not covered by tests
}
x$set_required()
x$set_ignore(c(".github", "LICENSE.md"))
write_checklist(x)
Expand Down
5 changes: 1 addition & 4 deletions R/setup_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ setup_project <- function(path = ".") {
x$set_default(c("en-GB", "nl-BE", "fr-FR")[answer])

if ("license" %in% checks && !file_exists(path(path, "LICENSE.md"))) {
insert_file(
repo = repo, filename = "cc_by_4_0.md", template = "generic_template",
target = path, new_name = "LICENSE.md"
)
set_license(x)
}

x$set_required(checks = checks)
Expand Down
10 changes: 2 additions & 8 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,11 @@ checklist_diff <- function(root) {
if (inherits(try(git_info(repo = root), silent = TRUE), "try-error")) {
return(invisible(NULL))
}
branch_info <- git_branch_list(repo = root)
branch_info$ref[
grep("/main$", branch_info$ref) |>
c(grep("/master$", branch_info$ref)) |>
head(1)
] |>
git_diff(repo = root) -> changes
changes <- git_diff(repo = root)
if (length(changes) == 0) {
return(invisible(NULL))
}
cli_h1("git diff")
cli_h1("unstaged changes")
changes$patch |>
gsub(pattern = "^.*?index.*?\n.*?\n", replacement = "") |>
strsplit(split = "\n") |>
Expand Down
Loading
Loading