Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.

feat: infer purity of imported functions (and names) #171

Closed
5 tasks
lukarade opened this issue Sep 27, 2023 · 0 comments · Fixed by #238
Closed
5 tasks

feat: infer purity of imported functions (and names) #171

lukarade opened this issue Sep 27, 2023 · 0 comments · Fixed by #238
Assignees
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions

Comments

@lukarade
Copy link
Contributor

lukarade commented Sep 27, 2023

Is your feature request related to a problem?

Currently, references for imported functions and names are not detected.
Therefor their impact on the purity result is not put into consideration.

Desired solution

  • Resolve references for imported target/value nodes
  • Resolve references for imported function calls
  • Deal with aliases
  • Infer purity for imported target/value nodes
  • Infer purity for imported functions
@lukarade lukarade added enhancement 💡 New feature or request purity Inferring the purity of functions labels Sep 27, 2023
@lukarade lukarade self-assigned this Sep 27, 2023
@lukarade lukarade changed the title feat: resolve reference for multiple imports and imports with aliases feat: infer purity of imported functions (and names) Feb 27, 2024
@lukarade lukarade linked a pull request Feb 27, 2024 that will close this issue
lars-reimann pushed a commit that referenced this issue Mar 8, 2024
…#238)

Closes #171 #225 #237 

### Summary of Changes

After reviewing the new `resolve_references` approach, we found that
`build_call_graph` and thus `infer_purity` could also be optimised.
`built_call_graph` now uses the new `CallGraphBuilder` class and an
improved recursive approach to build a call graph from a
`Reasons`object:
First the data for classes is pre-processed, so that the `__init__` are
linked to their respective class.
Then, a function iterates over all `Reasons` objects and adds either a
`CallGraphNode` - for self defined functions and builtins, a
`CombinedCallGraphNode` - for a node that represents a cycle of
functions or an `ImportedCallGraphNode` - for imported functions to the
call graph. When a node is edited, all calls of that node are added as
children to that node.

`infer_purity` now uses the new `PurityAnalyzer` class to analyze the
call graph for impurity.
As before, all reasons for impurity are detected by first analyzing the
children of a `CallGraphNode` and propagating their results, before
analyzing the node itself. Imported nodes are treated separately.
Combined nodes are decombined to their original functions, and the
results of the combined node is transferred.

---------

Co-authored-by: megalinter-bot <[email protected]>
@github-project-automation github-project-automation bot moved this from Backlog to ✔️ Done in Library Analysis Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions
Projects
Status: ✔️ Done
1 participant