diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 48cf63577..4e77b61eb 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -39,7 +39,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.6.4 + uses: JamesIves/github-pages-deploy-action@v4.6.8 with: clean: false branch: gh-pages diff --git a/paper/.gitignore b/paper/.gitignore new file mode 100644 index 000000000..075b2542a --- /dev/null +++ b/paper/.gitignore @@ -0,0 +1 @@ +/.quarto/ diff --git a/paper/paper.Rmd b/paper/paper.Rmd index 05e3e3f61..e6f08cb0b 100644 --- a/paper/paper.Rmd +++ b/paper/paper.Rmd @@ -46,7 +46,7 @@ output: standalone: true bibliography: paper.bib csl: apa.csl -link-citations: yes +link-citations: true --- ```{r setup, warning=FALSE, message=FALSE, echo=FALSE} @@ -65,10 +65,12 @@ withr::local_options(list( # Statement of Need -R is an interpreted, dynamically-typed programming language [@base2023]. It is a popular choice for statistical analysis and visualization, and is used by a wide range of researchers and data scientists. The `{lintr}` package is an open-source R package that provides static code analysis [@enwiki:1218663830] to check for a variety of common problems related to readability, efficiency, consistency, style, etc. In particular, by default it enforces the tidyverse style guide [@Wickham2023]. It is designed to be easy to use and integrate into existing workflows, and can be used as part of an automated build or continuous integration process. `{lintr}` also integrates with a number of popular IDEs and text editors, such as RStudio and Visual Studio Code, making it convenient for users to run `{lintr}` checks on their code as they work. +A linter is a tool that analyzes code to identify potential errors, stylistic issues, or deviations from coding standards. It helps ensure consistency, readability, and best practices by flagging common mistakes, such as syntax errors, unused variables, or improper formatting. Linters are essential for improving code quality, preventing bugs, and maintaining a clean codebase, especially in collaborative development environments [@enwiki:1218663830]. `{lintr}` is an open-source package that provides linters for the R programming language, which is an interpreted, dynamically-typed programming language [@base2023], and is used by a wide range of researchers and data scientists. `{lintr}` can thus act as a valuable tool for R users to help improve the quality and reliability of their code. # Features +By default, `{lintr}` enforces the tidyverse style guide [@Wickham2023,@Müller2024]. In this respect, it differs from other static code analysis tools in R (like `{codetools}` [@Tierney2024]), which are not opinionated and don't enforce any particular style of writing code, but, rather, check R code for possible problems (incidentally, `{lintr}` uses `{codetools}` as a backend for object usage linters). Additionally, `{lintr}` is concerned only with R code, so code-adjacent text like inline `{roxygen2}` comments [@Wickham2024roxy] will not be covered (cf. `{roxylint}` [@Kelkhoff2024]). + As of this writing, `{lintr}` offers `r length(all_linters())` linters. ```{r all_linters} @@ -103,7 +105,7 @@ lint( - **Efficiency** -Sometimes the users might not be aware of a more efficient way offered by R for carrying out a computation. `{lintr}` offers linters to improve code efficiency by avoiding common inefficient patterns. +Sometimes users might not be aware of a more efficient way offered by R for carrying out a computation. `{lintr}` offers linters to improve code efficiency by avoiding common inefficient patterns. For example, the `any_is_na_linter()` linter detects usages of `any(is.na(x))` and suggests `anyNA(x)` as a more efficient alternative to detect presence of *any* missing values. @@ -217,11 +219,13 @@ There are two main ways to customize it: - Create new linters (by leveraging functions like `lintr::make_linter_from_xpath()`) tailored to match project- or organization-specific coding standards. +Indeed, `{goodpractice}` [@Padgham2024] bundles a set of custom linters that are not part of the default set of `{lintr}` linters, while `{box.linters}` [@Basa2024] extends `{lintr}` to support `{box}` modules [@Rudolph2024] and `{checklist}` includes linters as one of the strict checks for R packages [@Onkelinx2024]. `{flint}` [@Bacher2024] is a Rust-backed analogue inspired by `{lintr}` that also provides support for fixing lints. + # Benefits of using `{lintr}` There are several benefits to using `{lintr}` to analyze and improve R code. One of the most obvious is that it can help users identify and fix problems in their code, which can save time and effort during the development process. By catching issues early on, `{lintr}` can help prevent bugs and other issues from creeping into code, which can save time and effort when it comes to debugging and testing. -Another benefit of `{lintr}` is that it can help users write more readable and maintainable code. By enforcing a consistent style and highlighting potential issues, `{lintr}` can help users write code that is easier to understand and work with. This is especially important for larger projects or teams, where multiple contributors may be working on the same codebase and it is important to ensure that code is easy to follow and understand, particularly when frequently switching context among code primarily authored by different people. +Another benefit of `{lintr}` is that it can help users write more readable and maintainable code. By enforcing a consistent style and highlighting potential issues, `{lintr}` can help users write code that is easier to understand and work with. This is especially important for larger projects or teams, where multiple contributors may be working on the same codebase and it is important to ensure that code is easy to follow and understand, particularly when frequently switching context among code primarily authored by different people. `{lintr}` is designed to be easy to use and integrate into existing workflows, and can be used as part of an automated build or continuous integration process. `{lintr}` also integrates with a number of popular IDEs and text editors, such as RStudio and Visual Studio Code, making it convenient for users to run `{lintr}` checks on their code as they work. It can also be a useful tool for teaching and learning R. By providing feedback on code style and potential issues, it can help users learn good coding practices and improve their skills over time. This can be especially useful for beginners, who may not yet be familiar with all of the best practices for writing R code. diff --git a/paper/paper.bib b/paper/paper.bib index f9578f0c9..329f7c403 100644 --- a/paper/paper.bib +++ b/paper/paper.bib @@ -32,10 +32,86 @@ @book{mcconnell2004code publisher={Pearson Education} } - @misc{ enwiki:1218663830, +@misc{ enwiki:1218663830, author = "{Wikipedia contributors}", title = "Static program analysis --- {Wikipedia}{,} The Free Encyclopedia", year = "2024", url = "https://en.wikipedia.org/w/index.php?title=Static_program_analysis&oldid=1218663830", note = "[Online; accessed 7-May-2024]" } + +@Manual{Tierney2024, + title = {codetools: Code Analysis Tools for R}, + author = {Luke Tierney}, + year = {2024}, + note = {R package version 0.2-20}, + url = {https://CRAN.R-project.org/package=codetools}, + } + +@Manual{Bacher2024, + title = {flint: Find and Fix Lints in {R} Code}, + author = {Etienne Bacher}, + year = {2024}, + note = {R package version 0.0.2, +https://github.com/etiennebacher/flint}, + url = {https://flint.etiennebacher.com}, + } + +@Manual{Müller2024, + title = {styler: Non-Invasive Pretty Printing of R Code}, + author = {Kirill Müller and Lorenz Walthert and Indrajeet Patil}, + year = {2024}, + note = {R package version 1.10.3.9000, commit 6d2f0b34245b6bc712bf2fcabf240d9ca814f0ef}, + url = {https://github.com/r-lib/styler}, + } + +@Manual{Padgham2024, + title = {goodpractice: Advice on R Package Building}, + author = {Mark Padgham and Karina Marks and Daniel {de Bortoli} and Gabor Csardi and Hannah Frick and Owen Jones and Hannah Alexander}, + year = {2024}, + note = {R package version 1.0.5, +https://github.com/ropensci-review-tools/goodpractice}, + url = {https://docs.ropensci.org/goodpractice/}, + } + +@Manual{Rudolph2024, + title = {box: Write Reusable, Composable and Modular {R} Code}, + author = {Konrad Rudolph}, + year = {2024}, + note = {R package version 1.2.0}, + url = {https://CRAN.R-project.org/package=box}, + } + +@Manual{Basa2024, + title = {box.linters: Linters for 'box' Modules}, + author = {Ricardo Rodrigo Basa and Jakub Nowicki}, + year = {2024}, + note = {R package version 0.10.5}, + url = {https://CRAN.R-project.org/package=box.linters}, + } + +@Manual{Kelkhoff2024, + title = {roxylint: Lint 'roxygen2'-Generated Documentation}, + author = {Doug Kelkhoff}, + year = {2024}, + note = {R package version 0.1.0}, + url = {https://CRAN.R-project.org/package=roxylint}, + } + +@Manual{Wickham2024roxy, + title = {roxygen2: In-Line Documentation for {R}}, + author = {Hadley Wickham and Peter Danenberg and Gábor Csárdi and Manuel Eugster}, + year = {2024}, + note = {R package version 7.3.2}, + url = {https://CRAN.R-project.org/package=roxygen2}, + } + +@Manual{Onkelinx2024, + title = {checklist: A Thorough and Strict Set of Checks for {R} Packages and Source Code. Version 0.4.0}, + author = {Thierry Onkelinx}, + year = {2024}, + url = {https://inbo.github.io/checklist/}, + abstract = {An opinionated set of rules for R packages and R source code projects.}, + keywords = {quality control; documentation; publication}, + doi = {10.5281/zenodo.4028303}, + } diff --git a/paper/paper.md b/paper/paper.md index ebdc1677d..27793ea75 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -1,6 +1,6 @@ --- title: "Static Code Analysis for R" -date: "2024-09-05" +date: "2024-10-02" tags: ["R", "linter", "tidyverse"] authors: - name: Jim Hester @@ -46,27 +46,37 @@ output: standalone: true bibliography: paper.bib csl: apa.csl -link-citations: yes +link-citations: true --- # Statement of Need -R is an interpreted, dynamically-typed programming language [@base2023]. -It is a popular choice for statistical analysis and visualization, and -is used by a wide range of researchers and data scientists. The -`{lintr}` package is an open-source R package that provides static code -analysis [@enwiki:1218663830] to check for a variety of common problems -related to readability, efficiency, consistency, style, etc. In -particular, by default it enforces the tidyverse style guide -[@Wickham2023]. It is designed to be easy to use and integrate into -existing workflows, and can be used as part of an automated build or -continuous integration process. `{lintr}` also integrates with a number -of popular IDEs and text editors, such as RStudio and Visual Studio -Code, making it convenient for users to run `{lintr}` checks on their -code as they work. +A linter is a tool that analyzes code to identify potential errors, +stylistic issues, or deviations from coding standards. It helps ensure +consistency, readability, and best practices by flagging common +mistakes, such as syntax errors, unused variables, or improper +formatting. Linters are essential for improving code quality, preventing +bugs, and maintaining a clean codebase, especially in collaborative +development environments [@enwiki:1218663830]. `{lintr}` is an +open-source package that provides linters for the R programming +language, which is an interpreted, dynamically-typed programming +language [@base2023], and is used by a wide range of researchers and +data scientists. `{lintr}` can thus act as a valuable tool for R users +to help improve the quality and reliability of their code. # Features +By default, `{lintr}` enforces the tidyverse style guide +[@Wickham2023,@Müller2024]. In this respect, it differs from other +static code analysis tools in R (like `{codetools}` [@Tierney2024]), +which are not opinionated and don't enforce any particular style of +writing code, but, rather, check R code for possible problems +(incidentally, `{lintr}` uses `{codetools}` as a backend for object +usage linters). Additionally, `{lintr}` is concerned only with R code, +so code-adjacent text like inline `{roxygen2}` comments +[@Wickham2024roxy] will not be covered (cf. `{roxylint}` +[@Kelkhoff2024]). + As of this writing, `{lintr}` offers 113 linters. ``` r @@ -115,9 +125,9 @@ lint( - **Efficiency** -Sometimes the users might not be aware of a more efficient way offered -by R for carrying out a computation. `{lintr}` offers linters to improve -code efficiency by avoiding common inefficient patterns. +Sometimes users might not be aware of a more efficient way offered by R +for carrying out a computation. `{lintr}` offers linters to improve code +efficiency by avoiding common inefficient patterns. For example, the `any_is_na_linter()` linter detects usages of `any(is.na(x))` and suggests `anyNA(x)` as a more efficient alternative @@ -285,6 +295,14 @@ lint( `lintr::make_linter_from_xpath()`) tailored to match project- or organization-specific coding standards. +Indeed, `{goodpractice}` [@Padgham2024] bundles a set of custom linters +that are not part of the default set of `{lintr}` linters, while +`{box.linters}` [@Basa2024] extends `{lintr}` to support `{box}` modules +[@Rudolph2024] and `{checklist}` includes linters as one of the strict +checks for R packages [@Onkelinx2024]. `{flint}` [@Bacher2024] is a +Rust-backed analogue inspired by `{lintr}` that also provides support +for fixing lints. + # Benefits of using `{lintr}` There are several benefits to using `{lintr}` to analyze and improve R @@ -301,7 +319,12 @@ is easier to understand and work with. This is especially important for larger projects or teams, where multiple contributors may be working on the same codebase and it is important to ensure that code is easy to follow and understand, particularly when frequently switching context -among code primarily authored by different people. +among code primarily authored by different people. `{lintr}` is designed +to be easy to use and integrate into existing workflows, and can be used +as part of an automated build or continuous integration process. +`{lintr}` also integrates with a number of popular IDEs and text +editors, such as RStudio and Visual Studio Code, making it convenient +for users to run `{lintr}` checks on their code as they work. It can also be a useful tool for teaching and learning R. By providing feedback on code style and potential issues, it can help users learn