@eagleoutice/flowr 2.11.1 → 2.12.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 +187 -257
- package/abstract-interpretation/absint-visitor.d.ts +1 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +3 -1
- package/benchmark/summarizer/second-phase/graph.js +5 -0
- package/cli/common/options.d.ts +8 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +8 -0
- package/cli/repl/commands/repl-commands.d.ts +1 -0
- package/cli/repl/commands/repl-commands.js +66 -15
- package/cli/repl/commands/repl-dataflow.js +48 -4
- package/cli/repl/commands/repl-main.d.ts +2 -0
- package/cli/repl/commands/repl-main.js +5 -0
- package/cli/repl/commands/repl-query.d.ts +4 -1
- package/cli/repl/commands/repl-query.js +72 -22
- package/cli/repl/commands/repl-signature.d.ts +7 -0
- package/cli/repl/commands/repl-signature.js +119 -0
- package/cli/repl/core.d.ts +8 -1
- package/cli/repl/core.js +46 -6
- package/cli/repl/ghost-hint.d.ts +37 -0
- package/cli/repl/ghost-hint.js +72 -0
- package/cli/repl/parser/slice-query-parser.d.ts +11 -1
- package/cli/repl/parser/slice-query-parser.js +45 -16
- package/cli/repl/print-version.d.ts +2 -4
- package/cli/repl/print-version.js +41 -23
- package/cli/repl/server/connection.js +19 -17
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +3 -3
- package/cli/wiki.d.ts +2 -2
- package/cli/wiki.js +2 -2
- package/config.d.ts +63 -2
- package/config.js +64 -8
- package/control-flow/cfg-dead-code.js +0 -1
- package/control-flow/control-flow-graph.js +6 -6
- package/control-flow/diff-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/print/slice-diff-ansi.js +8 -8
- package/core/steps/all/core/20-dataflow.d.ts +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
- package/core/steps/pipeline/default-pipelines.d.ts +20 -16
- package/data/r-base-packages.generated.d.ts +44 -0
- package/data/r-base-packages.generated.js +32 -0
- package/data/r-base-primitives.generated.d.ts +1 -0
- package/data/r-base-primitives.generated.js +15 -0
- package/data/sigdb/sigdb.remote.json +112 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in.d.ts +14 -4
- package/dataflow/environments/built-in.js +13 -2
- package/dataflow/environments/data-masking-functions.d.ts +12 -0
- package/dataflow/environments/data-masking-functions.js +46 -0
- package/dataflow/environments/default-builtin-config.d.ts +72 -19
- package/dataflow/environments/default-builtin-config.js +48 -14
- package/dataflow/environments/diff.js +1 -1
- package/dataflow/environments/environment.js +1 -2
- package/dataflow/environments/identifier.d.ts +11 -4
- package/dataflow/environments/identifier.js +28 -10
- package/dataflow/environments/resolve-by-name.js +16 -2
- package/dataflow/extractor.js +6 -3
- package/dataflow/graph/call-graph.d.ts +2 -2
- package/dataflow/graph/df-helper.d.ts +4 -4
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/edge.d.ts +3 -3
- package/dataflow/graph/edge.js +3 -3
- package/dataflow/graph/graph-helper.d.ts +2 -2
- package/dataflow/internal/linker.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
- package/dataflow/internal/process/functions/call/common.js +8 -1
- package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
- package/dataflow/internal/process/functions/process-argument.js +12 -1
- package/dataflow/internal/process/process-named-call.d.ts +18 -1
- package/dataflow/internal/process/process-named-call.js +94 -0
- package/dataflow/processor.d.ts +18 -0
- package/documentation/data/faq/faqs.js +5 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-util/doc-cli-option.d.ts +10 -0
- package/documentation/doc-util/doc-cli-option.js +23 -0
- package/documentation/doc-util/doc-dfg.js +2 -1
- package/documentation/doc-util/doc-query.d.ts +9 -3
- package/documentation/doc-util/doc-query.js +9 -4
- package/documentation/wiki-dataflow-graph.js +8 -5
- package/documentation/wiki-interface.js +4 -2
- package/documentation/wiki-linter.js +1 -1
- package/documentation/wiki-linting-and-testing.js +4 -1
- package/documentation/wiki-mk/doc-context.d.ts +14 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-mk/doc-maker.js +3 -1
- package/documentation/wiki-query.js +36 -15
- package/documentation/wiki-setup.js +10 -7
- package/documentation/wiki-signature-database.d.ts +16 -0
- package/documentation/wiki-signature-database.js +293 -0
- package/linter/linter-format.d.ts +7 -0
- package/linter/linter-rules.d.ts +10 -9
- package/linter/rules/naming-convention.d.ts +1 -0
- package/linter/rules/naming-convention.js +2 -0
- package/linter/rules/no-leaked-credentials.js +1 -2
- package/linter/rules/roxygen-arguments.js +18 -5
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/undefined-symbol-util.d.ts +36 -0
- package/linter/rules/undefined-symbol-util.js +149 -0
- package/linter/rules/undefined-symbol.d.ts +58 -17
- package/linter/rules/undefined-symbol.js +143 -33
- package/linter/rules/unused-definition.d.ts +8 -1
- package/linter/rules/unused-definition.js +126 -1
- package/package.json +22 -10
- package/project/context/abstract-flowr-analyzer-context.js +7 -1
- package/project/context/flowr-analyzer-context.d.ts +8 -0
- package/project/context/flowr-analyzer-context.js +10 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
- package/project/context/flowr-analyzer-dependencies-context.js +51 -2
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-analyzer-files-context.js +2 -1
- package/project/context/flowr-analyzer-functions-context.js +1 -1
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/flowr-analyzer-builder.js +12 -2
- package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
- package/project/plugins/package-version-plugins/package.d.ts +5 -3
- package/project/plugins/package-version-plugins/package.js +27 -25
- package/project/plugins/plugin-registry.d.ts +3 -2
- package/project/plugins/plugin-registry.js +4 -2
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
- package/project/sigdb/build.d.ts +131 -0
- package/project/sigdb/build.js +628 -0
- package/project/sigdb/codec.d.ts +51 -0
- package/project/sigdb/codec.js +122 -0
- package/project/sigdb/decode.d.ts +58 -0
- package/project/sigdb/decode.js +129 -0
- package/project/sigdb/decompress.d.ts +44 -0
- package/project/sigdb/decompress.js +176 -0
- package/project/sigdb/hash.d.ts +9 -0
- package/project/sigdb/hash.js +54 -0
- package/project/sigdb/index-format.d.ts +40 -0
- package/project/sigdb/index-format.js +28 -0
- package/project/sigdb/manifest.d.ts +68 -0
- package/project/sigdb/manifest.js +146 -0
- package/project/sigdb/reader.d.ts +250 -0
- package/project/sigdb/reader.js +692 -0
- package/project/sigdb/schema.d.ts +196 -0
- package/project/sigdb/schema.js +33 -0
- package/project/sigdb/sigdb-download.d.ts +65 -0
- package/project/sigdb/sigdb-download.js +237 -0
- package/project/sigdb/signature-match.d.ts +26 -0
- package/project/sigdb/signature-match.js +40 -0
- package/project/sigdb/version.d.ts +20 -0
- package/project/sigdb/version.js +55 -0
- package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
- package/queries/catalog/absint-query/absint-query-executor.js +63 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
- package/queries/catalog/absint-query/absint-query-format.js +102 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
- package/queries/catalog/config-query/config-query-format.d.ts +3 -1
- package/queries/catalog/config-query/config-query-format.js +68 -9
- package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +6 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
- package/queries/catalog/linter-query/linter-query-format.js +40 -8
- package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
- package/queries/catalog/project-query/project-query-executor.js +96 -4
- package/queries/catalog/project-query/project-query-format.d.ts +44 -0
- package/queries/catalog/project-query/project-query-format.js +33 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
- package/queries/catalog/signature-query/signature-query-executor.js +461 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
- package/queries/catalog/signature-query/signature-query-format.js +76 -0
- package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
- package/queries/catalog/signature-query/signature-query-render.js +155 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
- package/queries/query-print.js +5 -0
- package/queries/query.d.ts +15 -5
- package/queries/query.js +7 -4
- package/r-bridge/init.js +5 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
- package/r-bridge/parser.d.ts +2 -0
- package/r-bridge/retriever.js +4 -1
- package/r-bridge/roxygen2/documentation-provider.js +2 -1
- package/r-bridge/shell.d.ts +5 -0
- package/r-bridge/shell.js +17 -1
- package/reconstruct/inline/source-inline-map.d.ts +48 -0
- package/reconstruct/inline/source-inline-map.js +94 -0
- package/reconstruct/reconstruct.d.ts +19 -2
- package/reconstruct/reconstruct.js +79 -16
- package/search/search-executor/search-generators.js +5 -22
- package/search/search-executor/search-transformer.js +10 -6
- package/slicing/criterion/parse.d.ts +28 -4
- package/slicing/criterion/parse.js +133 -18
- package/slicing/static/slice-call.d.ts +24 -1
- package/slicing/static/slice-call.js +90 -0
- package/slicing/static/static-slicer.d.ts +7 -0
- package/slicing/static/static-slicer.js +38 -3
- package/util/collections/arrays.d.ts +4 -5
- package/util/collections/arrays.js +7 -18
- package/util/hash.d.ts +14 -0
- package/util/hash.js +31 -0
- package/util/mermaid/dfg.d.ts +7 -2
- package/util/mermaid/dfg.js +53 -13
- package/util/r-base-packages.d.ts +19 -0
- package/util/r-base-packages.js +72 -0
- package/util/r-license.js +2 -10
- package/util/r-version.d.ts +45 -15
- package/util/r-version.js +97 -36
- package/util/range.d.ts +15 -0
- package/util/range.js +39 -0
- package/util/schema.d.ts +10 -0
- package/util/schema.js +22 -0
- package/util/text/ansi.d.ts +3 -0
- package/util/text/ansi.js +10 -0
- package/util/text/args.js +1 -2
- package/util/version.js +28 -8
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/documentation/wiki-package-database.d.ts +0 -9
- package/documentation/wiki-package-database.js +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
- package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
- package/project/plugins/package-version-plugins/pkgdb.js +0 -370
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
- package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isInstalledResourceFile = isInstalledResourceFile;
|
|
4
|
+
exports.useResolvesToDefinitionOrBuiltin = useResolvesToDefinitionOrBuiltin;
|
|
5
|
+
exports.isNonStandardEvaluated = isNonStandardEvaluated;
|
|
6
|
+
exports.isInSubscript = isInSubscript;
|
|
7
|
+
exports.collectScopeDefinedNames = collectScopeDefinedNames;
|
|
8
|
+
exports.isDefinedInEnclosingScope = isDefinedInEnclosingScope;
|
|
9
|
+
const edge_1 = require("../../dataflow/graph/edge");
|
|
10
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
11
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
12
|
+
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
13
|
+
/**
|
|
14
|
+
* Path heuristic for an R package `inst/` resource (installed verbatim, not namespace source). Fallback for
|
|
15
|
+
* the authoritative `FileRole.Install`, covering requests that bypass the file-role plugins.
|
|
16
|
+
*/
|
|
17
|
+
function isInstalledResourceFile(file) {
|
|
18
|
+
return file !== undefined && /(^|[\\/])inst[\\/]/.test(file);
|
|
19
|
+
}
|
|
20
|
+
const ResolveEdges = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the variable use `id` resolves to a local definition, a parameter, or a built-in (function or
|
|
23
|
+
* constant such as `T`, `pi`). Broader than `getOriginInDfg`, which misses built-in constants.
|
|
24
|
+
*/
|
|
25
|
+
function useResolvesToDefinitionOrBuiltin(graph, id) {
|
|
26
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? []) {
|
|
27
|
+
if (edge_1.DfEdge.doesNotIncludeType(edge, ResolveEdges) || edge_1.DfEdge.includesType(edge, edge_1.EdgeType.NonStandardEvaluation)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (node_id_1.NodeId.isBuiltIn(target)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const targetVtx = graph.getVertex(target);
|
|
34
|
+
if (targetVtx?.tag === vertex_1.VertexType.VariableDefinition || targetVtx?.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/** Whether any edge incident to `id` marks it as non-standard-evaluated (quoted), e.g. `quote`/`substitute`. */
|
|
41
|
+
function isNonStandardEvaluated(graph, id) {
|
|
42
|
+
const nse = (edge) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.NonStandardEvaluation);
|
|
43
|
+
return (graph.outgoingEdges(id)?.values().some(nse) ?? false) || (graph.ingoingEdges(id)?.values().some(nse) ?? false);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Whether the use `id` sits inside a `[`/`[[` subscript (not the accessed object). `data.table`'s
|
|
47
|
+
* `DT[i, j, by]` masks the subscript symbols as columns, but flowR cannot tell this apart from ordinary
|
|
48
|
+
* indexing (`x[i]`), so the rule suppresses subscript symbols by default. Stops at the enclosing function.
|
|
49
|
+
*/
|
|
50
|
+
function isInSubscript(graph, id) {
|
|
51
|
+
const idMap = graph.idMap;
|
|
52
|
+
if (idMap === undefined) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
let childId = id;
|
|
56
|
+
let parentId = idMap.get(id)?.info.parent;
|
|
57
|
+
for (let guard = 0; parentId !== undefined && guard < 64; guard++) {
|
|
58
|
+
const parent = idMap.get(parentId);
|
|
59
|
+
if (parent === undefined || parent.type === type_1.RType.FunctionDefinition) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (parent.type === type_1.RType.Access && (parent.operator === '[' || parent.operator === '[[') && parent.accessed.info.id !== childId) {
|
|
63
|
+
return true; // reached from a subscript, not the accessed object
|
|
64
|
+
}
|
|
65
|
+
childId = parentId;
|
|
66
|
+
parentId = parent.info.parent;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
/** AST nodes that make their children conditionally executed within their scope. */
|
|
71
|
+
const ConditionalNodeTypes = new Set([type_1.RType.IfThenElse, type_1.RType.ForLoop, type_1.RType.WhileLoop, type_1.RType.RepeatLoop]);
|
|
72
|
+
/**
|
|
73
|
+
* Walk from `startParent` up to the nearest enclosing {@link RType.FunctionDefinition} (or the top level),
|
|
74
|
+
* reporting that scope and whether the walk crossed no `if`/loop block - so a binding at the origin is
|
|
75
|
+
* guaranteed to execute whenever its scope runs. (`cds` is unsuitable: guard clauses like `if(...) stop()`
|
|
76
|
+
* add a control dependency to otherwise-unconditional sibling statements.)
|
|
77
|
+
*/
|
|
78
|
+
function enclosingScope(idMap, startParent) {
|
|
79
|
+
let cur = startParent;
|
|
80
|
+
let unconditional = true;
|
|
81
|
+
for (let guard = 0; cur !== undefined && guard < 256; guard++) {
|
|
82
|
+
const node = idMap.get(cur);
|
|
83
|
+
if (node === undefined) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
if (node.type === type_1.RType.FunctionDefinition) {
|
|
87
|
+
return { scope: cur, unconditional };
|
|
88
|
+
}
|
|
89
|
+
if (ConditionalNodeTypes.has(node.type)) {
|
|
90
|
+
unconditional = false;
|
|
91
|
+
}
|
|
92
|
+
cur = node.info.parent;
|
|
93
|
+
}
|
|
94
|
+
return { scope: 'top', unconditional };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Per scope, the names it binds unconditionally. flowR's static resolution does not always link a use in a
|
|
98
|
+
* nested function to a binding introduced later in an enclosing scope; the rule consults this as a fallback.
|
|
99
|
+
* Only unconditional bindings are recorded: one assigned solely inside an `if`/loop is not guaranteed to
|
|
100
|
+
* exist, so suppressing an unresolved use of it would hide a real possibly-undefined access.
|
|
101
|
+
*/
|
|
102
|
+
function collectScopeDefinedNames(graph) {
|
|
103
|
+
const idMap = graph.idMap;
|
|
104
|
+
const byScope = new Map();
|
|
105
|
+
if (idMap === undefined) {
|
|
106
|
+
return byScope;
|
|
107
|
+
}
|
|
108
|
+
for (const [id, vtx] of graph.vertices(true)) {
|
|
109
|
+
if (vtx.tag !== vertex_1.VertexType.VariableDefinition) {
|
|
110
|
+
continue; // function bindings/params surface as variable definitions of their name symbol
|
|
111
|
+
}
|
|
112
|
+
const name = idMap.get(id)?.lexeme;
|
|
113
|
+
if (name === undefined) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const { scope, unconditional } = enclosingScope(idMap, idMap.get(id)?.info.parent);
|
|
117
|
+
if (!unconditional) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
(byScope.get(scope) ?? byScope.set(scope, new Set()).get(scope)).add(name);
|
|
121
|
+
}
|
|
122
|
+
return byScope;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether `name` is bound in the scope of `useId` or an enclosing scope (up to the top level), per
|
|
126
|
+
* {@link collectScopeDefinedNames}. Suppresses forward-referenced closure variables flowR did not link.
|
|
127
|
+
*/
|
|
128
|
+
function isDefinedInEnclosingScope(graph, defined, useId, name) {
|
|
129
|
+
const idMap = graph.idMap;
|
|
130
|
+
if (idMap === undefined) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (defined.get('top')?.has(name)) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
let cur = idMap.get(useId)?.info.parent;
|
|
137
|
+
for (let guard = 0; cur !== undefined && guard < 256; guard++) {
|
|
138
|
+
const node = idMap.get(cur);
|
|
139
|
+
if (node === undefined) {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (node.type === type_1.RType.FunctionDefinition && defined.get(cur)?.has(name)) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
cur = node.info.parent;
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=undefined-symbol-util.js.map
|
|
@@ -1,28 +1,65 @@
|
|
|
1
1
|
import type { MergeableRecord } from '../../util/objects';
|
|
2
|
-
import
|
|
2
|
+
import type { FlowrSearchElement } from '../../search/flowr-search';
|
|
3
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
3
5
|
import { LintingRuleTag } from '../linter-tags';
|
|
6
|
+
/** whether the flagged symbol is used in a function-call position or as a plain variable */
|
|
7
|
+
export type UndefinedSymbolKind = 'function' | 'variable';
|
|
4
8
|
export interface UndefinedSymbolResult extends LintingResult {
|
|
5
|
-
/** the
|
|
9
|
+
/** the name that could not be resolved */
|
|
6
10
|
name: string;
|
|
11
|
+
/** whether the name is used as a function call or as a variable read */
|
|
12
|
+
kind: UndefinedSymbolKind;
|
|
13
|
+
/** packages that export this name - a hint that a `library()`/`::` might be missing (empty if none known) */
|
|
14
|
+
availableInPackages?: readonly string[];
|
|
15
|
+
/** an unresolved `library()` is in scope that could define this name; treat as low-confidence */
|
|
16
|
+
mayBeProvidedByUnresolvedLibrary?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface UndefinedSymbolConfig extends MergeableRecord {
|
|
19
|
+
/** flag names used in a function-call position that cannot be resolved (default `true`) */
|
|
20
|
+
checkFunctions: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* flag names used as a variable read that cannot be resolved (default `true`). Formulas and data-masking
|
|
23
|
+
* (dplyr/tidyr/ggplot, `subset`/`with`) are recognised via flowR's dataflow, so this is precise; residual
|
|
24
|
+
* false positives are possible in dynamic `eval`/`attach`.
|
|
25
|
+
*/
|
|
26
|
+
checkVariables: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* flag unresolved symbols used as `[`/`[[` subscripts (default `false`). Off by default to mute
|
|
29
|
+
* `data.table`'s `DT[i, j, by]` column masking, which flowR cannot distinguish from ordinary indexing.
|
|
30
|
+
*/
|
|
31
|
+
checkSubscripts: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Why unresolved candidates were suppressed instead of reported, kept in the metadata for auditability. */
|
|
34
|
+
export interface SuppressionCounts {
|
|
35
|
+
/** file below `inst/` (installed resource, not namespace source) */
|
|
36
|
+
installed: number;
|
|
37
|
+
/** exported by a package in scope: a loaded/DESCRIPTION package or a default-attached base package */
|
|
38
|
+
loadedPackage: number;
|
|
39
|
+
/** unconditionally bound in an enclosing scope that flowR's dataflow did not statically link */
|
|
40
|
+
enclosingScope: number;
|
|
41
|
+
/** consumed by non-standard evaluation (a quoting edge) */
|
|
42
|
+
nonStandardEval: number;
|
|
43
|
+
/** used as a `[`/`[[` subscript (muted `data.table`-style column masking) */
|
|
44
|
+
subscript: number;
|
|
7
45
|
}
|
|
8
|
-
export type UndefinedSymbolConfig = MergeableRecord;
|
|
9
46
|
export interface UndefinedSymbolMetadata extends MergeableRecord {
|
|
10
|
-
|
|
47
|
+
totalFunctionCalls: number;
|
|
48
|
+
totalVariableUses: number;
|
|
49
|
+
/** breakdown of unresolved candidates that were suppressed rather than reported */
|
|
50
|
+
suppressed: SuppressionCounts;
|
|
11
51
|
}
|
|
12
52
|
/**
|
|
13
|
-
* Flags calls
|
|
14
|
-
* package
|
|
15
|
-
*
|
|
53
|
+
* Flags function calls (`sd()`) and, opt-in, variable reads (`x`) that are neither defined locally, a
|
|
54
|
+
* builtin, nor exported by a package in scope - the DESCRIPTION/`library()` packages plus the default-attached
|
|
55
|
+
* base packages, all resolved from the `flowr-sigdb` database. To stay precise it consults flowR's dataflow:
|
|
56
|
+
* non-standard evaluation (quoting) is not reported, and an unloaded package that exports the name is offered
|
|
57
|
+
* as a hint. Over-approximative: NSE beyond what flowR models can still cause false positives.
|
|
16
58
|
*/
|
|
17
59
|
export declare const UNDEFINED_SYMBOL: {
|
|
18
|
-
readonly createSearch: (_config: UndefinedSymbolConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"],
|
|
19
|
-
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<
|
|
20
|
-
results:
|
|
21
|
-
certainty: LintingResultCertainty.Uncertain;
|
|
22
|
-
name: import("../../dataflow/environments/identifier").BrandedIdentifier;
|
|
23
|
-
involvedId: import("../../r-bridge/lang-4.x/ast/model/processing/node-id").NodeId;
|
|
24
|
-
loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
|
|
25
|
-
}[];
|
|
60
|
+
readonly createSearch: (_config: UndefinedSymbolConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | FlowrSearchElement<ParentInformation>[]>>>;
|
|
61
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, config: UndefinedSymbolConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
62
|
+
results: UndefinedSymbolResult[];
|
|
26
63
|
'.meta': UndefinedSymbolMetadata;
|
|
27
64
|
}>;
|
|
28
65
|
readonly prettyPrint: {
|
|
@@ -32,8 +69,12 @@ export declare const UNDEFINED_SYMBOL: {
|
|
|
32
69
|
readonly info: {
|
|
33
70
|
readonly name: "Undefined Symbol";
|
|
34
71
|
readonly certainty: LintingRuleCertainty.OverApproximative;
|
|
35
|
-
readonly description: "Flags
|
|
72
|
+
readonly description: "Flags functions and variables that are neither defined locally, a base R builtin, nor exported by a loaded package.";
|
|
36
73
|
readonly tags: readonly [LintingRuleTag.Bug, LintingRuleTag.Experimental];
|
|
37
|
-
readonly defaultConfig: {
|
|
74
|
+
readonly defaultConfig: {
|
|
75
|
+
readonly checkFunctions: true;
|
|
76
|
+
readonly checkVariables: true;
|
|
77
|
+
readonly checkSubscripts: false;
|
|
78
|
+
};
|
|
38
79
|
};
|
|
39
80
|
};
|
|
@@ -5,76 +5,186 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
5
5
|
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
6
6
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
7
7
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
8
|
+
const flowr_search_filters_1 = require("../../search/flowr-search-filters");
|
|
8
9
|
const assert_1 = require("../../util/assert");
|
|
9
10
|
const range_1 = require("../../util/range");
|
|
11
|
+
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
12
|
+
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
13
|
+
const r_base_primitives_generated_1 = require("../../data/r-base-primitives.generated");
|
|
10
14
|
const linter_format_1 = require("../linter-format");
|
|
11
15
|
const linter_tags_1 = require("../linter-tags");
|
|
16
|
+
const undefined_symbol_util_1 = require("./undefined-symbol-util");
|
|
12
17
|
/** calls that load a package; an unresolved one means we cannot enumerate all exports in scope */
|
|
13
18
|
const LibraryLoadFunctions = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'load_all', 'use', 'p_load']);
|
|
14
19
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* Packages a standard R session attaches by default (`getOption("defaultPackages")` plus `base`); their
|
|
21
|
+
* exports are in scope without an explicit `library()`. Non-attached base-priority packages (`tools`,
|
|
22
|
+
* `parallel`, `grid`, ...) still need loading and are flagged with a hint. Hardcoded for now; making this
|
|
23
|
+
* configurable (to respect `R_DEFAULT_PACKAGES`/`.Rprofile`) is left for later.
|
|
24
|
+
*/
|
|
25
|
+
const AttachedBasePackages = ['base', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods'];
|
|
26
|
+
/** upper bound on the number of packages named in a "did you forget to load it" hint */
|
|
27
|
+
const MaxHintPackages = 5;
|
|
28
|
+
/**
|
|
29
|
+
* Flags function calls (`sd()`) and, opt-in, variable reads (`x`) that are neither defined locally, a
|
|
30
|
+
* builtin, nor exported by a package in scope - the DESCRIPTION/`library()` packages plus the default-attached
|
|
31
|
+
* base packages, all resolved from the `flowr-sigdb` database. To stay precise it consults flowR's dataflow:
|
|
32
|
+
* non-standard evaluation (quoting) is not reported, and an unloaded package that exports the name is offered
|
|
33
|
+
* as a hint. Over-approximative: NSE beyond what flowR models can still cause false positives.
|
|
18
34
|
*/
|
|
19
35
|
exports.UNDEFINED_SYMBOL = {
|
|
20
|
-
createSearch: (_config) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall),
|
|
36
|
+
createSearch: (_config) => flowr_search_builder_1.Q.all().filter(flowr_search_filters_1.F.or(vertex_1.VertexType.FunctionCall, vertex_1.VertexType.Use)),
|
|
21
37
|
processSearchResult: async (elements, config, data) => {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
const graph = (await data.dataflow()).graph;
|
|
39
|
+
const ctx = data.inspectContext();
|
|
40
|
+
const deps = ctx.deps;
|
|
41
|
+
const meta = {
|
|
42
|
+
totalFunctionCalls: 0,
|
|
43
|
+
totalVariableUses: 0,
|
|
44
|
+
suppressed: { installed: 0, loadedPackage: 0, enclosingScope: 0, nonStandardEval: 0, subscript: 0 }
|
|
45
|
+
};
|
|
46
|
+
// `inst/` files are installed verbatim (resources, not namespace source); skip them. Key off the
|
|
47
|
+
// FileRole.Install role, with a path fallback for requests that bypass the file-role plugins.
|
|
48
|
+
const installedFiles = new Set(ctx.files.getFilesByRole(flowr_file_1.FileRole.Install).map(f => f.path()));
|
|
49
|
+
const isInstalledFile = (file) => file !== undefined && (installedFiles.has(file) || (0, undefined_symbol_util_1.isInstalledResourceFile)(file));
|
|
50
|
+
// a library() we could not resolve could export any of these symbols; we still report but flag the
|
|
51
|
+
// findings as low-confidence (`mayBeProvidedByUnresolvedLibrary`) so the severity can be lowered
|
|
27
52
|
const unknownIds = new Set();
|
|
28
|
-
for (const e of
|
|
53
|
+
for (const e of graph.unknownSideEffects) {
|
|
29
54
|
unknownIds.add(String(typeof e === 'object' ? e.id : e));
|
|
30
55
|
}
|
|
56
|
+
let unresolvedLibraryInScope = false;
|
|
31
57
|
if (unknownIds.size > 0) {
|
|
32
|
-
for (const [id, v] of
|
|
58
|
+
for (const [id, v] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
33
59
|
if (LibraryLoadFunctions.has(identifier_1.Identifier.getName(v.name)) && unknownIds.has(String(id))) {
|
|
34
|
-
|
|
60
|
+
unresolvedLibraryInScope = true;
|
|
61
|
+
break;
|
|
35
62
|
}
|
|
36
63
|
}
|
|
37
64
|
}
|
|
65
|
+
// scope-defined names, a fallback for closure variables flowR's dataflow did not statically link
|
|
66
|
+
const scopeDefined = (0, undefined_symbol_util_1.collectScopeDefinedNames)(graph);
|
|
67
|
+
// packages whose exports are in scope: DESCRIPTION/library() deps plus the default-attached base
|
|
68
|
+
// packages, each resolved (exports enriched) from the package database via getDependency
|
|
69
|
+
const loadedPackages = [
|
|
70
|
+
...deps.getDependencies().map(p => deps.getDependency(p.name) ?? p),
|
|
71
|
+
...AttachedBasePackages.map(n => deps.getDependency(n)).filter(assert_1.isNotUndefined)
|
|
72
|
+
];
|
|
73
|
+
// hint an unloaded package that exports `name` (e.g. `ggplot` -> `ggplot2`), from the package database
|
|
74
|
+
const attached = new Set(AttachedBasePackages);
|
|
75
|
+
const hintPackagesFor = (name) => deps.packagesExporting(name).filter(p => !attached.has(p)).slice(0, MaxHintPackages);
|
|
38
76
|
const results = elements.getElements().map(element => {
|
|
39
|
-
const
|
|
40
|
-
|
|
77
|
+
const id = element.node.info.id;
|
|
78
|
+
const vtx = graph.getVertex(id);
|
|
79
|
+
if (!vtx) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const inInstalledFile = isInstalledFile(element.node.info.file);
|
|
83
|
+
if ((0, vertex_1.isFunctionCallVertex)(vtx)) {
|
|
84
|
+
if (vtx.origin === 'unnamed' || !config.checkFunctions) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
meta.totalFunctionCalls++;
|
|
88
|
+
if (inInstalledFile) {
|
|
89
|
+
meta.suppressed.installed++;
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
return check(element, id, identifier_1.Identifier.getName(vtx.name), identifier_1.Identifier.getNamespace(vtx.name), 'function');
|
|
93
|
+
}
|
|
94
|
+
// variable use: only plain symbols (not argument names, `...`, or empty)
|
|
95
|
+
if (vtx.tag === vertex_1.VertexType.Use && config.checkVariables) {
|
|
96
|
+
const node = element.node;
|
|
97
|
+
if (node.type !== type_1.RType.Symbol || node.lexeme === '...' || node.lexeme === undefined) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
meta.totalVariableUses++;
|
|
101
|
+
if (inInstalledFile) {
|
|
102
|
+
meta.suppressed.installed++;
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return check(element, id, node.lexeme, undefined, 'variable');
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}).filter(assert_1.isNotUndefined);
|
|
109
|
+
/** shared resolution logic for a name used either as a function call or a variable */
|
|
110
|
+
function check(element, id, name, namespace, kind) {
|
|
111
|
+
// resolved by flowR itself (local/param/builtin) - never a candidate, so not counted as suppressed
|
|
112
|
+
if (kind === 'variable' ? (0, undefined_symbol_util_1.useResolvesToDefinitionOrBuiltin)(graph, id) : ((0, dfg_get_origin_1.getOriginInDfg)(graph, id)?.length ?? 0) > 0) {
|
|
41
113
|
return undefined;
|
|
42
114
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
if (origins && origins.length > 0) {
|
|
115
|
+
// a bare call to a registered flowR builtin whose dataflow origin was rewritten away from its
|
|
116
|
+
// builtin marker (e.g. a fully-resolved `UseMethod` dispatch is re-tagged as a plain function
|
|
117
|
+
// call) is still defined, so recognise it directly from the built-in environment
|
|
118
|
+
if (kind === 'function' && namespace === undefined && ctx.env.builtInEnvironment.memory.has(name)) {
|
|
48
119
|
return undefined;
|
|
49
120
|
}
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
? deps.getDependency(namespace)?.has(name) === true
|
|
54
|
-
: deps.getDependencies().some(p => p.has(name));
|
|
55
|
-
if (known) {
|
|
121
|
+
// a bare base-R primitive/internal (`is.na`) or base data constant (`.Machine`) is defined but
|
|
122
|
+
// missing from the sigdb export list, so recognise it directly (covers calls and variable reads)
|
|
123
|
+
if (namespace === undefined && r_base_primitives_generated_1.RBasePrimitives.has(name)) {
|
|
56
124
|
return undefined;
|
|
57
125
|
}
|
|
126
|
+
// exported by a package in scope (`pkg::fn`, a loaded package, or a default-attached base package)
|
|
127
|
+
if (namespace !== undefined ? deps.getDependency(namespace)?.has(name) === true : loadedPackages.some(p => p.has(name))) {
|
|
128
|
+
return suppress('loadedPackage');
|
|
129
|
+
}
|
|
130
|
+
// forward-referenced closure binding flowR's dataflow did not link (unconditional bindings only)
|
|
131
|
+
if ((0, undefined_symbol_util_1.isDefinedInEnclosingScope)(graph, scopeDefined, id, name)) {
|
|
132
|
+
return suppress('enclosingScope');
|
|
133
|
+
}
|
|
134
|
+
// consumed by non-standard evaluation (quoting), hence not an ordinary read
|
|
135
|
+
if ((0, undefined_symbol_util_1.isNonStandardEvaluated)(graph, id)) {
|
|
136
|
+
return suppress('nonStandardEval');
|
|
137
|
+
}
|
|
138
|
+
// `[`/`[[` subscript: muted by default (indistinguishable from `data.table` column masking)
|
|
139
|
+
if (kind === 'variable' && !config.checkSubscripts && (0, undefined_symbol_util_1.isInSubscript)(graph, id)) {
|
|
140
|
+
return suppress('subscript');
|
|
141
|
+
}
|
|
58
142
|
const loc = range_1.SourceLocation.fromNode(element.node);
|
|
59
|
-
|
|
143
|
+
if (loc === undefined) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
const availableInPackages = namespace === undefined ? hintPackagesFor(name) : [];
|
|
147
|
+
return {
|
|
60
148
|
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
61
149
|
name,
|
|
62
|
-
|
|
63
|
-
|
|
150
|
+
kind,
|
|
151
|
+
involvedId: id,
|
|
152
|
+
loc,
|
|
153
|
+
...(availableInPackages.length > 0 ? { availableInPackages } : {}),
|
|
154
|
+
...(unresolvedLibraryInScope ? { mayBeProvidedByUnresolvedLibrary: true } : {})
|
|
64
155
|
};
|
|
65
|
-
}
|
|
156
|
+
}
|
|
157
|
+
function suppress(reason) {
|
|
158
|
+
meta.suppressed[reason]++;
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
66
161
|
return { results, '.meta': meta };
|
|
67
162
|
},
|
|
68
163
|
prettyPrint: {
|
|
69
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result =>
|
|
70
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result =>
|
|
164
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `${result.mayBeProvidedByUnresolvedLibrary ? 'Possibly undefined' : 'Undefined'} ${result.kind} \`${result.name}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
165
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => {
|
|
166
|
+
const where = range_1.SourceLocation.format(result.loc);
|
|
167
|
+
const caveat = result.mayBeProvidedByUnresolvedLibrary ? ' (an unresolved library is loaded that might provide it)' : '';
|
|
168
|
+
if (result.availableInPackages && result.availableInPackages.length > 0) {
|
|
169
|
+
const pkgs = result.availableInPackages.map(p => `\`${p}\``).join(', ');
|
|
170
|
+
const hint = result.availableInPackages.length === 1 ? `\`library(${result.availableInPackages[0]})\`` : `one of ${pkgs}`;
|
|
171
|
+
return `\`${result.name}\` at ${where} is used but not defined; it is exported by ${pkgs} - did you forget to load it (e.g. ${hint})?${caveat}`;
|
|
172
|
+
}
|
|
173
|
+
return result.kind === 'function'
|
|
174
|
+
? `\`${result.name}\` at ${where} is called but is neither defined locally, a base R builtin, nor exported by a loaded package${caveat}`
|
|
175
|
+
: `\`${result.name}\` at ${where} is used as a variable but is never defined in scope${caveat}`;
|
|
176
|
+
}
|
|
71
177
|
},
|
|
72
178
|
info: {
|
|
73
179
|
name: 'Undefined Symbol',
|
|
74
180
|
certainty: linter_format_1.LintingRuleCertainty.OverApproximative,
|
|
75
|
-
description: 'Flags
|
|
181
|
+
description: 'Flags functions and variables that are neither defined locally, a base R builtin, nor exported by a loaded package.',
|
|
76
182
|
tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Experimental],
|
|
77
|
-
defaultConfig: {
|
|
183
|
+
defaultConfig: {
|
|
184
|
+
checkFunctions: true,
|
|
185
|
+
checkVariables: true,
|
|
186
|
+
checkSubscripts: false
|
|
187
|
+
}
|
|
78
188
|
}
|
|
79
189
|
};
|
|
80
190
|
//# sourceMappingURL=undefined-symbol.js.map
|
|
@@ -2,6 +2,7 @@ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
3
|
import { LintingRuleTag } from '../linter-tags';
|
|
4
4
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
+
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
5
6
|
export interface UnusedDefinitionResult extends LintingResult {
|
|
6
7
|
variableName?: string;
|
|
7
8
|
}
|
|
@@ -10,13 +11,18 @@ export interface UnusedDefinitionConfig extends MergeableRecord {
|
|
|
10
11
|
* Whether to include (potentially anonymous) function definitions in the search (e.g., should we report uncalled anonymous functions?).
|
|
11
12
|
*/
|
|
12
13
|
includeFunctionDefinitions: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to suppress definitions that the analyzed project exports via its `NAMESPACE` (the package's public API).
|
|
16
|
+
* flowR cannot observe external callers, so exported names would otherwise be reported as (uncertain) false positives.
|
|
17
|
+
*/
|
|
18
|
+
excludeExportedDefinitions: boolean;
|
|
13
19
|
}
|
|
14
20
|
export interface UnusedDefinitionMetadata extends MergeableRecord {
|
|
15
21
|
totalConsidered: number;
|
|
16
22
|
}
|
|
17
23
|
export declare const UNUSED_DEFINITION: {
|
|
18
24
|
readonly createSearch: (config: UnusedDefinitionConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
|
|
19
|
-
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: UnusedDefinitionConfig, data:
|
|
25
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: UnusedDefinitionConfig, data: ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
20
26
|
results: UnusedDefinitionResult[];
|
|
21
27
|
".meta": UnusedDefinitionMetadata;
|
|
22
28
|
}>;
|
|
@@ -31,6 +37,7 @@ export declare const UNUSED_DEFINITION: {
|
|
|
31
37
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
32
38
|
readonly defaultConfig: {
|
|
33
39
|
readonly includeFunctionDefinitions: true;
|
|
40
|
+
readonly excludeExportedDefinitions: true;
|
|
34
41
|
};
|
|
35
42
|
};
|
|
36
43
|
};
|