codeCheckModule: Statically check a SpaDES module's source code (v2)

View source: R/codecheck-api.R

codeCheckModuleR Documentation

Statically check a SpaDES module's source code (v2)

Description

Walks the module's source via xmlparsedata, collects every reference to sim$x / sim[["x"]] / get("x", envir = envir(sim)) and to parameters (Par$x, P(sim)$x, params(sim)$mod$x), then compares those uses to the module's defineModule() metadata. Reports any mismatches as a structured tibble of findings, optionally printed as grouped tables.

Usage

codeCheckModule(path, print = TRUE, enable = NULL, disable = NULL)

Arguments

path

Path to a module directory (containing ⁠<modName>/<modName>.R⁠, and optionally an ⁠R/⁠ subfolder of helper scripts) or to a single .R file. If a directory, the module name is the directory's basename.

print

Logical; print the grouped report. Default TRUE.

enable, disable

Optional character vectors of rule IDs to restrict the run. See names(SpaDES.core:::.CC_RULES) for the catalogue.

Details

This is the v2 implementation, selectable at simInit() time via options(spades.codeCheckEngine = "v2") (the default). The legacy v1 checker is still available via options(spades.codeCheckEngine = "v1").

Value

A data.frame of findings (one row per problem). Returned invisibly. Empty if the module is clean.


SpaDES.core documentation built on May 23, 2026, 5:07 p.m.