Robustness & maintenance follow-ups from a code audit
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- docker, javascript, r
Research direction
This is a grab-bag; pick one bullet first. For the locale bug, sanitize_r_name() lives in R/add_r_files.R and tests/testthat/test-add_r_files.R:244 is the failing case — reproduce with LANG=C. For deployment, compare add_dockerfile() with add_dockerfile_with_renv() under R/. The test bullets touch tests/testthat/test-install_dev_deps.R and the root .lintr. Done means a fix plus a regression test per bullet, with the Suggests-check script from the issue passing.
Written by the indexing model from the issue text.
Description
Smaller points found while auditing master (9938a41). Each one was checked against the code; they're grouped here to avoid flooding the tracker and can be split into dedicated issues if needed.
Robustness
-
sanitize_r_name()depends on the locale.iconv(name, to = "ASCII//TRANSLIT")returnsNAin a non-UTF-8 locale (e.g.LANG=C, common in Docker images), and the fallback keeps the raw name, so"éclair"becomes"clair".test-add_r_files.R:244fails underLANG=C.?iconvalso notes that//TRANSLITresults are platform-dependent. A small explicit transliteration table, or a warning when transliteration fails, would make the result deterministic. - The generated "app launches" test never runs in CI.
expect_running()callstestthat::skip_if_not(rlang_is_interactive()), so the test added byuse_recommended_tests()is always skipped inR CMD check/ CI. Related to #690. - Production mode is inconsistent across deployment helpers.
add_dockerfile(),add_dockerfile_shinyproxy()andadd_dockerfile_heroku()don't setgolem.app.prod = TRUEin theCMD, while theadd_dockerfile_with_renv*()variants do by default. Also, theapp_prodkey ofgolem-config.ymlis not read byapp_prod()(which only reads the R option), which is confusing. -
run_dev()installs missing packages without asking by default.install_required_packages = TRUEis forwarded asforce_install = TRUEtoinstall_dev_deps(). - Remote agent skills (
source = "remote"):- the
mainbranch is used with no pinned ref; manifest.ymland the zip archive are downloaded separately, so they can come from different commits;- target paths are built from manifest values (
targets.*.path,main_file_name, skill names) without validation. A guard against../ absolute paths would make sure nothing is written outside the project.
- the
-
bundle_resources():- CSS files are added as hand-built
<link href = "<basename(path)>/...">, which assumes the resource prefix equalsbasename(path).htmltools::htmlDependency(stylesheet = )would handle this; version = "0.0.1"is fixed, so the dependency URL never changes between app releases. Defaulting to the app version would help with browser caching.
- CSS files are added as hand-built
Tests & tooling
- Guard against regressions like #1251. Add a test asserting that runtime functions (
favicon(),bundle_resources(),add_resource_path(),with_golem_options(),golem_welcome_page(),maintenance_page(),get_golem_options(),app_prod(),activate_js(),invoke_js()) never reach a Suggests-backed helper (fs_*,cli_*,desc_*, ...). They're all clean today; acodetools::findGlobals()walk over the namespace is enough to check it (script below). -
test-install_dev_deps.Rperforms real network installs withoutskip_on_cran()/skip_if_offline(), and asserts nothing when the packages are already installed. Mocking the installer would make it deterministic. -
.lintrcan't be read by lintr. It has no final newline, so lintr fails with "Malformed config file". Either fix it or remove it, sinceairis the formatter. - Dead code:
ask_golem_creation_upon_config(),set_name(), and thegetRversion() >= "3.5"branch inuse_favicon()(Depends: R (>= 3.5.0)). -
add_js_input_binding()/add_js_output_binding()generate JS through ~80write_there()calls. A template file ininst/with placeholders would be easier to read and maintain.
Script used to check runtime functions against Suggests
ns <- asNamespace("golem")
runtime <- c(
"favicon",
"bundle_resources",
"add_resource_path",
"with_golem_options",
"golem_welcome_page",
"maintenance_page",
"get_golem_options",
"app_prod",
"app_dev",
"activate_js",
"invoke_js",
"is_running"
)
suggest_wrappers <- grep(
"^(fs_|cli_|desc_|usethis_|rstudioapi_|roxygen2_|pkgload_|testthat_|attachment_|dockerfiler_)",
ls(
ns,
all.names = TRUE
),
value = TRUE
)
reach <- function(
f,
seen = character()
) {
if (f %in% seen || !exists(f, ns, inherits = FALSE) || !is.function(ns[[f]])) {
return(seen)
}
seen <- c(
seen,
f
)
calls <- codetools::findGlobals(
ns[[f]],
merge = FALSE
)$functions
for (g in intersect(calls, ls(ns, all.names = TRUE))) {
seen <- reach(
g,
seen
)
}
seen
}
for (f in runtime) {
bad <- intersect(
reach(f),
suggest_wrappers
)
stopifnot(
length(bad) == 0
)
}
Generated by Claude Code
- Dominant language
- R
- Stars
- 947
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ThinkR-open/golem
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ThinkR-open/golem#1265 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ThinkR-open/golem#1259 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ThinkR-open/golem#1258 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
ThinkR-open/golem#1257 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ThinkR-open/golem#1256 ·
All issues in ThinkR-open/golem
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
leppott/BioMonTools#162 ·
-
publications
Difficulty 1/5 Under an hour Newbie friendliness 85/100
epiforecasts/epiforecasts.github.io#161 ·
Maintainers usually reply within 1 day
-
Label `{sas}` chunk source as `sas` instead of `txt`, so it gets syntax highlightingPossibly taken @michaelmayer2 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microbiome/OMA#1031 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
furrer-lab/abn#291 · 2 comments ·