Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the options for integrating a R linter in a text editors? lint in svTools, codetools etc

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()...

like image 619
user2503795 Avatar asked Apr 26 '12 09:04

user2503795


1 Answers

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).

like image 91
Thell Avatar answered Nov 05 '22 14:11

Thell