Skip to content

Commit 1db7cc7

Browse files
Address feedback from Reviewer-1 (#2664)
1 parent fa787b6 commit 1db7cc7

File tree

4 files changed

+128
-24
lines changed

4 files changed

+128
-24
lines changed

paper/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.quarto/

paper/paper.Rmd

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ output:
4646
standalone: true
4747
bibliography: paper.bib
4848
csl: apa.csl
49-
link-citations: yes
49+
link-citations: true
5050
---
5151

5252
```{r setup, warning=FALSE, message=FALSE, echo=FALSE}
@@ -65,10 +65,12 @@ withr::local_options(list(
6565

6666
# Statement of Need
6767

68-
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.
68+
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.
6969

7070
# Features
7171

72+
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]).
73+
7274
As of this writing, `{lintr}` offers `r length(all_linters())` linters.
7375

7476
```{r all_linters}
@@ -103,7 +105,7 @@ lint(
103105

104106
- **Efficiency**
105107

106-
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.
108+
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.
107109

108110
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.
109111

@@ -217,11 +219,13 @@ There are two main ways to customize it:
217219

218220
- Create new linters (by leveraging functions like `lintr::make_linter_from_xpath()`) tailored to match project- or organization-specific coding standards.
219221

222+
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.
223+
220224
# Benefits of using `{lintr}`
221225

222226
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.
223227

224-
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.
228+
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.
225229

226230
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.
227231

paper/paper.bib

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,86 @@ @book{mcconnell2004code
3232
publisher={Pearson Education}
3333
}
3434

35-
@misc{ enwiki:1218663830,
35+
@misc{ enwiki:1218663830,
3636
author = "{Wikipedia contributors}",
3737
title = "Static program analysis --- {Wikipedia}{,} The Free Encyclopedia",
3838
year = "2024",
3939
url = "https://en.wikipedia.org/w/index.php?title=Static_program_analysis&oldid=1218663830",
4040
note = "[Online; accessed 7-May-2024]"
4141
}
42+
43+
@Manual{Tierney2024,
44+
title = {codetools: Code Analysis Tools for R},
45+
author = {Luke Tierney},
46+
year = {2024},
47+
note = {R package version 0.2-20},
48+
url = {https://CRAN.R-project.org/package=codetools},
49+
}
50+
51+
@Manual{Bacher2024,
52+
title = {flint: Find and Fix Lints in {R} Code},
53+
author = {Etienne Bacher},
54+
year = {2024},
55+
note = {R package version 0.0.2,
56+
https://github.com/etiennebacher/flint},
57+
url = {https://flint.etiennebacher.com},
58+
}
59+
60+
@Manual{Müller2024,
61+
title = {styler: Non-Invasive Pretty Printing of R Code},
62+
author = {Kirill Müller and Lorenz Walthert and Indrajeet Patil},
63+
year = {2024},
64+
note = {R package version 1.10.3.9000, commit 6d2f0b34245b6bc712bf2fcabf240d9ca814f0ef},
65+
url = {https://github.com/r-lib/styler},
66+
}
67+
68+
@Manual{Padgham2024,
69+
title = {goodpractice: Advice on R Package Building},
70+
author = {Mark Padgham and Karina Marks and Daniel {de Bortoli} and Gabor Csardi and Hannah Frick and Owen Jones and Hannah Alexander},
71+
year = {2024},
72+
note = {R package version 1.0.5,
73+
https://github.com/ropensci-review-tools/goodpractice},
74+
url = {https://docs.ropensci.org/goodpractice/},
75+
}
76+
77+
@Manual{Rudolph2024,
78+
title = {box: Write Reusable, Composable and Modular {R} Code},
79+
author = {Konrad Rudolph},
80+
year = {2024},
81+
note = {R package version 1.2.0},
82+
url = {https://CRAN.R-project.org/package=box},
83+
}
84+
85+
@Manual{Basa2024,
86+
title = {box.linters: Linters for 'box' Modules},
87+
author = {Ricardo Rodrigo Basa and Jakub Nowicki},
88+
year = {2024},
89+
note = {R package version 0.10.5},
90+
url = {https://CRAN.R-project.org/package=box.linters},
91+
}
92+
93+
@Manual{Kelkhoff2024,
94+
title = {roxylint: Lint 'roxygen2'-Generated Documentation},
95+
author = {Doug Kelkhoff},
96+
year = {2024},
97+
note = {R package version 0.1.0},
98+
url = {https://CRAN.R-project.org/package=roxylint},
99+
}
100+
101+
@Manual{Wickham2024roxy,
102+
title = {roxygen2: In-Line Documentation for {R}},
103+
author = {Hadley Wickham and Peter Danenberg and Gábor Csárdi and Manuel Eugster},
104+
year = {2024},
105+
note = {R package version 7.3.2},
106+
url = {https://CRAN.R-project.org/package=roxygen2},
107+
}
108+
109+
@Manual{Onkelinx2024,
110+
title = {checklist: A Thorough and Strict Set of Checks for {R} Packages and Source Code. Version 0.4.0},
111+
author = {Thierry Onkelinx},
112+
year = {2024},
113+
url = {https://inbo.github.io/checklist/},
114+
abstract = {An opinionated set of rules for R packages and R source code projects.},
115+
keywords = {quality control; documentation; publication},
116+
doi = {10.5281/zenodo.4028303},
117+
}

paper/paper.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Static Code Analysis for R"
3-
date: "2024-09-05"
3+
date: "2024-10-02"
44
tags: ["R", "linter", "tidyverse"]
55
authors:
66
- name: Jim Hester
@@ -46,27 +46,37 @@ output:
4646
standalone: true
4747
bibliography: paper.bib
4848
csl: apa.csl
49-
link-citations: yes
49+
link-citations: true
5050
---
5151

5252
# Statement of Need
5353

54-
R is an interpreted, dynamically-typed programming language [@base2023].
55-
It is a popular choice for statistical analysis and visualization, and
56-
is used by a wide range of researchers and data scientists. The
57-
`{lintr}` package is an open-source R package that provides static code
58-
analysis [@enwiki:1218663830] to check for a variety of common problems
59-
related to readability, efficiency, consistency, style, etc. In
60-
particular, by default it enforces the tidyverse style guide
61-
[@Wickham2023]. It is designed to be easy to use and integrate into
62-
existing workflows, and can be used as part of an automated build or
63-
continuous integration process. `{lintr}` also integrates with a number
64-
of popular IDEs and text editors, such as RStudio and Visual Studio
65-
Code, making it convenient for users to run `{lintr}` checks on their
66-
code as they work.
54+
A linter is a tool that analyzes code to identify potential errors,
55+
stylistic issues, or deviations from coding standards. It helps ensure
56+
consistency, readability, and best practices by flagging common
57+
mistakes, such as syntax errors, unused variables, or improper
58+
formatting. Linters are essential for improving code quality, preventing
59+
bugs, and maintaining a clean codebase, especially in collaborative
60+
development environments [@enwiki:1218663830]. `{lintr}` is an
61+
open-source package that provides linters for the R programming
62+
language, which is an interpreted, dynamically-typed programming
63+
language [@base2023], and is used by a wide range of researchers and
64+
data scientists. `{lintr}` can thus act as a valuable tool for R users
65+
to help improve the quality and reliability of their code.
6766

6867
# Features
6968

69+
By default, `{lintr}` enforces the tidyverse style guide
70+
[@Wickham2023,@Müller2024]. In this respect, it differs from other
71+
static code analysis tools in R (like `{codetools}` [@Tierney2024]),
72+
which are not opinionated and don't enforce any particular style of
73+
writing code, but, rather, check R code for possible problems
74+
(incidentally, `{lintr}` uses `{codetools}` as a backend for object
75+
usage linters). Additionally, `{lintr}` is concerned only with R code,
76+
so code-adjacent text like inline `{roxygen2}` comments
77+
[@Wickham2024roxy] will not be covered (cf. `{roxylint}`
78+
[@Kelkhoff2024]).
79+
7080
As of this writing, `{lintr}` offers 113 linters.
7181

7282
``` r
@@ -115,9 +125,9 @@ lint(
115125

116126
- **Efficiency**
117127

118-
Sometimes the users might not be aware of a more efficient way offered
119-
by R for carrying out a computation. `{lintr}` offers linters to improve
120-
code efficiency by avoiding common inefficient patterns.
128+
Sometimes users might not be aware of a more efficient way offered by R
129+
for carrying out a computation. `{lintr}` offers linters to improve code
130+
efficiency by avoiding common inefficient patterns.
121131

122132
For example, the `any_is_na_linter()` linter detects usages of
123133
`any(is.na(x))` and suggests `anyNA(x)` as a more efficient alternative
@@ -285,6 +295,14 @@ lint(
285295
`lintr::make_linter_from_xpath()`) tailored to match project- or
286296
organization-specific coding standards.
287297

298+
Indeed, `{goodpractice}` [@Padgham2024] bundles a set of custom linters
299+
that are not part of the default set of `{lintr}` linters, while
300+
`{box.linters}` [@Basa2024] extends `{lintr}` to support `{box}` modules
301+
[@Rudolph2024] and `{checklist}` includes linters as one of the strict
302+
checks for R packages [@Onkelinx2024]. `{flint}` [@Bacher2024] is a
303+
Rust-backed analogue inspired by `{lintr}` that also provides support
304+
for fixing lints.
305+
288306
# Benefits of using `{lintr}`
289307

290308
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
301319
larger projects or teams, where multiple contributors may be working on
302320
the same codebase and it is important to ensure that code is easy to
303321
follow and understand, particularly when frequently switching context
304-
among code primarily authored by different people.
322+
among code primarily authored by different people. `{lintr}` is designed
323+
to be easy to use and integrate into existing workflows, and can be used
324+
as part of an automated build or continuous integration process.
325+
`{lintr}` also integrates with a number of popular IDEs and text
326+
editors, such as RStudio and Visual Studio Code, making it convenient
327+
for users to run `{lintr}` checks on their code as they work.
305328

306329
It can also be a useful tool for teaching and learning R. By providing
307330
feedback on code style and potential issues, it can help users learn

0 commit comments

Comments
 (0)