Skip to content

Commit 2f693ec

Browse files
authored
chore: Linting and update requirements.txt (#41)
1 parent 1754cfe commit 2f693ec

22 files changed

+332
-173
lines changed

.Rbuildignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ rsconnect/
1515
^jrHealthCheckConnect\.Rproj$
1616
/rsconnect/
1717
^\.github$
18-
^\.commitlintrc\.yml$
18+
^\.commitlintrc\.yml$
19+
^[.]?air[.]toml$
20+
^\.vscode$

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: audit.base
33
Title: Base package for Posit Checks
4-
Version: 0.6.21
4+
Version: 0.6.22
55
Authors@R:
66
person("Jumping", "Rivers", , "info@jumpingrivers.com", role = c("aut", "cre"))
77
Description: Base package for sharing classes between posit audit

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# audit.base 0.6.22 _2025-07-21_
2+
- chore: Use air for formatting
3+
- chore: Update requirements.txt for python example
4+
15
# audit.base 0.6.21 _2025-07-09_
26
- chore: Software bump
37
- feat: Update ubuntu to 24.04

R/check.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
init_r6_checks = function(dir, file, pkg_name) {
1111
exports = getNamespaceExports(pkg_name)
1212
check_exports = sort(exports[stringr::str_starts(exports, "check_")])
13-
r6_inits = purrr::map(check_exports, init_r6_check, dir = dir, file = file, pkg_name)
13+
r6_inits = purrr::map(
14+
check_exports,
15+
init_r6_check,
16+
dir = dir,
17+
file = file,
18+
pkg_name
19+
)
1420
purrr::discard(r6_inits, ~ is.null(.x))
1521
}
1622

R/check_server_headers.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@ check_server_headers = function(server) {
1414
# Detects if we are leaking server header information
1515
get_posit_headers = function(headers) {
1616
posit_header = headers %>%
17-
dplyr::filter(.data$header == "server" &
18-
stringr::str_detect(.data$message, "[p|P]osit")) %>%
17+
dplyr::filter(
18+
.data$header == "server" &
19+
stringr::str_detect(.data$message, "[p|P]osit")
20+
) %>%
1921
dplyr::mutate(
2022
documentation = "https://developer.mozilla.org/docs/Web/HTTP/Headers/Server",
2123
primary_header = TRUE,
2224
status = "WARN"
2325
)
2426
if (nrow(posit_header) == 0) {
25-
cli::cli_alert_success("{cli::col_green('server')}: Does not leak information")
27+
cli::cli_alert_success(
28+
"{cli::col_green('server')}: Does not leak information"
29+
)
2630
} else {
27-
cli::cli_alert_danger("{cli::col_red('server')}: Contains too much information")
31+
cli::cli_alert_danger(
32+
"{cli::col_red('server')}: Contains too much information"
33+
)
2834
}
2935
posit_header
3036
}

R/check_sys_deps.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
check_sys_deps = function(os_release, installed_libs, debug_level = 0:2) {
1313
debug_level = get_debug_level(debug_level)
1414
cli::cli_h2("Systems Libraries")
15-
cli::cli_alert_info("This may take a few minutes as we are deploying a plumber API onto Connect")
15+
cli::cli_alert_info(
16+
"This may take a few minutes as we are deploying a plumber API onto Connect"
17+
)
1618
# Clean up response
1719
pkg_look_up = get_os_sys_deps(os_release)
1820

R/config.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ create_config = function(file, pkg_name) {
2020
type = match.arg(type)
2121
yaml_file = file.path(dir, file)
2222
if (type == "error" && file.exists(yaml_file)) {
23-
cli::cli_abort("Config file already exists.
24-
Either delete or change the `type` argument.")
23+
cli::cli_abort(
24+
"Config file already exists.
25+
Either delete or change the `type` argument."
26+
)
2527
}
2628

2729
new_config = create_config_list(dir, file, default, pkg_name)
@@ -49,8 +51,10 @@ get_check_info = function(dir, file, pkg_name) {
4951
purrr::map_dfr(r6_inits, function(r6) c("class" = class(r6)[1], r6$info()))
5052
} else {
5153
tibble::tibble(
52-
class = character(0), group = character(0),
53-
short = character(0), context = character(0),
54+
class = character(0),
55+
group = character(0),
56+
short = character(0),
57+
context = character(0),
5458
long = character(0)
5559
)
5660
}
@@ -63,9 +67,7 @@ merge_configs = function(new, existing) {
6367
new[[v]] = merge_configs(new[[v]], existing[[v]])
6468
# Ensure that existing list is the same "type"
6569
# If not, new gets precedent
66-
} else if (v %in% xnames &&
67-
!is.null(existing[[v]]) &&
68-
!is.list(existing[[v]])) {
70+
} else if (v %in% xnames && !is.null(existing[[v]]) && !is.list(existing[[v]])) {
6971
new[[v]] = existing[[v]]
7072
}
7173
}

R/get_latest_versions_remote.R

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@ get_latest_versions_remote = function() {
44
r = get_latest_versions_from_posit("r")
55
py = get_latest_versions_from_posit("python")
66
# Drop latest to get all releases
7-
q = jsonlite::read_json("https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest")
8-
quarto = c("1.0.38", "1.1.189", "1.2.475", "1.3.450", "1.4.557", "1.5.57",
9-
stringr::str_remove(q$name, "^v"))
7+
q = jsonlite::read_json(
8+
"https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest"
9+
)
10+
quarto = c(
11+
"1.0.38",
12+
"1.1.189",
13+
"1.2.475",
14+
"1.3.450",
15+
"1.4.557",
16+
"1.5.57",
17+
"1.6.43",
18+
stringr::str_remove(q$name, "^v")
19+
)
1020

1121
software_tibble = tibble::tibble(
1222
software = rep(
@@ -31,7 +41,11 @@ get_latest_versions_from_posit = function(type = c("r", "python")) {
3141
url = glue::glue("https://cdn.posit.co/{type}/versions.json")
3242
versions = unlist(jsonlite::read_json(url))
3343
versions = unname(versions)
34-
tibble::tibble(patch = get_patch(versions), major = get_major(versions), versions = versions) %>%
44+
tibble::tibble(
45+
patch = get_patch(versions),
46+
major = get_major(versions),
47+
versions = versions
48+
) %>%
3549
dplyr::filter(!is.na(.data$patch)) %>%
3650
dplyr::arrange(.data$major, -.data$patch) %>%
3751
dplyr::group_by(.data$major) %>%

R/get_pkg_requirements.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# https://packagemanager.rstudio.com/__api__/swagger/index.html#/default/get_repos
2-
get_pkg_requirements = function(distribution = c("ubuntu", "redhat", "centos"),
3-
release = c("18.04", "20.04", "22.04", "24.04", "7", "8", "9"),
4-
base_url = "https://packagemanager.rstudio.com/__api__/repos/",
5-
repo_id = 2) {
2+
get_pkg_requirements = function(
3+
distribution = c("ubuntu", "redhat", "centos"),
4+
release = c("18.04", "20.04", "22.04", "24.04", "7", "8", "9"),
5+
base_url = "https://packagemanager.rstudio.com/__api__/repos/",
6+
repo_id = 2
7+
) {
68
distribution = match.arg(distribution)
79
release = match.arg(release)
8-
config_url = glue::glue("{repo_id}/sysreqs?all=true&distribution={distribution}&release={release}") # nolint
10+
config_url = glue::glue(
11+
"{repo_id}/sysreqs?all=true&distribution={distribution}&release={release}"
12+
) # nolint
913
url = glue::glue("{base_url}{config_url}")
1014
res = httr::GET(url)
1115
r = httr::content(res)

R/get_posit_remote_versions.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ get_posit_remote_versions = function(type = c("connect", "workbench")) {
2121
extract_posit_cves = function(section) {
2222
posit_name = rvest::html_attrs(section)
2323
posit_name = as.vector(posit_name["id"])
24-
posit_version = stringr::str_extract(posit_name, "[0-9]{4}\\.[0-9]{1,2}\\.[0-9]{1,2}")
24+
posit_version = stringr::str_extract(
25+
posit_name,
26+
"[0-9]{4}\\.[0-9]{1,2}\\.[0-9]{1,2}"
27+
)
2528

2629
li = section %>%
2730
rvest::html_elements("li") %>%

0 commit comments

Comments
 (0)