NOAA-FIMS / collaborative_workflow

contributors guide to FIMS, managing collaborations
https://noaa-fims.github.io/collaborative_workflow/
4 stars 1 forks source link

change to tidyverse style guide instead of Google for R code #133

Closed kellijohnson-NOAA closed 2 weeks ago

kellijohnson-NOAA commented 2 months ago

Is your feature request related to a problem? Please describe.

The collaborative workflow calls out the use of the Google Code Style Guide for R and C++ but the R interface team is proposing that we change to the less restrictive tidyverse style guide for the R code. The Google Guide is based off of the tidyverse guide. We are not proposing any changes to the C++ guide.

The main change is that the tidyverse guide recommends functions are named as verbs using snake_case rather than UpperCamelCase. We are not currently following the UpperCamelCase convention in the code base. Also, we believe that it will be difficult to set up a lintr to catch that function names are not UpperCamelCase.

There are three additional deviations between the guides. (1) The Google Guide does not allow the use of the right-hand assignment but the tidyverse guide declares it as a "lesser used" option in the section on assignments. (2) The Google Guide uses explicit return() statements in EVERY function. (3) The Google Guide calls for using :: with every function that does not come from a base R package. Regarding (2), there are MANY debates on the web if R users should make explicit calls to return() at the end of every function and @iantaylor-NOAA wisely pointed out during our group discussion on this that the code is still easy to read and functional with or without it so we did not see the loss of this rule as a negative. In Hadley and Jenny's book on building R packages they talk about (3) and recommend that you "almost" always use ::.

Describe the solution you'd like

Use the tidyverse style guide for the R code.

If you are opposed to the change feel free to make a comment below, give a thumbs down to this issue, email Kelli, or express your concern to a member of the FIMS implementation team if you do not feel comfortable emailing the issue creator and your feedback can be provided to me anonymously.

If the change is not denied in the next week, then the R interface group will submit a pull request to that can be reviewed by the documentation team.

Describe alternatives you've considered

Leave the Google Style Guide as the referenced guide for the R code and potentially update the code base to adhere to it.

Additional context Add any other context or screenshots about the feature request here.