Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline and tighten lintr checks (#220)
* Replace lint.yaml by lint-changed-file.yaml Copied from r-lib/actions with some extra bells and whistles copied from lint.yaml - triggered on develop and can be triggered manually - can be skipped with the [ci skip] instruction in the commit message * Try to include all linters * Fix some indents Indents in function argument definition have not been changed because they are an explicit style choice * Add fixed = TRUE to calls with fixed regexes * Add leading zero to double * Use toString() rather than paste(collapse = ", ") * Use anyNA() rather than any(is.na()) * Remove unused variables * Pass function directly to sapply instead of creating lambda * Use dedicated lengths() function * Remove unnecessary library() calls * Use file.path() to construct file paths * Replace unnecessary ifelse() by as.numeric() * Remove unnecessary paste0() in warning() and stop() * Remove unnecessary c() * Use seq_len() rather than : * Use sort() rather than order() * Remove nested if * Disable linters that generate too many false positive or that flag explicit style choices that diverge from default * Run devtools::document() * Add NEWS items * Increment version number * Remove extra trailing whitespace
- Loading branch information
Showing
37 changed files
with
236 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
- develop | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
- develop | ||
workflow_dispatch: | ||
|
||
name: lint-changed-files | ||
|
||
jobs: | ||
lint-changed-files: | ||
runs-on: ubuntu-latest | ||
if: "! contains(github.event.head_commit.message, '[ci skip]')" | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: | | ||
any::gh | ||
any::lintr | ||
any::purrr | ||
needs: check | ||
|
||
- name: Add lintr options | ||
run: | | ||
cat('\noptions(lintr.linter_file = ".lintr")\n', file = "~/.Rprofile", append = TRUE) | ||
shell: Rscript {0} | ||
|
||
- name: Install package | ||
run: R CMD INSTALL . | ||
|
||
- name: Extract and lint files changed by this PR | ||
run: | | ||
files <- gh::gh("GET https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files") | ||
changed_files <- purrr::map_chr(files, "filename") | ||
all_files <- list.files(recursive = TRUE) | ||
exclusions_list <- as.list(setdiff(all_files, changed_files)) | ||
lintr::lint_package(exclusions = exclusions_list) | ||
shell: Rscript {0} | ||
env: | ||
LINTR_ERROR_ON_LINT: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
linters: linters_with_defaults( | ||
line_length_linter = line_length_linter(80), | ||
cyclocomp_linter = cyclocomp_linter(complexity_limit = 20L), | ||
object_usage_linter = NULL) | ||
exclusions: c(list.files(path = "tests/", recursive = T, full.names = T), | ||
"vignettes/germany-age-stratified-nowcasting.Rmd.orig") | ||
exclude: "# nolint" | ||
linters: linters_with_tags( | ||
tags = NULL, # include all linters | ||
implicit_integer_linter = NULL, | ||
extraction_operator_linter = NULL, | ||
undesirable_function_linter = NULL, | ||
function_argument_linter = NULL, | ||
indentation_linter = NULL, | ||
object_name_linter = NULL, | ||
cyclocomp_linter(25L) | ||
) | ||
exclusions: c( | ||
list.files("tests", recursive = TRUE, full.names = TRUE), | ||
list.files("inst", recursive = TRUE, full.names = TRUE), | ||
"vignettes/germany-age-stratified-nowcasting.Rmd.orig" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.