From 71478a9c7cca57f7cd10eb61b112be753660ad8d Mon Sep 17 00:00:00 2001 From: Zena Lapp Date: Thu, 16 Nov 2023 21:29:00 -0700 Subject: [PATCH] Style code --- R/bistro.R | 2 +- R/identify_matches.R | 2 +- R/utils.R | 4 ++-- tests/testthat/test-utils.R | 10 ++++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/R/bistro.R b/R/bistro.R index a5d876b..212b5e2 100644 --- a/R/bistro.R +++ b/R/bistro.R @@ -105,7 +105,7 @@ bistro <- seed = 1, time_limit = 3, return_lrs = FALSE) { - check_pkg_version('tidyr', utils::packageVersion('tidyr'), '1.3.0') + check_pkg_version("tidyr", utils::packageVersion("tidyr"), "1.3.0") check_bistro_inputs( bloodmeal_profiles, human_profiles, diff --git a/R/identify_matches.R b/R/identify_matches.R index 6d0883a..029c561 100644 --- a/R/identify_matches.R +++ b/R/identify_matches.R @@ -9,7 +9,7 @@ #' @inheritParams calc_one_log10_lr #' @keywords internal identify_one_match_set <- function(log10_lrs, bloodmeal_id) { - check_pkg_version('tidyr', utils::packageVersion('tidyr'), '1.3.0') + check_pkg_version("tidyr", utils::packageVersion("tidyr"), "1.3.0") bm_id <- bloodmeal_id log10_lrs <- log10_lrs |> dplyr::filter(bloodmeal_id == bm_id) diff --git a/R/utils.R b/R/utils.R index 5634e02..0df72e2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -48,9 +48,9 @@ ignore_unused_imports <- function() { #' @param version required package version #' #' @return nothing or error if package version too old -check_pkg_version <- function(pkg, curr_version, version){ +check_pkg_version <- function(pkg, curr_version, version) { vers <- utils::compareVersion(as.character(curr_version), version) - if(vers == -1){ + if (vers == -1) { stop("The ", pkg, " package is version ", curr_version, " but must be >= ", version, ". Please update the package to use this function.") } } diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 0b32299..ca9c658 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -3,8 +3,10 @@ test_that("ignore_unused_imports works", { }) test_that("check_pkg_version works", { - expect_no_error(check_pkg_version('tidyr', '1.1.2', '1.1.1')) - expect_no_error(check_pkg_version('tidyr', '1.1.1', '1.1.1')) - expect_error(check_pkg_version('tidyr', '1.1.1', '1.1.2'), - "The tidyr package is version 1.1.1 but must be >= 1.1.2. Please update the package to use this function.") + expect_no_error(check_pkg_version("tidyr", "1.1.2", "1.1.1")) + expect_no_error(check_pkg_version("tidyr", "1.1.1", "1.1.1")) + expect_error( + check_pkg_version("tidyr", "1.1.1", "1.1.2"), + "The tidyr package is version 1.1.1 but must be >= 1.1.2. Please update the package to use this function." + ) })