@eagleoutice/flowr 2.13.2 → 2.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -43
- package/abstract-interpretation/absint-visitor.js +2 -2
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +1 -1
- package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
- package/abstract-interpretation/unsupported-functions.js +1 -1
- package/config.d.ts +8 -0
- package/config.js +9 -1
- package/control-flow/cfg-dead-code.js +72 -11
- package/control-flow/control-flow-graph.js +2 -1
- package/control-flow/extract-cfg.js +85 -8
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/dataflow/environments/append.d.ts +1 -1
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in.d.ts +5 -1
- package/dataflow/environments/built-in.js +5 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/default-builtin-config.d.ts +59 -4
- package/dataflow/environments/default-builtin-config.js +23 -11
- package/dataflow/environments/environment.d.ts +28 -4
- package/dataflow/environments/environment.js +66 -11
- package/dataflow/environments/identifier.d.ts +1 -0
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.d.ts +3 -1
- package/dataflow/eval/resolve/alias-tracking.js +8 -1
- package/dataflow/eval/resolve/resolve.d.ts +14 -0
- package/dataflow/eval/resolve/resolve.js +47 -0
- package/dataflow/fn/higher-order-function.js +3 -3
- package/dataflow/fn/recursive-function.js +1 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/df-helper.js +1 -1
- package/dataflow/graph/vertex.d.ts +32 -25
- package/dataflow/graph/vertex.js +40 -36
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +28 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +41 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +45 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +14 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +80 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +63 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +63 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +29 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +35 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +55 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +24 -0
- package/dataflow/internal/process/functions/process-parameter.js +2 -1
- package/documentation/doc-readme.js +14 -12
- package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.js +4 -24
- package/documentation/wiki-query.js +47 -0
- package/documentation/wiki-signature-database.js +3 -2
- package/linter/rules/absolute-path.js +1 -1
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/no-leaked-credentials.js +1 -1
- package/linter/rules/undefined-symbol-util.js +3 -1
- package/linter/rules/undefined-symbol.js +4 -5
- package/linter/rules/unused-definition.js +15 -10
- package/linter/rules/useless-loop.js +1 -1
- package/package.json +21 -9
- package/project/context/flowr-analyzer-context.d.ts +4 -4
- package/project/context/flowr-analyzer-context.js +3 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +11 -5
- package/project/context/flowr-analyzer-dependencies-context.js +8 -3
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/dependency-version-space.d.ts +118 -26
- package/project/dependency-version-space.js +343 -87
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
- package/project/plugins/package-version-plugins/package.d.ts +27 -10
- package/project/plugins/package-version-plugins/package.js +50 -25
- package/project/sigdb/reader.d.ts +26 -16
- package/project/sigdb/reader.js +52 -21
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -2
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +23 -24
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +53 -23
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +14 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +109 -20
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +45 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +22 -3
- package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
- package/queries/catalog/input-sources-query/input-types.js +64 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +76 -53
- package/queries/catalog/input-sources-query/simple-input-classifier.js +358 -101
- package/queries/catalog/project-query/project-query-executor.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-executor.js +112 -39
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
- package/queries/catalog/signature-query/signature-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-render.js +8 -3
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/retriever.d.ts +1 -1
- package/reconstruct/inline/source-inline-map.js +1 -1
- package/search/flowr-search-printer.js +10 -8
- package/slicing/static/static-slicer.d.ts +2 -2
- package/util/mermaid/dfg.js +1 -1
- package/util/objects.js +6 -4
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -0
- package/util/r-license.js +1 -4
- package/util/r-version.d.ts +12 -0
- package/util/r-version.js +16 -0
- package/util/range.d.ts +6 -2
- package/util/range.js +33 -15
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,25 @@ available for [VSCode](https://marketplace.visualstudio.com/items?itemName=code-
|
|
|
12
12
|
and [Docker](https://hub.docker.com/r/eagleoutice/flowr).
|
|
13
13
|
It offers a wide variety of features, for example:
|
|
14
14
|
|
|
15
|
+
* 📚 **dependency analysis**\
|
|
16
|
+
Given your analysis project, flowR offers a plethora of so-called [queries](https://github.com/flowr-analysis/flowr/wiki/query-api) to get more information about your code.
|
|
17
|
+
An important query is the [dependencies query](https://github.com/flowr-analysis/flowr/wiki/%5BQuery%5D-Dependencies), which shows you the library your project needs,
|
|
18
|
+
the data files it reads, the scripts it sources, and the data it outputs.
|
|
19
|
+
Building on it, the [guess dependency versions query](https://github.com/flowr-analysis/flowr/wiki/%5BQuery%5D-Guess-Dependency-Versions) narrows down the version range each
|
|
20
|
+
of these libraries has to have, by combining the constraints your project declares with the functions your code actually calls.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<details><summary>Example: Dependency Analysis with flowR</summary>
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
The following showcases the dependency view of the [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr):
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</details>
|
|
33
|
+
|
|
15
34
|
* 🐞 **code linting**\
|
|
16
35
|
Analyze your R scripts for common issues and potential bugs (see the [wiki page](https://github.com/flowr-analysis/flowr/wiki/linter) for more information on the currently supported linters).
|
|
17
36
|
|
|
@@ -24,7 +43,7 @@ It offers a wide variety of features, for example:
|
|
|
24
43
|
|
|
25
44
|
```shell
|
|
26
45
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
27
|
-
flowR repl v2.13.
|
|
46
|
+
flowR repl v2.13.3, R grammar v14 (tree-sitter engine)
|
|
28
47
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
29
48
|
```
|
|
30
49
|
|
|
@@ -33,12 +52,12 @@ It offers a wide variety of features, for example:
|
|
|
33
52
|
|
|
34
53
|
|
|
35
54
|
```text
|
|
36
|
-
Query: linter (
|
|
55
|
+
Query: linter (4 ms)
|
|
37
56
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
38
57
|
╰ File Path Validity (file-path-validity):
|
|
39
58
|
╰ certain:
|
|
40
59
|
╰ Path `/root/x.txt` at 1.1-23
|
|
41
|
-
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
60
|
+
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 0, processTimeMs: 1
|
|
42
61
|
╰ Seeded Randomness (seeded-randomness): no findings
|
|
43
62
|
╰ Absolute Paths (absolute-file-paths):
|
|
44
63
|
╰ certain:
|
|
@@ -54,7 +73,7 @@ It offers a wide variety of features, for example:
|
|
|
54
73
|
╰ Roxygen Arguments (roxygen-arguments): no findings
|
|
55
74
|
╰ No Leaked Credentials (no-leaked-credentials): no findings
|
|
56
75
|
╰ Undefined Symbol (undefined-symbol): no findings
|
|
57
|
-
All queries together required ≈
|
|
76
|
+
All queries together required ≈4 ms (1ms accuracy, total 5 ms)
|
|
58
77
|
```
|
|
59
78
|
|
|
60
79
|
|
|
@@ -76,17 +95,17 @@ It offers a wide variety of features, for example:
|
|
|
76
95
|
|
|
77
96
|
_Results (prettified and summarized):_
|
|
78
97
|
|
|
79
|
-
Query: **linter** (
|
|
98
|
+
Query: **linter** (5 ms)\
|
|
80
99
|
╰ **Deprecated Functions** (deprecated-functions): _no findings_\
|
|
81
100
|
╰ **File Path Validity** (file-path-validity):\
|
|
82
101
|
╰ certain:\
|
|
83
102
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
84
|
-
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
103
|
+
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 0, processTimeMs: 1\
|
|
85
104
|
╰ **Seeded Randomness** (seeded-randomness): _no findings_\
|
|
86
105
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
87
106
|
╰ certain:\
|
|
88
107
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
89
|
-
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs:
|
|
108
|
+
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0\
|
|
90
109
|
╰ **Unused Definitions** (unused-definitions): _no findings_\
|
|
91
110
|
╰ **Network Functions** (network-functions): _no findings_\
|
|
92
111
|
╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
|
|
@@ -97,11 +116,11 @@ It offers a wide variety of features, for example:
|
|
|
97
116
|
╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
|
|
98
117
|
╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
|
|
99
118
|
╰ **Undefined Symbol** (undefined-symbol): _no findings_\
|
|
100
|
-
_All queries together required ≈
|
|
119
|
+
_All queries together required ≈5 ms (1ms accuracy, total 5 ms)_
|
|
101
120
|
|
|
102
121
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
103
122
|
|
|
104
|
-
The analysis required
|
|
123
|
+
The analysis required _4.9 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
105
124
|
|
|
106
125
|
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
|
|
107
126
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -118,8 +137,8 @@ It offers a wide variety of features, for example:
|
|
|
118
137
|
".meta": {
|
|
119
138
|
"totalCalls": 0,
|
|
120
139
|
"totalFunctionDefinitions": 0,
|
|
121
|
-
"searchTimeMs":
|
|
122
|
-
"processTimeMs":
|
|
140
|
+
"searchTimeMs": 2,
|
|
141
|
+
"processTimeMs": 0
|
|
123
142
|
}
|
|
124
143
|
},
|
|
125
144
|
"file-path-validity": {
|
|
@@ -141,8 +160,8 @@ It offers a wide variety of features, for example:
|
|
|
141
160
|
"totalUnknown": 0,
|
|
142
161
|
"totalWritesBeforeAlways": 0,
|
|
143
162
|
"totalValid": 0,
|
|
144
|
-
"searchTimeMs":
|
|
145
|
-
"processTimeMs":
|
|
163
|
+
"searchTimeMs": 0,
|
|
164
|
+
"processTimeMs": 1
|
|
146
165
|
}
|
|
147
166
|
},
|
|
148
167
|
"seeded-randomness": {
|
|
@@ -153,7 +172,7 @@ It offers a wide variety of features, for example:
|
|
|
153
172
|
"callsWithAssignmentProducers": 0,
|
|
154
173
|
"callsWithNonConstantProducers": 0,
|
|
155
174
|
"callsWithOtherBranchProducers": 0,
|
|
156
|
-
"searchTimeMs":
|
|
175
|
+
"searchTimeMs": 0,
|
|
157
176
|
"processTimeMs": 0
|
|
158
177
|
}
|
|
159
178
|
},
|
|
@@ -173,7 +192,7 @@ It offers a wide variety of features, for example:
|
|
|
173
192
|
".meta": {
|
|
174
193
|
"totalConsidered": 1,
|
|
175
194
|
"totalUnknown": 0,
|
|
176
|
-
"searchTimeMs":
|
|
195
|
+
"searchTimeMs": 1,
|
|
177
196
|
"processTimeMs": 0
|
|
178
197
|
}
|
|
179
198
|
},
|
|
@@ -182,7 +201,7 @@ It offers a wide variety of features, for example:
|
|
|
182
201
|
".meta": {
|
|
183
202
|
"totalConsidered": 0,
|
|
184
203
|
"searchTimeMs": 0,
|
|
185
|
-
"processTimeMs":
|
|
204
|
+
"processTimeMs": 0
|
|
186
205
|
}
|
|
187
206
|
},
|
|
188
207
|
"network-functions": {
|
|
@@ -201,7 +220,7 @@ It offers a wide variety of features, for example:
|
|
|
201
220
|
"numAccesses": 0,
|
|
202
221
|
"totalAccessed": 0,
|
|
203
222
|
"searchTimeMs": 0,
|
|
204
|
-
"processTimeMs":
|
|
223
|
+
"processTimeMs": 0
|
|
205
224
|
}
|
|
206
225
|
},
|
|
207
226
|
"dead-code": {
|
|
@@ -216,7 +235,7 @@ It offers a wide variety of features, for example:
|
|
|
216
235
|
".meta": {
|
|
217
236
|
"numOfUselessLoops": 0,
|
|
218
237
|
"searchTimeMs": 0,
|
|
219
|
-
"processTimeMs":
|
|
238
|
+
"processTimeMs": 1
|
|
220
239
|
}
|
|
221
240
|
},
|
|
222
241
|
"problematic-inputs": {
|
|
@@ -262,16 +281,16 @@ It offers a wide variety of features, for example:
|
|
|
262
281
|
"subscript": 0
|
|
263
282
|
},
|
|
264
283
|
"searchTimeMs": 0,
|
|
265
|
-
"processTimeMs":
|
|
284
|
+
"processTimeMs": 0
|
|
266
285
|
}
|
|
267
286
|
}
|
|
268
287
|
},
|
|
269
288
|
".meta": {
|
|
270
|
-
"timing":
|
|
289
|
+
"timing": 5
|
|
271
290
|
}
|
|
272
291
|
},
|
|
273
292
|
".meta": {
|
|
274
|
-
"timing":
|
|
293
|
+
"timing": 5
|
|
275
294
|
}
|
|
276
295
|
}
|
|
277
296
|
```
|
|
@@ -335,7 +354,7 @@ It offers a wide variety of features, for example:
|
|
|
335
354
|
|
|
336
355
|
```shell
|
|
337
356
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
338
|
-
flowR repl v2.13.
|
|
357
|
+
flowR repl v2.13.3, R grammar v14 (tree-sitter engine)
|
|
339
358
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
340
359
|
```
|
|
341
360
|
|
|
@@ -349,7 +368,7 @@ It offers a wide variety of features, for example:
|
|
|
349
368
|
N <- 10
|
|
350
369
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
351
370
|
sum
|
|
352
|
-
All queries together required ≈
|
|
371
|
+
All queries together required ≈3 ms (1ms accuracy, total 3 ms)
|
|
353
372
|
```
|
|
354
373
|
|
|
355
374
|
|
|
@@ -363,25 +382,8 @@ It offers a wide variety of features, for example:
|
|
|
363
382
|
|
|
364
383
|
</details>
|
|
365
384
|
|
|
366
|
-
* 📚 **dependency analysis**\
|
|
367
|
-
Given your analysis project, flowR offers a plethora of so-called [queries](https://github.com/flowr-analysis/flowr/wiki/query-api) to get more information about your code.
|
|
368
|
-
An important query is the [dependencies query](https://github.com/flowr-analysis/flowr/wiki/%5BQuery%5D-Dependencies), which shows you the library your project needs,
|
|
369
|
-
the data files it reads, the scripts it sources, and the data it outputs.
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
<details><summary>Example: Dependency Analysis with flowR</summary>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
The following showcases the dependency view of the [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr):
|
|
376
|
-
|
|
377
|
-

|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
</details>
|
|
382
|
-
|
|
383
385
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
384
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
386
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">101.8 ms</span></i> (as of Jul 25, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
385
387
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
386
388
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph#perspectives-cg).
|
|
387
389
|
|
|
@@ -417,7 +419,7 @@ It offers a wide variety of features, for example:
|
|
|
417
419
|
|
|
418
420
|
```shell
|
|
419
421
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
420
|
-
flowR repl v2.13.
|
|
422
|
+
flowR repl v2.13.3, R grammar v14 (tree-sitter engine)
|
|
421
423
|
R> :dataflow* test/testfiles/example.R
|
|
422
424
|
```
|
|
423
425
|
|
|
@@ -690,7 +692,7 @@ It offers a wide variety of features, for example:
|
|
|
690
692
|
```
|
|
691
693
|
|
|
692
694
|
|
|
693
|
-
(The analysis required
|
|
695
|
+
(The analysis required _1.6 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
|
|
694
696
|
|
|
695
697
|
|
|
696
698
|
|
|
@@ -62,7 +62,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
62
62
|
return state.get(node.info.id);
|
|
63
63
|
}
|
|
64
64
|
const vertex = this.getDataflowGraph(node.info.id);
|
|
65
|
-
const call =
|
|
65
|
+
const call = vertex_1.FunctionCallVertex.is(vertex) ? vertex : undefined;
|
|
66
66
|
const origins = Array.isArray(call?.origin) ? call.origin : [];
|
|
67
67
|
if (node.type === type_1.RType.Symbol) {
|
|
68
68
|
const values = this.getVariableOrigins(node.info.id)
|
|
@@ -189,7 +189,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
189
189
|
this.replacements.delete(nodeId);
|
|
190
190
|
for (const replacement of replacements) {
|
|
191
191
|
const call = this.getDataflowGraph(replacement);
|
|
192
|
-
if (
|
|
192
|
+
if (vertex_1.FunctionCallVertex.is(call)) {
|
|
193
193
|
this.onReplacementCall({ call, ...this.getSourceAndTarget(call) });
|
|
194
194
|
}
|
|
195
195
|
}
|
|
@@ -136,6 +136,7 @@ function mapDataFrameIndexColRowAccess(access, inference, info) {
|
|
|
136
136
|
colnames: columns?.map(col => typeof col === 'string' ? col : undefined)
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
139
140
|
operand = undefined;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
@@ -121,7 +121,7 @@ function getFunctionArgument(args, argument, info) {
|
|
|
121
121
|
*/
|
|
122
122
|
function getFunctionArguments(node, dfg) {
|
|
123
123
|
const vertex = dfg.getVertex(node.info.id);
|
|
124
|
-
if (
|
|
124
|
+
if (vertex_1.FunctionCallVertex.is(vertex) && dfg.idMap !== undefined) {
|
|
125
125
|
const idMap = dfg.idMap;
|
|
126
126
|
return vertex.args
|
|
127
127
|
.map(arg => graph_1.FunctionArgument.isEmpty(arg) ? arg : idMap.get(arg.nodeId))
|
|
@@ -145,7 +145,7 @@ function getUnresolvedSymbolsInExpression(expression, dfg) {
|
|
|
145
145
|
const vertex = dfg.get(node.info.id);
|
|
146
146
|
const symbolName = identifier_1.Identifier.mapName(node.content, resolve_args_1.unquoteArgument);
|
|
147
147
|
// ignore symbols named ".", as they are used as argument placeholder in magrittr pipe operations
|
|
148
|
-
if (
|
|
148
|
+
if (vertex_1.UseVertex.is(vertex?.[0]) && vertex[1].size === 0 && symbolName !== '.') {
|
|
149
149
|
unresolvedSymbols.push(symbolName);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ResolveInfo } from '../../../dataflow/eval/resolve/alias-tracking';
|
|
2
2
|
import type { DataflowGraph } from '../../../dataflow/graph/graph';
|
|
3
3
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
4
4
|
import type { RNode } from '../../../r-bridge/lang-4.x/ast/model/model';
|
|
@@ -851,6 +851,7 @@ function mapDataFrameSubset(args, params, inference, info) {
|
|
|
851
851
|
colnames: selectedCols?.map(col => typeof col === 'string' ? col : undefined),
|
|
852
852
|
...(duplicateCols || mixedAccess ? { options: { duplicateCols: true } } : {})
|
|
853
853
|
});
|
|
854
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
854
855
|
operand = undefined;
|
|
855
856
|
}
|
|
856
857
|
}
|
|
@@ -932,6 +933,7 @@ function mapDataFrameSelect(args, params, inference, info) {
|
|
|
932
933
|
colnames: selectedCols?.map(col => typeof col === 'string' ? col : undefined),
|
|
933
934
|
...(renamedCols ? { options: { renamedCols: true } } : {})
|
|
934
935
|
});
|
|
936
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
935
937
|
operand = undefined;
|
|
936
938
|
}
|
|
937
939
|
return result;
|
|
@@ -982,6 +984,7 @@ function mapDataFrameMutate(args, params, inference, info) {
|
|
|
982
984
|
colnames: deletedCols,
|
|
983
985
|
options: { maybe: true }
|
|
984
986
|
});
|
|
987
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
985
988
|
operand = undefined;
|
|
986
989
|
}
|
|
987
990
|
return result;
|
|
@@ -60,7 +60,7 @@ function isDataFrameReplacement(functionName) {
|
|
|
60
60
|
}
|
|
61
61
|
function hasParentReplacement(node, dfg) {
|
|
62
62
|
const parentVertex = node.info.parent ? dfg.getVertex(node.info.parent) : undefined;
|
|
63
|
-
return
|
|
63
|
+
return vertex_1.FunctionCallVertex.is(parentVertex) && parentVertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Replacement);
|
|
64
64
|
}
|
|
65
65
|
function mapDataFrameContentAssignment(access, expression, inference) {
|
|
66
66
|
const dataFrame = access.accessed;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
-
import {
|
|
2
|
+
import type { AnyAbstractDomain } from './abstract-domain';
|
|
3
3
|
/**
|
|
4
4
|
* An interface for state-like domains that store abstract values for AST nodes.
|
|
5
5
|
*/
|
|
@@ -45,7 +45,7 @@ exports.UnsupportedFunctions = {
|
|
|
45
45
|
* Checks whether a data flow graph vertex represents an unsupported (environment-changing) function call (e.g. `eval`, `load`, `attach`, `rm`, ...)
|
|
46
46
|
*/
|
|
47
47
|
isUnsupportedCall(vertex, dfg) {
|
|
48
|
-
if (!
|
|
48
|
+
if (!vertex_1.FunctionCallVertex.is(vertex)) {
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
51
|
const entry = UnsupportedFunctionsList.find(entry => identifier_1.Identifier.matches(vertex.name, entry.identifier));
|
package/config.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { FlowrAnalyzerContext } from './project/context/flowr-analyzer-cont
|
|
|
10
10
|
import { ProjectKind } from './project/context/project-kind';
|
|
11
11
|
import type { BuiltInFlowrPluginArgs, BuiltInFlowrPluginName } from './project/plugins/plugin-registry';
|
|
12
12
|
import { type FlowrGasConfig } from './gas';
|
|
13
|
+
import type { InputClassifierConfig } from './queries/catalog/input-sources-query/simple-input-classifier';
|
|
13
14
|
export declare enum VariableResolve {
|
|
14
15
|
/** Don't resolve constants at all */
|
|
15
16
|
Disabled = "disabled",
|
|
@@ -201,6 +202,13 @@ export interface FlowrConfig extends MergeableRecord {
|
|
|
201
202
|
/** Rule names excluded from the *default* rule set (a rule requested explicitly still runs). */
|
|
202
203
|
readonly disabledRules: string[];
|
|
203
204
|
};
|
|
205
|
+
/**
|
|
206
|
+
* Teaches the {@link InputSourcesQuery|input-sources} analysis (and with it the `problematic-inputs` linter)
|
|
207
|
+
* about further frameworks. Everything here is *added* to what flowR already knows, so a shiny app keeps its
|
|
208
|
+
* `input` even when you declare your own. Usually set per {@link ProjectKind} via {@link specializeConfig}.
|
|
209
|
+
* @see {@link InputClassifierConfig} - for what the entries mean
|
|
210
|
+
*/
|
|
211
|
+
readonly inputSources?: DeepWritable<InputClassifierConfig<string[]>>;
|
|
204
212
|
/**
|
|
205
213
|
* Overwrite (parts of) this configuration depending on the {@link ProjectKind} flowR detects for the project,
|
|
206
214
|
* e.g. to give a shiny app its implicit sources. An entry may `inherit` another kind's overwrite (merged first,
|
package/config.js
CHANGED
|
@@ -18,6 +18,7 @@ const joi_1 = __importDefault(require("joi"));
|
|
|
18
18
|
const project_kind_1 = require("./project/context/project-kind");
|
|
19
19
|
const object_path_1 = __importDefault(require("object-path"));
|
|
20
20
|
const gas_1 = require("./gas");
|
|
21
|
+
const input_types_1 = require("./queries/catalog/input-sources-query/input-types");
|
|
21
22
|
var VariableResolve;
|
|
22
23
|
(function (VariableResolve) {
|
|
23
24
|
/** Don't resolve constants at all */
|
|
@@ -221,7 +222,8 @@ exports.FlowrConfig = {
|
|
|
221
222
|
[project_kind_1.ProjectKind.Package]: { solver: { resolveSource: { assumeFilesExist: true } } },
|
|
222
223
|
[project_kind_1.ProjectKind.Project]: { solver: { resolveSource: { assumeFilesExist: true } } },
|
|
223
224
|
[project_kind_1.ProjectKind.ShinyApp]: {
|
|
224
|
-
|
|
225
|
+
/* shiny evaluates global.R before the supporting files in R/, and the app itself last */
|
|
226
|
+
project: { implicitSources: ['global.R', 'R/*.R', 'ui.R', 'server.R', 'app.R'] },
|
|
225
227
|
solver: { resolveSource: { assumeFilesExist: true } }
|
|
226
228
|
},
|
|
227
229
|
[project_kind_1.ProjectKind.Script]: { inherit: project_kind_1.ProjectKind.Unknown },
|
|
@@ -320,6 +322,12 @@ exports.FlowrConfig = {
|
|
|
320
322
|
linter: joi_1.default.object({
|
|
321
323
|
disabledRules: joi_1.default.array().items(joi_1.default.string()).description('Linting rule names excluded from the default rule set (a rule requested explicitly via a linter query still runs). Usually set per project kind via specializeConfig.')
|
|
322
324
|
}).description('Linter configuration options.'),
|
|
325
|
+
inputSources: joi_1.default.object({
|
|
326
|
+
pure: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that only pass the constantness of their arguments on.'),
|
|
327
|
+
...Object.fromEntries(Object.values(input_types_1.InputType).map(t => [t, joi_1.default.array().items(joi_1.default.string()).optional().description(`Functions whose result is a '${t}' input.`)])),
|
|
328
|
+
linkedObjects: joi_1.default.array().items(joi_1.default.object()).optional().description('Objects a framework provides without a definition in the code, e.g. shiny\'s input.'),
|
|
329
|
+
linkedEntryPoints: joi_1.default.array().items(joi_1.default.object()).optional().description('Calls that hand a function to a framework, which binds its objects to the parameters by position.')
|
|
330
|
+
}).optional().description('Further frameworks the input-sources analysis should know about; entries are added to flowR\'s defaults.'),
|
|
323
331
|
specializeConfig: joi_1.default.object().pattern(joi_1.default.string().valid(...Object.values(project_kind_1.ProjectKind)), joi_1.default.object({
|
|
324
332
|
inherit: joi_1.default.string().valid(...Object.values(project_kind_1.ProjectKind)).optional().description('Inherit another kind\'s overwrite first (merged before this entry\'s own keys, which win).')
|
|
325
333
|
}).unknown(true)).optional()
|
|
@@ -4,7 +4,10 @@ exports.cfgAnalyzeDeadCode = cfgAnalyzeDeadCode;
|
|
|
4
4
|
const control_flow_graph_1 = require("./control-flow-graph");
|
|
5
5
|
const logic_1 = require("../util/logic");
|
|
6
6
|
const semantic_cfg_guided_visitor_1 = require("./semantic-cfg-guided-visitor");
|
|
7
|
+
const vertex_1 = require("../dataflow/graph/vertex");
|
|
8
|
+
const graph_1 = require("../dataflow/graph/graph");
|
|
7
9
|
const alias_tracking_1 = require("../dataflow/eval/resolve/alias-tracking");
|
|
10
|
+
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
8
11
|
const log_1 = require("../util/log");
|
|
9
12
|
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
13
|
const general_1 = require("../dataflow/eval/values/general");
|
|
@@ -14,7 +17,8 @@ const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
|
|
|
14
17
|
class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
|
|
15
18
|
cachedConditions = new Map();
|
|
16
19
|
cachedStatements = new Map();
|
|
17
|
-
|
|
20
|
+
cachedSwitch = new Map();
|
|
21
|
+
jumpIsolated = new Set();
|
|
18
22
|
getValue(id) {
|
|
19
23
|
const has = this.cachedConditions.get(id);
|
|
20
24
|
if (has) {
|
|
@@ -24,7 +28,7 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
|
|
|
24
28
|
return this.cachedConditions.get(id) ?? logic_1.Ternary.Maybe;
|
|
25
29
|
}
|
|
26
30
|
isUnconditionalJump(id) {
|
|
27
|
-
if (this.
|
|
31
|
+
if (this.jumpIsolated.has(id)) {
|
|
28
32
|
return false;
|
|
29
33
|
}
|
|
30
34
|
const has = this.cachedStatements.get(id);
|
|
@@ -45,7 +49,12 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
|
|
|
45
49
|
for (const [from, targets] of cfg.edges()) {
|
|
46
50
|
for (const [target, edge] of targets) {
|
|
47
51
|
if (control_flow_graph_1.CfgEdge.isControlDependency(edge)) {
|
|
48
|
-
const
|
|
52
|
+
const cause = control_flow_graph_1.CfgEdge.unpackCause(edge);
|
|
53
|
+
if (this.switchArmDefinitelyNotTaken(cause, from)) {
|
|
54
|
+
cfg.removeEdge(from, target);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const og = this.getValue(cause);
|
|
49
58
|
const w = control_flow_graph_1.CfgEdge.unpackWhen(edge);
|
|
50
59
|
if (og === logic_1.Ternary.Always && w === convert_values_1.RFalse) {
|
|
51
60
|
cfg.removeEdge(from, target);
|
|
@@ -126,21 +135,73 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
|
|
|
126
135
|
this.cachedStatements.set(data.call.id, !arg);
|
|
127
136
|
}
|
|
128
137
|
}
|
|
138
|
+
protectSubgraph(nodeId) {
|
|
139
|
+
const start = this.getCfgVertex(nodeId);
|
|
140
|
+
if (!start) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
(0, simple_visitor_1.visitCfgInOrder)(this.config.controlFlow.graph, [control_flow_graph_1.CfgVertex.getId(start)], n => {
|
|
144
|
+
if (control_flow_graph_1.CfgVertex.getEnd(start)?.includes(n)) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
this.jumpIsolated.add(n);
|
|
148
|
+
return false;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
129
151
|
onTryCall(data) {
|
|
130
152
|
if (data.call.args.length < 1 || data.call.args[0] === r_function_call_1.EmptyArgument) {
|
|
131
153
|
return;
|
|
132
154
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
155
|
+
this.protectSubgraph(data.call.args[0].nodeId);
|
|
156
|
+
}
|
|
157
|
+
switchArmDefinitelyNotTaken(cause, from) {
|
|
158
|
+
const v = this.config.dfg.getVertex(cause);
|
|
159
|
+
if (!vertex_1.FunctionCallVertex.is(v) || !v.origin.includes(built_in_proc_name_1.BuiltInProcName.Switch)) {
|
|
160
|
+
return false;
|
|
136
161
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
this.inTry.add(n);
|
|
162
|
+
const selected = this.selectedSwitchArm(v);
|
|
163
|
+
if (selected === 'unknown') {
|
|
142
164
|
return false;
|
|
165
|
+
}
|
|
166
|
+
const isArm = v.args.slice(1).some(a => graph_1.FunctionArgument.getReference(a) !== undefined && graph_1.FunctionArgument.getId(a) === from);
|
|
167
|
+
return isArm && from !== selected.id;
|
|
168
|
+
}
|
|
169
|
+
selectedSwitchArm(v) {
|
|
170
|
+
const cached = this.cachedSwitch.get(v.id);
|
|
171
|
+
if (cached !== undefined) {
|
|
172
|
+
return cached;
|
|
173
|
+
}
|
|
174
|
+
const result = this.computeSelectedSwitchArm(v);
|
|
175
|
+
this.cachedSwitch.set(v.id, result);
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
computeSelectedSwitchArm(v) {
|
|
179
|
+
const target = (0, alias_tracking_1.resolveIdToSingleString)(graph_1.FunctionArgument.getReference(v.args[0]), {
|
|
180
|
+
graph: this.config.dfg, full: true, idMap: this.config.normalizedAst.idMap, resolve: this.config.ctx.config.solver.variables, ctx: this.config.ctx
|
|
143
181
|
});
|
|
182
|
+
if (target === undefined) {
|
|
183
|
+
return 'unknown';
|
|
184
|
+
}
|
|
185
|
+
const arms = v.args.slice(1);
|
|
186
|
+
for (let i = 0; i < arms.length; i++) {
|
|
187
|
+
if (graph_1.FunctionArgument.getName(arms[i]) === target) {
|
|
188
|
+
for (let j = i; j < arms.length; j++) {
|
|
189
|
+
if (graph_1.FunctionArgument.getReference(arms[j]) !== undefined) {
|
|
190
|
+
return { id: graph_1.FunctionArgument.getId(arms[j]) };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return { id: undefined };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
let defaultId;
|
|
197
|
+
let defaults = 0;
|
|
198
|
+
for (const arm of arms) {
|
|
199
|
+
if (arm !== r_function_call_1.EmptyArgument && !graph_1.FunctionArgument.isNamed(arm) && graph_1.FunctionArgument.getReference(arm) !== undefined) {
|
|
200
|
+
defaults++;
|
|
201
|
+
defaultId = graph_1.FunctionArgument.getId(arm);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return defaults > 1 ? 'unknown' : { id: defaultId };
|
|
144
205
|
}
|
|
145
206
|
}
|
|
146
207
|
/** Breaks unsatisfiable control dependencies */
|
|
@@ -224,7 +224,8 @@ exports.CfgVertex = {
|
|
|
224
224
|
* @see {@link CfgVertex#getRootId|getRootId()} - for a way to get the root id of a vertex
|
|
225
225
|
*/
|
|
226
226
|
getId(vertex) {
|
|
227
|
-
|
|
227
|
+
const id = vertex === undefined ? undefined : (Array.isArray(vertex) ? vertex[1] : vertex);
|
|
228
|
+
return id;
|
|
228
229
|
},
|
|
229
230
|
/**
|
|
230
231
|
* Check whether two vertices are equal, i.e., they have the same type, id, and if they are basic block vertices, they also have the same elements in the same order.
|