You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, test_that() calls contain skip_if_not_installed(), which is good practice. However, some of those calls are redundant because testthat already imports those packages, so if testthat runs then we know that this package is necessarily installed.
One example I've seen (and done myself) is skip_if_not_installed("withr"), which is redundant since testthatimports withr. There could be other cases, such as brio and jsonlite. Would it make sense to have a linter to detect those unnecessary skip_if_not_installed()?
The text was updated successfully, but these errors were encountered:
I think this can go either way though -- {testthat} currently imports {with}, but what if it eventually changes to Suggests, or even refactors to use {withr2}, or the functionality is absorbed to {base}, etc?
So while I understand not using skip_if_not_installed("withr") for the reason stated, I also understand doing so as a future-proofing device.
This gets all the more complicated when considering recursive inclusions of packages -- should skip_if_not_installed("diffobj") pass (because it's required by {waldo})? These links are even more fragile & subject to unexpected breakage.
Right, I guess there's not much harm in ignoring the existing skip_if_not_installed("withr") and it makes things more future proof indeed. Not sure if this should be closed then.
Sometimes,
test_that()
calls containskip_if_not_installed()
, which is good practice. However, some of those calls are redundant becausetestthat
already imports those packages, so iftestthat
runs then we know that this package is necessarily installed.One example I've seen (and done myself) is
skip_if_not_installed("withr")
, which is redundant sincetestthat
importswithr
. There could be other cases, such asbrio
andjsonlite
. Would it make sense to have a linter to detect those unnecessaryskip_if_not_installed()
?The text was updated successfully, but these errors were encountered: