Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object_usage_linter fails to account for withr-defined names #2714

Open
MichaelChirico opened this issue Feb 4, 2025 · 0 comments
Open

object_usage_linter fails to account for withr-defined names #2714

MichaelChirico opened this issue Feb 4, 2025 · 0 comments
Labels
false-positive code that shouldn't lint, but does object linters 🏀

Comments

@MichaelChirico
Copy link
Collaborator

lint(linters = object_usage_linter(), R"{
foo <- function(f) {
  withr::with_connection(list(myCon = f), writeLines(letters, myCon))
}
}")
# <text>:3:63: warning: [object_usage_linter] no visible binding for global variable 'myCon'
#   withr::with_connection(list(myCon = f), writeLines(letters, myCon))
#                                                               ^~~~~

Obviously {codetools} does not (and probably will not) support myCon being defined as valid in this context by {withr}, but we can supplement to remove this false positive as we do in a few similar cases. {withr} is popular enough (100+ revdeps on CRAN) that this special case is warranted.

@MichaelChirico MichaelChirico added false-positive code that shouldn't lint, but does object linters 🏀 labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive code that shouldn't lint, but does object linters 🏀
Projects
None yet
Development

No branches or pull requests

1 participant