-
Notifications
You must be signed in to change notification settings - Fork 195
Description
Currently, if we want to skip linting certain lines in an Rmd file, we have two options (IIUC):
-
Include
# nolintor# nolint start/# nolint endin the code just like for .R scripts. This is somewhat awkward for .Rmd because .Rmd are especially made for reading, and readers are likely to be confused by these tags that have nothing to do with the tutorial (e.g.) per se. -
Include invisible chunks starting/stopping nolint ranges "behind the scenes", e.g.
```{r nolint_start, echo = FALSE} # nolint start: assignment_linter. ``` ```{r regular_chunk, ...} x = 4 ``` ```{r nolint_stop, echo = FALSE} # nolint end: assignment_linter. ```
This is also far from ideal and pretty limiting. It's OK for hiding whole files, but impractical for excluding small portions of code, as well as hugely increasing the amount of clutter in the source.
A good workaround IMO would be for lintr to understand an Rmd chunk option, e.g. nolint = :
```{r regular_chunk, ..., nolint = TRUE}
x = 4
```
I propose the following API for this option:
nolint = TRUE: exclude the chunk from lintingnolint = integer(n): exclude the lines listed innolint, given relative to the chunk (similar toeval, but we use lines instead of expressions)nolint = list(linter1 = TRUE || integer(n1), ..., linterk = TRUE || integer(nk)): linter-specific exclusions are given via named elements of a list, with the list elements' values being used just like one of the first two options
This should be a no-op from knitr's perspective and still analyzed statically, so e.g. knitr::opts_chunk is not a valid way to set this "pseudo-chunk option".