-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into check-random-order
- Loading branch information
Showing
288 changed files
with
6,718 additions
and
3,068 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
^\.Rproj\.user$ | ||
^\.idea$ | ||
^\.dev$ | ||
^\.devcontainer$ | ||
^\.lintr$ | ||
^\.lintr_new$ | ||
^wercker\.yml$ | ||
|
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 @@ | ||
# This script is designed to find linters that lack metadata tests. | ||
# To do so, it forces Lint() to give the wrong information, | ||
# runs the test suite, and finds linters that nevertheless pass all their tests. | ||
library(testthat) | ||
|
||
lint_file <- "R/lint.R" | ||
|
||
original <- readLines(lint_file) | ||
expected_line <- "line_number = as.integer(line_number)" | ||
if (sum(grepl(expected_line, original, fixed = TRUE)) != 1L) { | ||
stop(sprintf( | ||
"Please update this workflow -- need exactly one hit for line '%s' in file '%s'.", | ||
expected_line, lint_file | ||
)) | ||
} | ||
writeLines( | ||
sub(expected_line, "line_number = as.integer(2^31 - 1)", original, fixed = TRUE), | ||
lint_file | ||
) | ||
# Not useful in CI but good when running locally. | ||
withr::defer({ | ||
writeLines(original, lint_file) | ||
pkgload::load_all() | ||
}) | ||
|
||
pkgload::load_all() | ||
|
||
report <- test_dir( | ||
"tests/testthat", | ||
filter = "linter$", | ||
stop_on_failure = FALSE, | ||
reporter = SilentReporter$new() | ||
) | ||
names(report) <- gsub("^test-|\\.R$", "", vapply(report, `[[`, "file", FUN.VALUE = character(1L))) | ||
|
||
# Hack the nested structure of the testthat report to identify which files have | ||
# any failed test | ||
failed <- report |> | ||
vapply( | ||
\(x) any(vapply(x$results, inherits, "expectation_failure", FUN.VALUE = logical(1L))), | ||
logical(1L) | ||
) |> | ||
which() |> | ||
names() |> | ||
unique() | ||
|
||
passed <- setdiff( | ||
available_linters(tags = NULL)$linter, | ||
failed | ||
) | ||
|
||
if (length(passed) > 0L) { | ||
stop("Please add tests of lint metadata for the following linters: ", toString(passed)) | ||
} |
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 @@ | ||
# Test to ensure roxygenize() has been run on the current PR | ||
library(tools) | ||
library(roxygen2) | ||
|
||
old_dir <- file.path(tempdir(), "man") | ||
if (dir.exists(old_dir)) unlink(old_dir, recursive = TRUE) | ||
file.copy("man", tempdir(), recursive = TRUE) | ||
old_files <- list.files(old_dir, pattern = "\\.Rd$") | ||
new_dir <- "man" | ||
.Last <- function() unlink(old_dir, recursive = TRUE) | ||
|
||
# Rd2txt() prints to its out= argument, so we'd have to compare file contents; | ||
# plain parse_Rd() keeps srcref info that encodes the file path, which as.character() strips. | ||
normalize_rd <- function(rd_file) as.character(parse_Rd(rd_file)) | ||
|
||
rd_equal <- function(f1, f2) isTRUE(all.equal(normalize_rd(f1), normalize_rd(f2))) | ||
|
||
check_roxygenize_idempotent <- function(LOCALE) { | ||
Sys.setlocale("LC_COLLATE", LOCALE) | ||
roxygenize() | ||
|
||
new_files <- list.files(new_dir, pattern = "\\.Rd$") | ||
|
||
old_not_new <- setdiff(old_files, new_files) | ||
if (length(old_not_new) > 0L) { | ||
stop("Found saved .Rd files gone from a fresh run of roxygenize(): ", toString(old_not_new)) | ||
} | ||
|
||
new_not_old <- setdiff(new_files, old_files) | ||
if (length(new_not_old) > 0L) { | ||
stop("Found new .Rd files from a fresh run of roxygenize(): ", toString(new_not_old)) | ||
} | ||
|
||
for (file in new_files) { | ||
old_file <- file.path(old_dir, file) | ||
new_file <- file.path(new_dir, file) | ||
if (rd_equal(old_file, new_file)) { | ||
next | ||
} | ||
cat(sprintf("roxygenize() output differs from saved output for %s.\n", file)) | ||
cat("Here's the 'diff' comparison of the two files:\n") | ||
cat(" [---]: saved output in man/ directory\n") | ||
cat(" [+++]: roxygenize() output of R/ sources\n") | ||
system2("diff", c("--unified", old_file, new_file)) | ||
stop("Failed in LOCALE=", LOCALE, ".", call. = FALSE) | ||
} | ||
} | ||
|
||
# Run the check in a few locales to ensure there's no idempotency issues w.r.t. sorting, too | ||
for (LOCALE in c("C", "en_US", "hu_HU", "ja_JP")) { | ||
check_roxygenize_idempotent(LOCALE) | ||
} | ||
|
||
unlink(old_dir, recursive = TRUE) |
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,14 @@ | ||
FROM rocker/r-base | ||
|
||
RUN apt-get -qq update && \ | ||
apt-get install -y --no-install-recommends git libxml2-dev | ||
|
||
COPY DESCRIPTION . | ||
|
||
RUN Rscript -e ' \ | ||
install.packages("remotes"); \ | ||
remotes::install_deps(dependencies = c( \ | ||
"Imports", \ | ||
"Config/needs/development" \ | ||
)) \ | ||
' |
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,3 @@ | ||
{ | ||
"build": { "dockerfile": "Dockerfile", "context": ".."} | ||
} |
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 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
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,38 @@ | ||
# Various repo-level tests for code quality | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
name: repo-meta-tests | ||
|
||
jobs: | ||
repo-meta-tests: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: "release" | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: | | ||
any::roxygen2 | ||
- name: Ensure lint metadata is tested | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
callr::rscript(".dev/lint_metadata_test.R") | ||
shell: Rscript {0} | ||
|
||
- name: Ensure roxygen content matches man directory | ||
run: | | ||
callr::rscript(".dev/roxygen_test.R") | ||
shell: Rscript {0} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,11 @@ Package: lintr | |
Title: A 'Linter' for R Code | ||
Version: 3.1.1.9000 | ||
Authors@R: c( | ||
person("Jim", "Hester", , "[email protected]", role = c("aut", "cre")), | ||
person("Jim", "Hester", , role = "aut"), | ||
person("Florent", "Angly", role = "aut", | ||
comment = "fangly"), | ||
person("Russ", "Hyde", role = "aut"), | ||
person("Michael", "Chirico", role = "aut"), | ||
person("Michael", "Chirico", email = "[email protected]", role = c("aut", "cre")), | ||
person("Kun", "Ren", role = "aut"), | ||
person("Alexander", "Rosenstock", role = "aut", | ||
comment = "AshesITR"), | ||
|
@@ -37,14 +37,12 @@ Imports: | |
Suggests: | ||
bookdown, | ||
cli, | ||
httr (>= 1.2.1), | ||
jsonlite, | ||
mockery, | ||
patrick, | ||
patrick (>= 0.2.0), | ||
rlang, | ||
rmarkdown, | ||
rstudioapi (>= 0.2), | ||
testthat (>= 3.1.5), | ||
testthat (>= 3.2.1), | ||
tibble, | ||
tufte, | ||
withr (>= 2.5.0) | ||
|
@@ -53,10 +51,11 @@ Enhances: | |
VignetteBuilder: | ||
knitr | ||
Config/Needs/website: tidyverse/tidytemplate | ||
Config/Needs/development: pkgload, cli, testthat, patrick | ||
Config/testthat/edition: 3 | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.3 | ||
RoxygenNote: 7.3.1 | ||
Collate: | ||
'make_linter_from_xpath.R' | ||
'xp_utils.R' | ||
|
@@ -75,8 +74,7 @@ Collate: | |
'cache.R' | ||
'class_equals_linter.R' | ||
'commas_linter.R' | ||
'comment_linters.R' | ||
'comments.R' | ||
'commented_code_linter.R' | ||
'comparison_negation_linter.R' | ||
'condition_call_linter.R' | ||
'condition_message_linter.R' | ||
|
@@ -102,7 +100,6 @@ Collate: | |
'expect_true_false_linter.R' | ||
'expect_type_linter.R' | ||
'extract.R' | ||
'extraction_operator_linter.R' | ||
'fixed_regex_linter.R' | ||
'for_loop_index_linter.R' | ||
'function_argument_linter.R' | ||
|
@@ -143,6 +140,7 @@ Collate: | |
'nested_ifelse_linter.R' | ||
'nested_pipe_linter.R' | ||
'nonportable_path_linter.R' | ||
'shared_constants.R' | ||
'nrow_subset_linter.R' | ||
'numeric_leading_zero_linter.R' | ||
'nzchar_linter.R' | ||
|
@@ -175,8 +173,8 @@ Collate: | |
'seq_linter.R' | ||
'settings.R' | ||
'settings_utils.R' | ||
'shared_constants.R' | ||
'sort_linter.R' | ||
'source_utils.R' | ||
'spaces_inside_linter.R' | ||
'spaces_left_parentheses_linter.R' | ||
'sprintf_linter.R' | ||
|
@@ -185,14 +183,14 @@ Collate: | |
'strings_as_factors_linter.R' | ||
'system_file_linter.R' | ||
'terminal_close_linter.R' | ||
'todo_comment_linter.R' | ||
'trailing_blank_lines_linter.R' | ||
'trailing_whitespace_linter.R' | ||
'tree_utils.R' | ||
'undesirable_function_linter.R' | ||
'undesirable_operator_linter.R' | ||
'unnecessary_concatenation_linter.R' | ||
'unnecessary_lambda_linter.R' | ||
'unnecessary_nested_if_linter.R' | ||
'unnecessary_nesting_linter.R' | ||
'unnecessary_placeholder_linter.R' | ||
'unreachable_code_linter.R' | ||
|
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.