Skip to content

Commit 29580c6

Browse files
committed
Fix R CMD check notes
1 parent 132a2ff commit 29580c6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,5 @@ importFrom(brio,readLines)
237237
importFrom(brio,writeLines)
238238
importFrom(lifecycle,deprecated)
239239
importFrom(magrittr,"%>%")
240+
importFrom(methods,new)
240241
useDynLib(testthat, .registration = TRUE)

R/mock-oo.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ local_mocked_s3_method <- function(
2828
check_string(signature)
2929
check_function(definition)
3030

31-
old <- getS3method(generic, signature, optional = TRUE)
31+
old <- utils::getS3method(generic, signature, optional = TRUE)
3232
if (is.null(old)) {
3333
cli::cli_abort(
3434
"Can't find existing S3 method {.code {generic}.{signature}()}."
@@ -50,15 +50,18 @@ local_mocked_s4_method <- function(
5050
check_character(signature)
5151
check_function(definition)
5252

53-
old <- getMethod(generic, signature, optional = TRUE)
53+
old <- methods::getMethod(generic, signature, optional = TRUE)
5454
if (is.null(old)) {
5555
name <- paste0(generic, "(", paste0(signature, collapse = ","), ")")
5656
cli::cli_abort(
5757
"Can't find existing S4 method {.code {name}}."
5858
)
5959
}
60-
setMethod(generic, signature, definition, where = topenv(frame))
61-
withr::defer(setMethod(generic, signature, old, where = topenv(frame)), frame)
60+
methods::setMethod(generic, signature, definition, where = topenv(frame))
61+
withr::defer(
62+
methods::setMethod(generic, signature, old, where = topenv(frame)),
63+
frame
64+
)
6265
}
6366

6467

@@ -123,6 +126,9 @@ TestMockClass <- R6::R6Class(
123126
)
124127
)
125128

129+
# Silence R CMD check NOTE: I think it's because TestMockPerson is a claas
130+
# constructor
131+
#' @importFrom methods new
126132
TestMockPerson <- methods::setClass(
127133
"TestMockPerson",
128134
slots = c(name = "character", age = "numeric")

0 commit comments

Comments
 (0)