Skip to content

[Bug]: Unseeded randomness not detected if seed function potentially unreachable #2015

@OliverGerstl

Description

@OliverGerstl

What happened?

The current implementation of the seeded-randomness linter rule does not detect unseeded randomness if a seed setter function is used in a (potentially unreachable) control flow branch. The seed setter function call should be a control flow dominator of randomness function to report no issue.
For example, the seeded-randomness linter rule does not report an issue for runif in the following code, although set.seed is unreachable in this case:

if (1 < 0) {
    set.seed(1)
}
x <- runif(1)

What version of R do you have installed?

No response

What version of flowR did you use?

v2.6.2 (Nov 9, 2025)

Relevant log output

:query @linter rules:seeded-randomness "if (1 < 0) {set.seed(1)} x <- runif(1)"
Query: linter (18 ms)
   ╰ **Seeded Randomness** (seeded-randomness):
       ╰ _Metadata_: <code>{"consumerCalls":1,"callsWithFunctionProducers":1,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":16,"processTimeMs":1}</code>
All queries together required ≈18 ms (1ms accuracy, total 21 ms)

Meta Information

  • The issue is urgent
  • I used flowR as a docker image

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingflowr linterRelated to the linter that we're implementing on top of the search api

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions