enketo / enketo-validate

An ODK XForm validator around the Enketo form engine.

Home Page:https://enketo.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detect cyclic dependencies for calculations

MartijnR opened this issue · comments

E.g.:

  • node a has calculation b + 1
  • node b has calculation a + 1

Or:

  • node a has calculation b + 1
  • node b has calculation c + 1
  • node c has calculation a + 1

Suggested implementation:

  1. iterate through all calculation expressions to build a map of all calculation nodes with the nodes they reference (using xform._extractNodeReferences).
  2. then, for each calculation, do a recursive check of all dependent nodes (and their dependencies etc)
  3. check if any of the dependencies in 2 is the node itself