@eagleoutice/flowr 2.10.10 → 2.11.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 +35 -27
- package/cli/common/options.d.ts +2 -108
- package/cli/common/options.js +3 -27
- package/cli/common/scripts-info.d.ts +2 -123
- package/cli/common/scripts-info.js +0 -17
- package/cli/flowr-main-options.d.ts +5 -0
- package/cli/flowr-main-options.js +10 -0
- package/cli/flowr.js +2 -2
- package/cli/repl/commands/repl-commands.js +7 -6
- package/cli/repl/print-version.d.ts +3 -1
- package/cli/repl/print-version.js +21 -2
- package/cli/repl/server/connection.d.ts +2 -0
- package/cli/repl/server/connection.js +40 -31
- package/cli/script-core/summarizer-core.js +13 -32
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +2 -0
- package/config.d.ts +9 -0
- package/config.js +10 -0
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/dataflow/environments/append.d.ts +1 -2
- package/dataflow/environments/append.js +3 -10
- package/dataflow/environments/apply-kill.d.ts +21 -0
- package/dataflow/environments/apply-kill.js +155 -0
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +63 -3
- package/dataflow/environments/default-builtin-config.js +40 -8
- package/dataflow/environments/environment.d.ts +49 -32
- package/dataflow/environments/environment.js +133 -18
- package/dataflow/environments/identifier.d.ts +10 -0
- package/dataflow/environments/identifier.js +23 -0
- package/dataflow/environments/overwrite.js +2 -10
- package/dataflow/environments/resolve-by-name.d.ts +1 -1
- package/dataflow/environments/resolve-by-name.js +10 -2
- package/dataflow/environments/scoping.d.ts +9 -2
- package/dataflow/environments/scoping.js +15 -2
- package/dataflow/extractor.js +23 -2
- package/dataflow/graph/df-helper.d.ts +8 -0
- package/dataflow/graph/df-helper.js +8 -0
- package/dataflow/graph/graph.d.ts +4 -1
- package/dataflow/graph/graph.js +5 -1
- package/dataflow/info.d.ts +26 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
- package/documentation/data/faq/faqs.js +3 -0
- package/documentation/data/interface/doc-writing-code.js +4 -80
- package/documentation/doc-util/doc-structure.js +1 -2
- package/documentation/wiki-core.js +2 -1
- package/documentation/wiki-dataflow-graph.js +35 -1
- package/documentation/wiki-interface.js +2 -2
- package/documentation/wiki-linter.js +2 -0
- package/documentation/wiki-overview.js +1 -14
- package/documentation/wiki-package-database.d.ts +9 -0
- package/documentation/wiki-package-database.js +63 -0
- package/documentation/wiki-query.js +1 -0
- package/linter/linter-rules.d.ts +23 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.js +2 -1
- package/linter/rules/undefined-symbol.d.ts +39 -0
- package/linter/rules/undefined-symbol.js +80 -0
- package/package.json +4 -4
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +9 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
- package/project/context/flowr-analyzer-dependencies-context.js +39 -4
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
- package/project/context/flowr-analyzer-environment-context.js +3 -4
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/flowr-analyzer-builder.js +3 -0
- package/project/flowr-analyzer.d.ts +2 -1
- package/project/flowr-analyzer.js +3 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +176 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
- package/project/plugins/package-version-plugins/package.d.ts +3 -0
- package/project/plugins/package-version-plugins/package.js +12 -0
- package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
- package/project/plugins/package-version-plugins/pkgdb.js +370 -0
- package/project/plugins/plugin-registry.d.ts +4 -1
- package/project/plugins/plugin-registry.js +7 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
- package/queries/catalog/linter-query/linter-query-executor.js +1 -0
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
- package/search/search-executor/search-enrichers.d.ts +1 -1
- package/search/search-executor/search-enrichers.js +7 -4
- package/util/mermaid/mermaid.d.ts +4 -0
- package/util/mermaid/mermaid.js +8 -1
- package/util/text/ansi.d.ts +10 -1
- package/util/text/ansi.js +17 -4
- package/util/version.js +10 -2
- package/cli/common/features.d.ts +0 -9
- package/cli/common/features.js +0 -35
- package/cli/script-core/statistics-core.d.ts +0 -6
- package/cli/script-core/statistics-core.js +0 -104
- package/cli/script-core/statistics-helper-core.d.ts +0 -6
- package/cli/script-core/statistics-helper-core.js +0 -86
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -16
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -14
- package/statistics/features/common-syntax-probability.d.ts +0 -38
- package/statistics/features/common-syntax-probability.js +0 -169
- package/statistics/features/feature.d.ts +0 -179
- package/statistics/features/feature.js +0 -38
- package/statistics/features/post-processing.d.ts +0 -18
- package/statistics/features/post-processing.js +0 -26
- package/statistics/features/supported/assignments/assignments.d.ts +0 -12
- package/statistics/features/supported/assignments/assignments.js +0 -56
- package/statistics/features/supported/assignments/post-process.d.ts +0 -6
- package/statistics/features/supported/assignments/post-process.js +0 -126
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -143
- package/statistics/features/supported/comments/post-process.d.ts +0 -6
- package/statistics/features/supported/comments/post-process.js +0 -51
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -69
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
- package/statistics/features/supported/control-flow/post-process.js +0 -66
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -122
- package/statistics/features/supported/data-access/post-process.d.ts +0 -6
- package/statistics/features/supported/data-access/post-process.js +0 -108
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -168
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
- package/statistics/features/supported/expression-list/post-process.js +0 -45
- package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -81
- package/statistics/features/supported/loops/post-process.d.ts +0 -6
- package/statistics/features/supported/loops/post-process.js +0 -73
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -176
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -99
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
- package/statistics/features/supported/used-packages/post-process.js +0 -122
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -140
- package/statistics/features/supported/values/post-process.d.ts +0 -6
- package/statistics/features/supported/values/post-process.js +0 -73
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -111
- package/statistics/features/supported/variables/post-process.d.ts +0 -15
- package/statistics/features/supported/variables/post-process.js +0 -126
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -62
- package/statistics/meta-statistics.d.ts +0 -32
- package/statistics/meta-statistics.js +0 -16
- package/statistics/output/file-provider.d.ts +0 -36
- package/statistics/output/file-provider.js +0 -96
- package/statistics/output/print-stats.d.ts +0 -29
- package/statistics/output/print-stats.js +0 -81
- package/statistics/output/statistics-file.d.ts +0 -36
- package/statistics/output/statistics-file.js +0 -68
- package/statistics/statistics.d.ts +0 -29
- package/statistics/statistics.js +0 -108
- package/statistics/summarizer/auto-detect.d.ts +0 -5
- package/statistics/summarizer/auto-detect.js +0 -34
- package/statistics/summarizer/first-phase/process.d.ts +0 -6
- package/statistics/summarizer/first-phase/process.js +0 -81
- package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
- package/statistics/summarizer/post-process/clusterer.js +0 -40
- package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
- package/statistics/summarizer/post-process/file-based-count.js +0 -47
- package/statistics/summarizer/post-process/histogram.d.ts +0 -57
- package/statistics/summarizer/post-process/histogram.js +0 -126
- package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
- package/statistics/summarizer/post-process/post-process-output.js +0 -102
- package/statistics/summarizer/second-phase/process.d.ts +0 -15
- package/statistics/summarizer/second-phase/process.js +0 -118
- package/statistics/summarizer/summarizer.d.ts +0 -34
- package/statistics/summarizer/summarizer.js +0 -141
|
@@ -27,6 +27,7 @@ const resolve_by_name_1 = require("../dataflow/environments/resolve-by-name");
|
|
|
27
27
|
const default_pipelines_1 = require("../core/steps/pipeline/default-pipelines");
|
|
28
28
|
const text_1 = require("../util/text/text");
|
|
29
29
|
const linker_1 = require("../dataflow/internal/linker");
|
|
30
|
+
const apply_kill_1 = require("../dataflow/environments/apply-kill");
|
|
30
31
|
const doc_normalized_ast_1 = require("./doc-util/doc-normalized-ast");
|
|
31
32
|
const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
|
|
32
33
|
const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
@@ -965,7 +966,7 @@ Let's start by looking at the properties of the dataflow information object: ${O
|
|
|
965
966
|
|
|
966
967
|
${(() => {
|
|
967
968
|
/* this includes the meta field for timing and the quick CFG in order to enable re-use and improve performance */
|
|
968
|
-
(0, assert_1.guard)(Object.keys(result).length ===
|
|
969
|
+
(0, assert_1.guard)(Object.keys(result).length === 11, () => 'Update Dataflow Documentation! (Keys: ' + Object.keys(result).join(', ') + ')');
|
|
969
970
|
return '';
|
|
970
971
|
})()}
|
|
971
972
|
|
|
@@ -985,9 +986,42 @@ ${(0, doc_env_1.printEnvironmentToMarkdown)(result.environment.current)}
|
|
|
985
986
|
This shows us that the local environment contains a single definition for \`x\` (with id 0) and that the parent environment is the built-in environment.
|
|
986
987
|
Additionally, we get the information that the node with the id 2 was responsible for the definition of \`x\`.
|
|
987
988
|
|
|
989
|
+
#### Attached Packages and the Search Path
|
|
990
|
+
|
|
991
|
+
Calling \`library(pkg)\` (or \`require\`) attaches a package to the search path.
|
|
992
|
+
Mirroring R's \`search()\`, _flowR_ inserts the package's namespace and imports environments *below* the global environment (\`.GlobalEnv\`), so resolution walks **current scope -> enclosing scopes -> global -> attached packages -> built-ins**.
|
|
993
|
+
|
|
994
|
+
**A global binding shadows a package export** of the same name, exactly as in R:
|
|
995
|
+
|
|
996
|
+
\`\`\`r
|
|
997
|
+
filter <- function(x) x # your global definition
|
|
998
|
+
library(stats) # stats also exports filter()
|
|
999
|
+
filter(1) # -> resolves to YOUR filter, not stats::filter
|
|
1000
|
+
\`\`\`
|
|
1001
|
+
|
|
1002
|
+
**Most recently attached is nearest, and re-attaching is a no-op:**
|
|
1003
|
+
|
|
1004
|
+
\`\`\`r
|
|
1005
|
+
library(A) # search path (top-down): A
|
|
1006
|
+
library(B) # B, A
|
|
1007
|
+
library(A) # no-op B, A (A is not moved or duplicated)
|
|
1008
|
+
\`\`\`
|
|
1009
|
+
|
|
1010
|
+
**Attaching inside a function propagates to the caller** (R attaches globally), and across branches every possibly-attached package is kept (a sound over-approximation of R's single runtime path):
|
|
1011
|
+
|
|
1012
|
+
\`\`\`r
|
|
1013
|
+
f <- function() library(A) # attaches A when called
|
|
1014
|
+
f()
|
|
1015
|
+
someExportOfA() # -> resolves against A
|
|
1016
|
+
if (cond) library(B) # B is kept (may be attached)
|
|
1017
|
+
\`\`\`
|
|
1018
|
+
|
|
988
1019
|
Last but not least, the information contains the single **entry point** (${JSON.stringify(result.entryPoint)}) and a set of **exit points** (${JSON.stringify(result.exitPoints.map(e => e.nodeId))}).
|
|
989
1020
|
Besides marking potential exits, the exit points also provide information about why the exit occurs and which control dependencies affect the exit.
|
|
990
1021
|
|
|
1022
|
+
Finally, the **kill** property (${ctx.link('KillReference', undefined, { type: 'type' })}) tracks references that are removed from scope within the current subtree (e.g., via \`rm(x)\`).
|
|
1023
|
+
It is \`undefined\` unless such a removal occurred and, like the outgoing references, bubbles up so that the enclosing scope can apply the removal (see ${ctx.link(apply_kill_1.applyKills)}) at the right location.
|
|
1024
|
+
|
|
991
1025
|
### Unknown Side Effects
|
|
992
1026
|
|
|
993
1027
|
In case _flowR_ encounters a function call that it cannot handle, it marks the call as an unknown side effect.
|
|
@@ -35,8 +35,7 @@ ${(0, doc_structure_1.block)({
|
|
|
35
35
|
type: 'NOTE',
|
|
36
36
|
content: `
|
|
37
37
|
The default ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'server', false)} uses a simple [TCP](https://de.wikipedia.org/wiki/Transmission_Control_Protocol)
|
|
38
|
-
connection. If you want _flowR_ to expose a [WebSocket](https://de.wikipedia.org/wiki/WebSocket) server instead, add the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'ws', false)} flag (i.e., ${(0, doc_cli_option_1.multipleCliOptions)('flowr', 'server', 'ws')}) when starting _flowR_ from the command line
|
|
39
|
-
`
|
|
38
|
+
connection. If you want _flowR_ to expose a [WebSocket](https://de.wikipedia.org/wiki/WebSocket) server instead, add the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'ws', false)} flag (i.e., ${(0, doc_cli_option_1.multipleCliOptions)('flowr', 'server', 'ws')}) when starting _flowR_ from the command line.`
|
|
40
39
|
})}
|
|
41
40
|
|
|
42
41
|
${await (0, doc_server_message_1.printServerMessages)(parser)}
|
|
@@ -264,6 +263,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
|
264
263
|
variables: config_1.VariableResolve.Alias,
|
|
265
264
|
evalStrings: true,
|
|
266
265
|
trackEnvironments: true,
|
|
266
|
+
pkgdb: { enabled: true, eagerlyLoad: false, eagerlyLoadExports: false },
|
|
267
267
|
resolveSource: {
|
|
268
268
|
dropPaths: config_1.DropPathsOption.No,
|
|
269
269
|
ignoreCapitalization: true,
|
|
@@ -132,6 +132,7 @@ function(x) {
|
|
|
132
132
|
rule(knownParser, 'software-has-license', 'SoftwareHasLicenseConfig', 'SOFTWARE_HAS_LICENSE', 'lint-software-has-license', 'cat("a project without a license")', tagTypes);
|
|
133
133
|
rule(knownParser, 'software-has-tests', 'SoftwareHasTestsConfig', 'SOFTWARE_HAS_TESTS', 'lint-software-has-tests', 'cat("hello")', tagTypes);
|
|
134
134
|
rule(knownParser, 'no-leaked-credentials', 'NoLeakedCredentialsConfig', 'NO_LEAKED_CREDENTIALS', 'lint-no-leaked-credentials', 'password <- "s3cr3t"', tagTypes);
|
|
135
|
+
rule(knownParser, 'undefined-symbol', 'UndefinedSymbolConfig', 'UNDEFINED_SYMBOL', 'lint-undefined-symbol', 'undefined_helper(42)', tagTypes);
|
|
135
136
|
function rule(parser, name, configType, ruleType, testfile, example, types) {
|
|
136
137
|
const rule = linter_rules_1.LintingRules[name];
|
|
137
138
|
const tags = rule.info.tags.toSorted((a, b) => {
|
|
@@ -209,6 +210,7 @@ async function getTextMainPage(knownParser, tagTypes, ctx) {
|
|
|
209
210
|
const rules = registerRules(knownParser, tagTypes.info);
|
|
210
211
|
return `
|
|
211
212
|
This page describes the flowR linter, which is a tool that utilizes flowR's dataflow analysis to find common issues in R scripts. The linter can currently be used through the linter ${ctx.linkPage('wiki/Query API', 'query')}.
|
|
213
|
+
Some rules also draw on the ${ctx.linkPage('wiki/Package Database', 'package database')}.
|
|
212
214
|
For example:
|
|
213
215
|
|
|
214
216
|
${await (async () => {
|
|
@@ -28,7 +28,6 @@ for instructions on how to install _flowR_.
|
|
|
28
28
|
- [Generate Static Slices](#generate-static-slices)
|
|
29
29
|
- [Benchmark the Slicer](#benchmark-the-slicer)
|
|
30
30
|
- [Summarizing the Benchmark Results](#summarizing-the-benchmark-results)
|
|
31
|
-
- [Generate Usage Statistics of R Code](#generate-usage-statistics-of-r-code)
|
|
32
31
|
<!-- TOC -->
|
|
33
32
|
|
|
34
33
|
## _flowR_'s Modules
|
|
@@ -42,11 +41,9 @@ If you wish to use _flowR_, check out one of its extensions (e.g., the ${ctx.lin
|
|
|
42
41
|
the [REPL and server interfaces](#using-_flowr_-from-the-outside) or its coding API with the
|
|
43
42
|
${ctx.link(flowr_analyzer_1.FlowrAnalyzer)}.
|
|
44
43
|
|
|
45
|
-
The benchmark module is only of interest if you want to benchmark/measure the runtime performance and reduction of the slicer.
|
|
44
|
+
The benchmark module is only of interest if you want to benchmark/measure the runtime performance and reduction of the slicer.
|
|
46
45
|
It is available with the [\`benchmark\`](#benchmark-the-slicer) script.
|
|
47
46
|
|
|
48
|
-
The statistics module is mostly independent of the slicer and can be used to analyze R files regarding their use of function definitions, assignments, and more. It is used to identify common patterns in R code and is available with the [\`statistics\`](#generate-usage-statistics-of-r-code) script.
|
|
49
|
-
|
|
50
47
|
The [core](https://github.com/flowr-analysis/flowr/tree/main/src/core) module contains _flowR_'s read-eval-print loop (REPL) and
|
|
51
48
|
_flowR_'s server. Furthermore, it contains the root definitions of how _flowR_ slices (see the ${ctx.linkPage('wiki/Interface')} wiki page for more information).
|
|
52
49
|
|
|
@@ -230,16 +227,6 @@ For more options, run the following from the \`cli\` directory:
|
|
|
230
227
|
|
|
231
228
|
\`\`\`shell
|
|
232
229
|
npm run summarizer -- --help
|
|
233
|
-
\`\`\`
|
|
234
|
-
|
|
235
|
-
### Generate Usage Statistics of R Code
|
|
236
|
-
|
|
237
|
-
If you want to reproduce the statistics as presented in the original [master's thesis](http://dx.doi.org/10.18725/OPARU-50107), see the corresponding [wiki page](https://github.com/flowr-analysis/flowr/wiki/Thesis#how-to-reproduce-the-statistics-from-the-masters-thesis).
|
|
238
|
-
|
|
239
|
-
For more information, run the following from the \`cli\` directory:
|
|
240
|
-
|
|
241
|
-
\`\`\`shell
|
|
242
|
-
npm run stats -- --help
|
|
243
230
|
\`\`\`
|
|
244
231
|
`.trim();
|
|
245
232
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DocMakerArgs } from './wiki-mk/doc-maker';
|
|
2
|
+
import { DocMaker } from './wiki-mk/doc-maker';
|
|
3
|
+
/**
|
|
4
|
+
* https://github.com/flowr-analysis/flowr/wiki/Package-Database
|
|
5
|
+
*/
|
|
6
|
+
export declare class WikiPackageDatabase extends DocMaker<'wiki/Package Database.md'> {
|
|
7
|
+
constructor();
|
|
8
|
+
text({ ctx }: DocMakerArgs): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WikiPackageDatabase = void 0;
|
|
4
|
+
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
5
|
+
const doc_files_1 = require("./doc-util/doc-files");
|
|
6
|
+
const pkgdb_1 = require("../project/plugins/package-version-plugins/pkgdb");
|
|
7
|
+
const flowr_analyzer_package_versions_pkgdb_plugin_1 = require("../project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin");
|
|
8
|
+
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
9
|
+
/** point the resolver at your own database (a file path or http(s) URL) */
|
|
10
|
+
function usePackageDatabase(parser) {
|
|
11
|
+
const pkgdb = new flowr_analyzer_package_versions_pkgdb_plugin_1.FlowrAnalyzerPackageVersionsPkgDbPlugin('/path/to/pkgdb-all.json.br');
|
|
12
|
+
return new flowr_analyzer_builder_1.FlowrAnalyzerBuilder().setParser(parser).registerPlugins(pkgdb).build();
|
|
13
|
+
}
|
|
14
|
+
/** link a built-in plugin key (e.g. `versions:pkgdb`) to its registration */
|
|
15
|
+
function pluginLink(key) {
|
|
16
|
+
return `[\`${key}\`](${doc_files_1.RemoteFlowrFilePathBaseRef}src/project/plugins/plugin-registry.ts)`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* https://github.com/flowr-analysis/flowr/wiki/Package-Database
|
|
20
|
+
*/
|
|
21
|
+
class WikiPackageDatabase extends doc_maker_1.DocMaker {
|
|
22
|
+
constructor() {
|
|
23
|
+
super('wiki/Package Database.md', module.filename, 'bundled CRAN package database that resolves `library()` calls');
|
|
24
|
+
}
|
|
25
|
+
text({ ctx }) {
|
|
26
|
+
return `
|
|
27
|
+
# Package Database
|
|
28
|
+
|
|
29
|
+
flowR ships a database of CRAN package exports so it can resolve calls into the packages you load.
|
|
30
|
+
After \`library(ggplot2)\`, a call to \`ggplot()\` resolves to \`ggplot2::ggplot\`. This also backs
|
|
31
|
+
qualified names (a bare \`map()\` after \`library(purrr)\` is \`purrr::map\`, not the \`maps\` plot), the
|
|
32
|
+
${ctx.linkPage('wiki/Query API', 'dependencies and call-context queries')}, and the ${ctx.linkPage('wiki/Linter', '`undefined-symbol` rule')}.
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
The exports come from ${pluginLink('versions:pkgdb')}, which reads the bundled database (on by default;
|
|
37
|
+
see ${ctx.linkPage('wiki/Interface', 'configuring flowR', 'configuring-flowr')}).
|
|
38
|
+
|
|
39
|
+
*Which* version's exports are resolved is decided by the version-reading plugins that pin the packages
|
|
40
|
+
used in a project. These are only examples - more may be registered:
|
|
41
|
+
|
|
42
|
+
- ${pluginLink('versions:description')} reads a package's \`DESCRIPTION\` (\`Depends\` / \`Imports\`, ${(0, doc_files_1.linkFlowRSourceFile)('src/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.ts')}).
|
|
43
|
+
- ${pluginLink('versions:renv')} and ${pluginLink('versions:rv')} read a project's \`renv.lock\` / \`rv.lock\`
|
|
44
|
+
to pin exact versions (${(0, doc_files_1.linkFlowRSourceFile)('src/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.ts')}).
|
|
45
|
+
|
|
46
|
+
So \`library(pkg)\` resolves the pinned version's exports. To override or extend the bundle, hand
|
|
47
|
+
${pluginLink('versions:pkgdb')} extra sources (file paths, parsed objects, or \`http(s)\` URLs).
|
|
48
|
+
|
|
49
|
+
${ctx.code(usePackageDatabase, { dropLinesStart: 1 })}
|
|
50
|
+
|
|
51
|
+
File sources load lazily on the first package load, so scripts without \`library()\`/\`use()\` calls never
|
|
52
|
+
pay for parsing them (set \`solver.pkgdb.eagerlyLoad\` to mount the database up front, or \`solver.pkgdb.enabled: false\` to switch it off entirely).
|
|
53
|
+
For a URL source call ${ctx.linkM(flowr_analyzer_package_versions_pkgdb_plugin_1.FlowrAnalyzerPackageVersionsPkgDbPlugin, 'preload', { hideClass: true, codeFont: true })} (\`await pkgdb.preload()\`) before analysis to download it.
|
|
54
|
+
|
|
55
|
+
## Format
|
|
56
|
+
|
|
57
|
+
One JSON object (\`flowr-pkgdb\`, schema ${pkgdb_1.PkgDbSchema}) with a pooled string table.
|
|
58
|
+
Reader and writer both live in ${(0, doc_files_1.linkFlowRSourceFile)('src/project/plugins/package-version-plugins/pkgdb.ts')}.
|
|
59
|
+
`.trim();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.WikiPackageDatabase = WikiPackageDatabase;
|
|
63
|
+
//# sourceMappingURL=wiki-package-database.js.map
|
|
@@ -660,6 +660,7 @@ print("hello world!")
|
|
|
660
660
|
return `
|
|
661
661
|
This query extracts all dependencies from an R script, using a combination of a ${(0, doc_query_1.linkToQueryOfName)('call-context')}
|
|
662
662
|
and more advanced tracking in the ${ctx.linkPage('wiki/Dataflow Graph', 'Dataflow Graph')}.
|
|
663
|
+
Loaded libraries are resolved against the ${ctx.linkPage('wiki/Package Database', 'package database')}.
|
|
663
664
|
|
|
664
665
|
In other words, if you have a script simply reading: \`${exampleCode}\`, the following query returns the loaded library:
|
|
665
666
|
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -357,6 +357,29 @@ export declare const LintingRules: {
|
|
|
357
357
|
};
|
|
358
358
|
};
|
|
359
359
|
};
|
|
360
|
+
readonly 'undefined-symbol': {
|
|
361
|
+
readonly createSearch: (_config: import("./rules/undefined-symbol").UndefinedSymbolConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
362
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("../util/objects").MergeableRecord, data: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>) => Promise<{
|
|
363
|
+
results: {
|
|
364
|
+
certainty: import("./linter-format").LintingResultCertainty.Uncertain;
|
|
365
|
+
name: import("../dataflow/environments/identifier").BrandedIdentifier;
|
|
366
|
+
involvedId: import("../r-bridge/lang-4.x/ast/model/processing/node-id").NodeId;
|
|
367
|
+
loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
|
|
368
|
+
}[];
|
|
369
|
+
'.meta': import("./rules/undefined-symbol").UndefinedSymbolMetadata;
|
|
370
|
+
}>;
|
|
371
|
+
readonly prettyPrint: {
|
|
372
|
+
readonly query: (result: import("./rules/undefined-symbol").UndefinedSymbolResult) => string;
|
|
373
|
+
readonly full: (result: import("./rules/undefined-symbol").UndefinedSymbolResult) => string;
|
|
374
|
+
};
|
|
375
|
+
readonly info: {
|
|
376
|
+
readonly name: "Undefined Symbol";
|
|
377
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.OverApproximative;
|
|
378
|
+
readonly description: "Flags calls to functions that are neither defined locally, a known builtin, nor exported by a loaded package.";
|
|
379
|
+
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Experimental];
|
|
380
|
+
readonly defaultConfig: {};
|
|
381
|
+
};
|
|
382
|
+
};
|
|
360
383
|
};
|
|
361
384
|
export type LintingRuleNames = keyof typeof LintingRules;
|
|
362
385
|
export type LintingRuleMetadata<Name extends LintingRuleNames> = typeof LintingRules[Name] extends LintingRule<infer _Result, infer Metadata, infer _Config, infer _Info, infer _Elements> ? Metadata : never;
|
package/linter/linter-rules.js
CHANGED
|
@@ -17,6 +17,7 @@ const problematic_inputs_1 = require("./rules/problematic-inputs");
|
|
|
17
17
|
const software_has_license_1 = require("./rules/software-has-license");
|
|
18
18
|
const software_has_tests_1 = require("./rules/software-has-tests");
|
|
19
19
|
const no_leaked_credentials_1 = require("./rules/no-leaked-credentials");
|
|
20
|
+
const undefined_symbol_1 = require("./rules/undefined-symbol");
|
|
20
21
|
/**
|
|
21
22
|
* The registry of currently supported linting rules.
|
|
22
23
|
* A linting rule can be executed on a dataflow pipeline result using {@link executeLintingRule}.
|
|
@@ -37,6 +38,7 @@ exports.LintingRules = {
|
|
|
37
38
|
'roxygen-arguments': roxygen_arguments_1.ROXYGEN_ARGS,
|
|
38
39
|
'software-has-license': software_has_license_1.SOFTWARE_HAS_LICENSE,
|
|
39
40
|
'software-has-tests': software_has_tests_1.SOFTWARE_HAS_TESTS,
|
|
40
|
-
'no-leaked-credentials': no_leaked_credentials_1.NO_LEAKED_CREDENTIALS
|
|
41
|
+
'no-leaked-credentials': no_leaked_credentials_1.NO_LEAKED_CREDENTIALS,
|
|
42
|
+
'undefined-symbol': undefined_symbol_1.UNDEFINED_SYMBOL
|
|
41
43
|
};
|
|
42
44
|
//# sourceMappingURL=linter-rules.js.map
|
|
@@ -21,6 +21,7 @@ const dependencies_query_format_1 = require("../../queries/catalog/dependencies-
|
|
|
21
21
|
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
22
22
|
const path_1 = __importDefault(require("path"));
|
|
23
23
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
24
|
+
const other_path_functions_1 = require("../../queries/catalog/dependencies-query/function-info/other-path-functions");
|
|
24
25
|
function inferWd(file, wd) {
|
|
25
26
|
if (wd === '@script') {
|
|
26
27
|
// we can use the script path as the working directory
|
|
@@ -94,7 +95,7 @@ exports.ABSOLUTE_PATH = {
|
|
|
94
95
|
type: 'dependencies',
|
|
95
96
|
// we use the dependencies query to give us all functions that take a file path as input
|
|
96
97
|
ignoreDefaultFunctions: true,
|
|
97
|
-
readFunctions: read_functions_1.ReadFunctions.concat(write_functions_1.WriteFunctions, source_functions_1.SourceFunctions, config.additionalPathFunctions),
|
|
98
|
+
readFunctions: read_functions_1.ReadFunctions.concat(write_functions_1.WriteFunctions, source_functions_1.SourceFunctions, other_path_functions_1.OtherPathFunctions, config.additionalPathFunctions),
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
if (config.include.constructed) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
2
|
+
import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
|
|
3
|
+
import { LintingRuleTag } from '../linter-tags';
|
|
4
|
+
export interface UndefinedSymbolResult extends LintingResult {
|
|
5
|
+
/** the called name that could not be resolved */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export type UndefinedSymbolConfig = MergeableRecord;
|
|
9
|
+
export interface UndefinedSymbolMetadata extends MergeableRecord {
|
|
10
|
+
totalCalls: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Flags calls to functions that are neither defined locally, a known builtin, nor exported by a
|
|
14
|
+
* package loaded via `library()`/`require()`/`use()` (resolved from the `flowr-pkgdb` database).
|
|
15
|
+
* Over-approximative: reflection/NSE and packages without export info can cause false positives.
|
|
16
|
+
*/
|
|
17
|
+
export declare const UNDEFINED_SYMBOL: {
|
|
18
|
+
readonly createSearch: (_config: UndefinedSymbolConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
19
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: MergeableRecord, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
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
|
+
}[];
|
|
26
|
+
'.meta': UndefinedSymbolMetadata;
|
|
27
|
+
}>;
|
|
28
|
+
readonly prettyPrint: {
|
|
29
|
+
readonly query: (result: UndefinedSymbolResult) => string;
|
|
30
|
+
readonly full: (result: UndefinedSymbolResult) => string;
|
|
31
|
+
};
|
|
32
|
+
readonly info: {
|
|
33
|
+
readonly name: "Undefined Symbol";
|
|
34
|
+
readonly certainty: LintingRuleCertainty.OverApproximative;
|
|
35
|
+
readonly description: "Flags calls to functions that are neither defined locally, a known builtin, nor exported by a loaded package.";
|
|
36
|
+
readonly tags: readonly [LintingRuleTag.Bug, LintingRuleTag.Experimental];
|
|
37
|
+
readonly defaultConfig: {};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNDEFINED_SYMBOL = void 0;
|
|
4
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
5
|
+
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
6
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
7
|
+
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
8
|
+
const assert_1 = require("../../util/assert");
|
|
9
|
+
const range_1 = require("../../util/range");
|
|
10
|
+
const linter_format_1 = require("../linter-format");
|
|
11
|
+
const linter_tags_1 = require("../linter-tags");
|
|
12
|
+
/** calls that load a package; an unresolved one means we cannot enumerate all exports in scope */
|
|
13
|
+
const LibraryLoadFunctions = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'load_all', 'use', 'p_load']);
|
|
14
|
+
/**
|
|
15
|
+
* Flags calls to functions that are neither defined locally, a known builtin, nor exported by a
|
|
16
|
+
* package loaded via `library()`/`require()`/`use()` (resolved from the `flowr-pkgdb` database).
|
|
17
|
+
* Over-approximative: reflection/NSE and packages without export info can cause false positives.
|
|
18
|
+
*/
|
|
19
|
+
exports.UNDEFINED_SYMBOL = {
|
|
20
|
+
createSearch: (_config) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall),
|
|
21
|
+
processSearchResult: async (elements, config, data) => {
|
|
22
|
+
const dataflow = await data.dataflow();
|
|
23
|
+
const deps = data.inspectContext().deps;
|
|
24
|
+
const meta = { totalCalls: 0 };
|
|
25
|
+
// only report when every loaded library's exports are known: a library() whose package we could
|
|
26
|
+
// not resolve is flagged with an unknown side effect and could export the symbol, so we bail out
|
|
27
|
+
const unknownIds = new Set();
|
|
28
|
+
for (const e of dataflow.graph.unknownSideEffects) {
|
|
29
|
+
unknownIds.add(String(typeof e === 'object' ? e.id : e));
|
|
30
|
+
}
|
|
31
|
+
if (unknownIds.size > 0) {
|
|
32
|
+
for (const [id, v] of dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
33
|
+
if (LibraryLoadFunctions.has(identifier_1.Identifier.getName(v.name)) && unknownIds.has(String(id))) {
|
|
34
|
+
return { results: [], '.meta': meta };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const results = elements.getElements().map(element => {
|
|
39
|
+
const vtx = dataflow.graph.getVertex(element.node.info.id);
|
|
40
|
+
if (!vtx || !(0, vertex_1.isFunctionCallVertex)(vtx) || vtx.origin === 'unnamed') {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
meta.totalCalls++;
|
|
44
|
+
const name = identifier_1.Identifier.getName(vtx.name);
|
|
45
|
+
// resolved locally, as a builtin, or as an attached package export?
|
|
46
|
+
const origins = (0, dfg_get_origin_1.getOriginInDfg)(dataflow.graph, vtx.id);
|
|
47
|
+
if (origins && origins.length > 0) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// cross-check loaded packages' exports (covers namespace-only / `pkg::fn` loads)
|
|
51
|
+
const namespace = identifier_1.Identifier.getNamespace(vtx.name);
|
|
52
|
+
const known = namespace !== undefined
|
|
53
|
+
? deps.getDependency(namespace)?.has(name) === true
|
|
54
|
+
: deps.getDependencies().some(p => p.has(name));
|
|
55
|
+
if (known) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const loc = range_1.SourceLocation.fromNode(element.node);
|
|
59
|
+
return loc === undefined ? undefined : {
|
|
60
|
+
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
61
|
+
name,
|
|
62
|
+
involvedId: vtx.id,
|
|
63
|
+
loc
|
|
64
|
+
};
|
|
65
|
+
}).filter(assert_1.isNotUndefined);
|
|
66
|
+
return { results, '.meta': meta };
|
|
67
|
+
},
|
|
68
|
+
prettyPrint: {
|
|
69
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Call to \`${result.name}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
70
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => `\`${result.name}\` at ${range_1.SourceLocation.format(result.loc)} is neither defined locally nor exported by a loaded package`
|
|
71
|
+
},
|
|
72
|
+
info: {
|
|
73
|
+
name: 'Undefined Symbol',
|
|
74
|
+
certainty: linter_format_1.LintingRuleCertainty.OverApproximative,
|
|
75
|
+
description: 'Flags calls to functions that are neither defined locally, a known builtin, nor exported by a loaded package.',
|
|
76
|
+
tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Experimental],
|
|
77
|
+
defaultConfig: {}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=undefined-symbol.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.1",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
"main-dev": "node -r ts-node/register --watch src/cli/flowr.ts",
|
|
20
20
|
"publish-library": "cp .npmignore package.json README.md LICENSE dist/src/ && cd dist/src && npm publish --access public",
|
|
21
21
|
"release": "npx release-it --ci",
|
|
22
|
-
"stats": "ts-node src/cli/statistics-app.ts",
|
|
23
|
-
"stats-helper": "ts-node src/cli/statistics-helper-app.ts",
|
|
24
22
|
"slicer": "ts-node src/cli/slicer-app.ts",
|
|
25
23
|
"benchmark-helper": "ts-node src/cli/benchmark-helper-app.ts",
|
|
26
24
|
"benchmark": "npm run build-dev && node dist/src/cli/benchmark-app.js",
|
|
@@ -29,7 +27,8 @@
|
|
|
29
27
|
"capabilities-markdown": "ts-node src/documentation/doc-capabilities.ts",
|
|
30
28
|
"wiki": "ts-node src/cli/wiki.ts",
|
|
31
29
|
"wiki:watch": "node -r ts-node/register --watch src/cli/wiki.ts --keep-alive",
|
|
32
|
-
"build": "tsc --project .",
|
|
30
|
+
"build": "tsc --project . && npm run build:copy-data",
|
|
31
|
+
"build:copy-data": "node scripts/pkgdb-compress.mjs",
|
|
33
32
|
"build-dev": "npm run build && npm run build:copy-wasm",
|
|
34
33
|
"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",
|
|
35
34
|
"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/",
|
|
@@ -46,6 +45,7 @@
|
|
|
46
45
|
"test-full": "npm run test:coverage -- --no-watch -- --make-summary --test-installation",
|
|
47
46
|
"performance-test": "func() { cd test/performance/ && bash run-all-suites.sh $1 $2 $3 $4; cd ../../; }; func",
|
|
48
47
|
"test:performance": "npm run performance-test --",
|
|
48
|
+
"test:docker": "func() { for df in scripts/Dockerfile scripts/Dockerfile-NoR; do echo \"=== building $df ===\"; docker build -t flowr-docker-test -f \"$df\" . || return 1; echo \"=== smoke-testing $df ===\"; docker run --rm flowr-docker-test --version || return 1; done; }; func",
|
|
49
49
|
"detect-circular-deps": "npx madge --extensions ts,tsx --circular src/",
|
|
50
50
|
"checkup": "npm run flowr -- --execute \":version\" && npm run lint && npm run test-full -- --allowOnly=false && npm run test:system -- --no-watch && docker build -t test-flowr -f scripts/Dockerfile . && npm run doc && npm run wiki"
|
|
51
51
|
},
|
|
@@ -27,6 +27,8 @@ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends Flow
|
|
|
27
27
|
private callGraphCache;
|
|
28
28
|
protected constructor(args: FlowrAnalyzerCacheOptions<Parser>);
|
|
29
29
|
private initCacheProviders;
|
|
30
|
+
/** Free the current parse trees: tree-sitter trees live on the WASM heap, which the GC does not reclaim. */
|
|
31
|
+
private disposeParse;
|
|
30
32
|
static create<Parser extends KnownParser>(data: FlowrAnalyzerCacheOptions<Parser>): FlowrAnalyzerCache<Parser>;
|
|
31
33
|
receive(event: CacheInvalidationEvent): void;
|
|
32
34
|
private get;
|
|
@@ -28,13 +28,21 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
28
28
|
this.controlFlowCache = new flowr_analyzer_controlflow_cache_1.FlowrAnalyzerControlFlowCache();
|
|
29
29
|
this.callGraphCache = undefined;
|
|
30
30
|
}
|
|
31
|
+
/** Free the current parse trees: tree-sitter trees live on the WASM heap, which the GC does not reclaim. */
|
|
32
|
+
disposeParse() {
|
|
33
|
+
const files = this.peekParse()?.files;
|
|
34
|
+
for (const file of files ?? []) {
|
|
35
|
+
file.parsed?.delete?.();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
31
38
|
static create(data) {
|
|
32
39
|
return new FlowrAnalyzerCache(data);
|
|
33
40
|
}
|
|
34
41
|
receive(event) {
|
|
35
|
-
super.receive(event);
|
|
36
42
|
switch (event.type) {
|
|
37
43
|
case "full" /* CacheInvalidationEventType.Full */:
|
|
44
|
+
this.disposeParse();
|
|
45
|
+
super.receive(event);
|
|
38
46
|
this.initCacheProviders();
|
|
39
47
|
break;
|
|
40
48
|
default:
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
|
|
2
|
-
import { FlowrAnalyzerPackageVersionsPlugin } from '../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin';
|
|
2
|
+
import { FlowrAnalyzerPackageVersionsPlugin, type PkgDbLoadedInfo } from '../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin';
|
|
3
3
|
import type { Package } from '../plugins/package-version-plugins/package';
|
|
4
4
|
import type { FlowrAnalyzerFunctionsContext, ReadOnlyFlowrAnalyzerFunctionsContext } from './flowr-analyzer-functions-context';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* It prevents you from modifying the dependencies, but allows you to inspect them (which is probably what you want when using the {@link FlowrAnalyzer}).
|
|
8
|
-
* If you are a {@link FlowrAnalyzerPackageVersionsPlugin} and want to modify the dependencies, you can use the {@link FlowrAnalyzerDependenciesContext} directly.
|
|
6
|
+
* Read-only interface to the {@link FlowrAnalyzerDependenciesContext} for inspecting dependencies without modifying them.
|
|
9
7
|
*/
|
|
10
8
|
export interface ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
11
9
|
/**
|
|
@@ -28,21 +26,31 @@ export interface ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
|
28
26
|
* Get all dependencies known to this context.
|
|
29
27
|
*/
|
|
30
28
|
getDependencies(): readonly Readonly<Package>[];
|
|
29
|
+
/**
|
|
30
|
+
* Metadata of the package databases the version plugins currently have loaded.
|
|
31
|
+
*/
|
|
32
|
+
loadedPackageDatabases(): PkgDbLoadedInfo[];
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* If you are interested in inspecting these dependencies, refer to {@link ReadOnlyFlowrAnalyzerDependenciesContext}.
|
|
35
|
+
* Manages the project's dependencies, their versions, and their interplay with {@link FlowrAnalyzerPackageVersionsPlugin}s.
|
|
36
36
|
*/
|
|
37
37
|
export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerPackageVersionsPlugin> implements ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
38
38
|
readonly name = "flowr-analyzer-dependencies-context";
|
|
39
39
|
readonly functionsContext: FlowrAnalyzerFunctionsContext;
|
|
40
40
|
private dependencies;
|
|
41
41
|
private staticsLoaded;
|
|
42
|
+
/** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
|
|
43
|
+
private lazyResolvers;
|
|
44
|
+
private resolvedMisses;
|
|
42
45
|
reset(): void;
|
|
46
|
+
/** Register a resolver consulted by {@link getDependency} to fill in a package's exports lazily. */
|
|
47
|
+
addLazyResolver(resolver: (name: string, existing?: Package) => Package | undefined): void;
|
|
48
|
+
loadedPackageDatabases(): PkgDbLoadedInfo[];
|
|
49
|
+
/** Eagerly mount every version plugin's package database up front (see `solver.pkgdb.eagerlyLoad`). */
|
|
50
|
+
eagerlyLoadPackageDatabases(): void;
|
|
43
51
|
constructor(functionsContext: FlowrAnalyzerFunctionsContext, plugins?: readonly FlowrAnalyzerPackageVersionsPlugin[]);
|
|
44
52
|
resolveStaticDependencies(): void;
|
|
45
|
-
addDependency(pkg: Package):
|
|
53
|
+
addDependency(pkg: Package): this;
|
|
46
54
|
getDependency(name: string): Package | undefined;
|
|
47
55
|
getDependencies(): Package[];
|
|
48
56
|
}
|
|
@@ -4,18 +4,37 @@ exports.FlowrAnalyzerDependenciesContext = void 0;
|
|
|
4
4
|
const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
|
|
5
5
|
const flowr_analyzer_package_versions_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* If you are interested in inspecting these dependencies, refer to {@link ReadOnlyFlowrAnalyzerDependenciesContext}.
|
|
7
|
+
* Manages the project's dependencies, their versions, and their interplay with {@link FlowrAnalyzerPackageVersionsPlugin}s.
|
|
10
8
|
*/
|
|
11
9
|
class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1.AbstractFlowrAnalyzerContext {
|
|
12
10
|
name = 'flowr-analyzer-dependencies-context';
|
|
13
11
|
functionsContext;
|
|
14
12
|
dependencies = new Map();
|
|
15
13
|
staticsLoaded = false;
|
|
14
|
+
/** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
|
|
15
|
+
lazyResolvers = [];
|
|
16
|
+
resolvedMisses = new Set();
|
|
16
17
|
reset() {
|
|
17
18
|
this.dependencies = new Map();
|
|
18
19
|
this.staticsLoaded = false;
|
|
20
|
+
this.lazyResolvers = [];
|
|
21
|
+
this.resolvedMisses = new Set();
|
|
22
|
+
}
|
|
23
|
+
/** Register a resolver consulted by {@link getDependency} to fill in a package's exports lazily. */
|
|
24
|
+
addLazyResolver(resolver) {
|
|
25
|
+
this.lazyResolvers.push(resolver);
|
|
26
|
+
}
|
|
27
|
+
loadedPackageDatabases() {
|
|
28
|
+
if (!this.ctx.config.solver.pkgdb.enabled) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
return this.plugins.flatMap(p => p.loadedDatabases());
|
|
32
|
+
}
|
|
33
|
+
/** Eagerly mount every version plugin's package database up front (see `solver.pkgdb.eagerlyLoad`). */
|
|
34
|
+
eagerlyLoadPackageDatabases() {
|
|
35
|
+
for (const p of this.plugins) {
|
|
36
|
+
p.preloadDatabasesSync();
|
|
37
|
+
}
|
|
19
38
|
}
|
|
20
39
|
constructor(functionsContext, plugins) {
|
|
21
40
|
super(functionsContext.getAttachedContext(), flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin.defaultPlugin(), plugins);
|
|
@@ -33,12 +52,28 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
33
52
|
else {
|
|
34
53
|
this.dependencies.set(pkg.name, pkg);
|
|
35
54
|
}
|
|
55
|
+
return this;
|
|
36
56
|
}
|
|
37
57
|
getDependency(name) {
|
|
38
58
|
if (!this.staticsLoaded) {
|
|
39
59
|
this.resolveStaticDependencies();
|
|
40
60
|
}
|
|
41
|
-
|
|
61
|
+
const existing = this.dependencies.get(name);
|
|
62
|
+
// a package already carrying exports is complete; a version-only one is still enriched below
|
|
63
|
+
if (existing?.namespaceInfo || (!existing && this.resolvedMisses.has(name))) {
|
|
64
|
+
return existing;
|
|
65
|
+
}
|
|
66
|
+
if (!this.resolvedMisses.has(name)) {
|
|
67
|
+
for (const resolve of this.lazyResolvers) {
|
|
68
|
+
const resolved = resolve(name, existing);
|
|
69
|
+
if (resolved) {
|
|
70
|
+
this.addDependency(resolved); // merges exports into any existing version info
|
|
71
|
+
return this.dependencies.get(name);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
this.resolvedMisses.add(name);
|
|
75
|
+
}
|
|
76
|
+
return existing;
|
|
42
77
|
}
|
|
43
78
|
getDependencies() {
|
|
44
79
|
if (!this.staticsLoaded) {
|
|
@@ -3,8 +3,7 @@ import type { IEnvironment, REnvironmentInformation } from '../../dataflow/envir
|
|
|
3
3
|
import type { DeepReadonly } from 'ts-essentials';
|
|
4
4
|
import type { Fingerprint } from '../../slicing/static/fingerprint';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* which provides access to the built-in environment used during analysis.
|
|
6
|
+
* Read-only interface to the {@link FlowrAnalyzerEnvironmentContext}.
|
|
8
7
|
*/
|
|
9
8
|
export interface ReadOnlyFlowrAnalyzerEnvironmentContext {
|
|
10
9
|
/**
|
|
@@ -34,8 +33,7 @@ export interface ReadOnlyFlowrAnalyzerEnvironmentContext {
|
|
|
34
33
|
makeEmptyEnv(): REnvironmentInformation;
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
38
|
-
* It creates the built-in environment based on the configuration provided in the {@link FlowrAnalyzerContext}.
|
|
36
|
+
* Provides the built-in environment, created from the {@link FlowrAnalyzerContext} configuration.
|
|
39
37
|
*/
|
|
40
38
|
export declare class FlowrAnalyzerEnvironmentContext implements ReadOnlyFlowrAnalyzerEnvironmentContext {
|
|
41
39
|
readonly name = "flowr-analyzer-environment-context";
|