From 5208f3652013eacfe0e7b4d1972d5b83b1e20c2e Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Tue, 23 Jul 2024 22:00:03 +0200 Subject: [PATCH] Use lintr config file also in GHA --- .github/workflows/R-CMD-check.yaml | 1 - .github/workflows/lint-changed-files.yaml | 34 +++++------------------ .github/workflows/lint.yaml | 26 ++--------------- .lintr | 3 +- 4 files changed, 10 insertions(+), 54 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0880a3eb..386ff88c 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -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 diff --git a/.github/workflows/lint-changed-files.yaml b/.github/workflows/lint-changed-files.yaml index 1a860c26..07492f62 100644 --- a/.github/workflows/lint-changed-files.yaml +++ b/.github/workflows/lint-changed-files.yaml @@ -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: | @@ -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 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3371f801..a44ebbe4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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 diff --git a/.lintr b/.lintr index a7324e54..87afc9c2 100644 --- a/.lintr +++ b/.lintr @@ -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, @@ -12,7 +12,6 @@ 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, undesirable_function_linter = NULL,