rsc-enclosing-guard
the conditions a node runs under, found by the ifs and loops among its ancestors.
- Group
- Code
- Runs
- Optional: run it with
ur lint --rule rsc-enclosing-guard - Level
- warning
- Reads
- Every file
- Fix
- None: which of the walk's conditions a guard must meet is the author's to say, and a host that gives a module over syntax no graph has no
guardsto ask
Why
The ifs and loops around a node are only some of what decides whether it runs: a check before it that returns, breaks, or throws decides it as much, and an if around it decides nothing where both its branches reach it. What decides whether a statement runs is its control dependence, which the control facts give: guards(v) of common::graph::Graph is the conditions a vertex runs under, as the concurrency rules read them. Only the concurrency rules' modules are given the graph so far; a module over syntax can ask dominates(a, b) and postDominates(a, b) whether a check comes before or after a node on every path.
The fix, as Ur suggests it: ask guards(v), or dominates.
For agents
Ask what decides whether a node runs from the control facts, guards(v) of common::graph::Graph, or ask dominates whether a check comes before it on every path, rather than reading the ifs and loops among its ancestors.
Example
checks/Guarded.rscmodule checks::Guarded
bool guarded(Tree n) = any(a <- ancestors(n), a is If, contains(unparse(a.condition), "enabled"));
$ ur lint --rule rsc-enclosing-guard
warning[rsc-enclosing-guard]: the `If`s around `n`, taken as the conditions it runs under
--> ./checks/Guarded.rsc:3:28 `a <- ancestors(n)`
= hint: ask `guards(v)`, or `dominates`
0 clone classes and 1 `rsc-enclosing-guard` finding in 1 file