View source: R/package_hooks_linter.R
package_hooks_linter | R Documentation |
Check various common "gotchas" in .onLoad()
, .onAttach()
, .Last.lib()
, and .onDetach()
namespace hooks that will cause R CMD check
issues. See Writing R Extensions for details.
package_hooks_linter()
.onLoad()
shouldn't call cat()
, message()
, print()
, writeLines()
, packageStartupMessage()
,
require()
, library()
, or installed.packages()
.
.onAttach()
shouldn't call cat()
, message()
, print()
, writeLines()
, library.dynam()
,
require()
, library()
, or installed.packages()
.
.Last.lib()
and .onDetach()
shouldn't call library.dynam.unload()
.
.onLoad()
and .onAttach()
should take two arguments, with names matching ^lib
and ^pkg
;
.Last.lib()
and .onDetach()
should take one argument with name matching ^lib
.
correctness, package_development, style
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = ".onLoad <- function(lib, ...) { }",
linters = package_hooks_linter()
)
lint(
text = ".onAttach <- function(lib, pkg) { require(foo) }",
linters = package_hooks_linter()
)
lint(
text = ".onDetach <- function(pkg) { }",
linters = package_hooks_linter()
)
# okay
lint(
text = ".onLoad <- function(lib, pkg) { }",
linters = package_hooks_linter()
)
lint(
text = '.onAttach <- function(lib, pkg) { loadNamespace("foo") }',
linters = package_hooks_linter()
)
lint(
text = ".onDetach <- function(lib) { }",
linters = package_hooks_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.