Skip to content

Commit 3c83994

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4763c82 commit 3c83994

File tree

3 files changed

+74
-69
lines changed

3 files changed

+74
-69
lines changed

inst/hooks/exported/codemeta-description-updated.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env Rscript
22

3-
"A hook to make sure DESCRIPTION hasn’t been edited more recently than
3+
"A hook to make sure DESCRIPTION hasn’t been edited more recently than
44
codemeta.json.
55
66
Usage:
77
codemeta-description-updated [--root=<root_>] <_ignored>...
88
99
Options:
10-
--root=<root_> Path relative to the git root that contains the R package
10+
--root=<root_> Path relative to the git root that contains the R package
1111
root [default: .].
1212
1313
" -> doc

inst/hooks/exported/use-tidy-description.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env Rscript
22

3-
"A hook to run usethis::use_tidy_description() to ensure dependencies are
3+
"A hook to run usethis::use_tidy_description() to ensure dependencies are
44
ordered alphabetically and fields are in standard order.
55
66
Usage:

tests/testthat/test-hooks.R

Lines changed: 71 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@ run_test("use-tidy-description", "DESCRIPTION", suffix = "")
66

77
# in sub directory with correct root
88
run_test("use-tidy-description",
9-
"DESCRIPTION",
10-
suffix = "",
11-
cmd_args="--root=rpkg",
12-
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION")))
9+
"DESCRIPTION",
10+
suffix = "",
11+
cmd_args = "--root=rpkg",
12+
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
13+
)
1314

1415

1516

1617
# in sub directory with incorrect root
1718
# Need to generate the directoy `rpkg` but without DESCRIPTION file.
1819
run_test("use-tidy-description",
19-
"DESCRIPTION",
20-
suffix = "",
21-
cmd_args="--root=rpkg",
22-
std_err="No `DESCRIPTION` found in repository.",
23-
artifacts = c("rpkg/README.md" = test_path("in/README.md")))
20+
"DESCRIPTION",
21+
suffix = "",
22+
cmd_args = "--root=rpkg",
23+
std_err = "No `DESCRIPTION` found in repository.",
24+
artifacts = c("rpkg/README.md" = test_path("in/README.md"))
25+
)
2426

2527
### . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..
2628
### style-files ####
@@ -393,30 +395,30 @@ run_test("roxygenize",
393395

394396
# with outdated Rd present in correct root
395397
run_test("roxygenize",
396-
file_name = c("rpkg/man/flie.Rd" = "flie.Rd"),
397-
suffix = "",
398-
std_err = NA,
399-
cmd_args="--root=rpkg",
400-
std_out = "Writing NAMESPACE",
401-
artifacts = c(
402-
"rpkg/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
403-
"rpkg/R/roxygenize.R" = test_path("in/roxygenize.R")
404-
),
405-
file_transformer = function(files) {
406-
git_init()
407-
git2r::add(path = files)
408-
# hack to add artifact to trigger diff_requires_roxygenize()
409-
git2r::add(path = fs::path(fs::path_dir(fs::path_dir(files[1])), "rpkg/R"))
410-
files
411-
}
398+
file_name = c("rpkg/man/flie.Rd" = "flie.Rd"),
399+
suffix = "",
400+
std_err = NA,
401+
cmd_args = "--root=rpkg",
402+
std_out = "Writing NAMESPACE",
403+
artifacts = c(
404+
"rpkg/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
405+
"rpkg/R/roxygenize.R" = test_path("in/roxygenize.R")
406+
),
407+
file_transformer = function(files) {
408+
git_init()
409+
git2r::add(path = files)
410+
# hack to add artifact to trigger diff_requires_roxygenize()
411+
git2r::add(path = fs::path(fs::path_dir(fs::path_dir(files[1])), "rpkg/R"))
412+
files
413+
}
412414
)
413415

414416

415417
# without Rd present
416418
run_test("roxygenize",
417419
file_name = c("rpkg1/R/roxygenize.R" = "roxygenize.R"),
418420
suffix = "",
419-
cmd_args="--root=rpkg1",
421+
cmd_args = "--root=rpkg1",
420422
std_err = "Please commit the new `.Rd` files",
421423
artifacts = c(
422424
"rpkg1/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
@@ -427,22 +429,21 @@ run_test("roxygenize",
427429
git2r::add(path = files)
428430
files
429431
}
430-
431432
)
432433

433434
# with Rd present in wrong root
434435
run_test("roxygenize",
435-
file_name = c("R/roxygenize.R" = "roxygenize.R"),
436-
suffix = "",
437-
std_err = "Please commit the new `.Rd` files",
438-
artifacts = c(
439-
"DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf")
440-
),
441-
file_transformer = function(files) {
442-
git_init()
443-
git2r::add(path = files)
444-
files
445-
}
436+
file_name = c("R/roxygenize.R" = "roxygenize.R"),
437+
suffix = "",
438+
std_err = "Please commit the new `.Rd` files",
439+
artifacts = c(
440+
"DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf")
441+
),
442+
file_transformer = function(files) {
443+
git_init()
444+
git2r::add(path = files)
445+
files
446+
}
446447
)
447448

448449

@@ -516,38 +517,42 @@ run_test("codemeta-description-update",
516517

517518
# succeed in correct root
518519
run_test("codemeta-description-update",
519-
file_name = c("rpkg/DESCRIPTION" = "DESCRIPTION",
520-
"rpkg/codemeta.json" = "codemeta.json"),
521-
cmd_args="--root=rpkg",
522-
suffix = "",
523-
file_transformer = function(files) {
524-
if (length(files) > 1) {
525-
# transformer is called once on all files and once per file
526-
content_2 <- readLines(files[2])
527-
Sys.sleep(2)
528-
writeLines(content_2, files[2])
529-
}
530-
files
531-
}
520+
file_name = c(
521+
"rpkg/DESCRIPTION" = "DESCRIPTION",
522+
"rpkg/codemeta.json" = "codemeta.json"
523+
),
524+
cmd_args = "--root=rpkg",
525+
suffix = "",
526+
file_transformer = function(files) {
527+
if (length(files) > 1) {
528+
# transformer is called once on all files and once per file
529+
content_2 <- readLines(files[2])
530+
Sys.sleep(2)
531+
writeLines(content_2, files[2])
532+
}
533+
files
534+
}
532535
)
533536

534537
# # fail in wrong root
535538
run_test("codemeta-description-update",
536-
file_name = c("rpkg/DESCRIPTION" = "DESCRIPTION",
537-
"rpkg/codemeta.json" = "codemeta.json",
538-
"rpkg2/codemeta.json" = "README.md"),
539-
cmd_args="--root=rpkg2",
540-
std_err="No `DESCRIPTION` found in repository.",
541-
suffix = "",
542-
file_transformer = function(files) {
543-
if (length(files) > 1) {
544-
# transformer is called once on all files and once per file
545-
content_2 <- readLines(files[2])
546-
Sys.sleep(2)
547-
writeLines(content_2, files[2])
548-
}
549-
files
550-
}
539+
file_name = c(
540+
"rpkg/DESCRIPTION" = "DESCRIPTION",
541+
"rpkg/codemeta.json" = "codemeta.json",
542+
"rpkg2/codemeta.json" = "README.md"
543+
),
544+
cmd_args = "--root=rpkg2",
545+
std_err = "No `DESCRIPTION` found in repository.",
546+
suffix = "",
547+
file_transformer = function(files) {
548+
if (length(files) > 1) {
549+
# transformer is called once on all files and once per file
550+
content_2 <- readLines(files[2])
551+
Sys.sleep(2)
552+
writeLines(content_2, files[2])
553+
}
554+
files
555+
}
551556
)
552557

553558
### . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..

0 commit comments

Comments
 (0)