I am trying to extend SublimeLinter with a linter for R. SublimeLinter provides automatic linting in Sublime Text 2 for a lot of languages. The goal is that the linter runs in the background and highlights lines with coding errors or bad coding style.
Currently, I am using the lint
function in the svTools
package and it's working. The results, however, are not every satisfying. The linter catches to many )
in a line or to many }
but it doesn't detect the use of undefined variables, no coding style etc.
Are there any other options? I am aware of this discussion Writing a R lint program, R CMD check
, and codetools
. But how can I run R CMD check
on a normal .r file and not a package? What options should be used for an on the fly linter? Any other ideas?
Thanks!
edit: the lint
function also does not seem to be very good in detecting the location of the error or it basically always indicates column 1. For example, in fn = function(...) { ]
the column is 1 not the ]
at the end.
ps: I know that the lint
function is a wrapper for checkUsage()
...
Take a look at Andrew's (lint author) github repository, in particular NppToR for ideas on the editor integration.
As for how to run R CMD check on a normal .r file you could create a package skeleton and use the R path as a cache for the currently edited file. Obviously figuring out the best/required R CMD check options as you go; though it may be easier to read the source for how R CMD is doing what it does, as well as how some of the open source R IDEs make use of and parse the output (ie: RStudio and its' error reporting).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With