Skip to content

Commit c0c6455

Browse files
authored
refactor: ♻️ use assert_string() to check character scalars (#180)
# Description Instead of the `assert_character()` and `assert_scalar()` combo. See https://mllg.github.io/checkmate/reference/checkString.html. Needs no review. ## Checklist - [X] Ran `just run-all`
1 parent affd1dd commit c0c6455

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

R/convert.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ convert_file <- function(
103103
# Initial checks.
104104
checkmate::assert_character(path)
105105
checkmate::assert_file_exists(path)
106-
checkmate::assert_character(output_dir)
107-
checkmate::assert_scalar(output_dir)
106+
checkmate::assert_string(output_dir)
108107
checkmate::assert_int(chunk_size, lower = 10000L)
109108

110109
# Prepare variables used in repeat below.

R/list.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
list_sas_files <- function(path) {
1414
# Check input.
1515
checkmate::assert_directory(path)
16-
checkmate::assert_scalar(path)
16+
checkmate::assert_string(path)
1717

1818
# List all SAS files in the directory and its subdirectories.
1919
# (?i) makes the regex case-insensitive.
@@ -47,7 +47,7 @@ list_sas_files <- function(path) {
4747
list_parquet_files <- function(path) {
4848
# Check input.
4949
checkmate::assert_directory(path)
50-
checkmate::assert_scalar(path)
50+
checkmate::assert_string(path)
5151

5252
# List all Parquet files in the directory and its subdirectories.
5353
# (?i) makes the regex case-insensitive.

R/read.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ read_register <- function(
2020
path
2121
) {
2222
# Check input.
23-
checkmate::assert_character(path)
24-
checkmate::assert_scalar(path)
23+
checkmate::assert_string(path)
2524
checkmate::assert(
2625
checkmate::check_file_exists(path),
2726
checkmate::check_directory_exists(path)

tests/testthat/test-convert.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test_that("convert_file() errors with incorrect input parameters", {
7171
# Incorrect output_dir type.
7272
expect_error(
7373
convert_file(path = sas_kontakter[[1]], output_dir = 1),
74-
regexp = "character"
74+
regexp = "string"
7575
)
7676
# output_dir must be scalar.
7777
expect_error(

tests/testthat/test-read.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test_that("reading a non-existing Parquet register throws an error", {
7373
})
7474

7575
test_that("incorrect input type throws an error", {
76-
expect_error(read_register(123), regexp = "character")
76+
expect_error(read_register(123), regexp = "string")
7777
expect_error(
7878
read_register(c("path1.parquet", "path2.parquet")),
7979
regexp = "length 1"

0 commit comments

Comments
 (0)