Skip to content

Commit

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

* fix lints
  • Loading branch information
IndrajeetPatil authored Jul 26, 2024
1 parent a94dadc commit ff5457b
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 80 deletions.
32 changes: 5 additions & 27 deletions .github/workflows/lint-changed-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ jobs:
- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
upgrade: "TRUE"
upgrade: 'TRUE'
needs: check
extra-packages: |
any::gh
any::purrr
r-lib/lintr
needs: check

- name: Install package
run: R CMD INSTALL .
local::.
- name: Extract and lint files changed by this PR
run: |
Expand All @@ -39,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
4 changes: 1 addition & 3 deletions .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion R/ggpiestats.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ggpiestats <- function(
x_levels <- nlevels(pull(data, {{ x }}))
y_levels <- ifelse(test == "one.way", 0L, nlevels(pull(data, {{ y }})))

# TODO: one-way table in `BayesFactor` (richarddmorey/BayesFactor#159)
# one-way table not supported in `BayesFactor` ATM (richarddmorey/BayesFactor#159)
if (test == "two.way" && y_levels == 1L) bf.message <- FALSE

# faceting is possible only if both vars have more than one level
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-ggbarstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ test_that(
# dropped level dataset
mtcars_small <- dplyr::filter(mtcars, am == "0")

# TODO: should one-way table results be shown in the subtitle?
set.seed(123)
expect_doppelganger(
title = "works with dropped levels",
Expand Down
9 changes: 0 additions & 9 deletions tests/testthat/test-gghistostats.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ test_that(
}
)

# utilities ---------------

test_that(
".binwidth works as expected",
{
expect_equal(ggstatsplot:::.binwidth(mtcars$wt), 0.6913737, tolerance = 0.001)
}
)

# grouped_gghistostats works ---------------------------------------------

test_that(
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-ggpiestats.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ test_that(
# dropped level dataset
mtcars_small <- dplyr::filter(mtcars, am == "0")

# TODO: should one-way table results be shown in the subtitle?
set.seed(123)
expect_doppelganger(
title = "works with dropped levels",
Expand Down
14 changes: 0 additions & 14 deletions tests/testthat/test-ggscatterstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,6 @@ test_that("labeling variables and expressions work as expected", {
results.subtitle = FALSE
)
)

# TODO: generate snapshot on Windows machine
# set.seed(123)
# expect_doppelganger(
# title = "label variable but no expression",
# fig = ggscatterstats(
# data = df,
# x = sleep_total,
# y = sleep_cycle,
# label.expression = NULL,
# label.var = order,
# results.subtitle = FALSE
# )
# )
})

# subtitle output ----------------------------------------------------------
Expand Down

0 comments on commit ff5457b

Please sign in to comment.