Skip to content

Commit b9587dd

Browse files
Merge branch 'master' into ns-hooks-redux
2 parents 3604f9c + b4e3f72 commit b9587dd

File tree

12 files changed

+238
-46
lines changed

12 files changed

+238
-46
lines changed

.github/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html

.github/workflows/R-CMD-check.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
- master
6+
pull_request:
7+
branches:
8+
- main
9+
- master
10+
11+
name: R-CMD-check
12+
13+
jobs:
14+
R-CMD-check:
15+
runs-on: ${{ matrix.config.os }}
16+
17+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
config:
23+
- {os: macOS-latest, r: 'release'}
24+
- {os: windows-latest, r: 'release'}
25+
- {os: windows-latest, r: '3.6'}
26+
- {os: ubuntu-16.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
27+
- {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
28+
- {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
29+
- {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
30+
- {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
31+
- {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
32+
33+
env:
34+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
35+
RSPM: ${{ matrix.config.rspm }}
36+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- uses: r-lib/actions/setup-r@v1
42+
with:
43+
r-version: ${{ matrix.config.r }}
44+
http-user-agent: ${{ matrix.config.http-user-agent }}
45+
46+
- uses: r-lib/actions/setup-pandoc@v1
47+
48+
- name: Query dependencies
49+
run: |
50+
install.packages('remotes')
51+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
52+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
53+
shell: Rscript {0}
54+
55+
- name: Cache R packages
56+
if: runner.os != 'Windows'
57+
uses: actions/cache@v2
58+
with:
59+
path: ${{ env.R_LIBS_USER }}
60+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
61+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
62+
63+
- name: Install system dependencies
64+
if: runner.os == 'Linux'
65+
run: |
66+
while read -r cmd
67+
do
68+
eval sudo $cmd
69+
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))')
70+
71+
- name: Install dependencies
72+
run: |
73+
remotes::install_deps(dependencies = TRUE)
74+
remotes::install_cran("rcmdcheck")
75+
shell: Rscript {0}
76+
77+
- name: Session info
78+
run: |
79+
options(width = 100)
80+
pkgs <- installed.packages()[, "Package"]
81+
sessioninfo::session_info(pkgs, include_base = TRUE)
82+
shell: Rscript {0}
83+
84+
- name: Check
85+
env:
86+
_R_CHECK_CRAN_INCOMING_: false
87+
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
88+
shell: Rscript {0}
89+
90+
- name: Show testthat output
91+
if: always()
92+
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
93+
shell: bash
94+
95+
- name: Upload check results
96+
if: failure()
97+
uses: actions/upload-artifact@main
98+
with:
99+
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
100+
path: check

.github/workflows/lint.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
- master
6+
- "**"
7+
pull_request:
8+
branches:
9+
- main
10+
- master
11+
12+
name: lint
13+
14+
jobs:
15+
lint:
16+
runs-on: macOS-latest
17+
env:
18+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- uses: r-lib/actions/setup-r@v1
23+
24+
- name: Query dependencies
25+
run: |
26+
install.packages('remotes')
27+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
28+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
29+
shell: Rscript {0}
30+
31+
- name: Cache R packages
32+
uses: actions/cache@v2
33+
with:
34+
path: ${{ env.R_LIBS_USER }}
35+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
36+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
37+
38+
- name: Install dependencies
39+
run: |
40+
install.packages(c("remotes"))
41+
remotes::install_deps(dependencies = TRUE)
42+
remotes::install_github("jimhester/lintr")
43+
shell: Rscript {0}
44+
45+
- name: Lint
46+
run: lintr::lint_package()
47+
shell: Rscript {0}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
- master
6+
- '**'
7+
pull_request:
8+
branches:
9+
- main
10+
- master
11+
12+
name: test-coverage
13+
14+
jobs:
15+
test-coverage:
16+
runs-on: macOS-latest
17+
env:
18+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- uses: r-lib/actions/setup-r@v1
23+
24+
- uses: r-lib/actions/setup-pandoc@v1
25+
26+
- name: Query dependencies
27+
run: |
28+
install.packages('remotes')
29+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
30+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
31+
shell: Rscript {0}
32+
33+
- name: Cache R packages
34+
uses: actions/cache@v2
35+
with:
36+
path: ${{ env.R_LIBS_USER }}
37+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
38+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
39+
40+
- name: Install dependencies
41+
run: |
42+
install.packages(c("remotes"))
43+
remotes::install_deps(dependencies = TRUE)
44+
remotes::install_cran("covr")
45+
shell: Rscript {0}
46+
47+
- name: Test coverage
48+
run: covr::codecov()
49+
shell: Rscript {0}

.lintr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
linters: with_defaults( # The following TODOs are part of an effort to have {lintr} lint-free (#584)
22
line_length_linter = line_length_linter(120),
33
infix_spaces_linter = NULL, # TODO enable (#594)
4-
commented_code_linter = NULL, # TODO enable (#595)
54
cyclocomp_linter = cyclocomp_linter(29), # TODO reduce to 15
65
object_name_linter = NULL, # TODO enable (#597)
76
spaces_inside_linter = NULL, # TODO enable (#598)

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# lintr (development version)
22

3+
* Switched CI from Travis to GitHub Actions, using the full tidyverse recommended R CMD check. Code coverage and linting are implemented using separate GitHub Actions workflows (#572, @dragosmg)
34
* `save_cache` will now recursively create the cache directory; this avoids errors that could arise if any parent directories do not exist (#60, @dankessler).
45
* `extract_r_source` handles Rmd containing unevaluated code blocks with named
56
format specifiers (#472, @russHyde)

R/get_source_expressions.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,16 @@ fix_column_numbers <- function(content) {
327327
# getParseData() counts 1 tab as a variable number of spaces instead of one:
328328
# https://github.com/wch/r-source/blame/e7401b68ab0e032fce3e376aaca9a5431619b2b4/src/main/gram.y#L512
329329
# The number of spaces is so that the code is brought to the next 8-character indentation level e.g:
330-
# "1\t;" -> "1 ;"
331-
# "12\t;" -> "12 ;"
332-
# "123\t;" -> "123 ;"
333-
# "1234\t;" -> "1234 ;"
334-
# "12345\t;" -> "12345 ;"
335-
# "123456\t;" -> "123456 ;"
336-
# "1234567\t;" -> "1234567 ;"
337-
# "12345678\t;" -> "12345678 ;"
338-
# "123456789\t;" -> "123456789 ;"
339-
# "1234567890\t;" -> "1234567890 ;"
330+
# "1\t;" --> "1 ;"
331+
# "12\t;" --> "12 ;"
332+
# "123\t;" --> "123 ;"
333+
# "1234\t;" --> "1234 ;"
334+
# "12345\t;" --> "12345 ;"
335+
# "123456\t;" --> "123456 ;"
336+
# "1234567\t;" --> "1234567 ;"
337+
# "12345678\t;" --> "12345678 ;"
338+
# "123456789\t;" --> "123456789 ;"
339+
# "1234567890\t;" --> "1234567890 ;"
340340
fix_tab_indentations <- function(source_file) {
341341
pc <- getParseData(source_file)
342342

R/spaces_left_parentheses_linter.R

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ spaces_left_parentheses_linter <- function(source_file) {
77

88
parsed <- source_file$parsed_content[id, ]
99

10-
terminal_tokens_before <-
11-
source_file$parsed_content$token[
12-
source_file$parsed_content$line1 == parsed$line1 &
13-
source_file$parsed_content$col1 < parsed$col1 &
14-
source_file$parsed_content$terminal]
10+
terminal_tokens_before <- with(
11+
source_file$parsed_content,
12+
token[line1 == parsed$line1 & col1 < parsed$col1 & terminal]
13+
)
1514
last_type <- tail(terminal_tokens_before, n = 1)
1615

1716
is_function <- length(last_type) %!=% 0L &&
@@ -24,7 +23,24 @@ spaces_left_parentheses_linter <- function(source_file) {
2423
before_operator <- substr(line, parsed$col1 - 1L, parsed$col1 - 1L)
2524

2625
non_space_before <- re_matches(before_operator, rex(non_space))
27-
not_exception <- !(before_operator %in% c("!", ":", "[", "("))
26+
not_exception <- !(before_operator %in% c("!", ":", "[", "(", "^"))
27+
28+
# exception for unary - and unary +, #508
29+
before_operator_idx <- with(
30+
source_file$parsed_content,
31+
col1 == parsed$col1 - 1L & col1 == col2
32+
)
33+
is_sibling_expr <- if (any(before_operator_idx)) {
34+
with(
35+
source_file$parsed_content,
36+
token == "expr" & parent == parent[before_operator_idx]
37+
)
38+
} else {
39+
rep(FALSE, nrow(source_file$parsed_content))
40+
}
41+
not_exception <- not_exception &&
42+
!(before_operator %in% c("-", "+") &&
43+
nrow(source_file$parsed_content[is_sibling_expr, ]) == 1L)
2844

2945
if (non_space_before && not_exception) {
3046
Lint(

R/utils.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ escape_chars <- c(
194194
"\\f" = "\f", # form feed
195195
"\\v" = "\v" # vertical tab
196196
# dynamically-added:
197-
#"\\'" = "'", # ASCII apostrophe
198-
#"\\\"" = "\"", # ASCII quotation mark
199-
#"\\`" = "`" # ASCII grave accent (backtick)
197+
#"\\'" --> "'", # ASCII apostrophe
198+
#"\\\"" --> "\"", # ASCII quotation mark
199+
#"\\`" --> "`" # ASCII grave accent (backtick)
200200
)
201201

202202
unescape <- function(str, q="`") {

0 commit comments

Comments
 (0)