lintr
lintr copied to clipboard
option to disable the `object_usage_linter` inside `with` expressions
would it be possible to add an option to the object_usage_linter so it does not check the inside of with expressions?
running lintr::lint("this_file.R")
#this_file.R
test_fun <- function(df) {
with(df, first_var + second_var)
}
throw the following warnings:
this_file.R:2:12: warning: [object_usag e_linter] no visible binding for global variable ‘first_var’ with(df, first_var + second_var)
this_file.R:2:24: warning: [object_usag e_linter] no visible binding for global variable ‘second_var’ with(df, first_var + second_var)
but strangely no such warning appear with this code:
df <- readRDS("df_path.rds")
with(df, first_var + second_var)
Thanks
Hi, thanks for reporting this.
codetools::checkUsage() reports these issues by default, but it has a flag skipWith = FALSE that could be set to true to suppress these.
Regarding your second example: The object usage linter only checks (top-level) function definitions, so the second example doesn't trigger it.
Related: #941
Thanks for your answer, I will follow this issue then!