Skip to content

Commit 4c2de53

Browse files
committed
style: fix some style issues
1 parent e40ee0c commit 4c2de53

12 files changed

+25
-22
lines changed

R/assert.R

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#' \dQuote{or} or \dQuote{and} to combine the check functions with an OR
1616
#' or AND, respectively.
1717
#' @template assert
18-
#' @return Throws an error (or pushes the error message to an
19-
#' \code{\link{AssertCollection}} if \code{add} is not \code{NULL})
18+
#' @return Throws an error (or pushes the error message to an
19+
#' \code{\link{AssertCollection}} if \code{add} is not \code{NULL})
2020
#' if the checks fail and invisibly returns \code{TRUE} otherwise.
2121
#' @export
2222
#' @examples
@@ -25,7 +25,6 @@
2525
#' collection <- makeAssertCollection()
2626
#' assert(checkChoice(x, c("a", "b")), checkDataFrame(x), add = collection)
2727
#' collection$getMessages()
28-
#'
2928
assert = function(..., combine = "or", .var.name = NULL, add = NULL) {
3029
assertChoice(combine, c("or", "and"))
3130
assertClass(add, "AssertCollection", .var.name = "add", null.ok = TRUE)
@@ -61,16 +60,16 @@ assert = function(..., combine = "or", .var.name = NULL, add = NULL) {
6160
}
6261

6362
# Error handling in assert()
64-
#
63+
#
6564
# Internal helper function to handle errors in assert().
6665
# @param res [character(1)}]\cr
6766
# error message
6867
# @param v_name [\code{character}]\cr
6968
# Name(s) of the variable(s) whose assertion failed.
7069
# @param collection [\code{AssertCollection} | \code{NULL}]\cr
7170
# See AssertCollection.
72-
# @return mstopOrPush() throws an exception by calling
73-
# mstop() if 'collection' is NULL, or
71+
# @return mstopOrPush() throws an exception by calling
72+
# mstop() if 'collection' is NULL, or
7473
# pushes the error message to the collection otherwise.
7574
# @keywords internal
7675
mstopOrPush = function(res, v_name, collection = NULL) {

R/checkCharacter.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#' testCharacter("example", pattern = "xa")
3636
checkCharacter = function(x, n.chars = NULL, min.chars = NULL, max.chars = NULL, pattern = NULL, fixed = NULL, ignore.case = FALSE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL, typed.missing = FALSE, null.ok = FALSE) {
3737
.Call(c_check_character, x, n.chars, min.chars, max.chars, any.missing, all.missing, len, min.len, max.len, unique, sorted, names, typed.missing, null.ok) %and%
38-
checkCharacterPattern(x, pattern, fixed, ignore.case)
38+
checkCharacterPattern(x, pattern, fixed, ignore.case)
3939
}
4040

4141
checkCharacterPattern = function(x, pattern = NULL, fixed = NULL, ignore.case = FALSE) {

R/checkClass.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ checkClass = function(x, classes, ordered = FALSE, null.ok = FALSE) {
4545
if (length(w) > 0L) {
4646
cl = class(x)
4747
return(sprintf("Must inherit from class '%s', but has class%s '%s'",
48-
classes[w], if (length(cl) > 1L) "es" else "", paste0(cl, collapse = "','")))
48+
classes[w], if (length(cl) > 1L) "es" else "", paste0(cl, collapse = "','")))
4949
}
5050
if (ordered) {
5151
w = wf(ord != seq_along(ord))

R/checkDataFrame.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#' testDataFrame(iris, types = c("numeric", "factor"), min.rows = 1, col.names = "named")
1818
checkDataFrame = function(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, min.rows = NULL, max.rows = NULL, min.cols = NULL, max.cols = NULL, nrows = NULL, ncols = NULL, row.names = NULL, col.names = NULL, null.ok = FALSE) {
1919
.Call(c_check_dataframe, x, any.missing, all.missing, min.rows, max.rows, min.cols, max.cols, nrows, ncols, row.names, col.names, null.ok) %and%
20-
checkListTypes(x, types)
20+
checkListTypes(x, types)
2121
}
2222

2323
#' @export

R/checkFactor.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ checkFactor = function(x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, a
3535
checkFactorLevels(x, levels, ordered, empty.levels.ok, n.levels, min.levels, max.levels)
3636
}
3737

38-
checkFactorLevels = function(x , levels = NULL, ordered = NA, empty.levels.ok = TRUE, n.levels = NULL, min.levels = NULL, max.levels = NULL) {
38+
checkFactorLevels = function(x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, n.levels = NULL, min.levels = NULL, max.levels = NULL) {
3939
if (!is.null(x)) {
4040
if (!is.null(levels)) {
4141
qassert(levels, "S")

R/checkFileExists.R

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ checkFileExtension = function(x, extension = NULL) {
3939
qassert(extension, "S+")
4040
ii = Reduce(`|`, lapply(tolower(extension), endsWith, x = tolower(x)))
4141
if (!all(ii))
42-
return(sprintf("File extension must be in {'%s'} (case insensitive), but file name is '%s'",
43-
paste0(extension, collapse = "','"),
44-
x[wf(!ii)]))
42+
return(sprintf(
43+
"File extension must be in {'%s'} (case insensitive), but file name is '%s'",
44+
paste0(extension, collapse = "','"), x[wf(!ii)]
45+
))
4546
}
4647
return(TRUE)
4748
}

R/checkList.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#' testList(list(NA, NA_real_), unique = TRUE)
4141
checkList = function(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) {
4242
.Call(c_check_list, x, any.missing, all.missing, len, min.len, max.len, unique, names, null.ok) %and%
43-
checkListTypes(x, types)
43+
checkListTypes(x, types)
4444
}
4545

4646
checkListTypes = function(x, types = character(0L)) {

R/checkMultiClass.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ checkMultiClass = function(x, classes, null.ok = FALSE) {
2222
return(TRUE)
2323
if (!inherits(x, classes)) {
2424
cl = class(x)
25-
return(sprintf("Must inherit from class '%s', but has class%s '%s'",
26-
paste0(classes, collapse = "'/'"), if (length(cl) > 1L) "es" else "", paste0(cl, collapse = "','")))
25+
return(sprintf(
26+
"Must inherit from class '%s', but has class%s '%s'",
27+
paste0(classes, collapse = "'/'"), if (length(cl) > 1L) "es" else "", paste0(cl, collapse = "','")
28+
))
2729
}
2830
return(TRUE)
2931
}

R/checkNames.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#' \item{unnamed:}{Checks \code{x} to be \code{NULL}.}
1313
#' \item{named:}{Checks \code{x} for regular names which excludes names to be \code{NA} or empty (\code{""}).}
1414
#' \item{unique:}{Performs checks like with \dQuote{named} and additionally tests for non-duplicated names.}
15-
#' \item{strict:}{Performs checks like with \dQuote{unique} and additionally fails for names with UTF-8 characters and names which do not comply to R's variable name restrictions. As regular expression, this is \dQuote{^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$}.}
15+
#' \item{strict:}{Performs checks like with \dQuote{unique} and additionally fails for names with UTF-8 characters and names which do not comply to R's variable name restrictions.
16+
#' As regular expression, this is \dQuote{^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$}.}
1617
#' \item{ids:}{Same as \dQuote{strict}, but does not enforce uniqueness.}
1718
#' }
1819
#' Note that for zero-length \code{x}, all these name checks evaluate to \code{TRUE}.

R/checkString.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#' testString(letters)
2020
checkString = function(x, na.ok = FALSE, n.chars = NULL, min.chars = NULL, max.chars = NULL, pattern = NULL, fixed = NULL, ignore.case = FALSE, null.ok = FALSE) {
2121
.Call(c_check_string, x, na.ok, n.chars, min.chars, max.chars, null.ok) %and%
22-
checkCharacterPattern(x, pattern, fixed, ignore.case)
22+
checkCharacterPattern(x, pattern, fixed, ignore.case)
2323
}
2424

2525
#' @export

R/helper.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@ check_subset_internal = function(x, choices, match, what = NULL) {
7676
check_set_equal_internal = function(x, y, match, what = NULL) {
7777
if ((!isSameType(x, y) && !allMissing(x))) {
7878
return(set_msg("Must be setequal to %s, but has different type",
79-
what, set_collapse(y)))
79+
what, set_collapse(y)))
8080
}
8181

8282
ii = match(x, y)
8383
if (anyMissing(ii)) {
8484
return(set_msg("must be a permutation of set %s, but has extra elements %s",
85-
what, set_collapse(y), set_collapse(x[is.na(ii)])
85+
what, set_collapse(y), set_collapse(x[is.na(ii)])
8686
))
8787
}
8888

8989
ii = match(y, x)
9090
if (anyMissing(ii)) {
9191
return(set_msg("must be a set equal to %s, but is missing elements %s",
92-
what, set_collapse(y), set_collapse(y[is.na(ii)])
92+
what, set_collapse(y), set_collapse(y[is.na(ii)])
9393
))
9494
}
9595

R/zzz.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ register_tinytest = function() {
138138
setHook(packageEvent("tinytest", "onLoad"), function(...) register_tinytest(), action = "append")
139139
}
140140

141-
.onUnload = function (libpath) {
141+
.onUnload = function(libpath) {
142142
library.dynam.unload("checkmate", libpath) # nocov
143143
}

0 commit comments

Comments
 (0)