-
Notifications
You must be signed in to change notification settings - Fork 186
Linting code chunks in Rmd not working consistently with knitr #797
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
Related to #796 |
Reproduced this:
This code block, when added to This seems to happen because "R" is one of |
Also, lintr should attack any code blocks that have engine="Rscript"
|
One area that I'm not sure how to handle are custom knitr engines Some of these are used to run R code, and so should be linted, eg, details and targets Other packages add custom knitr engines that don't run R code (eg, nomnoml; I believe this is the case for the tufte "marginfigure" engine mentioned in #796) and so should be ignored. Perhaps the lintr config should allow the user to add additional engines whose code should be linted. |
I agree re the bug for {therom} example:
Throws an assignment lint in current master |
So my thoughts: |
Makes perfect sense. |
Sounds like a good idea. Maybe the option name should be more specific to rmd, e.g. Also we should use the existing default mechanism to set |
I was going to suggest rmd_engines as well, so agree with that & everything. great suggestions! |
Ha, I hadn't thought of using |
A quick google-fu turned up this gem from 2010. |
|
Summary of aims: With no With a .lintr config like this (or with knitr_engines = ... in the lint() arguments):
{lintr} would lint all code blocks for "r", "R", "Rscript" and "targets" engines With .lintr configured like this:
{lintr} would only lint blocks with the "r" engine. Does this seem OK everyone, @jimhester ? |
sure, sounds good. |
* Anticipate raw HTML from extended knitr engines Closes #796 Plus styling changes. * Also include bookdown engines ##797 * don't piggyback; move tests to their own file * also add test for bookdown engines; ignore file * also update .lintr_new * Update test-knitr_formats.R * Update NEWS.md * don't use bookdown vector * address review comment * Update test-knitr_extended_formats.R * update comment * fix tests * Use `loadNamespace()` instead * Update for tufte update * Update NEWS.md * extend/clarify comment * qualify rex namespace, use test_path() * use test_path() * much-extended NEWS item * grammar fix Co-authored-by: Indrajeet Patil <patilindrajeet.science@gmail.com> Co-authored-by: Michael Chirico <chiricom@google.com>
Consider the following Rmd (saved to e.g.
lintr-test.Rmd
):Linting the file has the following output:
To my understanding, it should lint the first two R chunks and ignores the third one.
However, the current chunk extraction does not seem to work consistently with knitr in that knitr treats
r
andR
as the same. Thetheorem
is brought up at REditorSupport/languageserver#421 where bookdown seems to provide some markdown extensions where additional engines are implemented (as introduced at https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html).I think the expected behavior should be linting the
R
orr
chunks and ignores all other chunks.The text was updated successfully, but these errors were encountered: