Skip to content

Commit

Permalink
Merge pull request #103 from inbo/fix-license
Browse files Browse the repository at this point in the history
fix license and filename checks
  • Loading branch information
ThierryO authored Mar 21, 2023
2 parents c1e200b + 0f5ddd5 commit d3c2691
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 9 deletions.
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.0",
"version": "0.3.1",
"license": "GPL-3.0",
"upload_type": "software",
"description": "<p>An opinionated set of rules for R packages and R source code\nprojects.<\/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.0
version: 0.3.1
2 changes: 1 addition & 1 deletion 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.0
Version: 0.3.1
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# checklist 0.3.1

* Fixes two bugs in case `MIT` license was chosen
* GitHub Actions now uses the latest version of checklist as default when
checking packages or projects.

# checklist 0.3.0

* Improved `create_project()` and `setup_project()` which interactively guides
Expand Down
2 changes: 2 additions & 0 deletions R/check_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ Please send a pull request if you need support for this license.",
if (current_license == "MIT + file LICENSE") {
author <- this_desc$get_author(role = "cph")
cph <- paste(c(author$given, author$family), collapse = " ")
cph <- gsub("([\\(\\)\\.\\\\\\|\\[\\]\\{\\}\\^\\$\\*\\+\\?])",
"\\\\\\1", cph, perl = TRUE)
problems <- c(
problems,
"Copyright holder in LICENSE.md doesn't match the one in DESCRIPTION"[
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 = ".") {
"\\.[a-zA-Z]+ignore", "\\.Rprofile", "\\.[a-zA-Z]+\\.(json|yml)",
"CITATION", "DESCRIPTION", "NAMESPACE", "CITATION\\.cff",
"README\\.R?md", "NEWS\\.md",
"CODE_OF_CONDUCT\\.md", "CONTRIBUTING\\.md", "LICENSE\\.(md)?",
"CODE_OF_CONDUCT\\.md", "CONTRIBUTING\\.md", "LICENSE(\\.md)?",
"SUPPORT\\.md", "SECURITY\\.md", "FUNDING\\.yml",
"Dockerfile", "WORDLIST.*", "docker-compose.*\\.yml"
),
Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ citHeader("To cite `checklist` in publications please use:")
# begin checklist entry
citEntry(
entry = "Manual",
title = "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.0",
title = "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.1",
author = c( author = c(person(given = "Thierry", family = "Onkelinx"))),
year = 2023,
url = "https://inbo.github.io/checklist/",
abstract = "An opinionated set of rules for R packages and R source code projects.",
textVersion = "Onkelinx, Thierry (2023) checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.0. https://github.com/inbo/checklist/; https://inbo.github.io/checklist/",
textVersion = "Onkelinx, Thierry (2023) checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.1. https://github.com/inbo/checklist/; https://inbo.github.io/checklist/",
keywords = "quality control; documentation; publication",
doi = "10.5281/zenodo.4028303",
)
Expand Down
2 changes: 1 addition & 1 deletion inst/package_template/check_on_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
permissions:
contents: read
steps:
- uses: inbo/actions/check_pkg@checklist-0.3.0
- uses: inbo/actions/check_pkg@main
2 changes: 1 addition & 1 deletion inst/package_template/check_on_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: inbo/actions/check_pkg@checklist-0.3.0
- uses: inbo/actions/check_pkg@main
2 changes: 1 addition & 1 deletion inst/project_template/check_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
permissions:
contents: read
steps:
- uses: inbo/actions/check_project@v2
- uses: inbo/actions/check_project@main
32 changes: 32 additions & 0 deletions tests/testthat/test_d_check_license.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,27 @@ test_that("check_license() works", {
email = "[email protected]",
comment = c(ORCID = "0000-0001-8804-4216")
)
change_cph <- function(cph = "test escape characters ().[]") {
descr <- readLines(path(repo, "DESCRIPTION"))
cph_line <- grep("cph", descr, value = FALSE)
new_cph <- paste0(
" person(\"", cph,
"\", , , \"[email protected]\", role = c(\"cph\", \"fnd\"))"
)
descr[cph_line] <- new_cph
writeLines(descr, path(repo, "DESCRIPTION"))
license <- readLines(path(repo, "LICENSE"))
license[2] <- paste0("COPYRIGHT HOLDER: ", cph)
writeLines(license, path(repo, "LICENSE"))
license_md <- readLines(path(repo, "LICENSE.md"))
license_md[3] <- paste0("Copyright (c) ", format(Sys.Date(), "%Y"),
" ", cph)
writeLines(license_md, path(repo, "LICENSE.md"))
}
path <- tempfile("check_license")
dir.create(path)
oldwd <- setwd(path)
on.exit(setwd(oldwd), add = TRUE)
on.exit(unlink(path, recursive = TRUE), add = TRUE)

package <- "checklicense"
Expand All @@ -33,6 +52,12 @@ test_that("check_license() works", {
file.exists(path(repo, "LICENSE")),
TRUE
)
x <- check_license(repo)
expect_identical(
x$.__enclos_env__$private$errors$license,
character(0)
)

# copyright holder mismatch
mit[3] <- paste0("Copyright (c) ", format(Sys.Date(), "%Y"),
" INBO")
Expand All @@ -43,6 +68,13 @@ test_that("check_license() works", {
c("Copyright holder in LICENSE.md doesn't match the one in DESCRIPTION",
"Copyright statement in LICENSE.md not in correct format"))

# test all escape characters in copyright holder
change_cph()
x <- check_license(repo)
expect_identical(
x$.__enclos_env__$private$errors$license,
character(0)
)

file_delete(path(repo, "LICENSE.md"))
expect_is(x <- check_license(repo), "checklist")
Expand Down

0 comments on commit d3c2691

Please sign in to comment.