Skip to content

Commit 4b3d4a3

Browse files
committed
feat: update our default_linters for lintr >= 3.2.0
1 parent 9b165d6 commit 4b3d4a3

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Imports:
3636
Suggests:
3737
desc (>= 1.4.0),
3838
devtools (>= 2.4.4),
39-
lintr (>= 3.1.1),
39+
lintr (>= 3.2.0),
4040
pkgload (>= 1.3.0),
4141
pkgsnip (>= 0.0.9037),
4242
rstudioapi (>= 0.13),

R/sysdata.rda

14.9 KB
Binary file not shown.

Rmd/sysdata.nopurl.Rmd

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,33 @@ editor_options:
2020

2121
## `default_linters`
2222

23+
NOTES:
24+
25+
- Non-default linters that we tested but dismissed due to annoyance or disagreement include:
26+
27+
- `nested_pipe_linter` (nesting pipes doesn't ncessarily have to make the code less-readable, on the contrary!)
28+
- `strings_as_factors_linter` (unnecessary when the code requires R \>= 4.0)
29+
2330
```{r}
2431
default_linters <- lintr::linters_with_defaults(
2532
absolute_path_linter = lintr::absolute_path_linter(),
2633
any_duplicated_linter = lintr::any_duplicated_linter(),
2734
any_is_na_linter = lintr::any_is_na_linter(),
28-
assignment_linter = lintr::assignment_linter(allow_cascading_assign = FALSE,
29-
allow_pipe_assign = TRUE),
35+
assignment_linter = lintr::assignment_linter(operator = c("<-", "<<-", "%<>%")),
3036
boolean_arithmetic_linter = lintr::boolean_arithmetic_linter(),
31-
# TODO: add `function_braces = "not_inline"` once https://github.com/r-lib/lintr/pull/2240 is merged
37+
# TODO: set `function_braces = "not_inline"` once lintr 3.2.1+ is released
3238
brace_linter = lintr::brace_linter(allow_single_line = TRUE),
3339
class_equals_linter = lintr::class_equals_linter(),
40+
comparison_negation_linter = lintr::comparison_negation_linter(),
41+
condition_call_linter = lintr::condition_call_linter(),
3442
condition_message_linter = lintr::condition_message_linter(),
3543
conjunct_test_linter = lintr::conjunct_test_linter(allow_filter = "always"),
3644
consecutive_assertion_linter = lintr::consecutive_assertion_linter(),
45+
consecutive_mutate_linter = lintr::consecutive_mutate_linter(),
46+
cyclocomp_linter = lintr::cyclocomp_linter(),
3747
empty_assignment_linter = lintr::empty_assignment_linter(),
3848
expect_comparison_linter = lintr::expect_comparison_linter(),
49+
expect_identical_linter = lintr::expect_identical_linter(),
3950
expect_length_linter = lintr::expect_length_linter(),
4051
expect_named_linter = lintr::expect_named_linter(),
4152
expect_not_linter = lintr::expect_not_linter(),
@@ -47,7 +58,9 @@ default_linters <- lintr::linters_with_defaults(
4758
fixed_regex_linter = lintr::fixed_regex_linter(),
4859
for_loop_index_linter = lintr::for_loop_index_linter(),
4960
function_argument_linter = lintr::function_argument_linter(),
61+
function_return_linter = lintr::function_return_linter(),
5062
if_not_else_linter = lintr::if_not_else_linter(exceptions = NULL),
63+
if_switch_linter = lintr::if_switch_linter(),
5164
ifelse_censor_linter = lintr::ifelse_censor_linter(),
5265
implicit_assignment_linter = lintr::implicit_assignment_linter(),
5366
implicit_integer_linter = lintr::implicit_integer_linter(allow_colon = TRUE),
@@ -61,7 +74,8 @@ default_linters <- lintr::linters_with_defaults(
6174
length_levels_linter = lintr::length_levels_linter(),
6275
length_test_linter = lintr::length_test_linter(),
6376
lengths_linter = lintr::lengths_linter(),
64-
line_length_linter = lintr::line_length_linter(160),
77+
line_length_linter = lintr::line_length_linter(length = 160L),
78+
list_comparison_linter = lintr::list_comparison_linter(),
6579
literal_coercion_linter = lintr::literal_coercion_linter(),
6680
# NOTE: non-base-R fns aren't up for inclusion in default `except` arg, thus we have to customize ourselves
6781
# cf. https://github.com/r-lib/lintr/issues/2109#issuecomment-1842245434
@@ -70,34 +84,49 @@ default_linters <- lintr::linters_with_defaults(
7084
"switch",
7185
"extract")),
7286
nested_ifelse_linter = lintr::nested_ifelse_linter(),
87+
nrow_subset_linter = lintr::nrow_subset_linter(),
7388
numeric_leading_zero_linter = lintr::numeric_leading_zero_linter(),
74-
object_length_linter = lintr::object_length_linter(40),
75-
# TODO: remove once https://github.com/r-lib/lintr/issues/2252 is fixed
89+
nzchar_linter = lintr::nzchar_linter(),
90+
object_length_linter = lintr::object_length_linter(length = 40L),
91+
object_overwrite_linter = lintr::object_overwrite_linter(packages = "base"),
92+
# TODO: try re-enabling once https://github.com/r-lib/lintr/issues/2252 is fixed
7693
object_usage_linter = NULL,
94+
one_call_pipe_linter = lintr::one_call_pipe_linter(),
7795
outer_negation_linter = lintr::outer_negation_linter(),
7896
paste_linter = lintr::paste_linter(),
7997
pipe_call_linter = lintr::pipe_call_linter(),
98+
pipe_return_linter = lintr::pipe_return_linter(),
99+
print_linter = lintr::print_linter(),
100+
# disabled because being able to use both types of quotes allows to avoid having to escape the respective other quote type
80101
quotes_linter = NULL,
81102
redundant_equals_linter = lintr::redundant_equals_linter(),
82103
redundant_ifelse_linter = lintr::redundant_ifelse_linter(),
83104
regex_subset_linter = lintr::regex_subset_linter(),
105+
rep_len_linter = lintr::rep_len_linter(),
84106
repeat_linter = lintr::repeat_linter(),
107+
return_linter = lintr::return_linter(allow_implicit_else = FALSE),
108+
routine_registration_linter = lintr::routine_registration_linter(),
109+
sample_int_linter = lintr::sample_int_linter(),
85110
scalar_in_linter = lintr::scalar_in_linter(),
86111
sort_linter = lintr::sort_linter(),
87112
sprintf_linter = lintr::sprintf_linter(),
113+
stopifnot_all_linter = lintr::stopifnot_all_linter(),
88114
string_boundary_linter = lintr::string_boundary_linter(),
89115
system_file_linter = lintr::system_file_linter(),
116+
terminal_close_linter = lintr::terminal_close_linter(),
90117
todo_comment_linter = lintr::todo_comment_linter(),
118+
# disabled since RStudio's built-in `StripTrailingWhitespace` proj opt ignores .Rmd code chunks
91119
trailing_whitespace_linter = NULL,
92120
undesirable_function_linter = lintr::undesirable_function_linter(symbol_is_undesirable = FALSE),
93-
undesirable_operator_linter = lintr::undesirable_operator_linter(
94-
op = c(lintr::default_undesirable_operators,
95-
"->" = "Makes it harder to see in code where an object is defined.")
96-
),
121+
undesirable_operator_linter = lintr::undesirable_operator_linter(op = c(lintr::default_undesirable_operators,
122+
"->" = "Makes it harder to see in code where an object is defined.")),
97123
unnecessary_concatenation_linter = lintr::unnecessary_concatenation_linter(),
98-
unnecessary_nesting_linter = lintr::unnecessary_nesting_linter(),
124+
unnecessary_lambda_linter = lintr::unnecessary_lambda_linter(),
125+
# TODO: enable once https://github.com/r-lib/lintr/issues/2748 is fixed
126+
# unnecessary_nesting_linter = lintr::unnecessary_nesting_linter(),
99127
unnecessary_placeholder_linter = lintr::unnecessary_placeholder_linter(),
100128
unreachable_code_linter = lintr::unreachable_code_linter(),
129+
which_grepl_linter = lintr::which_grepl_linter(),
101130
yoda_test_linter = lintr::yoda_test_linter()
102131
)
103132
```

0 commit comments

Comments
 (0)