Force library calls to all be at the top of the script.
See also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "
library(dplyr)
print('test')
library(tidyr)
",
linters = library_call_linter()
)
#> ::warning file=<text>,line=4,col=5::file=<text>,line=4,col=5,[library_call_linter] Move all library calls to the top of the script.
lint(
text = "
library(dplyr)
print('test')
library(tidyr)
library(purrr)
",
linters = library_call_linter()
)
#> ::warning file=<text>,line=4,col=5::file=<text>,line=4,col=5,[library_call_linter] Move all library calls to the top of the script.
#> ::warning file=<text>,line=5,col=5::file=<text>,line=5,col=5,[library_call_linter] Move all library calls to the top of the script.
# okay
lint(
text = "
library(dplyr)
print('test')
",
linters = library_call_linter()
)
lint(
text = "
# comment
library(dplyr)
",
linters = library_call_linter()
)