Skip to content

[Linting Rule] Foreign Function Calls

github-actions[bot] edited this page Oct 25, 2026 · 1 revision

Generated from 'wiki-linter.ts' on 2026-10-25, 09:29:25 UTC (v2.16.6), do not edit directly.

Foreign Function Calls [overview]

bug cmd-check 40 robustness

This rule ports the following steps of R CMD check (see the conformance table for the legend):

# Step Coverage Note
40 foreign function calls (book) 🔷⭐ ⭐ also resolves PACKAGE arguments through variables
routine registration needs the installed package

This rule is a best-effort rule.

Finds problems in .Call, .C, .External, and .Fortran calls: a missing or empty PACKAGE, calls into base or other packages, and undeclared packages. Routine and package names are resolved through variables.
This linting rule is implemented in src/linter/rules/cmd-check/foreign-function-calls.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The foreign-function-calls rule accepts the following configuration options:

  • resolveValues
    also resolve the routine and PACKAGE through variables, which R CMD check cannot see (default true)
    R CMD check #40

Examples

f <- function(x) .Call("C_mean", x)

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "foreign-function-calls",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (2 ms)
   ╰ Foreign Function Calls (foreign-function-calls):
       ╰ certain:
           ╰ .Call("C_mean"): missing-package at 1.18-35

More examples are the test cases in test/functionality/linter/cmd-check/lint-foreign-function-calls.test.ts.

Clone this wiki locally