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

<% a %> in knitr source code #185

Closed
gaborcsardi opened this issue Nov 10, 2016 · 4 comments
Closed

<% a %> in knitr source code #185

gaborcsardi opened this issue Nov 10, 2016 · 4 comments

Comments

@gaborcsardi
Copy link
Member

lintr fails on knits with this:

Error in grep(pattern$chunk.begin, lines, perl = TRUE) :
  invalid 'pattern' argument

To reproduce:

cat("'<% a %>'\n", file = tmp <- tempfile());
lintr::lint(tmp)
#> Error in grep(pattern$chunk.begin, lines, perl = TRUE) :
#>   invalid 'pattern' argument
@jimhester
Copy link
Member

This looks to be because in knitr the brew pattern has only an inline pattern, not a chunk start or end.

FWIW In devel lintr you can now pass strings directly to lintr::lint() if you end them with a newline.

 lintr::lint("'<% a %>'\n")
#> <text>:1:1: style: Only use double-quotes.
#> '<% a %>'
#> ^~~~~~~~~
#> <text>:2:1: style: Trailing blank lines are superfluous.
#> 
#> ^

@gaborcsardi
Copy link
Member Author

Thanks!

Btw. knitr is nasty because its files are full of the knitr patterns, obviously. see #127

Do you need to use those patterns for parsing? I haven't looked much, but in reneral it would be great to parse without them, or at least not everything.

FWIW In devel lintr you can now pass strings directly to lintr::lint() if you end them with a newline.

But then how do I lint my files whose name ends with a newline? :P

@jimhester
Copy link
Member

after 72f1985, 7fe7e90 knitr is now fully lintable and returns 5,569 lints with the default linters :).

Maybe not necessary for everything, it seemed easier to do it this way rather than have a file extension whitelist or something.

@gaborcsardi
Copy link
Member Author

I don't mind the lints, just the errors....

Anyway, maybe I'll take a look, I'll pick up goodpractice soon again, and will do some lintr related stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants