Unused declared function and data objects linter
Source:R/unused_declared_object_linter.R
unused_declared_object_linter.Rd
Checks that all defined/declared functions and data objects are used within the source file.
Functions and data objects that are marked with @export
are ignored.
Details
For use in rhino
, see the
Explanation: Rhino style guide
to learn about the details.
Examples
# will produce lint
code <- "
#' @export
public_function <- function() {
}
private_function <- function() {
}
local_data <- \"A\"
"
lintr::lint(text = code, linters = unused_declared_object_linter())
#> ::warning file=<text>,line=7,col=1::file=<text>,line=7,col=1,[unused_declared_object_linter] Declared function/object unused.
#> ::warning file=<text>,line=11,col=1::file=<text>,line=11,col=1,[unused_declared_object_linter] Declared function/object unused.
# okay
code <- "
#' @export
public_function <- function() {
some_variable <- local_data
private_function()
}
private_function <- function() {
}
local_data <- \"A\"
"
lintr::lint(text = code, linters = unused_declared_object_linter())
#> ::warning file=<text>,line=4,col=3::file=<text>,line=4,col=3,[unused_declared_object_linter] Declared function/object unused.