Skip to content

[Linting Rule] Seeded Randomness

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

Generated from 'wiki-linter.ts' on 2026-10-27, 10:46:55 UTC (v2.16.6), do not edit directly.

Seeded Randomness [overview]

smell reproducibility robustness

This rule is a best-effort rule.

Finds randomness-based function calls not preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like set.seed.
This linting rule is implemented in src/linter/rules/seeded-randomness.ts.

Configuration

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

  • randomnessConsumers
    A set of randomness consumer function names that require a seed to be set prior to invocation.
  • randomnessProducers
    A set of functions and variables whose invocation or assignment causes a random seeded to be set. Each entry has a type, which is either function or assignment, and a name, which is the name of the function or variable. The default value for this is the function set.seed and the variable .Random.seed.

Examples

runif(1)

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

[ { "type": "linter",   "rules": [ { "name": "seeded-randomness",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (1 ms)
   ╰ Seeded Randomness (seeded-randomness):
       ╰ certain:
           ╰ Function runif at 1.1-8

More examples are the test cases in test/functionality/linter/lint-seeded-randomness.test.ts.

Clone this wiki locally

⌂ 换网址