Skip to content

[Linting Rule] Call Contracts

github-actions[bot] edited this page Nov 27, 2026 · 1 revision

Generated from 'wiki-linter.ts' on 2026-11-13, 12:11:51 UTC (v2.17.6), do not edit directly.

Call Contracts [overview]

bug robustness

This rule is a best-effort rule.

Finds calls that hand a function a value its contract rules out, or leave out an argument it needs, so they fail whenever they run.
This linting rule is implemented in src/linter/rules/call-contracts.ts.

Examples

f <- function(x, n) { stopifnot(length(x) >= n); x }
f(1:3, 5)
g <- function(how = c("fast", "exact")) match.arg(how)
g("slow")
combn(4, -1)
strsplit(1, "a")

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

[ { "type": "linter",   "rules": [ { "name": "call-contracts",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (105 ms)
   ╰ Call Contracts (call-contracts):
       ╰ uncertain:
           ╰ call of f fails its contract at 2.1-9
           ╰ call of g fails its contract at 4.1-9
           ╰ call of combn fails its contract at 5.1-12
           ╰ call of strsplit fails its contract at 6.1-16

More examples are the test cases in test/functionality/linter/lint-call-contracts.test.ts.

Clone this wiki locally