Skip to content

Commit dc9ec4c

Browse files
committed
chore: Formatting and linting
1 parent 174bfe4 commit dc9ec4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+558
-273
lines changed

.lintr

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
linters: with_defaults(
1+
linters: lintr::linters_with_defaults(
22
assignment_linter = NULL,
33
commented_code_linter = NULL,
4-
line_length_linter(100),
5-
cyclocomp_linter = NULL
6-
)
4+
line_length_linter = lintr::line_length_linter(100)
5+
)

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: inteRgrate
33
Title: Opinionated Package Coding Styles
4-
Version: 1.0.22
4+
Version: 1.0.23
55
Authors@R:
66
person("Jumping", "Rivers", , "info@jumpingrivers.com", role = c("aut", "cre"))
77
Description: A set of functions to enforce styling in functions. This
@@ -18,9 +18,10 @@ Imports:
1818
tibble,
1919
usethis
2020
Suggests:
21+
cyclocomp,
2122
roxygen2,
2223
testthat,
2324
withr
2425
Encoding: UTF-8
2526
LazyData: true
26-
RoxygenNote: 7.1.2
27+
RoxygenNote: 7.3.3

NEWS.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# inteRgrate 1.0.23 (2026-01-22)
2+
* chore: Spring clean; formatting linting, running jarl
3+
14
# inteRgrate 1.0.22 _2022-05-25_
25
* Bug: Remove empty lines from .Rbuildignore for `check_version()`
36

@@ -38,10 +41,10 @@
3841
# inteRgrate 1.0.8 _2021-01-05_
3942
* Feature: `check_version()` now works with multiple pkgs in a repo
4043
* Bug: `check_lintr()` ignores `R/*.rda` files (fixes #33)
41-
44+
4245
# inteRgrate 1.0.7 _2020-11-25_
4346
* Feature: `check_all()` to run all checks
44-
* Feature: Call `stop()` at the of the checks
47+
* Feature: Call `stop()` at the of the checks
4548

4649
# inteRgrate 1.0.6 _2020-10-23_
4750
* Feature: allow `*` as emphasis indicator
@@ -64,7 +67,7 @@
6467
* Feature: Ensure files end with a line break
6568
* Feature: Build pkgs and set ENV variables
6669
* Feature: Add tests for yml parsing
67-
70+
6871
# inteRgrate 1.0.1
6972
* Breaking changes
7073
* Feature: use __rcmdcheck__ instead of __devtools__. This breaks/changes a few things.

R/build.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build_pkg = function() {
1818
set_renviron_var("PKG_TARBALL_PATH", full_path)
1919
cli::cli_alert_info("PKG_TARBALL_PATH {full_path}")
2020

21-
return(pkg_tar_ball)
21+
pkg_tar_ball
2222
}
2323

2424
#' @rdname build_pkg

R/check_all.R

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@
1010
#' @details The arguments for the function correspond to a particular check, e.g. check_ARGNAME().
1111
#' Note: As this package matures, this function will include the newer checks.
1212
#' @export
13-
check_all = function(pkg = TRUE, lintr = TRUE,
14-
namespace = TRUE, r_filenames = TRUE,
15-
version = TRUE, gitignore = TRUE,
16-
tidy_description = TRUE, readme = TRUE,
17-
file_permissions = TRUE, line_breaks = TRUE,
18-
tag = TRUE, news = TRUE,
19-
rproj = TRUE) {
13+
check_all = function(
14+
pkg = TRUE,
15+
lintr = TRUE,
16+
namespace = TRUE,
17+
r_filenames = TRUE,
18+
version = TRUE,
19+
gitignore = TRUE,
20+
tidy_description = TRUE,
21+
readme = TRUE,
22+
file_permissions = TRUE,
23+
line_breaks = TRUE,
24+
tag = TRUE,
25+
news = TRUE,
26+
rproj = TRUE
27+
) {
2028
.check$all = TRUE
2129
# Extract all arguments and values
2230
args = as.list(environment())
@@ -30,5 +38,5 @@ check_all = function(pkg = TRUE, lintr = TRUE,
3038
msg_error("Issues Detected")
3139
stop("Please fix")
3240
}
33-
return(invisible(NULL))
41+
invisible(NULL)
3442
}

R/check_gitignore.R

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,29 @@ check_gitignore = function(path = ".") {
4141
## .e.g *.synctex(busy)
4242
ignores = ignores[!stringr::str_detect(ignores, pattern = "\\(|\\)")]
4343

44-
list_ignores = sapply(glob2rx(ignores, trim.head = FALSE, trim.tail = FALSE),
45-
function(ignore) stringr::str_detect(git_global_ignore, ignore))
44+
list_ignores = sapply(
45+
glob2rx(ignores, trim.head = FALSE, trim.tail = FALSE),
46+
function(ignore) stringr::str_detect(git_global_ignore, ignore)
47+
)
4648

47-
mat_ignores = matrix(list_ignores, ncol = length(git_global_ignore), byrow = TRUE)
49+
mat_ignores = matrix(
50+
list_ignores,
51+
ncol = length(git_global_ignore),
52+
byrow = TRUE
53+
)
4854

4955
ignore_files = apply(mat_ignores, 2, any)
5056
missing_ignores = git_global_ignore[!ignore_files]
5157
if (length(missing_ignores) != 0L) {
5258
for (ignore in missing_ignores) {
5359
msg_error(paste("Missing", ignore, " from .gitignore"))
5460
}
55-
msg_error("Copying github.com/github/gitignore/blob/master/R.gitignore is a good start.")
61+
msg_error(
62+
"Copying github.com/github/gitignore/blob/master/R.gitignore is a good start."
63+
)
5664
msg_error("Please update your .gitignore")
5765
} else {
5866
cli::cli_alert_success(".gitignore looks good")
5967
}
60-
return(invisible(NULL))
68+
invisible(NULL)
6169
}

R/check_lintr.R

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
get_exclusions = function() {
2-
if (!file.exists(".lintr")) return(c("^R/|^cache/|^packrat/|^renv/"))
2+
if (!file.exists(".lintr")) {
3+
return(c("^R/|^cache/|^packrat/|^renv/"))
4+
}
35

46
exclusions = read.dcf(".lintr", all = TRUE)$exclusions
57

6-
if (is.null(exclusions)) return(c("^R/|^cache/|^packrat/|^renv/"))
8+
if (is.null(exclusions)) {
9+
return(c("^R/|^cache/|^packrat/|^renv/"))
10+
}
711
exclusions = stringr::str_split(exclusions, ",")[[1]]
812
exclusions = stringr::str_remove(exclusions, "list\\W?\\(")
913
exclusions = stringr::str_remove(exclusions, "\\)$")
1014
exclusions = stringr::str_squish(exclusions)
1115
exclusions = stringr::str_remove_all(exclusions, ("^\"|\"$"))
1216

1317
## Convert to regular expression
14-
pattern = paste0(c(exclusions, "^R/", "^cache/", "^packrat/", "^renv/"), collapse = "|")
15-
return(pattern)
18+
pattern = paste0(
19+
c(exclusions, "^R/", "^cache/", "^packrat/", "^renv/"),
20+
collapse = "|"
21+
)
22+
pattern
1623
}
1724

1825
lint_files = function() {
1926
lint_errors = FALSE
20-
lints = lintr::lint_package(exclusions = list("R/RcppExports.R", "renv", "packrat", "cache"))
27+
lints = lintr::lint_package(
28+
exclusions = list("R/RcppExports.R", "renv", "packrat", "cache")
29+
)
2130
if (length(lints) > 0) {
2231
lapply(lints, print)
2332
lint_errors = TRUE
@@ -34,7 +43,7 @@ lint_files = function() {
3443
}
3544
}
3645

37-
return(lint_errors)
46+
lint_errors
3847
}
3948

4049
#' @title The lintr check
@@ -63,5 +72,5 @@ check_lintr = function(path = ".") {
6372
} else {
6473
cli::cli_alert_success("Lint looks good")
6574
}
66-
return(invisible(NULL))
75+
invisible(NULL)
6776
}

R/check_namespace.R

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,33 @@ check_namespace = function(no_imports = NULL, path = ".") {
1616
cli::cli_h3("Checking namespace for imports()...check_namespace()")
1717
namespace = readLines(file.path(path, "NAMESPACE"))
1818

19-
imports_only = namespace[substr(namespace, 1, 7) == "import("]
19+
imports_only = namespace[startsWith(namespace, "import(")]
2020
if (length(imports_only) == no_imports) {
21-
msg = glue("Imports look good - {length(imports_only)} found, {no_imports} allowed")
21+
msg = glue(
22+
"Imports look good - {length(imports_only)} found, {no_imports} allowed"
23+
)
2224
cli::cli_alert_success(msg)
2325
return(invisible(NULL))
2426
} else if (length(imports_only) < no_imports) {
25-
msg = glue("Imports look good - {length(imports_only)} found, {no_imports} allowed.
26-
But you could reduce the number of imports allowed")
27+
msg = glue(
28+
"Imports look good - {length(imports_only)} found, {no_imports} allowed.
29+
But you could reduce the number of imports allowed"
30+
)
2731
cli::cli_alert_warning(msg)
2832
return(invisible(NULL))
2933
}
3034

3135
imports_only = substr(imports_only, 8, nchar(imports_only) - 1)
3236
for (import in imports_only) {
33-
msg = glue::glue("The package {import} is being directly imported - \\
34-
use importFrom instead.")
37+
msg = glue::glue(
38+
"The package {import} is being directly imported - \\
39+
use importFrom instead."
40+
)
3541
msg_error(msg)
3642
}
37-
msg = glue::glue("A total of {length(imports_only)} imports detected. \\
38-
But only {no_imports} are allowed.")
43+
msg = glue::glue(
44+
"A total of {length(imports_only)} imports detected. \\
45+
But only {no_imports} are allowed."
46+
)
3947
msg_error(msg)
4048
}

R/check_news.R

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
check_news_major = function(news, pkg_name, version) {
2-
pattern = glue::glue("^# <pkg_name> <version> [_\\*]20\\d{2}-\\d{2}-\\d{2}[_\\*]$",
3-
.open = "<", .close = ">")
2+
pattern = glue::glue(
3+
"^# <pkg_name> <version> [_\\*]20\\d{2}-\\d{2}-\\d{2}[_\\*]$",
4+
.open = "<",
5+
.close = ">"
6+
)
47
if (stringr::str_detect(news[1], pattern = pattern, negate = TRUE)) {
5-
msg = glue::glue("Top line of NEWS.md not have correct format. It should be
6-
# {pkg_name} {version} _{Sys.Date()}_")
8+
msg = glue::glue(
9+
"Top line of NEWS.md not have correct format. It should be
10+
# {pkg_name} {version} _{Sys.Date()}_"
11+
)
712
msg_error(msg)
813
} else {
914
cli::cli_alert_success("Your NEWS.md has the correct format")
@@ -13,8 +18,10 @@ check_news_major = function(news, pkg_name, version) {
1318
check_news_minor = function(news, pkg_name, version) {
1419
pattern = glue::glue("^# {pkg_name} \\(development version\\)$")
1520
if (stringr::str_detect(news[1], pattern = pattern, negate = TRUE)) {
16-
msg = glue::glue("Top line of NEWS.md not have correct format. It should be
17-
# {pkg_name} (development version)")
21+
msg = glue::glue(
22+
"Top line of NEWS.md not have correct format. It should be
23+
# {pkg_name} (development version)"
24+
)
1825
msg_error(msg)
1926
} else {
2027
cli::cli_alert_success("Your NEWS.md has the correct format")
@@ -45,7 +52,7 @@ check_news = function(pattern = NULL, path = ".") {
4552
} else {
4653
check_news_minor(news, pkg_name, version)
4754
}
48-
return(invisible(NULL))
55+
invisible(NULL)
4956
}
5057

5158

@@ -67,5 +74,5 @@ check_all_news = function(pattern = NULL) {
6774
} else {
6875
cli::cli_alert_success("Your NEWS.md has the correct format")
6976
}
70-
return(invisible(NULL))
77+
invisible(NULL)
7178
}

R/check_pkg.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ check_pkg = function(path = ".") {
1616
## Install package dependencies
1717
cli::cli_h2("Installing package")
1818
remotes::install_deps(path, dependencies = TRUE, upgrade = "never")
19-
remotes::install_local(path, upgrade = "never", build_vignettes = TRUE, force = TRUE)
19+
remotes::install_local(
20+
path,
21+
upgrade = "never",
22+
build_vignettes = TRUE,
23+
force = TRUE
24+
)
2025

21-
check_output = rcmdcheck::rcmdcheck(path = ".",
22-
args = c("--timings"), # Add option for as--cran?
23-
error_on = "error")
26+
check_output = rcmdcheck::rcmdcheck(
27+
path = ".",
28+
args = c("--timings"), # Add option for as--cran?
29+
error_on = "error"
30+
)
2431
check_output = rcmdcheck::check_details(check_output)
2532

2633
allowed_notes = get_env_variable("ALLOWED_NOTES", 0)
@@ -43,5 +50,5 @@ check_pkg = function(path = ".") {
4350
if (no_of_warnings > allowed_warnings || no_of_notes > allowed_notes) {
4451
msg_error("You have too many WARNINGS and/or NOTES")
4552
}
46-
return(invisible(NULL))
53+
invisible(NULL)
4754
}

0 commit comments

Comments
 (0)