r-devel / r-dev-env

A containerised development environment for editing and compiling the R source code.
https://contributor.r-project.org/r-dev-env/
MIT License
29 stars 6 forks source link

Use a linter that follows R core guidelines #49

Closed hturner closed 2 days ago

hturner commented 1 year ago

Currently the linter in VS code shows the indentation in R/trunsrc/utils/ as being incorrect.

Ideally we would have a linter that does not complain about existing R code in base R, since R Core do not want changes in a patch that are just altering the style.

To investigate: What linter is currently used? Is it https://cran.r-project.org/web/packages/lintr/index.html? Can we adapt it?

Note that relying on an add-on package presents similar issues as discussed in #25.

hturner commented 1 year ago

Yes, the linting is done with lintr via languageserver and we can customise it: https://github.com/REditorSupport/vscode-R/wiki/Code-linting.

jamestripp commented 1 year ago

We can configure the lintr options via a .lintr file (a relevant screenshot from the lintr vignette is below). That gives us options for changing the settings if they deviate from best practice for the R source code.

image

hturner commented 7 months ago

I had a look at an example file from the R sources (http://svn.r-project.org/R/trunk/src/library/stats/R/anova.R), where the current linter shows many issues. I could customise the linter a little bit to make some of these issues go away, but some issues were unresolvable, e.g.

So I think it is better for us to turn the linter off. This can be done by changing the setting "r.lsp.diagnostics" to false. (c.f. https://stackoverflow.com/questions/68858490/disable-r-linting-in-vscode).

If you do this in an active codespace, you need to restart to see the effect. Hopefully we can make this the setting from the start, I think we are already changing some settings in the container.

hturner commented 2 days ago

The linter was disabled in v0.2 and screenshots have since been updated so no longer show linting problems.