@eagleoutice/flowr 2.13.16 → 2.14.1
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 +36 -25
- package/abstract-interpretation/absint-visitor.js +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
- package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
- package/abstract-interpretation/data-frame/resolve-args.js +10 -5
- package/benchmark/calibration.d.ts +16 -7
- package/benchmark/calibration.js +44 -17
- package/benchmark/slicer.d.ts +3 -2
- package/benchmark/slicer.js +9 -5
- package/benchmark/stats/size-of.js +1 -1
- package/benchmark/summarizer/first-phase/process.d.ts +2 -0
- package/benchmark/summarizer/first-phase/process.js +2 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.d.ts +5 -31
- package/cli/common/options.js +2 -8
- package/cli/common/scripts-info.d.ts +5 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/core.js +1 -1
- package/cli/repl/execute.d.ts +2 -2
- package/cli/repl/execute.js +2 -2
- package/cli/repl/parser/slice-query-parser.js +1 -1
- package/cli/repl/print-version.js +2 -2
- package/config.d.ts +16 -0
- package/config.js +83 -5
- package/control-flow/extract-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -1
- package/control-flow/useless-loop.js +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/apply-kill.js +1 -1
- package/dataflow/environments/built-in-props.d.ts +13 -2
- package/dataflow/environments/built-in-props.js +23 -1
- package/dataflow/environments/built-in.d.ts +7 -1
- package/dataflow/environments/built-in.js +42 -3
- package/dataflow/environments/default-builtin-config.d.ts +518 -11
- package/dataflow/environments/default-builtin-config.js +218 -23
- package/dataflow/environments/environment.d.ts +10 -2
- package/dataflow/environments/environment.js +25 -7
- package/dataflow/environments/identifier.d.ts +8 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.d.ts +6 -0
- package/dataflow/environments/query-fn-props.js +22 -2
- package/dataflow/environments/reference-to-maybe.js +5 -5
- package/dataflow/environments/resolve-by-name.d.ts +3 -0
- package/dataflow/environments/resolve-by-name.js +44 -7
- package/dataflow/environments/resolve-helper.d.ts +6 -0
- package/dataflow/environments/resolve-helper.js +6 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
- package/dataflow/eval/resolve/alias-tracking.js +21 -14
- package/dataflow/eval/resolve/node-value.d.ts +6 -0
- package/dataflow/eval/resolve/node-value.js +15 -9
- package/dataflow/eval/resolve/resolve-argument.js +2 -2
- package/dataflow/eval/resolve/resolve-numbers.js +2 -2
- package/dataflow/eval/resolve/resolve-operators.js +5 -4
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +3 -3
- package/dataflow/eval/resolve/resolve.d.ts +5 -5
- package/dataflow/eval/resolve/resolve.js +10 -11
- package/dataflow/eval/values/general.d.ts +4 -1
- package/dataflow/eval/values/general.js +1 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/fn/exceptions-of-function.d.ts +3 -1
- package/dataflow/fn/exceptions-of-function.js +87 -39
- package/dataflow/fn/higher-order-function.js +5 -4
- package/dataflow/fn/strict-function.d.ts +40 -0
- package/dataflow/fn/strict-function.js +337 -0
- package/dataflow/graph/call-graph.js +14 -14
- package/dataflow/graph/df-helper.d.ts +24 -1
- package/dataflow/graph/df-helper.js +29 -7
- package/dataflow/graph/diff-dataflow-graph.js +6 -6
- package/dataflow/graph/edge.d.ts +27 -0
- package/dataflow/graph/edge.js +33 -0
- package/dataflow/graph/graph-helper.d.ts +3 -4
- package/dataflow/graph/graph-helper.js +4 -5
- package/dataflow/graph/graph.d.ts +39 -3
- package/dataflow/graph/graph.js +75 -7
- package/dataflow/graph/vertex.d.ts +42 -6
- package/dataflow/graph/vertex.js +42 -6
- package/dataflow/info.d.ts +26 -0
- package/dataflow/info.js +28 -1
- package/dataflow/internal/linker.d.ts +1 -0
- package/dataflow/internal/linker.js +11 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +29 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +44 -20
- package/dataflow/internal/process/functions/call/common.d.ts +9 -1
- package/dataflow/internal/process/functions/call/common.js +17 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
- package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
- package/dataflow/internal/process/functions/call/nse.js +113 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
- package/dataflow/internal/process/functions/call/quoted.js +21 -9
- package/dataflow/origin/dfg-get-origin.d.ts +1 -0
- package/dataflow/origin/dfg-get-origin.js +9 -6
- package/documentation/data/faq/faqs.js +88 -88
- package/documentation/data/faq/recommended-configs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +1 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-auto-gen.js +6 -2
- package/documentation/doc-util/doc-functions.js +1 -1
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +18 -18
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-linting-and-testing.js +93 -5
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-overview.js +12 -1
- package/documentation/wiki-query.js +53 -0
- package/documentation/wiki-signature-database.js +3 -0
- package/linter/linter-output.js +1 -1
- package/linter/linter-rules.d.ts +24 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- package/linter/rules/unclosed-connection.d.ts +44 -0
- package/linter/rules/unclosed-connection.js +200 -0
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +5 -4
- package/linter/rules/undefined-symbol.js +3 -3
- package/linter/rules/unused-definition.js +2 -1
- package/package.json +38 -51
- package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
- package/project/context/flowr-analyzer-environment-context.js +25 -0
- package/project/dependency-version-space.d.ts +3 -3
- package/project/dependency-version-space.js +3 -4
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -4
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +36 -7
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +16 -16
- package/project/sigdb/codec.d.ts +1 -1
- package/project/sigdb/codec.js +13 -13
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +33 -33
- package/project/sigdb/index-format.js +2 -2
- package/project/sigdb/manifest.d.ts +3 -1
- package/project/sigdb/manifest.js +68 -27
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +14 -14
- package/project/sigdb/schema.d.ts +2 -2
- package/project/sigdb/schema.js +2 -2
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
- package/queries/catalog/dependencies-query/link-devices.js +3 -9
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
- package/queries/catalog/signature-query/signature-query-executor.js +3 -2
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/slice-query-options.js +1 -1
- package/queries/query-function-filter.d.ts +8 -2
- package/queries/query-function-filter.js +11 -1
- package/queries/query.d.ts +11 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
- package/r-bridge/lang-4.x/ast/model/model.js +4 -4
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/retriever.d.ts +2 -1
- package/r-bridge/retriever.js +3 -2
- package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
- package/r-bridge/roxygen2/documentation-provider.js +1 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +2 -14
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +2 -2
- package/slicing/criterion/parse.js +5 -5
- package/slicing/static/fingerprint.js +1 -1
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/static-slicer.js +4 -3
- package/util/assert.js +1 -1
- package/util/log.d.ts +4 -1
- package/util/log.js +15 -2
- package/util/logic.js +2 -2
- package/util/mermaid/cfg.js +1 -1
- package/util/mermaid/dfg.js +6 -6
- package/util/mermaid/mermaid.js +3 -1
- package/util/objects.d.ts +12 -0
- package/util/objects.js +48 -0
- package/util/quads.js +19 -6
- package/util/schema.js +2 -2
- package/util/simple-df/dfg-ascii.js +14 -3
- package/util/text/ansi.d.ts +2 -0
- package/util/text/ansi.js +8 -0
- package/util/text/name-rank.d.ts +29 -0
- package/util/text/name-rank.js +39 -0
- package/util/text/url-encoding.d.ts +15 -0
- package/util/text/url-encoding.js +59 -0
- package/util/version.js +1 -1
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -44
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNCLOSED_CONNECTION = void 0;
|
|
4
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
5
|
+
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
6
|
+
const graph_1 = require("../../dataflow/graph/graph");
|
|
7
|
+
const edge_1 = require("../../dataflow/graph/edge");
|
|
8
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
9
|
+
const info_1 = require("../../dataflow/info");
|
|
10
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
11
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
12
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
13
|
+
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
14
|
+
const range_1 = require("../../util/range");
|
|
15
|
+
const assert_1 = require("../../util/assert");
|
|
16
|
+
const linter_format_1 = require("../linter-format");
|
|
17
|
+
const linter_tags_1 = require("../linter-tags");
|
|
18
|
+
/** the edges the connection flows along, from the call opening it to the argument of the call closing it */
|
|
19
|
+
const ConnectionFlow = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall | edge_1.EdgeType.Returns | edge_1.EdgeType.Argument;
|
|
20
|
+
/** The arguments holding the handle the call acts on, all of them if it does not state which. */
|
|
21
|
+
function handleArguments(vertex, sig) {
|
|
22
|
+
const stated = sig && built_in_props_1.FnSig.posWith(built_in_props_1.FnSig.layout(sig), vertex.args.length, built_in_props_1.ArgProp.Handle);
|
|
23
|
+
return stated?.length ? stated.map(i => vertex.args[i]) : vertex.args;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Adds every opening call whose connection may reach `start`, an argument of a closing call, to `out`.
|
|
27
|
+
* Unlike {@link Dataflow.provenance} this stops at an opening call and follows no control dependency,
|
|
28
|
+
* so a close in a branch does not claim what that branch opens beside it.
|
|
29
|
+
*/
|
|
30
|
+
function openCallsReaching(graph, start, opens, out) {
|
|
31
|
+
const visited = new Set([start]);
|
|
32
|
+
const pending = [start];
|
|
33
|
+
while (pending.length > 0) {
|
|
34
|
+
const current = pending.pop();
|
|
35
|
+
if (opens.has(current)) {
|
|
36
|
+
out.add(current);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
for (const [target, edge] of graph.outgoingEdges(current) ?? graph_1.NoEdges) {
|
|
40
|
+
if (edge_1.DfEdge.includesType(edge, ConnectionFlow) && !visited.has(target)) {
|
|
41
|
+
visited.add(target);
|
|
42
|
+
pending.push(target);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The variable definition the opened connection is bound to, if it is bound to one. */
|
|
48
|
+
function bindingOf(graph, open) {
|
|
49
|
+
for (const [source, edge] of graph.ingoingEdges(open) ?? graph_1.NoEdges) {
|
|
50
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy) && vertex_1.VariableDefinitionVertex.is(graph.getVertex(source))) {
|
|
51
|
+
return source;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
/** The statement `id` belongs to, i.e. the ancestor that is an element of an expression list. */
|
|
57
|
+
function enclosingStatement(idMap, id) {
|
|
58
|
+
let node = idMap.get(id);
|
|
59
|
+
while (node !== undefined) {
|
|
60
|
+
const parent = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
61
|
+
if (parent === undefined || parent.type === type_1.RType.ExpressionList) {
|
|
62
|
+
return node;
|
|
63
|
+
}
|
|
64
|
+
node = parent;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
/** A fix closing the connection after the last statement using it, if it is bound to a name to close. */
|
|
69
|
+
function closeFix(graph, open) {
|
|
70
|
+
const idMap = graph.idMap;
|
|
71
|
+
const definition = bindingOf(graph, open);
|
|
72
|
+
const name = idMap && definition !== undefined ? (0, node_id_1.recoverName)(definition, idMap) : undefined;
|
|
73
|
+
if (idMap === undefined || definition === undefined || name === undefined) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const reads = (graph.ingoingEdges(definition) ?? graph_1.NoEdges).entries()
|
|
77
|
+
.filter(([, edge]) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)).map(([source]) => source);
|
|
78
|
+
const statements = [definition, ...reads]
|
|
79
|
+
.map(id => range_1.SourceLocation.fromNode(enclosingStatement(idMap, id)))
|
|
80
|
+
.filter(assert_1.isNotUndefined);
|
|
81
|
+
const last = statements.reduce((a, b) => a === undefined || range_1.SourceRange.compare(range_1.SourceLocation.getRange(a), range_1.SourceLocation.getRange(b)) < 0 ? b : a, undefined);
|
|
82
|
+
if (last === undefined) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const [startLine, startColumn, endLine, endColumn] = last;
|
|
86
|
+
return [{
|
|
87
|
+
type: 'replace',
|
|
88
|
+
loc: range_1.SourceLocation.from([endLine, endColumn + 1, endLine, endColumn], range_1.SourceLocation.getFile(last)),
|
|
89
|
+
description: `Close the connection with \`close(${name})\``,
|
|
90
|
+
replacement: `\n${' '.repeat(startLine === endLine ? startColumn - 1 : 0)}close(${name})`
|
|
91
|
+
}];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* How certain we are that the connection opened at `open` is left open,
|
|
95
|
+
* or `undefined` if the given closing calls close it in every run that opens it.
|
|
96
|
+
*/
|
|
97
|
+
function unclosedCertainty(graph, open, closes) {
|
|
98
|
+
if (closes === undefined) {
|
|
99
|
+
return linter_format_1.LintingResultCertainty.Certain;
|
|
100
|
+
}
|
|
101
|
+
const openCds = graph.getVertex(open)?.cds ?? [];
|
|
102
|
+
const uncovered = new Set();
|
|
103
|
+
for (const close of closes) {
|
|
104
|
+
const closeCds = graph.getVertex(close)?.cds ?? [];
|
|
105
|
+
/* opening within a loop and closing outside of it closes the connection of the last iteration only */
|
|
106
|
+
if (info_1.ControlDependency.minus(openCds, closeCds).some(cd => info_1.ControlDependency.isIterated(cd, graph.idMap))) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const only = info_1.ControlDependency.minus(closeCds, openCds);
|
|
110
|
+
if (only.length === 0) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
for (const cd of only) {
|
|
114
|
+
uncovered.add(cd);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/* the closes may still cover every branch between them, as in `if(p) close(c) else close(c)` */
|
|
118
|
+
return uncovered.size > 0 && info_1.ControlDependency.happensInEveryBranchSet(uncovered) ? undefined : linter_format_1.LintingResultCertainty.Uncertain;
|
|
119
|
+
}
|
|
120
|
+
/** The calls opening and the calls closing a connection, as the props state and the configuration adds. */
|
|
121
|
+
function connectionCalls(elements, dataflow, config) {
|
|
122
|
+
const opensByName = config.openFns.length > 0 ? identifier_1.Identifier.regex(...config.openFns) : undefined;
|
|
123
|
+
const closesByName = config.closeFns.length > 0 ? identifier_1.Identifier.regex(...config.closeFns) : undefined;
|
|
124
|
+
const opens = new Map();
|
|
125
|
+
const closes = [];
|
|
126
|
+
for (const { node } of elements) {
|
|
127
|
+
const stated = (0, query_fn_props_1.callFnProps)(node.info.id, dataflow);
|
|
128
|
+
if (stated === undefined) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const props = stated.props ?? 0;
|
|
132
|
+
const name = identifier_1.Identifier.toString(stated.name);
|
|
133
|
+
const loc = range_1.SourceLocation.fromNode(node);
|
|
134
|
+
if (loc !== undefined && ((props & built_in_props_1.CallProp.Opens) !== 0 || opensByName?.test(name))) {
|
|
135
|
+
opens.set(node.info.id, loc);
|
|
136
|
+
}
|
|
137
|
+
else if ((props & built_in_props_1.CallProp.Closes) !== 0 || closesByName?.test(name)) {
|
|
138
|
+
const vertex = dataflow.graph.getVertex(node.info.id);
|
|
139
|
+
if (vertex_1.FunctionCallVertex.is(vertex)) {
|
|
140
|
+
closes.push([vertex, stated.sig]);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return { opens, closes };
|
|
145
|
+
}
|
|
146
|
+
exports.UNCLOSED_CONNECTION = {
|
|
147
|
+
createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall),
|
|
148
|
+
processSearchResult: async (elements, config, data) => {
|
|
149
|
+
const dataflow = await data.dataflow();
|
|
150
|
+
const graph = dataflow.graph;
|
|
151
|
+
const { opens, closes } = connectionCalls(elements.getElements(), dataflow, config);
|
|
152
|
+
const openIds = new Set(opens.keys());
|
|
153
|
+
const closedBy = new Map();
|
|
154
|
+
for (const [close, sig] of opens.size > 0 ? closes : []) {
|
|
155
|
+
const reached = new Set();
|
|
156
|
+
for (const arg of handleArguments(close, sig)) {
|
|
157
|
+
const ref = graph_1.FunctionArgument.getReference(arg);
|
|
158
|
+
if (ref !== undefined) {
|
|
159
|
+
openCallsReaching(graph, ref, openIds, reached);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
for (const open of reached) {
|
|
163
|
+
const known = closedBy.get(open);
|
|
164
|
+
if (known) {
|
|
165
|
+
known.push(close.id);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
closedBy.set(open, [close.id]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const results = [];
|
|
173
|
+
for (const [open, loc] of opens) {
|
|
174
|
+
const certainty = unclosedCertainty(graph, open, closedBy.get(open));
|
|
175
|
+
if (certainty === undefined) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
/* closing what another path closes as well errors in R, so only a connection nothing closes gets a fix */
|
|
179
|
+
const quickFix = certainty === linter_format_1.LintingResultCertainty.Certain ? closeFix(graph, open) : undefined;
|
|
180
|
+
results.push({ certainty, involvedId: open, loc, ...(quickFix ? { quickFix } : {}) });
|
|
181
|
+
}
|
|
182
|
+
return { results, '.meta': { totalOpened: opens.size, totalClosed: closes.length } };
|
|
183
|
+
},
|
|
184
|
+
prettyPrint: {
|
|
185
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Unclosed connection at ${range_1.SourceLocation.format(result.loc)}`,
|
|
186
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => `The connection opened at ${range_1.SourceLocation.format(result.loc)} is not closed on every path that opens it`
|
|
187
|
+
},
|
|
188
|
+
info: {
|
|
189
|
+
name: 'Unclosed Connection',
|
|
190
|
+
tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Smell],
|
|
191
|
+
/* a connection handed to code flowR cannot resolve, as in `lapply(cons, close)`, is reported although it is closed */
|
|
192
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
193
|
+
description: 'Flags connections that are opened but not closed on every path opening them.',
|
|
194
|
+
defaultConfig: {
|
|
195
|
+
openFns: [],
|
|
196
|
+
closeFns: []
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=unclosed-connection.js.map
|
|
@@ -7,7 +7,7 @@ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
|
7
7
|
export declare function isInstalledResourceFile(file: string | undefined): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Whether the variable use `id` resolves to a local definition, a parameter, or a built-in (function or
|
|
10
|
-
* constant such as `T`, `pi`). Broader than `
|
|
10
|
+
* constant such as `T`, `pi`). Broader than `Dataflow.origin`, which misses built-in constants.
|
|
11
11
|
*/
|
|
12
12
|
export declare function useResolvesToDefinitionOrBuiltin(graph: DataflowGraph, id: NodeId): boolean;
|
|
13
13
|
/**
|
|
@@ -11,6 +11,7 @@ const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
|
11
11
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
12
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
13
13
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
14
|
+
const graph_1 = require("../../dataflow/graph/graph");
|
|
14
15
|
/**
|
|
15
16
|
* Path heuristic for an R package `inst/` resource (installed verbatim, not namespace source). Fallback for
|
|
16
17
|
* the authoritative `FileRole.Install`, covering requests that bypass the file-role plugins.
|
|
@@ -21,10 +22,10 @@ function isInstalledResourceFile(file) {
|
|
|
21
22
|
const ResolveEdges = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall;
|
|
22
23
|
/**
|
|
23
24
|
* Whether the variable use `id` resolves to a local definition, a parameter, or a built-in (function or
|
|
24
|
-
* constant such as `T`, `pi`). Broader than `
|
|
25
|
+
* constant such as `T`, `pi`). Broader than `Dataflow.origin`, which misses built-in constants.
|
|
25
26
|
*/
|
|
26
27
|
function useResolvesToDefinitionOrBuiltin(graph, id) {
|
|
27
|
-
for (const [target, edge] of graph.outgoingEdges(id) ??
|
|
28
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
28
29
|
if (edge_1.DfEdge.doesNotIncludeType(edge, ResolveEdges) || edge_1.DfEdge.includesType(edge, edge_1.EdgeType.NonStandardEvaluation)) {
|
|
29
30
|
continue;
|
|
30
31
|
}
|
|
@@ -32,7 +33,7 @@ function useResolvesToDefinitionOrBuiltin(graph, id) {
|
|
|
32
33
|
return true;
|
|
33
34
|
}
|
|
34
35
|
const targetVtx = graph.getVertex(target);
|
|
35
|
-
if (
|
|
36
|
+
if (vertex_1.VariableDefinitionVertex.is(targetVtx) || vertex_1.FunctionDefinitionVertex.is(targetVtx)) {
|
|
36
37
|
return true;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -109,7 +110,7 @@ function collectScopeDefinedNames(graph) {
|
|
|
109
110
|
return byScope;
|
|
110
111
|
}
|
|
111
112
|
for (const [id, vtx] of graph.vertices(true)) {
|
|
112
|
-
if (
|
|
113
|
+
if (!vertex_1.VariableDefinitionVertex.is(vtx)) {
|
|
113
114
|
continue; // function bindings/params surface as variable definitions of their name symbol
|
|
114
115
|
}
|
|
115
116
|
const name = idMap.get(id)?.lexeme;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UNDEFINED_SYMBOL = void 0;
|
|
4
4
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
5
5
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
6
|
-
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
7
6
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
8
7
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
9
8
|
const flowr_search_filters_1 = require("../../search/flowr-search-filters");
|
|
@@ -15,6 +14,7 @@ const r_base_packages_1 = require("../../util/r-base-packages");
|
|
|
15
14
|
const linter_format_1 = require("../linter-format");
|
|
16
15
|
const linter_tags_1 = require("../linter-tags");
|
|
17
16
|
const undefined_symbol_util_1 = require("./undefined-symbol-util");
|
|
17
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
18
18
|
/** calls that load a package; an unresolved one means we cannot enumerate all exports in scope */
|
|
19
19
|
const LibraryLoadFunctions = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'load_all', 'use', 'p_load']);
|
|
20
20
|
// standard packages attached by default; exports are in scope without library()
|
|
@@ -106,7 +106,7 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
106
106
|
return check(element, id, identifier_1.Identifier.getName(vtx.name), identifier_1.Identifier.getNamespace(vtx.name), 'function');
|
|
107
107
|
}
|
|
108
108
|
// variable use: only plain symbols (not argument names, `...`, or empty)
|
|
109
|
-
if (
|
|
109
|
+
if (vertex_1.UseVertex.is(vtx) && config.checkVariables) {
|
|
110
110
|
const node = element.node;
|
|
111
111
|
if (node.type !== type_1.RType.Symbol || node.lexeme === '...' || node.lexeme === undefined) {
|
|
112
112
|
return undefined;
|
|
@@ -123,7 +123,7 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
123
123
|
/** shared resolution logic for a name used either as a function call or a variable */
|
|
124
124
|
function check(element, id, name, namespace, kind) {
|
|
125
125
|
// resolved by flowR itself (local/param/builtin) - never a candidate, so not counted as suppressed
|
|
126
|
-
if (kind === 'variable' ? (0, undefined_symbol_util_1.useResolvesToDefinitionOrBuiltin)(graph, id) : (
|
|
126
|
+
if (kind === 'variable' ? (0, undefined_symbol_util_1.useResolvesToDefinitionOrBuiltin)(graph, id) : (df_helper_1.Dataflow.origin(graph, id)?.length ?? 0) > 0) {
|
|
127
127
|
return undefined;
|
|
128
128
|
}
|
|
129
129
|
// a bare call to a registered flowR builtin whose dataflow origin was rewritten away from its
|
|
@@ -19,6 +19,7 @@ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
|
19
19
|
const default_builtin_config_1 = require("../../dataflow/environments/default-builtin-config");
|
|
20
20
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
21
21
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
22
|
+
const graph_1 = require("../../dataflow/graph/graph");
|
|
22
23
|
/**
|
|
23
24
|
* The dots parameter is a special parameter and must never be reported as an unused definition.
|
|
24
25
|
*/
|
|
@@ -154,7 +155,7 @@ function buildQuickFix(variable, dfg, ast) {
|
|
|
154
155
|
}
|
|
155
156
|
const definedBys = getDefinitionArguments(variable.info.id, dfg);
|
|
156
157
|
const hasImportantArgs = definedBys.some(d => dfg.unknownSideEffects.has(d))
|
|
157
|
-
|| definedBys.flatMap(e => Array.from(dfg.outgoingEdges(e) ??
|
|
158
|
+
|| definedBys.flatMap(e => Array.from(dfg.outgoingEdges(e) ?? graph_1.NoEdges))
|
|
158
159
|
.some(([target, e]) => {
|
|
159
160
|
return edge_1.DfEdge.includesType(e, InterestingEdgesTargets) || dfg.unknownSideEffects.has(target);
|
|
160
161
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -16,49 +16,46 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"setup:dev": "npm ci && ts-node --transpile-only scripts/setup-dev.ts",
|
|
19
|
-
"main": "npm run build:bundle-flowr && node dist/src/cli/flowr.min.js",
|
|
20
19
|
"flowr": "npm run main --",
|
|
21
20
|
"flowr:dev": "npm run sync:sigdb && npm run gen:base-packages && npm run main-dev --",
|
|
21
|
+
"main": "npm run build:bundle-flowr && node dist/src/cli/flowr.min.js",
|
|
22
22
|
"main-dev": "node -r ts-node/register --watch src/cli/flowr.ts",
|
|
23
|
-
"publish-library": "cp .npmignore package.json README.md LICENSE dist/src/ && cd dist/src && npm publish --access public",
|
|
24
|
-
"release": "npx release-it --ci",
|
|
25
23
|
"slicer": "ts-node src/cli/slicer-app.ts",
|
|
24
|
+
"benchmark": "npm run build:dev && node dist/src/cli/benchmark-app.js",
|
|
26
25
|
"benchmark-helper": "ts-node src/cli/benchmark-helper-app.ts",
|
|
27
|
-
"benchmark": "npm run build-dev && node dist/src/cli/benchmark-app.js",
|
|
28
26
|
"summarizer": "ts-node src/cli/summarizer-app.ts",
|
|
29
|
-
"benchmark:test-counts": "ts-node --transpile-only scripts/test-label-counts.ts",
|
|
30
|
-
"benchmark:compact": "ts-node --transpile-only scripts/compact-benchmark-data.ts",
|
|
31
|
-
"export-quads": "ts-node src/cli/export-quads-app.ts",
|
|
32
|
-
"capabilities-markdown": "ts-node src/documentation/doc-capabilities.ts",
|
|
33
|
-
"wiki": "ts-node src/cli/wiki.ts",
|
|
34
|
-
"wiki:watch": "node -r ts-node/register --watch src/cli/wiki.ts --keep-alive",
|
|
35
27
|
"build": "npm run gen:base-packages && tsc --project . && npm run build:copy-data",
|
|
28
|
+
"build:dev": "npm run build && npm run build:copy-wasm",
|
|
29
|
+
"build:bundle-flowr": "npm run build && esbuild --bundle dist/src/cli/flowr.js --platform=node --tree-shaking=true --minify --external:clipboardy --target=node22 --outfile=dist/src/cli/flowr.min.js && npm run build:copy-wasm",
|
|
30
|
+
"build:copy-data": "ts-node --transpile-only scripts/sigdb-copy.ts",
|
|
31
|
+
"build:copy-wasm": "mkdir -p dist/node_modules/@davisvaughan/tree-sitter-r/ && mkdir -p dist/node_modules/web-tree-sitter && cp node_modules/@davisvaughan/tree-sitter-r/tree-sitter-r.wasm dist/node_modules/@davisvaughan/tree-sitter-r/ && cp node_modules/web-tree-sitter/tree-sitter.wasm dist/node_modules/web-tree-sitter/",
|
|
36
32
|
"gen:base-packages": "ts-node --transpile-only scripts/gen-base-packages.ts",
|
|
37
|
-
"
|
|
38
|
-
"check:generic-labels": "ts-node --transpile-only scripts/check-generic-labels.ts",
|
|
33
|
+
"gen:landing": "ts-node --transpile-only scripts/gen-landing.ts && ts-node --transpile-only scripts/gen-sigdb-index.ts && ts-node --transpile-only scripts/gen-playground.ts",
|
|
39
34
|
"gen:sigdb-remote": "ts-node --transpile-only scripts/sigdb-remote.ts",
|
|
35
|
+
"sync:sigdb": "ts-node --transpile-only scripts/sigdb-sync.ts",
|
|
40
36
|
"publish:sigdb": "ts-node scripts/publish-sigdb.ts",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"build:copy-wasm": "mkdir -p dist/node_modules/@davisvaughan/tree-sitter-r/ && mkdir -p dist/node_modules/web-tree-sitter && cp node_modules/@davisvaughan/tree-sitter-r/tree-sitter-r.wasm dist/node_modules/@davisvaughan/tree-sitter-r/ && cp node_modules/web-tree-sitter/tree-sitter.wasm dist/node_modules/web-tree-sitter/",
|
|
37
|
+
"wiki": "ts-node src/cli/wiki.ts",
|
|
38
|
+
"wiki:watch": "node -r ts-node/register --watch src/cli/wiki.ts --keep-alive",
|
|
39
|
+
"doc": "node --max-old-space-size=8192 node_modules/typedoc/dist/cli.js",
|
|
45
40
|
"typecheck": "tsc --noEmit --project .",
|
|
46
|
-
"lint-local": "npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint-local --rule \"no-warning-comments: off\"",
|
|
47
41
|
"lint": "npm run license-compat -- --summary && npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint",
|
|
42
|
+
"lint-local": "npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint-local --rule \"no-warning-comments: off\"",
|
|
48
43
|
"license-compat": "license-checker-rseidelsohn --onlyAllow 'MIT;MPL-2.0;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;BlueOak-1.0.0;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD' --clarificationsFile license-clarifications.json",
|
|
49
|
-
"
|
|
44
|
+
"check:generic-labels": "ts-node --transpile-only scripts/check-generic-labels.ts",
|
|
45
|
+
"detect-circular-deps": "npx madge --extensions ts,tsx --circular src/",
|
|
46
|
+
"checkup": "ts-node scripts/checkup-parallel.ts",
|
|
50
47
|
"test": "vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
|
|
48
|
+
"test:full": "npm run test:coverage -- --no-watch --reporter=default --reporter=json --outputFile.json=coverage/flowr-test-results.json -- --make-summary --test-installation",
|
|
49
|
+
"test:coverage": "npm run test -- --coverage",
|
|
51
50
|
"test:verbose": "FLOWR_VERBOSE=true vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
|
|
52
51
|
"test:system": "vitest --dir test/system-tests --config test/system-tests/vitest.config.mts",
|
|
53
|
-
"test:coverage": "npm run test -- --coverage",
|
|
54
|
-
"test:full": "npm run test-full",
|
|
55
52
|
"test:bench": "vitest bench --config test/vitest.config.mts",
|
|
56
|
-
"test
|
|
57
|
-
"performance-test": "func() { cd test/performance/ && bash run-all-suites.sh \"$@\"; }; func",
|
|
58
|
-
"test:performance": "npm run performance-test --",
|
|
53
|
+
"test:performance": "func() { cd test/performance/ && bash run-all-suites.sh \"$@\"; }; func",
|
|
59
54
|
"test:docker": "func() { b() { docker build ${1:+--network=$1} -t flowr-docker-test -f \"$2\" .; }; r() { docker run --rm ${1:+--network=$1} flowr-docker-test --version; }; for df in scripts/Dockerfile scripts/Dockerfile-NoR; do echo \"=== building $df ===\"; b '' \"$df\" || { echo '(retrying with --network=host: bridge networking unavailable)'; b host \"$df\"; } || return 1; echo \"=== smoke-testing $df ===\"; r '' || r host || return 1; done; }; func",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
55
|
+
"benchmark:test-counts": "ts-node --transpile-only scripts/test-label-counts.ts",
|
|
56
|
+
"benchmark:compact": "ts-node --transpile-only scripts/compact-benchmark-data.ts",
|
|
57
|
+
"publish-library": "cp .npmignore package.json README.md LICENSE dist/src/ && cd dist/src && npm publish --access public",
|
|
58
|
+
"release": "npx release-it --ci"
|
|
62
59
|
},
|
|
63
60
|
"keywords": [
|
|
64
61
|
"static code analysis",
|
|
@@ -161,9 +158,9 @@
|
|
|
161
158
|
"hooks": {
|
|
162
159
|
"before:init": [
|
|
163
160
|
"npm run lint",
|
|
164
|
-
"npm run test
|
|
161
|
+
"npm run test:full"
|
|
165
162
|
],
|
|
166
|
-
"after:bump": "npm run build
|
|
163
|
+
"after:bump": "npm run build:dev",
|
|
167
164
|
"after:git:release": "echo After git push, before github release",
|
|
168
165
|
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
|
|
169
166
|
},
|
|
@@ -186,11 +183,11 @@
|
|
|
186
183
|
}
|
|
187
184
|
},
|
|
188
185
|
"devDependencies": {
|
|
186
|
+
"@codemirror/legacy-modes": "^6.5.3",
|
|
189
187
|
"@commitlint/cli": "^20.5.0",
|
|
190
188
|
"@commitlint/config-angular": "^20.5.0",
|
|
191
|
-
"@eagleoutice/eslint-config-flowr": "^2.
|
|
192
|
-
"@j-ulrich/release-it-regex-bumper": "^5.
|
|
193
|
-
"@stylistic/eslint-plugin": "^5.10.0",
|
|
189
|
+
"@eagleoutice/eslint-config-flowr": "^2.1.1",
|
|
190
|
+
"@j-ulrich/release-it-regex-bumper": "^5.6.0",
|
|
194
191
|
"@types/command-line-args": "^5.2.3",
|
|
195
192
|
"@types/command-line-usage": "^5.0.4",
|
|
196
193
|
"@types/commonmark": "^0.27.10",
|
|
@@ -198,23 +195,17 @@
|
|
|
198
195
|
"@types/n-readlines": "^1.0.6",
|
|
199
196
|
"@types/n3": "^1.26.0",
|
|
200
197
|
"@types/object-hash": "^3.0.6",
|
|
201
|
-
"@types/object-path": "^0.11.4",
|
|
202
198
|
"@types/seedrandom": "^3.0.8",
|
|
203
199
|
"@types/semver": "^7.7.0",
|
|
204
200
|
"@types/tmp": "^0.2.6",
|
|
205
201
|
"@types/ws": "^8.18.1",
|
|
206
|
-
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
207
|
-
"@typescript-eslint/parser": "^8.65.0",
|
|
208
202
|
"@vitest/coverage-v8": "^4.1.8",
|
|
203
|
+
"codemirror": "^6.0.2",
|
|
209
204
|
"esbuild": "^0.28.1",
|
|
210
205
|
"eslint": "^10.8.0",
|
|
211
|
-
"eslint-plugin-check-file": "^3.3.2",
|
|
212
|
-
"eslint-plugin-import-x": "^4.17.1",
|
|
213
|
-
"eslint-plugin-jsdoc": "^62.9.0",
|
|
214
|
-
"eslint-plugin-tsdoc": "^0.5.2",
|
|
215
|
-
"eslint-plugin-unused-imports": "^4.4.1",
|
|
216
206
|
"license-checker-rseidelsohn": "^4.4.2",
|
|
217
|
-
"release-it": "^
|
|
207
|
+
"release-it": "^21.0.2",
|
|
208
|
+
"seedrandom": "^3.0.5",
|
|
218
209
|
"ts-node": "^10.9.2",
|
|
219
210
|
"typedoc": "^0.28.17",
|
|
220
211
|
"typedoc-plugin-missing-exports": "^4.1.2",
|
|
@@ -225,34 +216,24 @@
|
|
|
225
216
|
"dependencies": {
|
|
226
217
|
"@davisvaughan/tree-sitter-r": "^1.2.0",
|
|
227
218
|
"@jupyterlab/nbformat": "^4.5.4",
|
|
228
|
-
"@xmldom/xmldom": "^0.9.7",
|
|
229
219
|
"bzip2": "^0.1.1",
|
|
230
|
-
"clipboardy": "^4.0.0",
|
|
231
220
|
"command-line-args": "^6.0.1",
|
|
232
221
|
"command-line-usage": "^7.0.3",
|
|
233
222
|
"commonmark": "^0.31.2",
|
|
234
|
-
"dagre": "^0.8.5",
|
|
235
|
-
"diff": "^8.0.3",
|
|
236
223
|
"gray-matter": "^4.0.3",
|
|
237
224
|
"ignore": "^5.3.2",
|
|
238
225
|
"joi": "^18.0.1",
|
|
239
226
|
"lz-string": "^1.5.0",
|
|
240
227
|
"n-readlines": "^3.4.1",
|
|
241
|
-
"n3": "^1.26.0",
|
|
242
228
|
"object-hash": "^3.0.0",
|
|
243
|
-
"object-path": "^0.11.8",
|
|
244
229
|
"object-sizeof": "^2.6.5",
|
|
245
|
-
"rotating-file-stream": "^3.2.8",
|
|
246
|
-
"seedrandom": "^3.0.5",
|
|
247
230
|
"semver": "^7.7.4",
|
|
248
231
|
"smol-toml": "^1.7.0",
|
|
249
|
-
"tar": "^7.4.3",
|
|
250
232
|
"tmp": "^0.2.3",
|
|
251
233
|
"ts-essentials": "^10.1.1",
|
|
252
234
|
"tslog": "^4.10.2",
|
|
253
235
|
"web-tree-sitter": "^0.24.7",
|
|
254
|
-
"ws": "^8.18.0"
|
|
255
|
-
"xpath-ts2": "^1.4.2"
|
|
236
|
+
"ws": "^8.18.0"
|
|
256
237
|
},
|
|
257
238
|
"allowScripts": {
|
|
258
239
|
"@davisvaughan/tree-sitter-r@1.2.0": true,
|
|
@@ -260,5 +241,11 @@
|
|
|
260
241
|
"esbuild@0.28.1": true,
|
|
261
242
|
"plantuml-pipe@1.6.0": true,
|
|
262
243
|
"unrs-resolver@1.12.2": true
|
|
244
|
+
},
|
|
245
|
+
"optionalDependencies": {
|
|
246
|
+
"clipboardy": "^4.0.0",
|
|
247
|
+
"dagre": "^0.8.5",
|
|
248
|
+
"n3": "^1.26.0",
|
|
249
|
+
"rotating-file-stream": "^3.2.8"
|
|
263
250
|
}
|
|
264
251
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
2
2
|
import type { IEnvironment, REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
3
3
|
import type { DeepReadonly } from 'ts-essentials';
|
|
4
|
+
import type { IdentifierDefinition } from '../../dataflow/environments/identifier';
|
|
5
|
+
import { Identifier } from '../../dataflow/environments/identifier';
|
|
6
|
+
import type { BuiltInIdentifierDefinition } from '../../dataflow/environments/built-in';
|
|
4
7
|
import type { Fingerprint } from '../../slicing/static/fingerprint';
|
|
5
8
|
/**
|
|
6
9
|
* Read-only interface to the {@link FlowrAnalyzerEnvironmentContext}.
|
|
@@ -10,6 +13,21 @@ export interface ReadOnlyFlowrAnalyzerEnvironmentContext {
|
|
|
10
13
|
* Get the built-in environment used during analysis.
|
|
11
14
|
*/
|
|
12
15
|
get builtInEnvironment(): DeepReadonly<IEnvironment>;
|
|
16
|
+
/**
|
|
17
|
+
* Every built-in definition flowR carries for `name`, matched by its plain name.
|
|
18
|
+
*/
|
|
19
|
+
builtInDefinitionsOf(name: Identifier): readonly IdentifierDefinition[];
|
|
20
|
+
/**
|
|
21
|
+
* The built-in function flowR defines for `name`, respecting its namespace: `dplyr::filter` picks
|
|
22
|
+
* flowR's `dplyr` definition rather than whatever else is registered under `filter`.
|
|
23
|
+
*/
|
|
24
|
+
builtInFunctionOf(name: Identifier): BuiltInIdentifierDefinition | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether flowR carries definitions of its own for package `pkg`, i.e. whether it knows what attaching
|
|
27
|
+
* that package brings even when no signature database resolves it. Built once and kept, as the built-in
|
|
28
|
+
* environment does not change during an analysis.
|
|
29
|
+
*/
|
|
30
|
+
knowsPackage(pkg: string): boolean;
|
|
13
31
|
/**
|
|
14
32
|
* Get the empty built-in environment used during analysis.
|
|
15
33
|
* The empty built-in environment only contains primitive definitions.
|
|
@@ -40,9 +58,14 @@ export declare class FlowrAnalyzerEnvironmentContext implements ReadOnlyFlowrAna
|
|
|
40
58
|
private readonly builtInEnv;
|
|
41
59
|
private readonly emptyBuiltInEnv;
|
|
42
60
|
private builtInEnvFingerprint;
|
|
61
|
+
/** the packages {@link knowsPackage} answers for, collected from the built-in environment on first use */
|
|
62
|
+
private knownPackages;
|
|
43
63
|
constructor(ctx: FlowrAnalyzerContext);
|
|
44
64
|
get builtInEnvironment(): DeepReadonly<IEnvironment>;
|
|
45
65
|
get emptyBuiltInEnvironment(): DeepReadonly<IEnvironment>;
|
|
66
|
+
builtInDefinitionsOf(name: Identifier): readonly IdentifierDefinition[];
|
|
67
|
+
knowsPackage(pkg: string): boolean;
|
|
68
|
+
builtInFunctionOf(name: Identifier): BuiltInIdentifierDefinition | undefined;
|
|
46
69
|
makeCleanEnv(): REnvironmentInformation;
|
|
47
70
|
getCleanEnvFingerprint(): Fingerprint;
|
|
48
71
|
makeCleanEnvWithEmptyBuiltIns(): REnvironmentInformation;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FlowrAnalyzerEnvironmentContext = void 0;
|
|
4
4
|
const environment_1 = require("../../dataflow/environments/environment");
|
|
5
5
|
const built_in_config_1 = require("../../dataflow/environments/built-in-config");
|
|
6
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
6
7
|
const fingerprint_1 = require("../../slicing/static/fingerprint");
|
|
7
8
|
/**
|
|
8
9
|
* Provides the built-in environment, created from the {@link FlowrAnalyzerContext} configuration.
|
|
@@ -12,6 +13,8 @@ class FlowrAnalyzerEnvironmentContext {
|
|
|
12
13
|
builtInEnv;
|
|
13
14
|
emptyBuiltInEnv;
|
|
14
15
|
builtInEnvFingerprint;
|
|
16
|
+
/** the packages {@link knowsPackage} answers for, collected from the built-in environment on first use */
|
|
17
|
+
knownPackages;
|
|
15
18
|
constructor(ctx) {
|
|
16
19
|
const builtInsConfig = ctx.config.semantics.environment.overwriteBuiltIns;
|
|
17
20
|
const builtIns = (0, built_in_config_1.getBuiltInDefinitions)(builtInsConfig.definitions, builtInsConfig.loadDefaults);
|
|
@@ -26,6 +29,28 @@ class FlowrAnalyzerEnvironmentContext {
|
|
|
26
29
|
get emptyBuiltInEnvironment() {
|
|
27
30
|
return this.emptyBuiltInEnv;
|
|
28
31
|
}
|
|
32
|
+
builtInDefinitionsOf(name) {
|
|
33
|
+
return this.builtInEnv.memory.get(identifier_1.Identifier.getName(name)) ?? [];
|
|
34
|
+
}
|
|
35
|
+
knowsPackage(pkg) {
|
|
36
|
+
if (this.knownPackages === undefined) {
|
|
37
|
+
this.knownPackages = new Set();
|
|
38
|
+
for (const [, definitions] of this.builtInEnv.memory) {
|
|
39
|
+
for (const definition of definitions) {
|
|
40
|
+
const namespace = definition.name === undefined ? undefined : identifier_1.Identifier.getNamespace(definition.name);
|
|
41
|
+
if (namespace !== undefined) {
|
|
42
|
+
this.knownPackages.add(String(namespace));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return this.knownPackages.has(pkg);
|
|
48
|
+
}
|
|
49
|
+
builtInFunctionOf(name) {
|
|
50
|
+
const namespace = identifier_1.Identifier.getNamespace(name);
|
|
51
|
+
return this.builtInDefinitionsOf(name).find((d) => d.type === identifier_1.ReferenceType.BuiltInFunction && typeof d.processor === 'function'
|
|
52
|
+
&& (namespace === undefined || (d.name !== undefined && identifier_1.Identifier.getNamespace(d.name) === namespace)));
|
|
53
|
+
}
|
|
29
54
|
makeCleanEnv() {
|
|
30
55
|
return {
|
|
31
56
|
current: new environment_1.Environment(this.builtInEnv).asGlobal(),
|
|
@@ -204,7 +204,7 @@ export interface VersionSpaceOptions {
|
|
|
204
204
|
/** constraint sources to skip entirely: neither filtered on nor reported */
|
|
205
205
|
readonly disabled?: ReadonlySet<ConstraintSource>;
|
|
206
206
|
}
|
|
207
|
-
/** a target's sigdb package key, merged source and memoized signature resolver */
|
|
207
|
+
/** a target's sigdb package key, merged source, and memoized signature resolver */
|
|
208
208
|
interface PackageResolution {
|
|
209
209
|
readonly key: string;
|
|
210
210
|
readonly src: PackageSignatureSource | undefined;
|
|
@@ -219,7 +219,7 @@ interface PackageResolution {
|
|
|
219
219
|
/**
|
|
220
220
|
* The version space of one analysis: the surviving versions of each dependency and the transitive constraints
|
|
221
221
|
* refined to a fixpoint. Holding the shared inputs here keeps the passes to a handful of arguments and lets each
|
|
222
|
-
* package's sigdb key, source and decoded signatures be resolved once. The passes revisit the same versions
|
|
222
|
+
* package's sigdb key, source, and decoded signatures be resolved once. The passes revisit the same versions
|
|
223
223
|
* repeatedly, so that memoization is what makes the fixpoint affordable.
|
|
224
224
|
*/
|
|
225
225
|
export declare class VersionSpace {
|
|
@@ -231,7 +231,7 @@ export declare class VersionSpace {
|
|
|
231
231
|
readonly disabled: ReadonlySet<ConstraintSource>;
|
|
232
232
|
private readonly resolved;
|
|
233
233
|
constructor({ deps, usage, cutoff, rVersion, disabled }: VersionSpaceOptions);
|
|
234
|
-
/** the sigdb package, source and signature resolver of a target, resolved once */
|
|
234
|
+
/** the sigdb package, source, and signature resolver of a target, resolved once */
|
|
235
235
|
resolve(name: string): PackageResolution;
|
|
236
236
|
/** the versions of `name` surviving every constraint, see {@link survivingEntries} */
|
|
237
237
|
survivors(name: string, transitive: readonly TransitiveConstraint[], observe?: ConstraintObserver): SurvivingEntries;
|
|
@@ -36,7 +36,6 @@ const identifier_1 = require("../dataflow/environments/identifier");
|
|
|
36
36
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
37
37
|
const graph_1 = require("../dataflow/graph/graph");
|
|
38
38
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
39
|
-
const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
|
|
40
39
|
const r_base_packages_1 = require("../util/r-base-packages");
|
|
41
40
|
const undefined_symbol_util_1 = require("../linter/rules/undefined-symbol-util");
|
|
42
41
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -271,7 +270,7 @@ function collectOrphanUsage(graph, deps, usage, isKnown, options = {}) {
|
|
|
271
270
|
const name = identifier_1.Identifier.getName(vertex.name);
|
|
272
271
|
// a call bound to a real definition (local, parameter, closure, or import) *is* that definition, not a package
|
|
273
272
|
// export; only an unresolved or builtin-modeled call can be an orphan (flowR models e.g. `ggplot` as a builtin)
|
|
274
|
-
if (
|
|
273
|
+
if (df_helper_1.Dataflow.origin(graph, id)?.some(o => o.type === 2 /* OriginType.FunctionCallOrigin */) === true) {
|
|
275
274
|
continue;
|
|
276
275
|
}
|
|
277
276
|
// a bare name from a default-attached base package (or a base primitive) is defined without a library() call
|
|
@@ -530,7 +529,7 @@ function makeSignatureFilter(src, pkg, getFn, timeline, usage) {
|
|
|
530
529
|
/**
|
|
531
530
|
* The version space of one analysis: the surviving versions of each dependency and the transitive constraints
|
|
532
531
|
* refined to a fixpoint. Holding the shared inputs here keeps the passes to a handful of arguments and lets each
|
|
533
|
-
* package's sigdb key, source and decoded signatures be resolved once. The passes revisit the same versions
|
|
532
|
+
* package's sigdb key, source, and decoded signatures be resolved once. The passes revisit the same versions
|
|
534
533
|
* repeatedly, so that memoization is what makes the fixpoint affordable.
|
|
535
534
|
*/
|
|
536
535
|
class VersionSpace {
|
|
@@ -549,7 +548,7 @@ class VersionSpace {
|
|
|
549
548
|
this.rVersion = rVersion;
|
|
550
549
|
this.disabled = disabled;
|
|
551
550
|
}
|
|
552
|
-
/** the sigdb package, source and signature resolver of a target, resolved once */
|
|
551
|
+
/** the sigdb package, source, and signature resolver of a target, resolved once */
|
|
553
552
|
resolve(name) {
|
|
554
553
|
let entry = this.resolved.get(name);
|
|
555
554
|
if (entry === undefined) {
|