-
Notifications
You must be signed in to change notification settings - Fork 22
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
Document coding style used by R Core #133
Comments
Perhaps we can recommend use of lintr cc @MichaelChirico. |
In all my talks on the issue, I had emphasized that humans can much better format code than algorithms. |
more than happy to collaborate developing linters specific to base R. it really is an unfortunate experience to have a patch delayed due to stylistic issues -- having linters in place to at least cover some "don'ts" while leaving the "dos" more up to human judgment is certainly doable. |
@hturner Can we make a task list for this issue to keep track of things being committed in the new chapter and the things that still need to be added? |
@itsdebartha I updated my comment with an initial checklist. Meanwhile I re-discovered this vignette: https://cran.r-project.org/web/packages/rockchalk/vignettes/Rstyle.pdf, which gives guidance on style based on studying the source code of R and CRAN packages, along with an SEA score ("Subjective and completely unscientific personal Estimate Since this issue was motivated by a question on the R Contributor Slack about indentation style for C, I have done a little more digging. The R coding standards recommend to set the (See Indentation Styles). So all we can say is that the C code in R follows the GNU coding standards for C code in that the open-brace that starts the body of a C function should be in column one. Indentation in R code is similarly inconsistent. If we |
Discussed a bit about this issue during the R Development Hackathon at RSECon24. I would be happy to contribute a chapter for this as discussed with @hturner and @SaranjeetKaur. |
Is your feature request related to a problem? Please describe.
Contributors should be aware of the style typically used by R Core, so that R Core can focus on the code and not style issues when reviewing patches. Questions about style have come up on the Slack and I have also given feedback about this when reviewing patches before submission to Bugzilla.
Describe the solution you'd like
A new chapter/section on style. There is a little about R coding standards in the R-internals manual, e.g. using an indentation of 4 spaces in R and C code. Other style points I'm not sure are documented anywhere but I think are generally followed:
<-
rather than=
for assignment"
rather than'
for quoting textTRUE
andFALSE
notT
andF
We could work through https://style.tidyverse.org/ to check what is common to base R. @mmaechler has also given talks about style and may know if there is another reference we should use.
Describe alternatives you've considered
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: