blast_radius

Blast radius analysis

Description

Find all callers of a function across projects. Find callers of a function across projects

Given a function name and project, finds all internal callers within that project and all callers in downstream projects (projects whose DESCRIPTION lists this one in Depends, Imports, or LinkingTo).

Usage

1blast_radius(fn, project = NULL, scan_dir = path.expand("~"),
2             cache_dir = file.path(tools::R_user_dir("saber", "cache"), "symbols"),
3             exclude = default_exclude())

Arguments

  • fn: Character. Function name to search for.
  • project: Character. Project name (or path to project directory).
  • scan_dir: Directory to scan for downstream projects.
  • cache_dir: Directory for symbol cache files.
  • exclude: Character vector of directory basenames to skip when scanning for downstream projects.

Value

A data.frame with columns: caller, project, file, line.

Examples

1# Create a minimal project
2d <- file.path(tempdir(), "blastpkg")
3dir.create(file.path(d, "R"), recursive = TRUE, showWarnings = FALSE)
4writeLines("helper <- function(x) x + 1", file.path(d, "R", "helper.R"))
5writeLines("main <- function(x) helper(x * 2)", file.path(d, "R", "main.R"))
6
7# Find all callers of helper()
8blast_radius("helper", project = d, scan_dir = tempdir(),
9             cache_dir = tempdir())