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() should set useFancyQuotes=FALSE #1498

Closed
MichaelChirico opened this issue Aug 11, 2022 · 2 comments · Fixed by #1523
Closed

object_usage_linter() should set useFancyQuotes=FALSE #1498

MichaelChirico opened this issue Aug 11, 2022 · 2 comments · Fixed by #1523

Comments

@MichaelChirico
Copy link
Collaborator

MichaelChirico commented Aug 11, 2022

Compare:

str <- "foo <- function() {\n  x\n}\n"

options(useFancyQuotes = FALSE)
lintr::lint(text = str, linters = lintr::object_usage_linter())
# <text>:2:3: warning: [object_usage_linter] no visible binding for global variable 'x'.
#   x
#   ^
options(useFancyQuotes = TRUE)
lintr::lint(text = str, linters = lintr::object_usage_linter())
# <text>:2:3: warning: [object_usage_linter] no visible binding for global variable ‘x’.
#   x
#   ^

I think we should follow suit of testthat and turn off quotes here -- makes the lint appear differently depending on global options & it's harder to manipulate the message with non-ASCII characters.

The fix is pretty trivial to implement; filing here first as a gut check that this is the right approach.

@AshesITR
Copy link
Collaborator

I don't see an issue with using fancy quotes here, since the lint message is meant to be read by a user.

We can't guarantee ASCII messages anyway since the messages can contain arbitrary parts of user code.

@MichaelChirico
Copy link
Collaborator Author

That's basically right, but it's still something in our control that allows us to be more consistent. I don't think we use fancy quotes in any messages generated by us. And the fix is one line (wrap codetools call with with_options(list(useFancyQuotes = FALSE), ...))

@IndrajeetPatil IndrajeetPatil changed the title object_usage_linter should set useFancyQuotes=FALSE object_usage_linter() should set useFancyQuotes=FALSE Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants