When I program in python, I find using pylint very useful. However, when I program in R, there is nothing comparable.
As a small side project, I thought it would be fun to try and write a small lint program. Nothing too fancy, something along the lines of:
function(x=1, y=2)
instead of function(x=1,y=2)
However, I'm unsure of how to get started (I have started to look through the pylint soure code).
How should I get started? Are there standard programming techniques for this type of project? Any good resources that I should consider?
I would like to write the entire project in R.
lintr provides static code analysis for R. It checks for adherence to a given style, identifying syntax errors and possible semantic issues, then reports them to you so you can take action.
Definition of linter 1 : a machine for removing linters. 2 linters plural : the fuzz of short fibers that adheres to cottonseed after ginning.
Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs. The term originates from a Unix utility that examined C language source code.
Take a look at package codetools
that comes with R. Some details are found on the CRAN page for the package. The code in the package is run when you do R CMD check
for example so can catch unused variables etc. That might get you started on that aspect of rlint
.
To answer some of the other aspects... I'd start of writing simple functions that do one task, such as convert functions names to camel case. As you build up a body of small functions you can amalgamate them into a working lint wrapper function, whilst allowing users/developers flexibility to call the specific functions if they don't want the full lint behaviour.
lintr is an R package that does code linting for both style and possible semantic errors. It uses codetools under the hood as well as additional linting on top of it.
It also integrates with Emacs, Vim, Sublime Text and RStudio.
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