Skip to content

Commit abf7773

Browse files
authored
Merge pull request #477 from UCD-SERG/update-lintr-config
update lintr config
2 parents 7574dbc + fbb74e3 commit abf7773

4 files changed

Lines changed: 89 additions & 12 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ allpopsamples_hlye.csv$
3636
^vignettes/articles/\.quarto$
3737
^vignettes/articles/*_files$
3838
^man/check_strata\.Rd$
39+
^\.lintr\.R$

.lintr

Lines changed: 0 additions & 10 deletions
This file was deleted.

.lintr.R

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
3+
undesirable_functions <-
4+
lintr::default_undesirable_functions |>
5+
lintr::modify_defaults(
6+
7+
# following https://github.com/r-lib/devtools/blob/2aa51ef/.lintr.R:
8+
# Base messaging
9+
"message" = "use cli::cli_inform()",
10+
"warning" = "use cli::cli_warn()",
11+
"stop" = "use cli::cli_abort()",
12+
# rlang messaging
13+
"inform" = "use cli::cli_inform()",
14+
"warn" = "use cli::cli_warn()",
15+
"abort" = "use cli::cli_abort()",
16+
# older cli
17+
"cli_alert_danger" = "use cli::cli_inform()",
18+
"cli_alert_info" = "use cli::cli_inform()",
19+
"cli_alert_success" = "use cli::cli_inform()",
20+
"cli_alert_warning" = "use cli::cli_inform()",
21+
22+
library = paste(
23+
"\nuse `::`, `usethis::use_import_from()`, or `withr::local_package()`",
24+
"instead of modifying the global search path.",
25+
"\nSee:\n",
26+
"<https://r-pkgs.org/code.html#sec-code-r-landscape> and\n",
27+
"<https://r-pkgs.org/testing-design.html#sec-testing-design-self-contained>",
28+
"\nfor more details."
29+
),
30+
31+
structure = NULL,
32+
browser = NULL
33+
# see https://github.com/r-lib/lintr/pull/2227 and
34+
# rebuttal https://github.com/r-lib/lintr/pull/2227#issuecomment-1800302675
35+
36+
)
37+
38+
# define snake_case with uppercase acronyms allowed;
39+
# see https://github.com/r-lib/lintr/issues/2844 for details:
40+
withr::local_package("rex")
41+
snake_case_ACROs1 <- rex::rex(
42+
start,
43+
maybe("."),
44+
list(some_of(upper), maybe("s"), zero_or_more(digit)) %or% list(some_of(lower), zero_or_more(digit)),
45+
zero_or_more(
46+
"_",
47+
list(some_of(upper), maybe("s"), zero_or_more(digit)) %or% list(some_of(lower), zero_or_more(digit))
48+
),
49+
end
50+
)
51+
52+
linters <- lintr::linters_with_defaults(
53+
return_linter = NULL,
54+
trailing_whitespace_linter = NULL,
55+
lintr::redundant_equals_linter(),
56+
lintr::pipe_consistency_linter(pipe = "|>"),
57+
lintr::object_name_linter(
58+
regexes = c(snake_case_ACROs1 = snake_case_ACROs1)
59+
),
60+
lintr::undesirable_function_linter(
61+
fun = undesirable_functions,
62+
symbol_is_undesirable = TRUE
63+
)
64+
)
65+
66+
# prevent warnings from lintr::read_settings:
67+
rm(undesirable_functions)
68+
rm(snake_case_ACROs1)
69+
exclusions <- list(
70+
`data-raw` = list(
71+
pipe_consistency_linter = Inf,
72+
undesirable_function_linter = Inf
73+
),
74+
vignettes = list(
75+
undesirable_function_linter = Inf,
76+
object_name_linter = Inf
77+
),
78+
"inst/examples" = list(
79+
undesirable_function_linter = Inf
80+
),
81+
"tests/testthat.R" = list(
82+
undesirable_function_linter = Inf
83+
)
84+
85+
)

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: serocalculator
33
Title: Estimating Infection Rates from Serological Data
4-
Version: 1.4.0.9000
4+
Version: 1.4.0.9001
55
Authors@R: c(
66
person("Kristina", "Lai", , "kwlai@ucdavis.edu", role = c("aut", "cre")),
77
person("Chris", "Orwa", role = "aut"),
@@ -63,7 +63,8 @@ Suggests:
6363
qrcode,
6464
vdiffr,
6565
withr,
66-
forcats
66+
forcats,
67+
rex
6768
LinkingTo:
6869
Rcpp
6970
Config/testthat/edition: 3

0 commit comments

Comments
 (0)