|
274 | 274 | ~ |
275 | 275 |
|
276 | 276 | Best practices for R code are described in `The tidyverse style |
277 | | -guide <https://style.tidyverse.org/>`__. We check adherence to this |
278 | | -style guide by using |
279 | | -`lintr <https://cran.r-project.org/web/packages/lintr/index.html>`__ on |
280 | | -CircleCI. Please use `styler <https://styler.r-lib.org/>`__ to |
281 | | -automatically format your code according to this style guide. In the |
282 | | -future we would also like to make use of |
| 277 | +guide <https://style.tidyverse.org/>`__. We currently don't check adherence |
| 278 | +to this, but we strongly encourage any new R diagnostic to be checked against the |
| 279 | +style guide by using `lintr <https://cran.r-project.org/web/packages/lintr/index.html>`__. |
| 280 | +Please use `styler <https://styler.r-lib.org/>`__ to automatically format your code according |
| 281 | +to this style guide. To run these tools, uncomment these lines: |
| 282 | + |
| 283 | +.. literalinclude:: ../../../../.pre-commit-config.yaml |
| 284 | + :language: yaml |
| 285 | + :start-at: # - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R |
| 286 | + :end-at: - id: lintr |
| 287 | + :caption: R configuration in ``.pre-commit-config.yaml``. |
| 288 | + |
| 289 | +and run the commands: |
| 290 | + |
| 291 | +.. code-block:: bash |
| 292 | +
|
| 293 | + pre-commit run style-files --files esmvaltool/diag_scripts/your_script.R |
| 294 | + pre-commit run lintr --files esmvaltool/diag_scripts/your_script.R |
| 295 | +
|
| 296 | +These pre-commit hooks have been disabled by default because over the past few |
| 297 | +years all diagnostics that have been contributed were written in Python. |
| 298 | +However, if R contributions pick up again, we would be happy to enable these |
| 299 | +pre-commit hooks again. |
| 300 | +In the future we would also like to make use of |
283 | 301 | `goodpractice <https://cran.r-project.org/web/packages/goodpractice/index.html>`__ |
284 | 302 | to assess the quality of R code. |
285 | 303 |
|
|
0 commit comments