@eagleoutice/flowr 2.15.10 → 2.16.0
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 +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +176 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +51 -41
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +31 -4
- package/dataflow/internal/control-flow.js +61 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +446 -78
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +289 -251
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +54 -57
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +35 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/wiki-setup.js +23 -0
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +114 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +128 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +16 -41
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell.js +6 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +115 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -7,15 +7,16 @@ const function_semantics_1 = require("../../../../fn/function-semantics");
|
|
|
7
7
|
const control_flow_1 = require("../../../control-flow");
|
|
8
8
|
const common_1 = require("./common");
|
|
9
9
|
const edge_1 = require("../../../../graph/edge");
|
|
10
|
+
const logic_1 = require("../../../../../util/logic");
|
|
10
11
|
const graph_1 = require("../../../../graph/graph");
|
|
11
12
|
const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
|
|
12
13
|
const vertex_1 = require("../../../../graph/vertex");
|
|
13
|
-
const logger_1 = require("../../../../logger");
|
|
14
14
|
const identifier_1 = require("../../../../environments/identifier");
|
|
15
15
|
const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
|
|
16
16
|
const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
17
17
|
const r_access_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
18
18
|
const r_function_definition_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
19
|
+
const frame_reflection_1 = require("../../../../fn/frame-reflection");
|
|
19
20
|
exports.UnnamedFunctionCallPrefix = 'unnamed-fc-';
|
|
20
21
|
/**
|
|
21
22
|
* Whether a `$`/`[[` access callee resolved a field to a stored function: a resolved dispatch (`dispatch$foo()`)
|
|
@@ -23,17 +24,8 @@ exports.UnnamedFunctionCallPrefix = 'unnamed-fc-';
|
|
|
23
24
|
* while an opaque object (`g$greet()` on an untracked `g`) only carries the base `Returns`.
|
|
24
25
|
*/
|
|
25
26
|
function accessResolvesToField(graph, accessId, accessedId) {
|
|
26
|
-
const outgoing = graph.outgoingEdges(accessId);
|
|
27
|
-
if (outgoing === undefined) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
27
|
const base = node_id_1.NodeId.normalize(accessedId);
|
|
31
|
-
|
|
32
|
-
if (node_id_1.NodeId.normalize(target) !== base && edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns)) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
28
|
+
return (0, frame_reflection_1.edgeTargets)(graph, accessId, edge_1.EdgeType.Returns).some(target => node_id_1.NodeId.normalize(target) !== base);
|
|
37
29
|
}
|
|
38
30
|
/**
|
|
39
31
|
* Processes an unnamed function call.
|
|
@@ -45,62 +37,49 @@ function processUnnamedFunctionCall(functionCall, data) {
|
|
|
45
37
|
const functionRootId = functionCall.info.id;
|
|
46
38
|
const calledRootId = functionCall.calledFunction.info.id;
|
|
47
39
|
const functionCallName = `${exports.UnnamedFunctionCallPrefix}${functionRootId}`;
|
|
48
|
-
logger_1.dataflowLogger.debug(`Using ${functionRootId} as root for the unnamed function call`);
|
|
49
|
-
// we know that it reads the toplevel:
|
|
50
40
|
finalGraph.addEdge(functionRootId, calledRootId, edge_1.EdgeType.Reads);
|
|
51
|
-
// keep the defined function
|
|
52
41
|
finalGraph.mergeWith(calledFunction.graph);
|
|
42
|
+
/* the call is right there and fully resolved, so there is no need to force arguments */
|
|
53
43
|
const { finalEnv, callArgs, remainingReadInArgs, processedArguments } = (0, common_1.processAllArguments)({
|
|
54
44
|
functionName: calledFunction,
|
|
55
45
|
args: functionCall.arguments,
|
|
56
46
|
data,
|
|
57
47
|
finalGraph,
|
|
58
48
|
functionRootId
|
|
59
|
-
/* we know the call is right there and fully resolved, there is no need to artificially force arguments as we identify them within the subtree */
|
|
60
49
|
});
|
|
61
50
|
finalGraph.addVertex({
|
|
62
51
|
tag: vertex_1.VertexType.FunctionCall,
|
|
63
52
|
id: functionRootId,
|
|
64
53
|
environment: data.environment,
|
|
65
54
|
name: functionCallName,
|
|
66
|
-
/* can never be a direct built-in-call */
|
|
67
55
|
onlyBuiltin: false,
|
|
68
56
|
cds: data.cds,
|
|
69
|
-
args: callArgs,
|
|
57
|
+
args: callArgs,
|
|
70
58
|
origin: [built_in_proc_name_1.BuiltInProcName.Unnamed]
|
|
71
59
|
}, data.ctx.env.cleanEnv);
|
|
72
60
|
const cfgEntry = control_flow_1.ControlFlow.inSequence(finalGraph, [calledFunction, ...processedArguments], functionRootId);
|
|
73
|
-
/*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
let inIds = remainingReadInArgs;
|
|
82
|
-
inIds.push({ nodeId: functionRootId, name: functionCallName, cds: data.cds, type: identifier_1.ReferenceType.Function });
|
|
83
|
-
// if we just call a nested fdef
|
|
84
|
-
if (r_function_definition_1.RFunctionDefinition.is(functionCall.calledFunction)) {
|
|
85
|
-
function_semantics_1.FunctionSemantics.call.match.onCallAndLink(callArgs, functionCall.calledFunction.parameters, finalGraph);
|
|
61
|
+
/* what the called function forces is up to its body, just like for a named call */
|
|
62
|
+
const argumentExits = processedArguments.flatMap(a => control_flow_1.ControlFlow.promise(finalGraph, a, logic_1.Ternary.Maybe, functionRootId));
|
|
63
|
+
const called = functionCall.calledFunction;
|
|
64
|
+
if (r_function_definition_1.RFunctionDefinition.is(called)) {
|
|
65
|
+
function_semantics_1.FunctionSemantics.call.match.onCallAndLink(callArgs, called.parameters, finalGraph);
|
|
86
66
|
}
|
|
87
|
-
else if (r_access_1.RAccess.is(
|
|
88
|
-
|
|
67
|
+
else if (r_access_1.RAccess.is(called) && !accessResolvesToField(finalGraph, calledRootId, called.accessed.info.id)) {
|
|
68
|
+
/* `obj$method()` whose field did not resolve to a stored function is reached but unknown rather than dropped */
|
|
89
69
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(finalGraph, data.environment, functionRootId);
|
|
90
70
|
}
|
|
91
|
-
|
|
92
|
-
inIds = inIds.concat(calledFunction.in, calledFunction.unknownReferences);
|
|
71
|
+
const fnRef = { nodeId: functionRootId, name: functionCallName, cds: data.cds, type: identifier_1.ReferenceType.Function };
|
|
93
72
|
return {
|
|
94
73
|
unknownReferences: [],
|
|
95
|
-
in:
|
|
96
|
-
|
|
74
|
+
in: [...remainingReadInArgs, fnRef, ...calledFunction.in, ...calledFunction.unknownReferences],
|
|
75
|
+
/* we do not keep the argument out as it has been linked by the function */
|
|
97
76
|
out: calledFunction.out,
|
|
98
77
|
graph: finalGraph,
|
|
99
78
|
environment: finalEnv,
|
|
100
|
-
entryPoint:
|
|
79
|
+
entryPoint: functionRootId,
|
|
101
80
|
cfgEntry: cfgEntry === functionRootId ? undefined : cfgEntry,
|
|
102
81
|
cfgExit: functionRootId,
|
|
103
|
-
exitPoints: calledFunction.exitPoints,
|
|
82
|
+
exitPoints: calledFunction.exitPoints.concat(argumentExits),
|
|
104
83
|
hooks: calledFunction.hooks,
|
|
105
84
|
};
|
|
106
85
|
}
|
|
@@ -2,12 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processFunctionParameter = processFunctionParameter;
|
|
4
4
|
const processor_1 = require("../../../processor");
|
|
5
|
-
const log_1 = require("../../../../util/log");
|
|
6
5
|
const identifier_1 = require("../../../environments/identifier");
|
|
7
6
|
const define_1 = require("../../../environments/define");
|
|
8
7
|
const edge_1 = require("../../../graph/edge");
|
|
9
8
|
const control_flow_1 = require("../../control-flow");
|
|
9
|
+
const logic_1 = require("../../../../util/logic");
|
|
10
10
|
const r_function_definition_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
11
|
+
function definedByDefault(parameter, defaultValue) {
|
|
12
|
+
if (defaultValue === undefined) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
if (r_function_definition_1.RFunctionDefinition.is(parameter.defaultValue)) {
|
|
16
|
+
return [parameter.defaultValue.info.id];
|
|
17
|
+
}
|
|
18
|
+
return defaultValue.in.concat(defaultValue.unknownReferences).map(r => r.nodeId);
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* The dataflow of one function parameter: its name becomes a definition in the function's frame, and its
|
|
13
22
|
* default value, if it has one, is processed in the same frame so it may read the parameters before it.
|
|
@@ -16,52 +25,36 @@ const r_function_definition_1 = require("../../../../r-bridge/lang-4.x/ast/model
|
|
|
16
25
|
*/
|
|
17
26
|
function processFunctionParameter(parameter, data) {
|
|
18
27
|
const name = (0, processor_1.processDataflowFor)(parameter.name, data);
|
|
19
|
-
|
|
28
|
+
/* a default is a promise the parameter holds, forced where the parameter is first used */
|
|
29
|
+
const defaultValue = parameter.defaultValue === undefined ? undefined : (0, processor_1.processDataflowFor)(parameter.defaultValue, control_flow_1.ControlFlow.withinPromise(data, parameter.name.info.id));
|
|
20
30
|
const graph = defaultValue === undefined ? name.graph : name.graph.mergeWith(defaultValue.graph);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
type: identifier_1.ReferenceType.Parameter,
|
|
24
|
-
definedAt: parameter.info.id
|
|
25
|
-
}));
|
|
26
|
-
// keep the default's environment so its escaping (`<<-`) writes are carried on
|
|
31
|
+
const definedBy = definedByDefault(parameter, defaultValue);
|
|
32
|
+
/* keep the default's environment so its escaping (`<<-`) writes are carried on */
|
|
27
33
|
let environment = defaultValue?.environment ?? name.environment;
|
|
28
|
-
for (const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (r_function_definition_1.RFunctionDefinition.is(parameter.defaultValue)) {
|
|
35
|
-
graph.addEdge(wid, parameter.defaultValue.info.id, edge_1.EdgeType.DefinedBy);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
const definedBy = defaultValue.in.concat(defaultValue.unknownReferences);
|
|
39
|
-
for (const node of definedBy) {
|
|
40
|
-
graph.addEdge(wid, node.nodeId, edge_1.EdgeType.DefinedBy);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
34
|
+
for (const reference of name.unknownReferences) {
|
|
35
|
+
const written = { ...reference, type: identifier_1.ReferenceType.Parameter, definedAt: parameter.info.id };
|
|
36
|
+
graph.setDefinitionOfVertex(written, defaultValue === undefined ? [] : [defaultValue.entryPoint]);
|
|
37
|
+
environment = (0, define_1.define)(written, false, environment);
|
|
38
|
+
for (const node of definedBy) {
|
|
39
|
+
graph.addEdge(written.nodeId, node, edge_1.EdgeType.DefinedBy);
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
const boundAt = name.entryPoint;
|
|
46
43
|
if (defaultValue !== undefined) {
|
|
47
44
|
control_flow_1.ControlFlow.continuesWith(graph, defaultValue, boundAt);
|
|
48
|
-
for (const exit of defaultValue.exitPoints) {
|
|
49
|
-
/* R only forces a default when the parameter is used, so a jump within one does not cut the binding */
|
|
50
|
-
if (exit.type !== 0 /* ExitPointType.Default */) {
|
|
51
|
-
graph.addEdge(exit.nodeId, boundAt, edge_1.EdgeType.FlowEdge);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
45
|
}
|
|
46
|
+
/* R only forces a default when the parameter is used, so a jump within one does not cut the binding */
|
|
47
|
+
const defaultExits = control_flow_1.ControlFlow.promise(graph, defaultValue, logic_1.Ternary.Maybe, boundAt);
|
|
55
48
|
return {
|
|
56
49
|
unknownReferences: [],
|
|
57
50
|
in: defaultValue === undefined ? [] : defaultValue.in.concat(defaultValue.unknownReferences, name.in),
|
|
58
51
|
out: (defaultValue?.out ?? []).concat(name.out, name.unknownReferences),
|
|
59
|
-
graph
|
|
60
|
-
environment
|
|
52
|
+
graph,
|
|
53
|
+
environment,
|
|
61
54
|
entryPoint: parameter.info.id,
|
|
62
55
|
cfgEntry: defaultValue === undefined ? boundAt : control_flow_1.ControlFlow.entryOf(defaultValue),
|
|
63
56
|
cfgExit: boundAt,
|
|
64
|
-
exitPoints: [{ nodeId: parameter.info.id, type: 0 /* ExitPointType.Default */, cds: data.cds }],
|
|
57
|
+
exitPoints: [...defaultExits, { nodeId: parameter.info.id, type: 0 /* ExitPointType.Default */, cds: data.cds }],
|
|
65
58
|
hooks: []
|
|
66
59
|
};
|
|
67
60
|
}
|
|
@@ -17,11 +17,8 @@ function processSymbol(symbol, data) {
|
|
|
17
17
|
return (0, process_value_1.processValue)(symbol, data);
|
|
18
18
|
}
|
|
19
19
|
const sid = symbol.info.id;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
unknownReferences: identifier_1.Identifier.getName(symbol.content) === '.Options'
|
|
23
|
-
? [read, ...(0, built_in_ambient_state_1.readsOfOptionsVariable)(symbol, data)]
|
|
24
|
-
: [read],
|
|
20
|
+
return (0, built_in_ambient_state_1.ambientAccessOfSymbol)({
|
|
21
|
+
unknownReferences: [{ nodeId: sid, name: symbol.content, cds: data.cds, type: identifier_1.ReferenceType.Unknown }],
|
|
25
22
|
in: [],
|
|
26
23
|
out: [],
|
|
27
24
|
environment: data.environment,
|
|
@@ -33,6 +30,6 @@ function processSymbol(symbol, data) {
|
|
|
33
30
|
entryPoint: sid,
|
|
34
31
|
exitPoints: [{ nodeId: sid, type: 0 /* ExitPointType.Default */, cds: data.cds }],
|
|
35
32
|
hooks: []
|
|
36
|
-
};
|
|
33
|
+
}, symbol, data);
|
|
37
34
|
}
|
|
38
35
|
//# sourceMappingURL=process-symbol.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import { RNode } from '../../r-bridge/lang-4.x/ast/model/model';
|
|
4
|
+
import type { DataflowGraph } from '../graph/graph';
|
|
5
|
+
/**
|
|
6
|
+
* Program order of top-level code outside loops and quotes: it runs once, so its definitions are not there yet for the statements before.
|
|
7
|
+
* @helper dataflow
|
|
8
|
+
* @example
|
|
9
|
+
* ```r
|
|
10
|
+
* f <- function() y
|
|
11
|
+
* f() # runs once, before `y` is defined below
|
|
12
|
+
* y <- 1
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const ProgramOrder: {
|
|
16
|
+
readonly name: "ProgramOrder";
|
|
17
|
+
/** The top-level statement holding `id` if the program runs it once, in program order, `undefined` otherwise. */
|
|
18
|
+
readonly runsOnceAt: (this: void, id: NodeId, graph: DataflowGraph) => RNode<ParentInformation> | undefined;
|
|
19
|
+
/** How many top-level statements of the same file after `statement` the top-level definition at `definition` is made, `0` for any other. */
|
|
20
|
+
readonly offset: (this: void, definition: NodeId, statement: RNode<ParentInformation> | undefined, graph: DataflowGraph) => number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the definition at `definition` is made only after `statement` ran: it sits in a later top-level statement,
|
|
23
|
+
* which holds a nested one too, as the function it is nested in does not exist before.
|
|
24
|
+
*/
|
|
25
|
+
readonly definedLater: (this: void, definition: NodeId, statement: RNode<ParentInformation> | undefined, graph: DataflowGraph) => boolean;
|
|
26
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProgramOrder = void 0;
|
|
4
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
5
|
+
const info_1 = require("../info");
|
|
6
|
+
/**
|
|
7
|
+
* Program order of top-level code outside loops and quotes: it runs once, so its definitions are not there yet for the statements before.
|
|
8
|
+
* @helper dataflow
|
|
9
|
+
* @example
|
|
10
|
+
* ```r
|
|
11
|
+
* f <- function() y
|
|
12
|
+
* f() # runs once, before `y` is defined below
|
|
13
|
+
* y <- 1
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
exports.ProgramOrder = {
|
|
17
|
+
name: 'ProgramOrder',
|
|
18
|
+
/** The top-level statement holding `id` if the program runs it once, in program order, `undefined` otherwise. */
|
|
19
|
+
runsOnceAt(id, graph) {
|
|
20
|
+
const idMap = graph.idMap;
|
|
21
|
+
const node = idMap?.get(id);
|
|
22
|
+
if (idMap === undefined || node === undefined || !graph.isRoot(id)
|
|
23
|
+
|| graph.getVertex(id)?.cds?.some(cd => info_1.ControlDependency.isIterated(cd, idMap)) || graph.isQuoted(id)) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return model_1.RNode.topLevelStatement(node, idMap);
|
|
27
|
+
},
|
|
28
|
+
/** How many top-level statements of the same file after `statement` the top-level definition at `definition` is made, `0` for any other. */
|
|
29
|
+
offset(definition, statement, graph) {
|
|
30
|
+
return graph.isRoot(definition) ? statementsAfter(definition, statement, graph) : 0;
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Whether the definition at `definition` is made only after `statement` ran: it sits in a later top-level statement,
|
|
34
|
+
* which holds a nested one too, as the function it is nested in does not exist before.
|
|
35
|
+
*/
|
|
36
|
+
definedLater(definition, statement, graph) {
|
|
37
|
+
return statementsAfter(definition, statement, graph) > 0;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function statementsAfter(id, statement, graph) {
|
|
41
|
+
const idMap = graph.idMap;
|
|
42
|
+
const node = idMap?.get(id);
|
|
43
|
+
if (idMap === undefined || statement === undefined || node === undefined) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
const other = model_1.RNode.topLevelStatement(node, idMap);
|
|
47
|
+
return other.info.parent === statement.info.parent ? other.info.index - statement.info.index : 0;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=program-order.js.map
|
|
@@ -19,6 +19,7 @@ Want to try it without installing anything? Run code straight away in the ${(0,
|
|
|
19
19
|
Otherwise, you can download and build it from source, download the accompanying ${ctx.linkPage('flowr:docker', 'docker image')},
|
|
20
20
|
or use its ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')} and ${ctx.linkPage('flowr:rstudio-addin', 'RStudio Addin')}.
|
|
21
21
|
|
|
22
|
+
- [🌐 Using the Playground](#-using-the-playground)
|
|
22
23
|
- [🗒️ Using the Visual Studio Code Extension](#-using-the-visual-studio-code-extension)
|
|
23
24
|
- [🗒️ Using the RStudio Addin](#-using-the-rstudio-addin)
|
|
24
25
|
- [🐳️ Using the Docker Image](#-using-the-docker-image)
|
|
@@ -29,6 +30,17 @@ or use its ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')} and $
|
|
|
29
30
|
If you want to develop for _flowR_, you want to see how to [build from scratch](#-building-from-scratch) and have a
|
|
30
31
|
look at the [Contributing Guidelines](${doc_files_1.RemoteFlowrFilePathBaseRef}.github/CONTRIBUTING.md).
|
|
31
32
|
|
|
33
|
+
## 🌐 Using the Playground
|
|
34
|
+
|
|
35
|
+
The ${(0, doc_playground_1.linkToPlayground)('Playground', {})} runs _flowR_ in your browser and updates the dependencies, lints, and slice while you type.
|
|
36
|
+
It can also execute the script with [webR](https://docs.r-wasm.org/webr/latest/).
|
|
37
|
+
Press Run (or <kbd>Ctrl</kbd>+<kbd>Enter</kbd>) to evaluate the script in a fresh workspace.
|
|
38
|
+
The first run downloads R (about 30 MB), and packages loaded with \`library()\`, \`require()\`, or \`pkg::\` are installed when needed.
|
|
39
|
+
In the repl, lines starting with \`:\` are _flowR_ commands (see \`:help\`), all other lines are evaluated as R in the same session.
|
|
40
|
+
webR is downloaded from its CDN, and the page checks every file against the pinned webR release, whose npm signature and checksum the build verifies. A file that does not match is refused and R does not run.
|
|
41
|
+
R runs inside the browser with its own in-memory file system and cannot call \`system()\`.
|
|
42
|
+
Shared links contain the script and the _flowR_ commands only, never R input for the repl.
|
|
43
|
+
|
|
32
44
|
## 🗒️ Using the Visual Studio Code Extension
|
|
33
45
|
|
|
34
46
|
The easiest way to use _flowR_ is to install the ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')}.
|
|
@@ -115,6 +127,17 @@ For details on _how_ to contribute, please refer to the [CONTRIBUTING.md](${doc_
|
|
|
115
127
|
|
|
116
128
|
_flowR_ knows the exported functions of thousands of R packages, resolving \`library(pkg)\`/\`pkg::fn\` calls from a downloaded signature database (\`flowr-sigdb\`); no shards are committed (only the \`sigdb.remote.json\` pointer), everything else is fetched on demand. Search it live at [flowr-analysis.github.io/flowr/wiki/sigdb](${doc_files_1.FlowrSiteBaseRef}/wiki/sigdb/), try _flowR_ itself in the ${(0, doc_playground_1.linkToPlayground)('Playground', {})} without installing anything, or see the ${ctx.linkPage('wiki/Signature Database')} page for how the database works.
|
|
117
129
|
|
|
130
|
+
### 🌐 Working on the Playground
|
|
131
|
+
|
|
132
|
+
The playground lives in \`scripts/playground/\`. Its bundle is not committed, the documentation job builds it for GitHub Pages.
|
|
133
|
+
To build and serve it locally:
|
|
134
|
+
|
|
135
|
+
\`\`\`shell
|
|
136
|
+
npm run preview:playground
|
|
137
|
+
\`\`\`
|
|
138
|
+
|
|
139
|
+
Then open [localhost:8000/playground/](http://localhost:8000/playground/).
|
|
140
|
+
|
|
118
141
|
### 📦 Using _flowR_ as a Dependency in Another Project
|
|
119
142
|
|
|
120
143
|
_flowR_ is published as \`@eagleoutice/flowr\`, but you may want an unreleased branch or a local build instead. Plain \`npm install /path/to/flowr\` (or \`npm link\`) looks like it works, but skips resolving _flowR_'s own dependencies, so the bundled WASM parser fails at runtime with an \`ENOENT\` on \`tree-sitter.wasm\`. Package a tarball instead, which installs like any normal package:
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare const LintingRules: {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
readonly 'seeded-randomness': {
|
|
55
|
-
readonly createSearch: (config: import("./rules/seeded-randomness").SeededRandomnessConfig
|
|
55
|
+
readonly createSearch: (config: import("./rules/seeded-randomness").SeededRandomnessConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
56
56
|
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/seeded-randomness").SeededRandomnessConfig, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
|
|
57
57
|
results: {
|
|
58
58
|
involvedId: import("..").NodeId;
|
|
@@ -64,10 +64,13 @@ export declare const LintingRules: {
|
|
|
64
64
|
}>;
|
|
65
65
|
readonly info: {
|
|
66
66
|
readonly defaultConfig: (ctx: import("../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext) => {
|
|
67
|
-
randomnessProducers: {
|
|
68
|
-
type: "function"
|
|
67
|
+
randomnessProducers: ({
|
|
68
|
+
readonly type: "function";
|
|
69
|
+
readonly name: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: "assignment";
|
|
69
72
|
name: string;
|
|
70
|
-
}[];
|
|
73
|
+
})[];
|
|
71
74
|
randomnessConsumers: string[];
|
|
72
75
|
};
|
|
73
76
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility];
|
|
@@ -129,7 +132,7 @@ export declare const LintingRules: {
|
|
|
129
132
|
};
|
|
130
133
|
};
|
|
131
134
|
readonly 'naming-convention': {
|
|
132
|
-
readonly createSearch: (
|
|
135
|
+
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
133
136
|
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/naming-convention").NamingConventionConfig, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
|
|
134
137
|
results: import("./rules/naming-convention").NamingConventionResult[];
|
|
135
138
|
'.meta': {
|
|
@@ -258,7 +261,7 @@ export declare const LintingRules: {
|
|
|
258
261
|
};
|
|
259
262
|
};
|
|
260
263
|
readonly 'stop-call': {
|
|
261
|
-
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"
|
|
264
|
+
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
262
265
|
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, _config: import("../util/objects").MergeableRecord, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
|
|
263
266
|
results: import("ts-essentials").Writable<import("./rules/stop-with-call-arg").StopWithCallResult>[];
|
|
264
267
|
'.meta': import("./rules/stop-with-call-arg").StopWithCallMetadata;
|
|
@@ -277,8 +280,14 @@ export declare const LintingRules: {
|
|
|
277
280
|
};
|
|
278
281
|
readonly 'roxygen-arguments': {
|
|
279
282
|
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
280
|
-
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]
|
|
281
|
-
results:
|
|
283
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>) => {
|
|
284
|
+
results: {
|
|
285
|
+
certainty: import("./linter-format").LintingResultCertainty.Uncertain;
|
|
286
|
+
involvedId: import("..").NodeId;
|
|
287
|
+
loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
|
|
288
|
+
underDocumented: string[];
|
|
289
|
+
overDocumented: string[];
|
|
290
|
+
}[];
|
|
282
291
|
'.meta': {};
|
|
283
292
|
};
|
|
284
293
|
readonly prettyPrint: {
|
|
@@ -47,29 +47,24 @@ function buildQuickFix(str, filePath, wd) {
|
|
|
47
47
|
replacement: `${str.content.quotes}${files_1.RPath.relative(wd, filePath)}${str.content.quotes}`
|
|
48
48
|
}];
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
results.push(argValues.join(val));
|
|
69
|
-
}
|
|
70
|
-
return results;
|
|
71
|
-
}]
|
|
72
|
-
]);
|
|
50
|
+
/** The paths `file.path(...)` builds, `undefined` if a part is unknown. */
|
|
51
|
+
function filePathStrings(graph, vtx, ctx) {
|
|
52
|
+
const variables = ctx.config.solver.variables;
|
|
53
|
+
// in the future we can access `.Platform$file.sep` here
|
|
54
|
+
const fsep = (0, resolve_argument_1.getArgumentStringValue)(variables, graph, vtx, undefined, 'fsep', true, ctx);
|
|
55
|
+
const seps = fsep?.values().flatMap(s => s.values().filter(assert_1.isNotUndefined)).toArray() ?? ['/'];
|
|
56
|
+
if (seps.includes(dependencies_query_format_1.Unknown)) {
|
|
57
|
+
// if we have no fsep, we cannot construct a path
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const unnamed = (0, resolve_argument_1.getArgumentStringValue)(variables, graph, vtx, 'unnamed', undefined, true, ctx);
|
|
61
|
+
const args = [...unnamed?.values() ?? []].flatMap(v => [...v]);
|
|
62
|
+
if (args.length === 0 || args.some(v => v === dependencies_query_format_1.Unknown || v === undefined)) {
|
|
63
|
+
// if we have no arguments, we cannot construct a path
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return seps.map(sep => args.join(sep));
|
|
67
|
+
}
|
|
73
68
|
/**
|
|
74
69
|
* Resolve a raw string value to the path that should be checked for absoluteness.
|
|
75
70
|
* - `file://` URIs: extract the local path (always checked, ignoreUrls has no effect)
|
|
@@ -83,24 +78,24 @@ function resolvePathForAbsoluteCheck(value, ignoreUrls) {
|
|
|
83
78
|
}
|
|
84
79
|
return ignoreUrls && (0, strings_1.isUrl)(value) ? undefined : value;
|
|
85
80
|
}
|
|
81
|
+
/** A path built within a call that already reports it, as `file.path` within `read.csv`, is one finding. */
|
|
82
|
+
function withoutNested(results) {
|
|
83
|
+
return results.filter((r, i) => !results.some((o, j) => i !== j && o.filePath === r.filePath
|
|
84
|
+
&& (range_1.SourceRange.isStrictSubsetOf(r.loc, o.loc) || (j < i && range_1.SourceRange.equals(r.loc, o.loc)))));
|
|
85
|
+
}
|
|
86
86
|
exports.ABSOLUTE_PATH = {
|
|
87
87
|
/* this can be done better once we have types */
|
|
88
88
|
createSearch: (config, data) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
ignoreDefaultFunctions: true,
|
|
98
|
-
readFunctions: (0, read_functions_1.readFunctions)(data.inspectContext()).concat((0, write_functions_1.writeFunctions)(data.inspectContext()), source_functions_1.SourceFunctions, other_path_functions_1.OtherPathFunctions, config.additionalPathFunctions),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
89
|
+
const ctx = data.inspectContext();
|
|
90
|
+
const pathFunctions = (0, read_functions_1.readFunctions)(ctx).concat((0, write_functions_1.writeFunctions)(ctx), source_functions_1.SourceFunctions, other_path_functions_1.OtherPathFunctions, config.additionalPathFunctions);
|
|
91
|
+
let q = config.include.allStrings ? flowr_search_builder_1.Q.all().filter(type_1.RType.String) : flowr_search_builder_1.Q.fromQuery({
|
|
92
|
+
type: 'dependencies',
|
|
93
|
+
// we use the dependencies query to give us all functions that take a file path as input
|
|
94
|
+
ignoreDefaultFunctions: true,
|
|
95
|
+
readFunctions: pathFunctions,
|
|
96
|
+
});
|
|
101
97
|
if (config.include.constructed) {
|
|
102
98
|
q = q.merge(flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall).with(search_enrichers_1.Enrichment.CallTargets));
|
|
103
|
-
/* in the future, we want to directly check whether this is one of the supported functions */
|
|
104
99
|
}
|
|
105
100
|
return q.unique();
|
|
106
101
|
},
|
|
@@ -111,76 +106,57 @@ exports.ABSOLUTE_PATH = {
|
|
|
111
106
|
};
|
|
112
107
|
const queryResults = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData)?.queries;
|
|
113
108
|
const regex = config.absolutePathRegex ? new RegExp(config.absolutePathRegex) : undefined;
|
|
114
|
-
const
|
|
115
|
-
const
|
|
109
|
+
const { idMap } = await data.normalize();
|
|
110
|
+
const { graph } = await data.dataflow();
|
|
116
111
|
const ctx = data.inspectContext();
|
|
112
|
+
const absolute = (value) => {
|
|
113
|
+
const path = resolvePathForAbsoluteCheck(value, config.ignoreUrls);
|
|
114
|
+
return path !== undefined && (0, strings_1.isAbsolutePath)(path, regex) ? path : undefined;
|
|
115
|
+
};
|
|
116
|
+
const finding = (certainty, filePath, node, wd) => (0, objects_1.compactRecord)({
|
|
117
|
+
certainty,
|
|
118
|
+
filePath,
|
|
119
|
+
loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
|
|
120
|
+
quickFix: buildQuickFix(node, filePath, wd)
|
|
121
|
+
});
|
|
117
122
|
return {
|
|
118
|
-
results: elements.getElements().flatMap(element => {
|
|
123
|
+
results: withoutNested(elements.getElements().flatMap(element => {
|
|
119
124
|
metadata.totalConsidered++;
|
|
120
125
|
const node = element.node;
|
|
121
126
|
const wd = inferWd(node.info.file, config.useAsWd, ctx);
|
|
127
|
+
const query = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.QueryData);
|
|
122
128
|
if (r_string_1.RString.is(node)) {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
return [{
|
|
126
|
-
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
127
|
-
filePath: resolved,
|
|
128
|
-
loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
|
|
129
|
-
quickFix: buildQuickFix(node, resolved, wd)
|
|
130
|
-
}];
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
129
|
+
const path = absolute(node.content.str);
|
|
130
|
+
return path !== undefined && path.length >= 3 ? [finding(linter_format_1.LintingResultCertainty.Uncertain, path, node, wd)] : [];
|
|
135
131
|
}
|
|
136
|
-
else if (
|
|
137
|
-
const result = queryResults[
|
|
138
|
-
const
|
|
132
|
+
else if (query) {
|
|
133
|
+
const result = queryResults[query.query];
|
|
134
|
+
const reads = result.read.filter(r => r.nodeId === node.info.id);
|
|
135
|
+
const found = reads.flatMap(r => {
|
|
139
136
|
if (r.value === undefined || r.value === dependencies_query_format_1.Unknown || r.nodeId === undefined) {
|
|
140
137
|
return [];
|
|
141
138
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
const elem = normalize.idMap.get(r.nodeId);
|
|
147
|
-
return [{
|
|
148
|
-
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
149
|
-
filePath: resolved,
|
|
150
|
-
loc: elem ? range_1.SourceLocation.fromNode(elem) ?? range_1.SourceLocation.invalid() : range_1.SourceLocation.invalid(),
|
|
151
|
-
quickFix: buildQuickFix(elem, resolved, wd)
|
|
152
|
-
}];
|
|
139
|
+
const path = absolute(r.value);
|
|
140
|
+
return path === undefined ? [] : [finding(linter_format_1.LintingResultCertainty.Certain, path, idMap.get(r.nodeId), wd)];
|
|
153
141
|
});
|
|
154
|
-
if
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
else if (result.read.every(r => r.value !== dependencies_query_format_1.Unknown)) {
|
|
158
|
-
// if we have no absolute paths, but all paths are known, we can return an empty array
|
|
159
|
-
return [];
|
|
142
|
+
// if we have no absolute paths, but all paths are known, we can return an empty array
|
|
143
|
+
if (found.length > 0 || reads.every(r => r.value !== dependencies_query_format_1.Unknown)) {
|
|
144
|
+
return found;
|
|
160
145
|
}
|
|
161
146
|
}
|
|
162
147
|
else {
|
|
163
|
-
const
|
|
164
|
-
if (vertex_1.DfgVertex.isFunctionCall(
|
|
165
|
-
|
|
166
|
-
const strings =
|
|
148
|
+
const vertex = graph.getVertex(node.info.id);
|
|
149
|
+
if (vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
150
|
+
/* `file.path` is the only supported function that returns a file path */
|
|
151
|
+
const strings = vertex.name === 'file.path' ? filePathStrings(graph, vertex, ctx) : [];
|
|
167
152
|
if (strings) {
|
|
168
|
-
return strings.
|
|
169
|
-
const resolved = resolvePathForAbsoluteCheck(s, config.ignoreUrls);
|
|
170
|
-
return resolved !== undefined && (0, strings_1.isAbsolutePath)(resolved, regex) ? [resolved] : [];
|
|
171
|
-
}).map(str => ({
|
|
172
|
-
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
173
|
-
filePath: str,
|
|
174
|
-
loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid(),
|
|
175
|
-
quickFix: undefined
|
|
176
|
-
}));
|
|
153
|
+
return strings.map(absolute).filter(assert_1.isNotUndefined).map(path => finding(linter_format_1.LintingResultCertainty.Uncertain, path, node));
|
|
177
154
|
}
|
|
178
155
|
}
|
|
179
|
-
// check whether the df node is a function call that returns a file path
|
|
180
156
|
}
|
|
181
157
|
metadata.totalUnknown++;
|
|
182
|
-
return
|
|
183
|
-
})
|
|
158
|
+
return [];
|
|
159
|
+
})),
|
|
184
160
|
'.meta': metadata
|
|
185
161
|
};
|
|
186
162
|
},
|