Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create spec/static-analysis directory for static analysis of classes #5

Closed
ajvincent opened this issue Apr 9, 2021 · 2 comments
Closed

Comments

@ajvincent
Copy link
Owner

ajvincent commented Apr 9, 2021

... which is a hairy problem in and of itself.

sverweij/dependency-cruiser#336 is the closest I could find to what I need, more complex than eslint but not designed for unit tests.

Example: KeyHasher must store non-primitive keys weakly. Truly verifying that would require analysis of an abstract syntax tree (AST), trying to trace an entry point (an argument in one function) to points that assign or store a value. I could see that requiring a few things, of which I only know I need the first three:

  • An Acorn-generated AST.
  • Maybe a tree-walking tool to invoke traps for certain AST node types.
  • An entry tuple to pass in and start the analysis, looking for any assignment or storage which returned false for a rejected state (meaning a strong reference).
  • A composite set for assignment and storage nodes, with test functions returning true ("accept"), false ("reject") or undefined (for "unknown, dig deeper").
  • A composite set of tree nodes representing arguments and return / throw values from one function to another.
  • A "non-deterministic finite automation" (also known as a state machine) combining the previous two sets and a starting point.
    • Because of the changing nature of this and/or stack traces, the automaton might need to become a "push-down automaton", which is just lovely for the added complexity.

Crafting this would be ugly, but the composite collections I'm building could make it easier, ironically enough.

Honestly, the complexity of this type of analysis could result in a complementary project, where each one uses the other as a development dependency...

@ajvincent
Copy link
Owner Author

Note to self: look up "call graphs" in JavaScript. That's a pretty good starting point.

@ajvincent
Copy link
Owner Author

Too complicated for a project just starting out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant