Skip to content

Commit 51d8c62

Browse files
Merge branch 'main' into index_integer_literals
2 parents 3598b58 + f74502f commit 51d8c62

File tree

10 files changed

+64
-48
lines changed

10 files changed

+64
-48
lines changed

.github/workflows/touchstone-receive.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@ concurrency:
44
group: ${{ github.workflow }}-${{ github.head_ref }}
55
cancel-in-progress: true
66

7-
on: pull_request
7+
on:
8+
pull_request:
9+
paths:
10+
# Directories with source code and benchmarking code
11+
- "inst/**"
12+
- "R/**"
13+
- "src/**"
14+
- "touchstone/**"
15+
# Benchmarking config file
16+
- ".github/workflows/touchstone-*.yaml"
17+
# Package metadata
18+
- DESCRIPTION
819

920
jobs:
1021
prepare:

.pre-commit-config.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ default_language_version:
66

77
repos:
88
- repo: https://github.com/lorenzwalthert/precommit
9-
rev: v0.3.0
9+
rev: v0.3.2.9003
1010
hooks:
1111
- id: style-files
12-
args: ['--ignore-start="^# styler: on$"', '--ignore-stop="^# styler: off$"']
12+
args: ['--ignore-start="^# styler: off$"', '--ignore-stop="^# styler: on$"']
1313
exclude: >
1414
(?x)^(
1515
tests/testthat/.*/.*\.R(md|nw)?|
@@ -86,7 +86,7 @@ repos:
8686
tests/testthat/.*\.R(md)?
8787
)$
8888
- repo: https://github.com/pre-commit/pre-commit-hooks
89-
rev: v4.2.0
89+
rev: v4.3.0
9090
hooks:
9191
- id: check-added-large-files
9292
args: ['--maxkb=200']
@@ -102,7 +102,7 @@ repos:
102102
tests/testthat/_snaps/.*|
103103
)$
104104
- repo: https://github.com/lorenzwalthert/gitignore-tidy
105-
rev: 9dd648a2cbce0c0ce09255695b63ea4823699bec
105+
rev: a2260df7cc08de00d7312aeff68cea6bcba48c42
106106
hooks:
107107
- id: tidy-gitignore
108108
- repo: local
@@ -113,10 +113,3 @@ repos:
113113
language: fail
114114
files: '\.Rhistory|\.RData|\.Rds|\.rds$'
115115
# `exclude: <regex>` to allow committing specific files.
116-
- id: require-news-on-push
117-
name: Require bullet in NEWS.md
118-
description: NEWS.md must be updated with every PR.
119-
entry: inst/hooks/require-news-update.R
120-
stages: [push]
121-
language: script
122-
always_run: true

R/rules-line-breaks.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
#' code(to = execute)
2323
#' })
2424
#' call2(
25-
#' x = 2,
26-
#' {
25+
#' x = 2, {
2726
#' code(to = execute)
2827
#' },
29-
#' c = { # this is the named case
28+
#' c = {
29+
#' # this is the named case
3030
#' g(x = 7)
3131
#' }
3232
#' )
@@ -156,9 +156,10 @@ style_line_break_around_curly <- function(strict, pd) {
156156
opening_before <- (pd$token == "'{'")
157157
to_break <- lag(opening_before, default = FALSE) | closing_before
158158
len_to_break <- sum(to_break)
159-
pd$lag_newlines[to_break] <- ifelse(rep(strict, len_to_break),
160-
1L,
161-
pmax(1L, pd$lag_newlines[to_break])
159+
pd$lag_newlines[to_break] <- ifelse(
160+
pd$token[to_break] == "COMMENT",
161+
pmin(1L, pd$lag_newlines[to_break]),
162+
if (strict) 1L else pmax(1L, pd$lag_newlines[to_break])
162163
)
163164
} else {
164165
is_else <- pd$token == "ELSE"

R/token-define.R

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1+
# styler: off
12
token <- rbind.data.frame(
2-
c("&", "logical", "AND"),
3-
c("&&", "logical", "AND2"),
4-
c("|", "logical", "OR"),
5-
c("||", "logical", "OR2"),
6-
c(">", "logical", "GT"),
7-
c("<", "logical", "LT"),
8-
c("<=", "logical", "LE"),
9-
c(">=", "logical", "GE"),
10-
c("!=", "logical", "NE"),
11-
c("==", "logical", "EQ"),
12-
c("=", "assign_left", "EQ_SUB"),
13-
c("=", "assign_left", "EQ_ASSIGN"),
14-
c("<-", "assign_left", "LEFT_ASSIGN"),
15-
c("->", "assign_right", "RIGHT_ASSIGN"),
16-
c("+", "math", "'+'"),
17-
c("-", "math", "'-'"),
18-
c("*", "math", "'*'"),
19-
c("/", "math", "'/'"),
20-
c("^", "math", "'^'"),
21-
c("~", "formula", "'~'"),
22-
c("if", "cond", "IF"),
23-
c("else", "cond", "ELSE"),
24-
c("in", "loop_cond", "IN"),
25-
c("while", "loop_cond", "WHILE"),
3+
c("&", "logical", "AND"),
4+
c("&&", "logical", "AND2"),
5+
c("|", "logical", "OR"),
6+
c("||", "logical", "OR2"),
7+
c(">", "logical", "GT"),
8+
c("<", "logical", "LT"),
9+
c("<=", "logical", "LE"),
10+
c(">=", "logical", "GE"),
11+
c("!=", "logical", "NE"),
12+
c("==", "logical", "EQ"),
13+
c("=", "assign_left", "EQ_SUB"),
14+
c("=", "assign_left", "EQ_ASSIGN"),
15+
c("<-", "assign_left", "LEFT_ASSIGN"),
16+
c("->", "assign_right", "RIGHT_ASSIGN"),
17+
c("+", "math", "'+'"),
18+
c("-", "math", "'-'"),
19+
c("*", "math", "'*'"),
20+
c("/", "math", "'/'"),
21+
c("^", "math", "'^'"),
22+
c("~", "formula", "'~'"),
23+
c("if", "cond", "IF"),
24+
c("else", "cond", "ELSE"),
25+
c("in", "loop_cond", "IN"),
26+
c("while", "loop_cond", "WHILE"),
2627
stringsAsFactors = FALSE
2728
)
29+
# styler: on
2830

2931
colnames(token) <- c("text", "class", "token")
3032
math_token <- token$token[token$class == "math"]

man/set_line_break_before_curly_opening.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/indention_multiple/overall-out.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ a <- function(x) {
88
22 + 1
99
))
1010
if (x > 10) {
11-
for (x in 22) {
12-
# FIXME in operator only to be surrounded by one space. What about %in%?
11+
for (x in 22) { # FIXME in operator only to be surrounded by one space. What about %in%?
1312
prin(x)
1413
}
1514
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
X_and_F_symbol_linter <- function() { # nolint: object_name.
2+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
X_and_F_symbol_linter <- function() { # nolint: object_name.
2+
}

tests/testthat/test-cache-high-level-api.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test_that("no speedup when tranformer changes", {
137137
first <- system.time(style_text(text, transformers = t1))
138138
t1 <- tidyverse_style(indent_by = 4)
139139
second <- system.time(style_text(text, transformers = t1))
140-
expect_false(first["elapsed"] / 1.3 > second["elapsed"])
140+
expect_true(first["elapsed"] < 1.3 * second["elapsed"])
141141
})
142142

143143

tests/testthat/test-line_breaks_and_other.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ test_that("line is correctly broken around = ", {
6868
transformer = style_text
6969
), NA)
7070
})
71+
72+
test_that("comments are not moved down after {", {
73+
expect_warning(test_collection("line_breaks_and_other", "comment-around-curly",
74+
transformer = style_text
75+
), NA)
76+
})

0 commit comments

Comments
 (0)