I'm sure that this is a misunderstanding of mine, since I'm not really an R programmer...
I have my code here: https://gist.github.com/bnsh/3839c4eb2c6b31e32c39ec312014b2b8
#! /usr/bin/env Rscript
library(R6)
Cloaked <- R6::R6Class("Cloaked",
public = list(
msg = function() {
return(paste(
"this code _works_, but lintr (https://github.com/jimhester/lintr)",
"complains that cloak_class.R:19:8: warning: no visible binding for",
"global variable ‘Cloaked’ when I try to use Cloaked within a",
"function. It's fine tho, if I use it _outside_ a function."
))
}
)
)
main <- function() {
c <- Cloaked$new()
c$msg()
}
main()
It works... But, lintr complains: "cloak_class.R:19:8: warning: no visible binding for global variable ‘Cloaked’"
Actually, it's not about a class, really, because this also complains:
#! /usr/bin/env Rscript
cloaked <- function() {
return(paste(
"this code _works_, but lintr (https://github.com/jimhester/lintr)",
"complains that cloak_function.R:13:3: warning: no visible global",
"function definition for ‘cloaked’ when I try to use cloaked within",
"a function. It's fine tho, if I use it _outside_ a function."
))
}
main <- function() {
cloaked()
}
main()
This code also runs, but lintr says: cloak_function.R:13:3: warning: no visible global function definition for ‘cloaked’
Why? Short of doing something blunt instrument like # nolint start
/# nolint end
, what can I do to satisfy lintr?
Thanks!