Skip to content

Commit 86784c1

Browse files
Remove R development dependencies (#4306)
Co-authored-by: Bouwe Andela <b.andela@esciencecenter.nl>
1 parent 2c459ce commit 86784c1

3 files changed

Lines changed: 25 additions & 47 deletions

File tree

doc/sphinx/source/community/code_documentation.rst

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,30 @@ R
274274
~
275275

276276
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
283301
`goodpractice <https://cran.r-project.org/web/packages/goodpractice/index.html>`__
284302
to assess the quality of R code.
285303

environment.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ dependencies:
9696

9797
# R and dependencies
9898
- cdo
99-
- r-base >=3.5
99+
- r-base >=4.4
100100
- r-abind
101101
- r-akima
102102
- r-climdex.pcic
@@ -121,7 +121,3 @@ dependencies:
121121
- r-spei
122122
- r-udunits2
123123
- r-yaml
124-
# R packages needed for development
125-
- r-git2r # dependency of lintr
126-
- r-lintr ==3.1.2
127-
- r-styler ==1.10.3

tests/unit/test_lint.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
"""Lint tests."""
22

3-
import os
4-
import subprocess
5-
import sys
63
import textwrap
74
from pathlib import Path
85

9-
import pytest
10-
116
import esmvaltool
127
from esmvaltool.utils.nclcodestyle import nclcodestyle
138

@@ -47,34 +42,3 @@ def test_nclcodestyle():
4742
)
4843

4944
assert success, "Your NCL code does not follow our formatting standards."
50-
51-
52-
@pytest.mark.installation
53-
@pytest.mark.skipif(
54-
sys.platform == "darwin",
55-
reason="ESMValTool R not supported on OSX",
56-
)
57-
def test_r_lint(monkeypatch):
58-
"""Test R lint."""
59-
monkeypatch.setenv("LINTR_COMMENT_BOT", "FALSE")
60-
package_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
61-
checker = os.path.join(package_root, "tests", "unit", "check_r_code.R")
62-
try:
63-
output = subprocess.check_output(
64-
("Rscript", checker, package_root),
65-
stderr=subprocess.STDOUT,
66-
universal_newlines=True,
67-
)
68-
print(output)
69-
return
70-
except subprocess.CalledProcessError as ex:
71-
print(
72-
textwrap.dedent("""
73-
Your R code does not follow our formatting standards.
74-
75-
Please fix the following issues:
76-
"""),
77-
)
78-
print(ex.output)
79-
80-
assert False, "Your R code does not follow our formatting standards."

0 commit comments

Comments
 (0)