Skip to content

Commit 5aab034

Browse files
feat: Reinstate lint infrastructure as GHA (#396)
Co-authored-by: Kirill Müller <krlmlr@users.noreply.github.com> Co-authored-by: Kirill Müller <kirill@cynkra.com>
1 parent 0be61d2 commit 5aab034

64 files changed

Lines changed: 386 additions & 342 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
^.*\.Rproj$
22
^\.Rproj\.user$
3-
^\.lintr$
3+
^\.lintr\.R$
44
^cran-comments\.md$
55
^revdep-dev$
66
^man-roxygen$

.github/workflows/lint.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
push:
3+
branches: [main, master]
4+
pull_request:
5+
branches: [main, master]
6+
7+
name: lint
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
env:
13+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: r-lib/actions/setup-r@v2
18+
with:
19+
use-public-rspm: true
20+
21+
- uses: r-lib/actions/setup-r-dependencies@v2
22+
with:
23+
extra-packages: |
24+
r-lib/lintr
25+
local::.
26+
needs: lint
27+
28+
- name: Lint
29+
run: lintr::lint_package()
30+
shell: Rscript {0}
31+
env:
32+
LINTR_ERROR_ON_LINT: true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ inst/doc
88
CRAN-RELEASE
99
CRAN-SUBMISSION
1010
.vscode
11+
12+
*.Rcheck
13+
*.tar.gz
14+

.lintr

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

.lintr.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
linters <- modify_defaults(
2+
all_linters(),
3+
absolute_path_linter = NULL,
4+
commented_code_linter = NULL,
5+
condition_call_linter = NULL,
6+
cyclocomp_linter = NULL,
7+
expect_identical_linter = NULL,
8+
function_argument_linter = NULL,
9+
if_switch_linter = NULL, # false positive: r-lib/lintr#2835
10+
implicit_assignment_linter = NULL,
11+
implicit_integer_linter = NULL,
12+
keyword_quote_linter = NULL,
13+
line_length_linter = NULL,
14+
missing_argument_linter = NULL,
15+
namespace_linter = NULL,
16+
nonportable_path_linter = NULL,
17+
nzchar_linter = NULL,
18+
object_length_linter = NULL,
19+
object_name_linter = NULL,
20+
object_overwrite_linter = NULL,
21+
object_usage_linter = NULL,
22+
one_call_pipe_linter = NULL,
23+
strings_as_factors_linter = NULL,
24+
todo_comment_linter = NULL,
25+
undesirable_function_linter = NULL,
26+
unused_import_linter = NULL
27+
)

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Suggests:
3636
debugme,
3737
devtools,
3838
knitr,
39-
lintr,
4039
pkgload,
4140
rmarkdown,
4241
RSQLite,

R/compat-purrr.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ pmap <- function(.l, .f, ...) {
8686
))
8787
}
8888
.rlang_purrr_args_recycle <- function(args) {
89+
# nolint next: lengths_linter.
8990
lengths <- map_int(args, length)
9091
n <- max(lengths)
9192

92-
stopifnot(all(lengths == 1L | lengths == n))
93+
stopifnot(lengths == 1L | lengths == n)
9394
to_recycle <- lengths == 1L
95+
# nolint next: unnecessary_lambda_linter.
9496
args[to_recycle] <- map(args[to_recycle], function(x) rep.int(x, n))
9597

9698
args

R/dbi.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ dbi_generics <- function(version) {
4949

5050
if (version < "1.7.99.11") {
5151
generics <- setdiff(generics, c(
52-
"dbBindArrow"
52+
"dbBindArrow",
53+
NULL
5354
))
5455
}
5556

R/expectations.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ expect_all_args_have_default_values <- function(object) {
2525
has_method <- function(method_name) {
2626
function(x) {
2727
my_class <- class(x)
28+
# nolint next: expect_comparison_linter. Using 'info', absent from expect_gt().
2829
expect_true(
2930
length(findMethod(method_name, my_class)) > 0L,
3031
paste("object of class", my_class, "has no", method_name, "method")
@@ -55,15 +56,15 @@ expect_equal_df <- function(actual, expected) {
5556

5657
list_cols <- map_lgl(expected, is.list)
5758

58-
if (!any(list_cols)) {
59-
order_actual <- do.call(order, actual)
60-
order_expected <- do.call(order, expected)
61-
} else {
59+
if (any(list_cols)) {
6260
expect_false(all(list_cols))
6361
expect_equal(anyDuplicated(actual[!list_cols]), 0)
6462
expect_equal(anyDuplicated(expected[!list_cols]), 0)
6563
order_actual <- do.call(order, actual[!list_cols])
6664
order_expected <- do.call(order, expected[!list_cols])
65+
} else {
66+
order_actual <- do.call(order, actual)
67+
order_expected <- do.call(order, expected)
6768
}
6869

6970
has_rownames_actual <- is.character(attr(actual, "row.names"))

R/run.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ run_tests <- function(ctx, tests, skip, run_only, test_suite) {
9292

9393
if (any(skip_flag)) {
9494
test_that(paste0(test_context, ": skipped tests"), {
95-
skip(paste0("DBItest::run_tests(): by request: ", paste(names(tests)[skip_flag], collapse = ", ")))
95+
skip(paste0("DBItest::run_tests(): by request: ", toString(names(tests)[skip_flag])))
9696
})
9797
}
9898

0 commit comments

Comments
 (0)