@eagleoutice/flowr 2.10.7 → 2.10.9
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 +21 -21
- package/abstract-interpretation/domains/multi-value-state-domain.d.ts +4 -10
- package/abstract-interpretation/domains/multi-value-state-domain.js +1 -6
- package/abstract-interpretation/domains/partial-product-domain.d.ts +6 -2
- package/abstract-interpretation/domains/partial-product-domain.js +7 -3
- package/config.d.ts +10 -0
- package/config.js +6 -2
- package/control-flow/extract-cfg.js +9 -3
- package/dataflow/extractor.js +10 -1
- package/dataflow/graph/graph.js +6 -2
- package/dataflow/info.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +20 -0
- package/documentation/wiki-linting-and-testing.js +1 -1
- package/documentation/wiki-mk/doc-context.d.ts +21 -1
- package/documentation/wiki-mk/doc-context.js +9 -0
- package/documentation/wiki-search.js +13 -2
- package/linter/linter-rules.d.ts +4 -2
- package/linter/rules/absolute-path.d.ts +3 -0
- package/linter/rules/absolute-path.js +37 -12
- package/linter/rules/file-path-validity.d.ts +9 -2
- package/linter/rules/file-path-validity.js +83 -36
- package/linter/rules/problematic-inputs.js +4 -1
- package/package.json +4 -3
- package/queries/catalog/dependencies-query/function-info/read-functions.js +21 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +18 -1
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +3 -1
- package/queries/catalog/input-sources-query/input-source-functions.js +322 -46
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +14 -9
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +4 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +8 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +13 -6
- package/queries/catalog/input-sources-query/simple-input-classifier.js +33 -8
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -2
- package/queries/catalog/linter-query/linter-query-format.js +9 -3
- package/queries/query.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +10 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +10 -2
- package/search/flowr-search-builder.d.ts +50 -16
- package/search/flowr-search-builder.js +33 -17
- package/search/flowr-search-filters.d.ts +10 -1
- package/search/flowr-search-filters.js +10 -0
- package/search/flowr-search.d.ts +8 -3
- package/search/search-executor/search-generators.d.ts +2 -0
- package/search/search-executor/search-generators.js +2 -2
- package/util/objects.js +3 -1
- package/util/text/strings.d.ts +7 -0
- package/util/text/strings.js +23 -0
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ It offers a wide variety of features, for example:
|
|
|
24
24
|
|
|
25
25
|
```shell
|
|
26
26
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
27
|
-
flowR repl using flowR v2.10.
|
|
27
|
+
flowR repl using flowR v2.10.8, R grammar v14 (tree-sitter engine)
|
|
28
28
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -35,11 +35,11 @@ It offers a wide variety of features, for example:
|
|
|
35
35
|
```text
|
|
36
36
|
Query: linter (2 ms)
|
|
37
37
|
╰ Deprecated Functions (deprecated-functions):
|
|
38
|
-
╰ Metadata: totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs:
|
|
38
|
+
╰ Metadata: totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs: 0, processTimeMs: 0
|
|
39
39
|
╰ File Path Validity (file-path-validity):
|
|
40
40
|
╰ certain:
|
|
41
41
|
╰ Path `/root/x.txt` at 1.1-23
|
|
42
|
-
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
42
|
+
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 0
|
|
43
43
|
╰ Seeded Randomness (seeded-randomness):
|
|
44
44
|
╰ Metadata: consumerCalls: 0, callsWithFunctionProducers: 0, callsWithAssignmentProducers: 0, callsWithNonConstantProducers: 0, callsWithOtherBranchProducers: 0, searchTimeMs: 0, processTimeMs: 0
|
|
45
45
|
╰ Absolute Paths (absolute-file-paths):
|
|
@@ -86,13 +86,13 @@ It offers a wide variety of features, for example:
|
|
|
86
86
|
|
|
87
87
|
_Results (prettified and summarized):_
|
|
88
88
|
|
|
89
|
-
Query: **linter** (
|
|
89
|
+
Query: **linter** (3 ms)\
|
|
90
90
|
╰ **Deprecated Functions** (deprecated-functions):\
|
|
91
|
-
╰ _Metadata_: <code>totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs:
|
|
91
|
+
╰ _Metadata_: <code>totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs: 1, processTimeMs: 0</code>\
|
|
92
92
|
╰ **File Path Validity** (file-path-validity):\
|
|
93
93
|
╰ certain:\
|
|
94
94
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
95
|
-
╰ _Metadata_: <code>totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
95
|
+
╰ _Metadata_: <code>totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
96
96
|
╰ **Seeded Randomness** (seeded-randomness):\
|
|
97
97
|
╰ _Metadata_: <code>consumerCalls: 0, callsWithFunctionProducers: 0, callsWithAssignmentProducers: 0, callsWithNonConstantProducers: 0, callsWithOtherBranchProducers: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
98
98
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
@@ -106,9 +106,9 @@ It offers a wide variety of features, for example:
|
|
|
106
106
|
╰ **Network Functions** (network-functions):\
|
|
107
107
|
╰ _Metadata_: <code>totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
108
108
|
╰ **Dataframe Access Validation** (dataframe-access-validation):\
|
|
109
|
-
╰ _Metadata_: <code>numOperations: 0, numAccesses: 0, totalAccessed: 0, searchTimeMs: 0, processTimeMs:
|
|
109
|
+
╰ _Metadata_: <code>numOperations: 0, numAccesses: 0, totalAccessed: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
110
110
|
╰ **Dead Code** (dead-code):\
|
|
111
|
-
╰ _Metadata_: <code>consideredNodes: 5, searchTimeMs:
|
|
111
|
+
╰ _Metadata_: <code>consideredNodes: 5, searchTimeMs: 1, processTimeMs: 0</code>\
|
|
112
112
|
╰ **Useless Loops** (useless-loop):\
|
|
113
113
|
╰ _Metadata_: <code>numOfUselessLoops: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
114
114
|
╰ **Problematic inputs** (problematic-inputs):\
|
|
@@ -117,11 +117,11 @@ It offers a wide variety of features, for example:
|
|
|
117
117
|
╰ _Metadata_: <code>consideredNodes: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
118
118
|
╰ **Roxygen Arguments** (roxygen-arguments):\
|
|
119
119
|
╰ _Metadata_: <code>searchTimeMs: 0, processTimeMs: 0</code>\
|
|
120
|
-
_All queries together required ≈
|
|
120
|
+
_All queries together required ≈3 ms (1ms accuracy, total 3 ms)_
|
|
121
121
|
|
|
122
122
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
123
123
|
|
|
124
|
-
The analysis required _2.
|
|
124
|
+
The analysis required _2.8 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
125
125
|
|
|
126
126
|
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.
|
|
127
127
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -138,7 +138,7 @@ It offers a wide variety of features, for example:
|
|
|
138
138
|
".meta": {
|
|
139
139
|
"totalCalls": 0,
|
|
140
140
|
"totalFunctionDefinitions": 0,
|
|
141
|
-
"searchTimeMs":
|
|
141
|
+
"searchTimeMs": 1,
|
|
142
142
|
"processTimeMs": 0
|
|
143
143
|
}
|
|
144
144
|
},
|
|
@@ -161,7 +161,7 @@ It offers a wide variety of features, for example:
|
|
|
161
161
|
"totalUnknown": 0,
|
|
162
162
|
"totalWritesBeforeAlways": 0,
|
|
163
163
|
"totalValid": 0,
|
|
164
|
-
"searchTimeMs":
|
|
164
|
+
"searchTimeMs": 0,
|
|
165
165
|
"processTimeMs": 0
|
|
166
166
|
}
|
|
167
167
|
},
|
|
@@ -230,14 +230,14 @@ It offers a wide variety of features, for example:
|
|
|
230
230
|
"numAccesses": 0,
|
|
231
231
|
"totalAccessed": 0,
|
|
232
232
|
"searchTimeMs": 0,
|
|
233
|
-
"processTimeMs":
|
|
233
|
+
"processTimeMs": 0
|
|
234
234
|
}
|
|
235
235
|
},
|
|
236
236
|
"dead-code": {
|
|
237
237
|
"results": [],
|
|
238
238
|
".meta": {
|
|
239
239
|
"consideredNodes": 5,
|
|
240
|
-
"searchTimeMs":
|
|
240
|
+
"searchTimeMs": 1,
|
|
241
241
|
"processTimeMs": 0
|
|
242
242
|
}
|
|
243
243
|
},
|
|
@@ -273,11 +273,11 @@ It offers a wide variety of features, for example:
|
|
|
273
273
|
}
|
|
274
274
|
},
|
|
275
275
|
".meta": {
|
|
276
|
-
"timing":
|
|
276
|
+
"timing": 3
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
".meta": {
|
|
280
|
-
"timing":
|
|
280
|
+
"timing": 3
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
```
|
|
@@ -342,7 +342,7 @@ It offers a wide variety of features, for example:
|
|
|
342
342
|
|
|
343
343
|
```shell
|
|
344
344
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
345
|
-
flowR repl using flowR v2.10.
|
|
345
|
+
flowR repl using flowR v2.10.8, R grammar v14 (tree-sitter engine)
|
|
346
346
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
347
347
|
```
|
|
348
348
|
|
|
@@ -356,7 +356,7 @@ It offers a wide variety of features, for example:
|
|
|
356
356
|
N <- 10
|
|
357
357
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
358
358
|
sum
|
|
359
|
-
All queries together required ≈
|
|
359
|
+
All queries together required ≈1 ms (1ms accuracy, total 2 ms)
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
|
|
@@ -390,7 +390,7 @@ It offers a wide variety of features, for example:
|
|
|
390
390
|
|
|
391
391
|
|
|
392
392
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
393
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
393
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">99.7 ms</span></i> (as of Jun 13, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
394
394
|
_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,
|
|
395
395
|
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).
|
|
396
396
|
|
|
@@ -426,7 +426,7 @@ It offers a wide variety of features, for example:
|
|
|
426
426
|
|
|
427
427
|
```shell
|
|
428
428
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
429
|
-
flowR repl using flowR v2.10.
|
|
429
|
+
flowR repl using flowR v2.10.8, R grammar v14 (tree-sitter engine)
|
|
430
430
|
R> :dataflow* test/testfiles/example.R
|
|
431
431
|
```
|
|
432
432
|
|
|
@@ -734,7 +734,7 @@ It offers a wide variety of features, for example:
|
|
|
734
734
|
```
|
|
735
735
|
|
|
736
736
|
|
|
737
|
-
(The analysis required _2.
|
|
737
|
+
(The analysis required _2.2 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment.)
|
|
738
738
|
|
|
739
739
|
|
|
740
740
|
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
-
import { type AbstractProduct, PartialProductDomain } from './partial-product-domain';
|
|
2
|
+
import { type AbstractProduct, type ProductReduction, PartialProductDomain } from './partial-product-domain';
|
|
3
3
|
import { type StateDomainLift, StateAbstractDomain } from './state-abstract-domain';
|
|
4
|
-
/**
|
|
5
|
-
* A reduction function for abstract values of a product domain.
|
|
6
|
-
*/
|
|
7
|
-
export type Reduction<Product extends AbstractProduct> = (value: Product) => Product;
|
|
8
4
|
/**
|
|
9
5
|
* A multi-value state abstract domain that maps AST node IDs to multiple abstract values from different abstract domains.
|
|
10
6
|
* @template Product - Type of the abstract product of the multi-value domain combining multiple abstract values
|
|
11
7
|
* @see {@link NodeId} for the node IDs of the AST nodes
|
|
12
8
|
*/
|
|
13
9
|
export declare class MultiValueStateDomain<Product extends AbstractProduct, Value extends StateDomainLift<MultiValueDomain<Product>> = StateDomainLift<MultiValueDomain<Product>>> extends StateAbstractDomain<MultiValueDomain<Product>, Value> {
|
|
14
|
-
constructor(value: Value, domain: Required<Product>, reductions?: readonly
|
|
10
|
+
constructor(value: Value, domain: Required<Product>, reductions?: readonly ProductReduction<Product>[]);
|
|
15
11
|
create(value: StateDomainLift<MultiValueDomain<Product>>): this;
|
|
16
12
|
getValue<Key extends keyof Product>(node: NodeId, property: Key): Product[Key] | undefined;
|
|
17
13
|
hasValue(node: NodeId, property: keyof Product): boolean;
|
|
@@ -24,9 +20,7 @@ export declare class MultiValueStateDomain<Product extends AbstractProduct, Valu
|
|
|
24
20
|
* @see {@link MultiValueStateDomain} for a state abstract domain of a multi-value domain
|
|
25
21
|
*/
|
|
26
22
|
export declare class MultiValueDomain<Product extends AbstractProduct> extends PartialProductDomain<Product> {
|
|
27
|
-
|
|
28
|
-
constructor(value: Product, domain: Required<Product>, reductions?: readonly Reduction<Product>[]);
|
|
23
|
+
constructor(value: Product, domain: Required<Product>, reductions?: readonly ProductReduction<Product>[]);
|
|
29
24
|
create(value: Product): this;
|
|
30
|
-
static top<Product extends AbstractProduct>(domain: Required<Product>, reductions?: readonly
|
|
31
|
-
protected reduce(value: Product): Product;
|
|
25
|
+
static top<Product extends AbstractProduct>(domain: Required<Product>, reductions?: readonly ProductReduction<Product>[]): MultiValueDomain<Product>;
|
|
32
26
|
}
|
|
@@ -41,10 +41,8 @@ exports.MultiValueStateDomain = MultiValueStateDomain;
|
|
|
41
41
|
* @see {@link MultiValueStateDomain} for a state abstract domain of a multi-value domain
|
|
42
42
|
*/
|
|
43
43
|
class MultiValueDomain extends partial_product_domain_1.PartialProductDomain {
|
|
44
|
-
reductions;
|
|
45
44
|
constructor(value, domain, reductions = []) {
|
|
46
|
-
super(value, domain);
|
|
47
|
-
this.reductions = reductions;
|
|
45
|
+
super(value, domain, reductions);
|
|
48
46
|
}
|
|
49
47
|
create(value) {
|
|
50
48
|
return new MultiValueDomain(value, this.domain, this.reductions);
|
|
@@ -52,9 +50,6 @@ class MultiValueDomain extends partial_product_domain_1.PartialProductDomain {
|
|
|
52
50
|
static top(domain, reductions = []) {
|
|
53
51
|
return new MultiValueDomain({}, domain, reductions);
|
|
54
52
|
}
|
|
55
|
-
reduce(value) {
|
|
56
|
-
return this.reductions.reduce((current, reduction) => reduction(current), value);
|
|
57
|
-
}
|
|
58
53
|
}
|
|
59
54
|
exports.MultiValueDomain = MultiValueDomain;
|
|
60
55
|
//# sourceMappingURL=multi-value-state-domain.js.map
|
|
@@ -8,6 +8,8 @@ export type AbstractProduct<Domain extends AnyAbstractDomain = AnyAbstractDomain
|
|
|
8
8
|
export type ConcreteProductOf<Product extends AbstractProduct> = {
|
|
9
9
|
[Key in keyof Product]: Product[Key] extends AbstractDomain<infer Concrete, unknown, unknown, unknown> ? Concrete : never;
|
|
10
10
|
};
|
|
11
|
+
/** A reduction function of a reduced product domain refining the abstract value based on the values of its sub abstract domains. */
|
|
12
|
+
export type ProductReduction<Product extends AbstractProduct> = (value: Product) => Product;
|
|
11
13
|
/**
|
|
12
14
|
* A partial product abstract domain as named Cartesian product of (optional) sub abstract domains.
|
|
13
15
|
* The sub abstract domains are represented by a (partial) record mapping property names to abstract domains.
|
|
@@ -16,7 +18,8 @@ export type ConcreteProductOf<Product extends AbstractProduct> = {
|
|
|
16
18
|
*/
|
|
17
19
|
export declare abstract class PartialProductDomain<Product extends AbstractProduct> extends AbstractDomain<ConcreteProductOf<Product>, Product, Product, Product> {
|
|
18
20
|
readonly domain: Required<Product>;
|
|
19
|
-
|
|
21
|
+
readonly reductions: readonly ProductReduction<Product>[];
|
|
22
|
+
constructor(value: Product, domain: Required<Product>, reductions?: readonly ProductReduction<Product>[]);
|
|
20
23
|
abstract create(value: Product): this;
|
|
21
24
|
bottom(): this;
|
|
22
25
|
top(): this;
|
|
@@ -37,7 +40,8 @@ export declare abstract class PartialProductDomain<Product extends AbstractProdu
|
|
|
37
40
|
isValue(): boolean;
|
|
38
41
|
isValue(): this is this;
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
43
|
+
* Applies the {@link reductions} of the (reduced) product domain to refine the abstract value based on its components.
|
|
44
|
+
* Subclasses may override this to implement a fixed reduction instead of (or in addition to) the configurable reductions.
|
|
41
45
|
*/
|
|
42
46
|
protected reduce(value: Product): Product;
|
|
43
47
|
}
|
|
@@ -12,8 +12,11 @@ const record_1 = require("../../util/record");
|
|
|
12
12
|
*/
|
|
13
13
|
class PartialProductDomain extends abstract_domain_1.AbstractDomain {
|
|
14
14
|
domain;
|
|
15
|
-
|
|
15
|
+
reductions;
|
|
16
|
+
constructor(value, domain, reductions = []) {
|
|
16
17
|
super(record_1.Record.mapProperties(value, entry => entry?.create(entry.value)));
|
|
18
|
+
// must be assigned before reduce is called, as the (overridable) reduce may depend on the reductions
|
|
19
|
+
this.reductions = reductions;
|
|
17
20
|
this._value = this.reduce(this.value);
|
|
18
21
|
this.domain = domain;
|
|
19
22
|
}
|
|
@@ -153,10 +156,11 @@ class PartialProductDomain extends abstract_domain_1.AbstractDomain {
|
|
|
153
156
|
return true;
|
|
154
157
|
}
|
|
155
158
|
/**
|
|
156
|
-
*
|
|
159
|
+
* Applies the {@link reductions} of the (reduced) product domain to refine the abstract value based on its components.
|
|
160
|
+
* Subclasses may override this to implement a fixed reduction instead of (or in addition to) the configurable reductions.
|
|
157
161
|
*/
|
|
158
162
|
reduce(value) {
|
|
159
|
-
return value;
|
|
163
|
+
return this.reductions.reduce((current, reduction) => reduction(current), value);
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
exports.PartialProductDomain = PartialProductDomain;
|
package/config.d.ts
CHANGED
|
@@ -83,6 +83,16 @@ export interface FlowrLaxSourcingOptions extends MergeableRecord {
|
|
|
83
83
|
* - `faa-bar.R` (replaced spaces and oo)
|
|
84
84
|
*/
|
|
85
85
|
readonly applyReplacements?: Record<string, string>[];
|
|
86
|
+
/**
|
|
87
|
+
* Whether to check the heap memory usage before analyzing a sourced file,
|
|
88
|
+
* skipping the analysis when memory pressure exceeds {@link memoryThreshold}.
|
|
89
|
+
*/
|
|
90
|
+
readonly checkMemoryOnSource?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Fraction of the V8 heap limit at which source analysis is skipped (0-1).
|
|
93
|
+
* Only effective when {@link checkMemoryOnSource} is true.
|
|
94
|
+
*/
|
|
95
|
+
readonly memoryThreshold?: number;
|
|
86
96
|
}
|
|
87
97
|
export type ConfigPlugin<T extends BuiltInFlowrPluginName | string> = T | string | (T extends BuiltInFlowrPluginName ? [T, BuiltInFlowrPluginArgs<T>] : [string, unknown[]]);
|
|
88
98
|
/**
|
package/config.js
CHANGED
|
@@ -105,7 +105,9 @@ exports.FlowrConfig = {
|
|
|
105
105
|
ignoreCapitalization: true,
|
|
106
106
|
inferWorkingDirectory: InferWorkingDirectory.ActiveScript,
|
|
107
107
|
searchPath: [],
|
|
108
|
-
repeatedSourceLimit: 2
|
|
108
|
+
repeatedSourceLimit: 2,
|
|
109
|
+
checkMemoryOnSource: true,
|
|
110
|
+
memoryThreshold: 0.9
|
|
109
111
|
},
|
|
110
112
|
instrument: {
|
|
111
113
|
dataflowExtractors: undefined
|
|
@@ -172,7 +174,9 @@ exports.FlowrConfig = {
|
|
|
172
174
|
inferWorkingDirectory: joi_1.default.string().valid(...Object.values(InferWorkingDirectory)).description('Try to infer the working directory from the main or any script to analyze.'),
|
|
173
175
|
searchPath: joi_1.default.array().items(joi_1.default.string()).description('Additionally search in these paths.'),
|
|
174
176
|
repeatedSourceLimit: joi_1.default.number().optional().description('How often the same file can be sourced within a single run? Please be aware: in case of cyclic sources this may not reach a fixpoint so give this a sensible limit.'),
|
|
175
|
-
applyReplacements: joi_1.default.array().items(joi_1.default.object()).description('Provide name replacements for loaded files')
|
|
177
|
+
applyReplacements: joi_1.default.array().items(joi_1.default.object()).description('Provide name replacements for loaded files'),
|
|
178
|
+
checkMemoryOnSource: joi_1.default.boolean().optional().description('Check heap memory usage before analyzing a sourced file, skipping when memory pressure exceeds the configured threshold.'),
|
|
179
|
+
memoryThreshold: joi_1.default.number().min(0).max(1).optional().description('Fraction of the V8 heap limit (0-1) at which source analysis is skipped. Only effective when checkMemoryOnSource is true.')
|
|
176
180
|
}).optional().description('If lax source calls are active, flowR searches for sourced files much more freely, based on the configurations you give it. This option is only in effect if `ignoreSourceCalls` is set to false.'),
|
|
177
181
|
slicer: joi_1.default.object({
|
|
178
182
|
threshold: joi_1.default.number().optional().description('The maximum number of iterations to perform on a single function call during slicing.'),
|
|
@@ -549,9 +549,15 @@ function cfgExprList(node, _grouping, expressions) {
|
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
551
|
result.graph.mergeWith(expression.graph);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
552
|
+
for (const b of expression.breaks) {
|
|
553
|
+
result.breaks.push(b);
|
|
554
|
+
}
|
|
555
|
+
for (const n of expression.nexts) {
|
|
556
|
+
result.nexts.push(n);
|
|
557
|
+
}
|
|
558
|
+
for (const r of expression.returns) {
|
|
559
|
+
result.returns.push(r);
|
|
560
|
+
}
|
|
555
561
|
result.exitPoints = expression.exitPoints;
|
|
556
562
|
}
|
|
557
563
|
const exitId = control_flow_graph_1.CfgVertex.toExitId(nodeId);
|
package/dataflow/extractor.js
CHANGED
|
@@ -121,7 +121,16 @@ function produceDataFlowGraph(parser, completeAst, ctx) {
|
|
|
121
121
|
referenceChain: [files[0].filePath],
|
|
122
122
|
ctx
|
|
123
123
|
};
|
|
124
|
-
let df
|
|
124
|
+
let df;
|
|
125
|
+
try {
|
|
126
|
+
df = (0, processor_1.processDataflowFor)(files[0].root, dfData);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
if (e instanceof RangeError) {
|
|
130
|
+
throw new Error(`Dataflow analysis exceeded the call stack for '${files[0].filePath ?? '<inline>'}' (code is too deeply nested). Consider --stack-size=65536 when invoking Node.js.`, { cause: e });
|
|
131
|
+
}
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
125
134
|
for (let i = 1; i < files.length; i++) {
|
|
126
135
|
/* source requests register automatically */
|
|
127
136
|
df = (0, built_in_source_1.standaloneSourceFile)(i, files[i], dfData, df);
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -349,14 +349,18 @@ class DataflowGraph {
|
|
|
349
349
|
* in the context of function definitions
|
|
350
350
|
*/
|
|
351
351
|
mergeWith(otherGraph, mergeRootVertices = true) {
|
|
352
|
-
if (otherGraph === undefined) {
|
|
352
|
+
if (otherGraph === undefined || otherGraph === this) {
|
|
353
353
|
return this;
|
|
354
354
|
}
|
|
355
355
|
this.mergeVertices(otherGraph, mergeRootVertices);
|
|
356
356
|
for (const [type, ids] of otherGraph.types) {
|
|
357
357
|
const existing = this.types.get(type);
|
|
358
358
|
if (existing) {
|
|
359
|
-
existing
|
|
359
|
+
if (existing !== ids) {
|
|
360
|
+
for (const id of ids) {
|
|
361
|
+
existing.push(id);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
360
364
|
}
|
|
361
365
|
else {
|
|
362
366
|
this.types.set(type, ids.slice());
|
package/dataflow/info.js
CHANGED
|
@@ -38,7 +38,9 @@ function addNonDefaultExitPoints(existing, invertExitCds, activeCds, add) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const invertedCds = toAdd.flatMap(e => e.cds?.filter(icd => !activeCds?.some(e => e.id === icd.id && e.when === icd.when)).map(negateControlDependency)).filter(assert_1.isNotUndefined);
|
|
41
|
-
|
|
41
|
+
for (const ep of toAdd) {
|
|
42
|
+
existing.push(ep);
|
|
43
|
+
}
|
|
42
44
|
for (const icd of invertedCds) {
|
|
43
45
|
if (!invertExitCds.some(e => e.id === icd.id && e.when === icd.when)) {
|
|
44
46
|
invertExitCds.push(icd);
|
|
@@ -180,7 +180,9 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
180
180
|
}
|
|
181
181
|
const ingoing = [];
|
|
182
182
|
for (const refs of remainingRead.values()) {
|
|
183
|
-
|
|
183
|
+
for (const ref of refs) {
|
|
184
|
+
ingoing.push(ref);
|
|
185
|
+
}
|
|
184
186
|
}
|
|
185
187
|
const rootNode = data.completeAst.idMap.get(rootId);
|
|
186
188
|
const withGroup = rootNode?.grouping;
|
|
@@ -25,6 +25,7 @@ const parser_1 = require("../../../../../../r-bridge/lang-4.x/ast/parser/json/pa
|
|
|
25
25
|
const shell_executor_1 = require("../../../../../../r-bridge/shell-executor");
|
|
26
26
|
const assert_1 = require("../../../../../../util/assert");
|
|
27
27
|
const path_1 = __importDefault(require("path"));
|
|
28
|
+
const v8_1 = require("v8");
|
|
28
29
|
const general_1 = require("../../../../../eval/values/general");
|
|
29
30
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
30
31
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
@@ -210,6 +211,25 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId) {
|
|
|
210
211
|
else {
|
|
211
212
|
(0, assert_1.guard)(textRequest !== undefined, `Expected text request to be defined for sourced file ${JSON.stringify(request)}`);
|
|
212
213
|
}
|
|
214
|
+
if (textRequest.path) {
|
|
215
|
+
const dotIdx = textRequest.path.lastIndexOf('.');
|
|
216
|
+
const ext = dotIdx >= 0 ? textRequest.path.slice(dotIdx).toLowerCase() : '';
|
|
217
|
+
if (ext !== '' && ext !== '.r') {
|
|
218
|
+
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source of non-R file ${JSON.stringify(textRequest.path)}`);
|
|
219
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
220
|
+
return information;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const resolveSource = data.ctx.config.solver.resolveSource;
|
|
224
|
+
if (resolveSource?.checkMemoryOnSource) {
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
226
|
+
const { used_heap_size, heap_size_limit } = (0, v8_1.getHeapStatistics)();
|
|
227
|
+
if (heap_size_limit > 0 && used_heap_size / heap_size_limit > (resolveSource.memoryThreshold ?? .9)) {
|
|
228
|
+
logger_1.dataflowLogger.warn(`Skipping source of ${JSON.stringify(request)} due to memory pressure (${Math.round(used_heap_size / 1048576)}/${Math.round(heap_size_limit / 1048576)} MB used)`);
|
|
229
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
230
|
+
return information;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
213
233
|
const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(textRequest.r);
|
|
214
234
|
const normalized = (typeof parsed !== 'string' ?
|
|
215
235
|
(0, parser_1.normalizeTreeSitter)({ files: [{ parsed, filePath: textRequest.path }] }, getId, data.ctx.config)
|
|
@@ -51,7 +51,7 @@ This command includes the construction of the docker image, the generation of th
|
|
|
51
51
|
|
|
52
52
|
The functionality tests represent conventional unit (and depending on your terminology component/api) tests.
|
|
53
53
|
We use [vitest](https://vitest.dev/) as our testing framework.
|
|
54
|
-
You can run the tests by issuing (some quick benchmarks may be available with \`
|
|
54
|
+
You can run the tests by issuing (some quick benchmarks may be available with \`npm run test:bench\`):
|
|
55
55
|
|
|
56
56
|
${(0, doc_code_1.codeBlock)('shell', 'npm run test')}
|
|
57
57
|
|
|
@@ -173,7 +173,27 @@ export interface GeneralDocContext {
|
|
|
173
173
|
*/
|
|
174
174
|
doc(element: ElementIdOrRef, filter?: Omit<ElementFilter, 'file'>): string;
|
|
175
175
|
/**
|
|
176
|
-
* Returns the
|
|
176
|
+
* Returns the documentation for a member of a class as Markdown string.
|
|
177
|
+
* This is a convenience method around {@link GeneralDocContext#doc|doc}.
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* docM(MyClass, 'myMethod')
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* Creates the documentation for the `myMethod` member of the `MyClass` class in the code base.
|
|
184
|
+
* @see {@link GeneralDocContext#doc|doc} - for the underlying impl.
|
|
185
|
+
* @see {@link GeneralDocContext#docO|docO} - to get documentation using an object reference instead of a class and member name.
|
|
186
|
+
*/
|
|
187
|
+
docM<T extends NamedPrototype>(cls: T, element: ProtoKeys<T> | StaticKeys<T>, filter?: Omit<ElementFilter, 'file'>): string;
|
|
188
|
+
/**
|
|
189
|
+
* Returns the documentation for a type/element definition which is retrieved from an object reference.
|
|
190
|
+
* This is similar to {@link GeneralDocContext#doc}, but it uses an object reference to identify the element.
|
|
191
|
+
*/
|
|
192
|
+
docO<T extends object & {
|
|
193
|
+
name: string;
|
|
194
|
+
}>(obj: T, element: keyof T, filter?: Omit<ElementFilter, 'file'>): string;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the code snippet for a code element as Markdown string.
|
|
177
197
|
* @param element - The element to create a code snippet for, the name can be qualified with `::` to specify the class.
|
|
178
198
|
* @param fmt - Formatting options for the code snippet (see {@link FnElementInfo})
|
|
179
199
|
* @param filter - An optional filter to further specify the element to get the code for, in case multiple elements with the same name exist.
|
|
@@ -56,6 +56,15 @@ function makeDocContextForTypes(shell, ...rootFolders) {
|
|
|
56
56
|
doc(element, filter) {
|
|
57
57
|
return (0, doc_types_1.getDocumentationForType)(getNameFromElementIdOrRef(element), info, '', filter);
|
|
58
58
|
},
|
|
59
|
+
docM(cls, element, filter) {
|
|
60
|
+
const className = cls.prototype.constructor.name;
|
|
61
|
+
const fullName = `${className}::${String(element)}`;
|
|
62
|
+
return this.doc(fullName, filter);
|
|
63
|
+
},
|
|
64
|
+
docO(obj, element, filter) {
|
|
65
|
+
const fullName = `${obj.name}::${String(element)}`;
|
|
66
|
+
return this.doc(fullName, filter);
|
|
67
|
+
},
|
|
59
68
|
link(element, fmt, filter) {
|
|
60
69
|
(0, assert_1.guard)(filter?.file === undefined, 'filtering for files is not yet supported for link');
|
|
61
70
|
return (0, doc_types_1.shortLink)(getNameFromElementIdOrRef(element), info, fmt?.codeFont, fmt?.realNameWrapper, filter?.fuzzy, filter?.type);
|
|
@@ -38,16 +38,27 @@ and can be further refined with _transformers_ or _modifiers_.
|
|
|
38
38
|
Such queries can be constructed starting from the ${ctx.link('Q')} object (backed by ${ctx.link('FlowrSearchGenerator')}) and
|
|
39
39
|
are fully serializable so you can use them when communicating with the [Query API](${doc_files_1.FlowrWikiBaseRef}/Query%20API).
|
|
40
40
|
|
|
41
|
+
## File Path Filtering
|
|
42
|
+
|
|
43
|
+
Many convenience functions and the \`get\` generator support filtering by file path using the \`filePathRegex\` parameter.
|
|
44
|
+
This is useful when you want to search for nodes only in specific files.
|
|
45
|
+
Additionally, inline code (code without a file path) is treated as having an empty path \`""\` for regex matching purposes.
|
|
46
|
+
|
|
47
|
+
The ${ctx.link(flowr_search_builder_1.FlowrSearchGenerator)} provides several convenience functions for searching variables with file path filtering.
|
|
48
|
+
${ctx.linkO(flowr_search_builder_1.FlowrSearchGenerator, 'var')} and other functions like ${ctx.linkO(flowr_search_builder_1.FlowrSearchGenerator, 'get')}
|
|
49
|
+
also allow you to pass in a regex to only match files that fit your specified pattern!
|
|
50
|
+
|
|
51
|
+
|
|
41
52
|
We offer the following generators:
|
|
42
53
|
|
|
43
|
-
${Object.keys(flowr_search_builder_1.Q).sort().map(key => `- ${ctx.
|
|
54
|
+
${Object.keys(flowr_search_builder_1.Q).filter(n => n !== 'name').sort((a, b) => a.localeCompare(b)).map(key => `- ${ctx.linkO(flowr_search_builder_1.FlowrSearchGenerator, key)}\\\n${ctx.docO(flowr_search_builder_1.FlowrSearchGenerator, key)}`).join('\n')}
|
|
44
55
|
|
|
45
56
|
Likewise, we have a palette of _transformers_ and _modifiers_:
|
|
46
57
|
|
|
47
58
|
${
|
|
48
59
|
/* let's iterate over all methods of FlowrSearchBuilder */
|
|
49
60
|
Object.getOwnPropertyNames(Object.getPrototypeOf(new flowr_search_builder_1.FlowrSearchBuilder(undefined)))
|
|
50
|
-
.filter(n => n !== 'constructor').sort().map(key => `- ${ctx.
|
|
61
|
+
.filter(n => n !== 'constructor' && n !== 'name').sort().map(key => `- ${ctx.linkM(flowr_search_builder_1.FlowrSearchBuilder, key)}\\\n${ctx.docM(flowr_search_builder_1.FlowrSearchBuilder, key)}`).join('\n')}
|
|
51
62
|
|
|
52
63
|
Every search (and consequently the search pipeline) works with an array of ${ctx.link('FlowrSearchElement')} (neatly wrapped in ${ctx.link(flowr_search_1.FlowrSearchElements)}).
|
|
53
64
|
Hence, even operations such as \`.first\` or \`.last\` return an array of elements (albeit with a single or no element).
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -33,10 +33,10 @@ export declare const LintingRules: {
|
|
|
33
33
|
dataflow: import("../dataflow/info").DataflowInformation;
|
|
34
34
|
cfg: import("../control-flow/control-flow-graph").ControlFlowInformation;
|
|
35
35
|
analyzer: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
36
|
-
}) => {
|
|
36
|
+
}) => Promise<{
|
|
37
37
|
results: import("./rules/file-path-validity").FilePathValidityResult[];
|
|
38
38
|
".meta": import("./rules/file-path-validity").FilePathValidityMetadata;
|
|
39
|
-
}
|
|
39
|
+
}>;
|
|
40
40
|
readonly info: {
|
|
41
41
|
readonly name: "File Path Validity";
|
|
42
42
|
readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
|
|
@@ -46,6 +46,7 @@ export declare const LintingRules: {
|
|
|
46
46
|
readonly additionalReadFunctions: readonly [];
|
|
47
47
|
readonly additionalWriteFunctions: readonly [];
|
|
48
48
|
readonly includeUnknown: false;
|
|
49
|
+
readonly checkUrls: false;
|
|
49
50
|
};
|
|
50
51
|
};
|
|
51
52
|
readonly prettyPrint: {
|
|
@@ -118,6 +119,7 @@ export declare const LintingRules: {
|
|
|
118
119
|
readonly additionalPathFunctions: readonly [];
|
|
119
120
|
readonly absolutePathRegex: undefined;
|
|
120
121
|
readonly useAsWd: "@script";
|
|
122
|
+
readonly ignoreUrls: true;
|
|
121
123
|
};
|
|
122
124
|
};
|
|
123
125
|
};
|
|
@@ -26,6 +26,8 @@ export interface AbsoluteFilePathConfig extends MergeableRecord {
|
|
|
26
26
|
* This is only relevant with quickfixes. In the future we may be sensitive to setwd etc.
|
|
27
27
|
*/
|
|
28
28
|
useAsWd: SupportedWd;
|
|
29
|
+
/** Automatically ignore URLs (http/https/ftp) so they are not reported as absolute paths. */
|
|
30
|
+
ignoreUrls: boolean;
|
|
29
31
|
}
|
|
30
32
|
export interface AbsoluteFilePathMetadata extends MergeableRecord {
|
|
31
33
|
totalConsidered: number;
|
|
@@ -59,6 +61,7 @@ export declare const ABSOLUTE_PATH: {
|
|
|
59
61
|
readonly additionalPathFunctions: readonly [];
|
|
60
62
|
readonly absolutePathRegex: undefined;
|
|
61
63
|
readonly useAsWd: "@script";
|
|
64
|
+
readonly ignoreUrls: true;
|
|
62
65
|
};
|
|
63
66
|
};
|
|
64
67
|
};
|