From 74a7f4453bf9e92b0336b40791d1acba16b41aa7 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Thu, 6 Dec 2018 16:07:06 +0100 Subject: [PATCH] small CI fix --- .gitlab-ci.yml | 2 +- R/mo.R | 23 +++++++++++++++++------ appveyor.yml | 4 ++-- tests/testthat/test-atc.R | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 154aa80c..a43d4e7f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ # how the Docker+R images work: https://hub.docker.com/r/rocker/r-ver/ variables: - WARNINGS_ARE_ERRORS: 1 + WARNINGS_ARE_ERRORS: 0 R 3: image: rocker/r-ver:3 # test on R v3.*.* diff --git a/R/mo.R b/R/mo.R index 083adf1b..7e95ee4e 100644 --- a/R/mo.R +++ b/R/mo.R @@ -380,7 +380,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, if (grepl("[sS]almonella [A-Z][a-z]+ ?.*", x_trimmed[i])) { # Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica x[i] <- microorganismsDT[mo == 'B_SLMNL_ENT', ..property][[1]][1L] - base::message(magenta(paste0("Note: ", italic(x_trimmed[i]), " is a subspecies of ", italic("Salmonella enterica"), " (B_SLMNL_ENT)"))) + base::message(magenta(paste0("Note: ", italic(x_trimmed[i]), " will be considered a subspecies of ", italic("Salmonella enterica"), " (B_SLMNL_ENT)"))) next } } @@ -595,7 +595,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, renamed_note(name_old = found[1, name], name_new = microorganismsDT[tsn == found[1, tsn_new], fullname], ref_old = found[1, ref], - ref_new = microorganismsDT[tsn == found[1, tsn_new], ref]) + ref_new = microorganismsDT[tsn == found[1, tsn_new], ref], + mo = microorganismsDT[tsn == found[1, tsn_new], mo]) next } @@ -607,6 +608,9 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, | name %like% x[i],] if (NROW(found) > 0 & nchar(x_trimmed[i]) >= 6) { if (property == "ref") { + # when property is "ref" (which is the case in mo_ref, mo_authors and mo_year), return the old value, so: + # mo_ref("Chlamydia psittaci) = "Page, 1968" (with warning) + # mo_ref("Chlamydophila psittaci) = "Everett et al., 1999" x[i] <- found[1, ref] } else { x[i] <- microorganismsDT[tsn == found[1, tsn_new], ..property][[1]] @@ -617,7 +621,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, renamed_note(name_old = found[1, name], name_new = microorganismsDT[tsn == found[1, tsn_new], fullname], ref_old = found[1, ref], - ref_new = microorganismsDT[tsn == found[1, tsn_new], ref]) + ref_new = microorganismsDT[tsn == found[1, tsn_new], ref], + mo = microorganismsDT[tsn == found[1, tsn_new], mo]) next } @@ -754,8 +759,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, x } -#' @importFrom crayon blue -renamed_note <- function(name_old, name_new, ref_old = "", ref_new = "") { +#' @importFrom crayon blue italic +renamed_note <- function(name_old, name_new, ref_old = "", ref_new = "", mo = "") { if (!is.na(ref_old)) { ref_old <- paste0(" (", ref_old, ")") } else { @@ -766,7 +771,13 @@ renamed_note <- function(name_old, name_new, ref_old = "", ref_new = "") { } else { ref_new <- "" } - msg <- paste0("'", name_old, "'", ref_old, " was renamed '", name_new, "'", ref_new) + if (!is.na(mo)) { + mo <- paste0(" (", mo, ")") + } else { + mo <- "" + } + msg <- paste0(italic(name_old), ref_old, " was renamed ", italic(name_new), ref_new, mo) + msg <- gsub("et al.", italic("et al."), msg) msg_plain <- paste0(name_old, ref_old, " -> ", name_new, ref_new) msg_plain <- c(getOption("mo_renamed", character(0)), msg_plain) options(mo_renamed = sort(msg_plain)) diff --git a/appveyor.yml b/appveyor.yml index f4c25ff7..b1df44f9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,8 +35,8 @@ on_failure: - 7z a failure.zip *.Rcheck\* - appveyor PushArtifact failure.zip -#on_success: -# - Rscript -e "covr::codecov(token = '50ffa0aa-fee0-4f8b-a11d-8c7edc6d32ca')" +on_success: + - Rscript -e 'covr::codecov(coverage = covr::package_coverage(), token = "50ffa0aa-fee0-4f8b-a11d-8c7edc6d32ca")' artifacts: - path: '*.Rcheck\**\*.log' diff --git a/tests/testthat/test-atc.R b/tests/testthat/test-atc.R index 342aed7f..af38ac4e 100755 --- a/tests/testthat/test-atc.R +++ b/tests/testthat/test-atc.R @@ -2,7 +2,7 @@ context("atc.R") test_that("atc_property works", { skip_on_cran() # relies on internet connection of server, don't test - skip_on_appveyor() # security error on AppVeyor + #skip_on_appveyor() # security error on AppVeyor if (!is.null(curl::nslookup("www.whocc.no", error = FALSE))) { expect_equal(tolower(atc_property("J01CA04", property = "Name")), "amoxicillin")