-
Notifications
You must be signed in to change notification settings - Fork 186
lintr:::get_source_expressions fails when a code comment contains an r script command surrounded by backticks #879
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
Comments
I believe it's a duplicate of #743 |
Do you know of any workaround? |
sadly no... the detection logic for Rmd is too greedy. Needs an overhaul but it was quite messy when I tried to take a quick look at fixing it. |
@MichaelChirico any starting points if we want to give it a look re: overhaul? For us this issue is quite a problem since we use the |
Try and find out how knitr decides if a file is Rmd or not, perhaps there's an exported function we could re use. otherwise, we might try running parse() first and if that fails, check if the file is Rmd |
@MichaelChirico cool thx! |
We were surprised our files linted correctly despite having obvious linting issues, so I have investigated and narrowed it down to this minimal reprex:
The above doesn't lint.
I further narrowed the issue down to backticks in combination with r and something because the following do lint correctly:
In short - all three are needed: backticks, r and something in addition to r.
Then, I dug inside inflix_spaces_linter and tracked the issue to the parsing function, Given a file "test.R",


lintr:::get_source_expressions("test.R")
returns:Without the comment, it parses correctly:
Environment:
lintr version 2.0.1
R: 4.1.0
Is this a known issue?
The text was updated successfully, but these errors were encountered: