Skip to content

Commit

Permalink
Use lintr config file also in GHA (#290)
Browse files Browse the repository at this point in the history
* Use lintr config file also in GHA

* Update .lintr

* Update .lintr
  • Loading branch information
IndrajeetPatil committed Jul 26, 2024
1 parent 409eafe commit 6940fbe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 56 deletions.
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
cache-version: 10
upgrade: 'TRUE'
extra-packages: |
any::rcmdcheck
Expand Down
34 changes: 7 additions & 27 deletions .github/workflows/lint-changed-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
upgrade: 'TRUE'
needs: check
extra-packages: |
any::gh
r-lib/lintr
any::purrr
needs: check

- name: Install package
run: R CMD INSTALL .
r-lib/lintr
local::.
- name: Extract and lint files changed by this PR
run: |
Expand All @@ -37,28 +37,8 @@ jobs:
changed_files <- purrr::map_chr(files, "filename")
all_files <- list.files(recursive = TRUE)
exclusions_list <- as.list(setdiff(all_files, changed_files))
lint_package(linters = all_linters(
absolute_path_linter = NULL,
assignment_linter = NULL,
commented_code_linter = NULL,
cyclocomp_linter(25L),
if_not_else_linter(exceptions = character(0L)),
implicit_integer_linter = NULL,
library_call_linter = NULL,
line_length_linter(120L),
namespace_linter = NULL,
nonportable_path_linter = NULL,
object_name_linter = NULL,
object_length_linter(50L),
object_usage_linter = NULL,
string_boundary_linter = NULL,
strings_as_factors_linter = NULL,
todo_comment_linter = NULL,
undesirable_function_linter = NULL,
undesirable_operator_linter = NULL,
unnecessary_concatenation_linter(allow_single_expression = FALSE),
unused_import_linter = NULL
), exclusions = exclusions_list)
# lintr config in `.lintr` file
lint_package(exclusions = exclusions_list)
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
26 changes: 2 additions & 24 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,12 @@ jobs:
local::.
needs: lint

# TODO: Revisit to remove some of these allowances after more important lints
# have been removed.
- name: Lint
run: |
options(crayon.enabled = TRUE)
library(lintr)
lint_package(linters = all_linters(
absolute_path_linter = NULL,
assignment_linter = NULL,
commented_code_linter = NULL,
cyclocomp_linter(25L),
if_not_else_linter(exceptions = character(0L)),
implicit_integer_linter = NULL,
library_call_linter = NULL,
line_length_linter(120L),
namespace_linter = NULL,
nonportable_path_linter = NULL,
object_name_linter = NULL,
object_length_linter(50L),
object_usage_linter = NULL,
string_boundary_linter = NULL,
strings_as_factors_linter = NULL,
todo_comment_linter = NULL,
undesirable_function_linter = NULL,
undesirable_operator_linter = NULL,
unnecessary_concatenation_linter(allow_single_expression = FALSE),
unused_import_linter = NULL
))
# lintr config in `.lintr` file
lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
6 changes: 2 additions & 4 deletions .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linters: all_linters(
absolute_path_linter = NULL,
assignment_linter = NULL,
commented_code_linter = NULL,
cyclocomp_linter(25L),
cyclocomp_linter(20L),
if_not_else_linter(exceptions = character(0L)),
implicit_integer_linter = NULL,
library_call_linter = NULL,
Expand All @@ -12,11 +12,9 @@ linters: all_linters(
object_name_linter = NULL,
object_length_linter(50L),
object_usage_linter = NULL,
todo_comment_linter = NULL,
string_boundary_linter = NULL,
strings_as_factors_linter = NULL,
strings_as_factors_linter = NULL, # since R > 4.0
undesirable_function_linter = NULL,
undesirable_operator_linter = NULL,
unnecessary_concatenation_linter(allow_single_expression = FALSE),
unused_import_linter = NULL
)

0 comments on commit 6940fbe

Please sign in to comment.