NIEHS / beethoven

BEETHOVEN is: Building an Extensible, rEproducible, Test-driven, Harmonized, Open-source, Versioned, ENsemble model for air quality
https://niehs.github.io/beethoven/
Other
4 stars 0 forks source link

Linting bypass for cyclomatic complexity cases #208

Closed sigmafelix closed 9 months ago

sigmafelix commented 9 months ago

Before

download_something <- function () {
    if (...) {download.file(...)} else { return(NULL) }
}

After

# nolint start
download_something <- function () {
    if (...) {download.file(...)} else { return(NULL) }
}
# nolint end

It should be noted that bypassing should be allowed to functions with cyclomatic complexity only. Codes in general should abide by the general style guidance from linters. To see whether there is cyclomatic complexity, please run linter this code in RStudio Addins > Lint current file

image

After linting, a tab named "Markers" will appear at the third quadrant (given that your RStudio is in default panel configurations).

sigmafelix commented 9 months ago

Relevant download functions in ./input/Rinput/download_functions got # nolint start and # nolint end in my working branch isong-calc-covar.

sigmafelix commented 9 months ago

This issue is moved to "Wiki" section.

mitchellmanware commented 9 months ago

@sigmafelix

Another way to implement #nolint on the data download functions is with a .lintr configuration file. The configuration file will allow us to "exclude" specific lines/sections of code in the download...data.R functions from one or more linters, in this case the cyclocomp_linter.

Using this method we can ensure that all other linters are applied to the download functions, and avoid potentially confusing #nolint start/end lines of code within the R/ folder.

I have explored the .lintr configuration file on branch mm_download_function_enhancements_1117, and applied it to the GEOS-CF, GMTED, and NCEP NARR data download functions.

https://cran.r-project.org/web/packages/lintr/vignettes/lintr.html

sigmafelix commented 9 months ago

@mitchellmanware Sounds good. I will delete the obsolete wiki page.