Skip to content

Commit

Permalink
Merge pull request #1144 from r-lib/fix-pre-commit
Browse files Browse the repository at this point in the history
Use latest (and stable!) pre-commit
  • Loading branch information
lorenzwalthert authored Aug 21, 2023
2 parents aca7223 + 0c9ff1f commit 1fc5b13
Show file tree
Hide file tree
Showing 39 changed files with 5 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default_language_version:

repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: f3498c421d68a1db26de1a1fe3ecc91dd6f03b5e
rev: v0.3.2.9019
hooks:
- id: style-files
args:
Expand Down
2 changes: 1 addition & 1 deletion R/nest.R
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ nest_parse_data <- function(pd_flat) {

rhs <- nest_(child, "child", setdiff(names(child), "parent_"))

nested <- left_join(internal, rhs, by = c("id" = "parent_"))
nested <- left_join(internal, rhs, by = c(id = "parent_"))

children <- nested$child
for (i in seq_along(children)) {
Expand Down
2 changes: 1 addition & 1 deletion R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ local_test_setup <- function(cache = FALSE,
.local_envir = parent.frame()) {
current_cache <- cache_info(format = "tabular")
withr::local_options(
list("styler.quiet" = TRUE, "R.cache.rootPath" = tempfile()),
list(styler.quiet = TRUE, R.cache.rootPath = tempfile()),
.local_envir = .local_envir
)
if (cache) {
Expand Down
4 changes: 2 additions & 2 deletions R/ui-caching.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ cache_info <- function(cache_name = NULL, format = "both") {
#' @export
cache_activate <- function(cache_name = NULL,
verbose = !getOption("styler.quiet", FALSE)) {
options("styler.cache_name" = cache_name %||% styler_version)
options(styler.cache_name = cache_name %||% styler_version)
path <- cache_find_path(cache_name)

if (verbose) {
Expand All @@ -155,7 +155,7 @@ cache_activate <- function(cache_name = NULL,
#' @rdname cache_activate
#' @export
cache_deactivate <- function(verbose = !getOption("styler.quiet", FALSE)) {
options("styler.cache_name" = NULL)
options(styler.cache_name = NULL)

if (verbose) {
cat("Deactivated cache.\n")
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-create_token.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("can create a token that has relevant columns", {
pd_names <- c(
"token", "text", "short", "lag_newlines", "newlines", "pos_id",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-create_tree.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("create_trees outputs identical structure if trees have same structure", {
skip_if_not_installed("DiagrammeR")
skip_if_not_installed("data.tree")
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-curly-curly.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("curly-culry", {
expect_warning(test_collection("curly-curly",
"mixed",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-exception_handling.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("style_text returns custom error", {
expect_error(style_text("a <- 3 4"), "unexpected numeric constant")
})
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-helpers.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("can construct and print vertical", {
skip_if_not_installed("prettycode")
expect_snapshot({
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-identify-roxygen-examples.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#' Things to consider:
#' * one function declaration or many
#' * example(s) is last tag or not?
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-indention_curly.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("indention on one-liner curley only is not changed", {
expect_warning(test_collection("indention_curly_brackets",
"one_line_curly",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-indention_fun_calls.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("edge cases work", {
expect_warning(test_collection("indention_fun_calls",
transformer = style_text, strict = FALSE
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-indention_multiple.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("multiple round brackets don't cause extraindention", {
expect_warning(test_collection("indention_multiple",
"round_only",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-indention_operators.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("pipe is indended correctly", {
expect_warning(test_collection("indention_operators",
"pipe",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-indention_round_brackets.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("one-line function call yields correct indention", {
expect_warning(test_collection("indention_round_brackets",
"one_line",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-insertion_comment_interaction.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


## ............................................................................
## strict = TRUE ####

Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-line_breaks_and_other.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("line breaks involing curly brackets", {
expect_warning(test_collection("line_breaks_and_other", "curly",
transformer = style_text
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-line_breaks_fun_call.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that("line breaks work in general", {
expect_warning(test_collection("line_breaks_fun_call",
"token_dependent_mixed",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-math_token_spacing.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("invalid tokens return error", {
expect_error(test_collection(
"math_token_spacing", "non_strict_math_spacing_all",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-parsing.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("repreated parsing solves wrong parent assignment", {
expect_warning(
test_collection(
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-relocate_eq_assign.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Tests code in R/relevel.R
test_that("tree hierarchy is the same no matter whether = or <- is used", {
skip_if_not_installed("DiagrammeR")
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-rmd.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("can style .Rmd files", {
expect_warning(test_collection("rmd", "simple",
transformer = transform_mixed,
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-rnw.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("can style .Rnw files", {
expect_warning(test_collection(
"rnw", "008-outdec",
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-roundtrip.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@



test_that("parse_tree_must_be_identical works", {
expect_true(
parse_tree_must_be_identical(tidyverse_style(scope = "line_breaks"))
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-roxygen-examples-parse.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("simple examples can be parsed", {
expected_out <- c("\n", "x <- 1\n")
expect_equal(parse_roxygen(c("#' @examples", "#' x <- 1"))$text, expected_out)
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-scope-AsIs.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("no indention manipulation but spaces manipulation", {
expect_warning(test_collection(
"scope-AsIs", "scope_spaces-",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-scope-character.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("no indention manipulation but spaces manipulation", {
expect_warning(test_collection(
"scope-character", "scope_spaces",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-serialize_tests.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("No files to compare returns error", {
expect_error(test_collection("serialize_tests", "xyz",
transformer = as_is
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-spacing.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("curly braces", {
expect_warning(test_collection(
"spacing", "round",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-square_brackets.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("square brackets cause indention", {
expect_warning(test_collection(
"indention_square_brackets",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-start_line.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("leading spaces are preserved at start of text", {
expect_warning(test_collection("start_line",
transformer = style_empty
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-strict.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("can style example source file with strict = TRUE", {
expect_warning(test_collection(
"strict", "strict",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-tidyeval.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("no spaces within bang-bang operator !!!", {
expect_warning(test_collection("tidyeval", "bang_bang",
transformer = style_text
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-token_adding_removing.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("other manipulations are correct (add braces, semi-colon etc.)", {
expect_warning(test_collection("token_adding_removing", "mixed_token",
transformer = style_text
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-unary.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("no spaces before unary operator", {
expect_warning(test_collection("unary_spacing",
"unary_simple",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-unindention.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("round brackets are unindented correctly", {
expect_warning(test_collection("unindention",
"mixed",
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-unindention_regex.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that("forced regex token-dependent indention", {
expect_warning(test_collection(
"unindention_regex", "regex_force_with",
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("non-comment-helpers", {
pd <- compute_parse_data_nested("a <- # hi \n x %>% b()")
child <- pd$child[[1]]
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-varia.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("ensure_last_n_empty", {
expect_equal(
ensure_last_n_empty("x"),
Expand Down

0 comments on commit 1fc5b13

Please sign in to comment.