Skip to content

Expose cache_dir on fn_graph() to keep checks out of ~/.cache#32

Merged
TroyHernandez merged 3 commits into
mainfrom
fn-graph-cache-dir
May 17, 2026
Merged

Expose cache_dir on fn_graph() to keep checks out of ~/.cache#32
TroyHernandez merged 3 commits into
mainfrom
fn-graph-cache-dir

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Problem

`fn_graph()` called `symbols(project_dir)` without a `cache_dir` argument, so its example (`man/fn_graph.Rd`) and matching tinytest (`inst/tinytest/test_fn_graph.R`) both wrote to the user's persistent cache during R CMD check:

~/.cache/R/saber/symbols/fngdemo.rds
~/.cache/R/saber/symbols/fngraph-<HHMMSS>.rds

CRAN flags this with the checking for new files in some other directories NOTE. The same path was contributing to the downstream NOTE on corteza (https://www.stats.ox.ac.uk/pub/bdr/donttest/corteza.out).

Fix

Expose `cache_dir` as a parameter on `fn_graph()` mirroring the existing pattern in `blast_radius()` and `symbols()`:

```r
fn_graph <- function(project_dir, include_external = FALSE,
cache_dir = file.path(tools::R_user_dir("saber", "cache"), "symbols"),
...) {
idx <- symbols(project_dir, cache_dir = cache_dir)
...
}
```

Default is unchanged, so existing callers keep working. Example and test now pass `cache_dir = tempdir()`.

Verification

```
$ Rscript --vanilla tests/tinytest.R
All ok, 150 results (0.1s)

$ r -e 'tinypkgr::check()'
saber 0.7.1: 0 error(s), 0 warning(s), 0 note(s)

$ find ~/.cache/R/saber -type f -newer R/fn_graph.R
(no output)
```

`fn_graph` has zero in-repo callers per `saber::blast_radius("fn_graph", project = ".")`, so the signature addition is safe.

fn_graph() called symbols(project_dir) without a cache_dir, so its
example and the matching tinytest wrote to the user's persistent cache
(~/.cache/R/saber/symbols/<basename>.rds). That triggered CRAN's
'checking for new files in some other directories' NOTE on packages
that exercise fn_graph during R CMD check, and on saber itself when
the example runs.

Add cache_dir as an exposed parameter mirroring blast_radius() and
symbols(), forward it to symbols(), and update the example + test to
pass tempdir(). The default is unchanged for callers that omit it, so
existing usage keeps working.
… work

Inserting cache_dir between include_external and ... broke existing
positional callers: fn_graph(d, FALSE, 900) used to forward 900 into
graph_svg(...) but would now bind it to cache_dir and fail in symbols().

Putting cache_dir after ... makes it name-only, which matches base R
convention (paste's sep/collapse, c's recursive, etc.) and preserves
positional forwarding for graph_svg.
@TroyHernandez TroyHernandez merged commit 7af34f6 into main May 17, 2026
4 checks passed
@TroyHernandez TroyHernandez deleted the fn-graph-cache-dir branch May 17, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant