## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(reproducr) ## ----test-entry--------------------------------------------------------------- # Temporarily add a test entry to verify the detection logic # (this is what a test in tests/testthat/ would do) # 1. Write a script that calls the at-risk function test_script <- tempfile(fileext = ".R") writeLines("x <- dplyr::summarise(mtcars, n = dplyr::n())", test_script) # 2. Audit it — package version will be from installed library report <- audit_script(test_script, renv = FALSE, verbose = FALSE) # 3. Confirm the call was detected report$calls[, c("pkg", "fn", "pkg_version")] # 4. Run the changelog check risks <- risk_score(report, methods = "changelog") # 5. If the installed version is in the risk window, it will be flagged if (nrow(risks) > 0) { as.data.frame(risks)[, c("call", "pkg_version", "risk", "check")] } else { cat("Installed version is outside the risk window — entry is correct,\n") cat("but not triggered by this version.\n") } ## ----test-with-version-------------------------------------------------------- # Force the version to sit inside the dplyr::summarise risk window report_forced <- report report_forced$calls$pkg_version <- as.character(report_forced$calls$pkg_version) report_forced$calls$pkg_version[report_forced$calls$pkg == "dplyr"] <- "1.1.0" risks_forced <- risk_score(report_forced, methods = "changelog") as.data.frame(risks_forced)[, c("call", "pkg_version", "risk")] ## ----cleanup, include = FALSE------------------------------------------------- unlink(test_script)