@eagleoutice/flowr 2.11.1 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -263
- 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 +3 -1
- 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 +19 -1
- 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/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 +10 -1
- package/queries/query.js +5 -2
- 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 +22 -4
- package/slicing/criterion/parse.js +125 -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
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WikiSignatureDatabase = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
10
|
+
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
11
|
+
const doc_files_1 = require("./doc-util/doc-files");
|
|
12
|
+
const reader_1 = require("../project/sigdb/reader");
|
|
13
|
+
const schema_1 = require("../project/sigdb/schema");
|
|
14
|
+
const manifest_1 = require("../project/sigdb/manifest");
|
|
15
|
+
const config_1 = require("../config");
|
|
16
|
+
const flowr_analyzer_package_versions_sigdb_plugin_1 = require("../project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin");
|
|
17
|
+
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
18
|
+
function cranDatabaseAvailable() {
|
|
19
|
+
return (0, manifest_1.defaultSigDbPath)('current') !== undefined || (0, manifest_1.defaultSigDbPath)('full') !== undefined;
|
|
20
|
+
}
|
|
21
|
+
/** point the resolver at your own database (a file path or manifest) */
|
|
22
|
+
function usePackageDatabase(parser) {
|
|
23
|
+
const sigdb = new flowr_analyzer_package_versions_sigdb_plugin_1.FlowrAnalyzerPackageVersionsSigDbPlugin('/path/to/sigs.manifest.json.br');
|
|
24
|
+
return new flowr_analyzer_builder_1.FlowrAnalyzerBuilder().setParser(parser).registerPlugins(sigdb).build();
|
|
25
|
+
}
|
|
26
|
+
/** a coarse duration in short units (`µs`/`ms`); we only ever quote estimates, never false precision */
|
|
27
|
+
function roughDuration(ms) {
|
|
28
|
+
if (ms < 0.001) {
|
|
29
|
+
return '<1 µs';
|
|
30
|
+
}
|
|
31
|
+
if (ms < 1) {
|
|
32
|
+
return `${Number((ms * 1000).toPrecision(2))} µs`;
|
|
33
|
+
}
|
|
34
|
+
return `${Number(ms.toPrecision(2))} ms`;
|
|
35
|
+
}
|
|
36
|
+
async function measurePerformance() {
|
|
37
|
+
const src = (0, manifest_1.defaultSigDbPath)();
|
|
38
|
+
if (src === undefined) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const t0 = Date.now();
|
|
43
|
+
const db = src.endsWith('.manifest.json') || src.endsWith('.manifest.json.br')
|
|
44
|
+
? await reader_1.SigDatabaseSet.openManifest(src)
|
|
45
|
+
: await reader_1.SigDatabase.open(src);
|
|
46
|
+
const loadMs = Date.now() - t0;
|
|
47
|
+
const names = db.packageNames();
|
|
48
|
+
const sample = [0, 0.25, 0.5, 0.75, 0.99].map(f => names[Math.min(names.length - 1, Math.floor(f * names.length))]);
|
|
49
|
+
for (const n of sample) {
|
|
50
|
+
db.lookup(n);
|
|
51
|
+
}
|
|
52
|
+
const iterations = sample.length * 4;
|
|
53
|
+
const t1 = process.hrtime.bigint();
|
|
54
|
+
for (let i = 0; i < iterations; i++) {
|
|
55
|
+
db.lookup(sample[i % sample.length]);
|
|
56
|
+
}
|
|
57
|
+
const perLookupMs = Number(process.hrtime.bigint() - t1) / iterations / 1e6;
|
|
58
|
+
db.close();
|
|
59
|
+
return `Measured here at generation time: opening the bundle took ${roughDuration(loadMs)}, and a warmed`
|
|
60
|
+
+ ` per-package export lookup takes ${roughDuration(perLookupMs)}. Each \`library()\` or \`::\` in a script`
|
|
61
|
+
+ ' is then one cached lookup.';
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** group an integer into thousands with commas, deterministically (locale-independent) */
|
|
68
|
+
function groupThousands(n) {
|
|
69
|
+
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
70
|
+
}
|
|
71
|
+
/** a coarse, human-readable byte size (`.br` sizes only ever quoted approximately) */
|
|
72
|
+
function humanBytes(bytes) {
|
|
73
|
+
if (bytes < 1024) {
|
|
74
|
+
return `${bytes} B`;
|
|
75
|
+
}
|
|
76
|
+
const kb = bytes / 1024;
|
|
77
|
+
if (kb < 1024) {
|
|
78
|
+
return `${Math.round(kb)} KB`;
|
|
79
|
+
}
|
|
80
|
+
return `${(kb / 1024).toFixed(1)} MB`;
|
|
81
|
+
}
|
|
82
|
+
/** what a shard holds, derived from its id and popularity split (base R, the top-N CRAN packages, or the rest) */
|
|
83
|
+
function shardContents(s) {
|
|
84
|
+
if (s.id.startsWith('base')) {
|
|
85
|
+
return 'base-R packages (`base`, `stats`, `graphics`, ...)';
|
|
86
|
+
}
|
|
87
|
+
if (s.shard === 'top') {
|
|
88
|
+
return `the ${groupThousands(s.topN ?? s.packages)} most-downloaded CRAN packages`;
|
|
89
|
+
}
|
|
90
|
+
if (s.shard === 'rest') {
|
|
91
|
+
return 'the remaining CRAN packages';
|
|
92
|
+
}
|
|
93
|
+
return 'CRAN packages';
|
|
94
|
+
}
|
|
95
|
+
/** how many versions a tier keeps per package */
|
|
96
|
+
function tierHistory(s) {
|
|
97
|
+
return s.tier === 'current' ? 'latest only' : 'full history';
|
|
98
|
+
}
|
|
99
|
+
/** resolve a manifest-relative source to its shipped file, preferring the compressed `.br` */
|
|
100
|
+
function resolveShipped(baseDir, rel) {
|
|
101
|
+
for (const candidate of [path_1.default.resolve(baseDir, rel + '.br'), path_1.default.resolve(baseDir, rel)]) {
|
|
102
|
+
if (fs_1.default.existsSync(candidate)) {
|
|
103
|
+
return candidate;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
/** time (at generation time) how long it takes to decompress one shipped `.br`, i.e. its first-touch load cost */
|
|
109
|
+
function measureLoad(file) {
|
|
110
|
+
if (!file.endsWith('.br')) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const raw = fs_1.default.readFileSync(file);
|
|
115
|
+
const t0 = Date.now();
|
|
116
|
+
zlib_1.default.brotliDecompressSync(raw, { params: { [zlib_1.default.constants.BROTLI_DECODER_PARAM_LARGE_WINDOW]: 1 } });
|
|
117
|
+
return Date.now() - t0;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A table of the databases the default bundle actually ships, read -- at generation time, never hardcoded --
|
|
125
|
+
* from the manifests. Each shard becomes a row (contents, retained history, package and version counts, its
|
|
126
|
+
* on-disk size, and the measured cost of decompressing it on first touch). Every bundled manifest is unioned
|
|
127
|
+
* (deduped by shard/dictionary id), so the separate `history` manifest's shards show up alongside `current`,
|
|
128
|
+
* matching what the runtime actually mounts. `undefined` when no bundled manifest is present (e.g. a checkout
|
|
129
|
+
* without generated data).
|
|
130
|
+
*/
|
|
131
|
+
function bundledDatabaseTable() {
|
|
132
|
+
const manifestPaths = (0, manifest_1.defaultSigDbPaths)().filter(p => /\.manifest\.json(\.br)?$/.test(p));
|
|
133
|
+
if (manifestPaths.length === 0) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
const sizeOf = (file) => file ? humanBytes(fs_1.default.statSync(file).size) : 'n/a';
|
|
137
|
+
const loadOf = (file) => {
|
|
138
|
+
const load = file ? measureLoad(file) : undefined;
|
|
139
|
+
return load !== undefined ? `≈ ${roughDuration(load)}` : 'n/a';
|
|
140
|
+
};
|
|
141
|
+
const shardRows = [];
|
|
142
|
+
const dictRows = [];
|
|
143
|
+
const seenShards = new Set();
|
|
144
|
+
const seenDicts = new Set();
|
|
145
|
+
for (const manifestPath of manifestPaths) {
|
|
146
|
+
let shards;
|
|
147
|
+
let dicts;
|
|
148
|
+
try {
|
|
149
|
+
const manifest = (0, manifest_1.readManifestFile)(manifestPath);
|
|
150
|
+
shards = manifest.shards;
|
|
151
|
+
dicts = manifest.dicts ?? [];
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const baseDir = path_1.default.dirname(manifestPath);
|
|
157
|
+
for (const s of shards) {
|
|
158
|
+
if (seenShards.has(s.id)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
seenShards.add(s.id);
|
|
162
|
+
const file = resolveShipped(baseDir, s.path);
|
|
163
|
+
shardRows.push(`| \`${s.id}\` | ${shardContents(s)} | ${tierHistory(s)} | ${groupThousands(s.packages)} | ${groupThousands(s.versions)} | ${sizeOf(file)} | ${loadOf(file)} |`);
|
|
164
|
+
}
|
|
165
|
+
for (const d of dicts) {
|
|
166
|
+
// every manifest names its dict id `shared`; the files differ per scope, so dedupe (and label) by path
|
|
167
|
+
if (seenDicts.has(d.path)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
seenDicts.add(d.path);
|
|
171
|
+
const file = resolveShipped(baseDir, d.path);
|
|
172
|
+
const label = path_1.default.basename(d.path).replace(/\.sigs\.ndjson$/, '');
|
|
173
|
+
dictRows.push(`| \`${label}\` | ${groupThousands(d.strings)} shared strings | - | - | - | ${sizeOf(file)} | ${loadOf(file)} |`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (shardRows.length === 0) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
return `| Shard | Contents | Versions kept | Packages | Versions | Size (\`.br\`) | Load (first touch) |
|
|
180
|
+
|-------|----------|---------------|---------:|---------:|-------------:|-------------------:|
|
|
181
|
+
${[...shardRows, ...dictRows].join('\n')}`;
|
|
182
|
+
}
|
|
183
|
+
/** link a built-in plugin key (e.g. `versions:sigdb`) to its registration */
|
|
184
|
+
function pluginLink(key) {
|
|
185
|
+
return `[\`${key}\`](${doc_files_1.RemoteFlowrFilePathBaseRef}src/project/plugins/plugin-registry.ts)`;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* https://github.com/flowr-analysis/flowr/wiki/Package-Database
|
|
189
|
+
*/
|
|
190
|
+
class WikiSignatureDatabase extends doc_maker_1.DocMaker {
|
|
191
|
+
constructor() {
|
|
192
|
+
super('wiki/Signature Database.md', module.filename, 'bundled signature database that resolves `library()` calls');
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Regenerate only when the CRAN shards are actually present. A fresh checkout (and every CI run) ships no shards
|
|
196
|
+
* at all until they are downloaded, and this page documents the *CRAN* database: regenerating without them would
|
|
197
|
+
* replace the shard table and figures with empty/base-only numbers and publish that over the real page. Skipping
|
|
198
|
+
* leaves the committed page untouched, so the workflow reports no change and publishes nothing.
|
|
199
|
+
*/
|
|
200
|
+
async make(args) {
|
|
201
|
+
if (!cranDatabaseAvailable()) {
|
|
202
|
+
console.log(` [${this.getTarget()}] skipped: no CRAN sigdb present (not downloaded); keeping the committed page`);
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return super.make(args);
|
|
206
|
+
}
|
|
207
|
+
async text({ ctx }) {
|
|
208
|
+
const performance = await measurePerformance();
|
|
209
|
+
const databases = bundledDatabaseTable();
|
|
210
|
+
return `
|
|
211
|
+
|
|
212
|
+
# Signature Database
|
|
213
|
+
|
|
214
|
+
flowR ships a database of the complete history of all exports in every version of all CRAN packages so it can resolve calls into the packages you load.
|
|
215
|
+
After \`library(ggplot2)\`, a call to \`ggplot()\` resolves to \`ggplot2::ggplot\`. The same database
|
|
216
|
+
qualifies bare names and backs various components like the ${ctx.linkPage('wiki/Query API', 'dependencies and call-context queries')}
|
|
217
|
+
as well as the ${ctx.linkPage('wiki/Linter', 'undefined symbol')} rule.
|
|
218
|
+
|
|
219
|
+
## Configuration
|
|
220
|
+
|
|
221
|
+
The exports come from ${pluginLink('versions:sigdb')}, which reads bundled databases. It is enabled by
|
|
222
|
+
default (see ${ctx.linkPage('wiki/Interface', 'configuring flowR', 'configuring-flowr')}).
|
|
223
|
+
|
|
224
|
+
*Which* version's exports get resolved is decided by the version-reading plugins that pin the packages a
|
|
225
|
+
project uses.
|
|
226
|
+
|
|
227
|
+
${ctx.code(usePackageDatabase, { dropLinesStart: 1 })}
|
|
228
|
+
|
|
229
|
+
File sources load lazily on the first package load, so a script with no \`library()\` or \`use()\` calls
|
|
230
|
+
never pays to parse them. Set ${ctx.linkConfig('solver.sigdb.eagerlyLoad')} to mount the database up front instead, or
|
|
231
|
+
${ctx.linkConfig('solver.sigdb.enabled')} to \`false\` to switch it off entirely. For a compressed (\`.br\`) or manifest source,
|
|
232
|
+
${ctx.linkM(flowr_analyzer_package_versions_sigdb_plugin_1.FlowrAnalyzerPackageVersionsSigDbPlugin, 'preload', { hideClass: true })} it before analysis to mount it.
|
|
233
|
+
|
|
234
|
+
The base-R packages (\`base\`, \`stats\`, \`graphics\`, ...) resolve against an assumed R version, which
|
|
235
|
+
defaults to \`${config_1.DefaultAssumedRVersion}\` (${ctx.linkConfig('solver.sigdb.assumedRVersion')}, or \`"auto"\` to detect the local R).
|
|
236
|
+
So \`library(stats)\` attaches that release's exports, and a bare \`sd()\` qualifies to \`stats::sd\` even
|
|
237
|
+
without attaching the base namespaces to the graph. Set ${ctx.linkConfig('solver.sigdb.linkBaseR')} to also link them as
|
|
238
|
+
dataflow edges.
|
|
239
|
+
|
|
240
|
+
**No** signature shards are committed: the \`base.*\` floor (self-contained base-R signatures, a few hundred KB), the
|
|
241
|
+
\`current.*\` scope (every package's latest version) and \`history.*\` (every older version) all live as assets on the
|
|
242
|
+
free ${ctx.linkConfig('solver.sigdb.downloadRepo')} GitHub release. The only committed file is a tiny **link file**,
|
|
243
|
+
\`src/data/sigdb/sigdb.remote.json\`, which records the release tag and each shard's sha256 and size, so
|
|
244
|
+
\`:signature download\` builds the direct release-CDN URL (no API rate limit), verifies every shard by content hash,
|
|
245
|
+
and skips any already cached. Because the link file is versioned, a \`git pull\` that updates it re-syncs only the
|
|
246
|
+
shards whose hash changed — and with ${ctx.linkConfig('solver.sigdb.autoSync')} that check runs on startup and re-downloads in the
|
|
247
|
+
background; \`npm run build\` bakes the shards in as well. The richest downloaded scope is used (order \`full\` >
|
|
248
|
+
\`current\` > \`base\`), so once fetched \`library(stats)\` resolves. Any path in ${ctx.linkConfig('solver.sigdb.additionalPaths')} (or
|
|
249
|
+
\`$FLOWR_SIGDB_DIR\`) is searched alongside the default, so a downloaded bundle stays mounted on every start.
|
|
250
|
+
${databases ? `
|
|
251
|
+
## Bundled Databases
|
|
252
|
+
|
|
253
|
+
The default bundle is not a single file but a set of shards that a manifest routes between (see
|
|
254
|
+
${ctx.link(reader_1.SigDatabaseSet)}). Nothing is read when the manifest opens. The first lookup of a package
|
|
255
|
+
decompresses only the one shard that holds it, plus the shared dictionary once. The following ship with this
|
|
256
|
+
build; the load column is the decompression time measured at generation time.
|
|
257
|
+
|
|
258
|
+
${databases}
|
|
259
|
+
|
|
260
|
+
Which shard answers a lookup follows from the package and the version asked for. A base-R package comes from
|
|
261
|
+
\`base-current\`, one of the 1,000 most-downloaded CRAN packages from \`current-top\`, and anything else from
|
|
262
|
+
\`current-rest\`. The \`*-full\` and \`history-*\` shards hold every historical version and are only touched when
|
|
263
|
+
an older, pinned version is requested, so a normal analysis never decompresses them. Each scope carries its own
|
|
264
|
+
shared dictionary that its shards depend on, so it is decompressed the first time any of its packages is looked up and then reused.
|
|
265
|
+
The flowR Docker images ship this dictionary already decompressed, so a container reads it in place and skips
|
|
266
|
+
that step (the load column above is the cost a plain npm install pays).
|
|
267
|
+
|
|
268
|
+
Every shard, dictionary, and manifest is published in both brotli (\`.br\`) and zstd (\`.zst\`, faster to decompress) compression, and flowR uses whichever the runtime supports: \`.zst\` when the Node version exposes [zstd](https://nodejs.org/api/zlib.html#zstd) (Node ≥ 22.15), otherwise \`.br\`. \`:signature download\` fetches only that one variant per file, and \`:version\` reports the format each loaded database resolved to.
|
|
269
|
+
` : ''}
|
|
270
|
+
## Format
|
|
271
|
+
|
|
272
|
+
The on-disk format is \`flowr-sigdb\` (schema ${schema_1.SigDbSchema}). Beyond each version's exports it records, per
|
|
273
|
+
version, every function's signature (parameters, whether each is forced or optional, and its default) and
|
|
274
|
+
call graph, together with that version's declared dependencies (\`Depends\`, \`Imports\`, ... with their
|
|
275
|
+
version qualifiers). The layout is NDJSON: a header, then a shared string dictionary, then one
|
|
276
|
+
self-contained blob per package, next to a sidecar \`.idx\`. A reader (${ctx.link(reader_1.SigDatabase)}) therefore
|
|
277
|
+
loads the dictionary once and then **seeks straight to the packages it needs**, never reading the rest.
|
|
278
|
+
The bundle is written by ${ctx.link('SigDbBuilder')} and can be split into several small shards (current-only
|
|
279
|
+
versus full history, top-N versus the rest) that a \`flowr-sigdb-manifest\` routes transparently
|
|
280
|
+
(${ctx.link(reader_1.SigDatabaseSet)}), and which information gets stored is selectable (${ctx.link('SigDbFeatures')}).
|
|
281
|
+
crawlr produces the bundle from its analysis of CRAN.
|
|
282
|
+
|
|
283
|
+
## Performance
|
|
284
|
+
|
|
285
|
+
The dictionary is read once, the reader then seeks straight to each requested package, and consumers cache
|
|
286
|
+
what they derive (the \`base\`-package list is precomputed when flowR is bundled, so it costs nothing at
|
|
287
|
+
analysis time). ${performance ??
|
|
288
|
+
'After the one-time load a per-package lookup is O(1), so each `library()` or `::` a script uses is a single cached lookup.'}
|
|
289
|
+
`.trim();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
exports.WikiSignatureDatabase = WikiSignatureDatabase;
|
|
293
|
+
//# sourceMappingURL=wiki-signature-database.js.map
|
|
@@ -31,6 +31,13 @@ export interface LinterRuleInformation<Config extends MergeableRecord = never> {
|
|
|
31
31
|
* This is used to display the rule in the UI and to provide a brief overview of what the rule does.
|
|
32
32
|
*/
|
|
33
33
|
readonly description: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the rule runs when a linter query does not explicitly list any rules.
|
|
36
|
+
* Defaults to `true` when omitted. Set to `false` for noisy or heuristic rules
|
|
37
|
+
* that should only run when requested explicitly (an explicit rule list overrides this flag).
|
|
38
|
+
* @see {@link executeLinterQuery} - reads this flag to pick the default rule set
|
|
39
|
+
*/
|
|
40
|
+
readonly activeByDefault?: boolean;
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
43
|
* The base interface for a linting rule, which contains all of its relevant settings.
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ export declare const LintingRules: {
|
|
|
125
125
|
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
126
126
|
readonly defaultConfig: {
|
|
127
127
|
readonly includeFunctionDefinitions: true;
|
|
128
|
+
readonly excludeExportedDefinitions: true;
|
|
128
129
|
};
|
|
129
130
|
};
|
|
130
131
|
};
|
|
@@ -146,6 +147,7 @@ export declare const LintingRules: {
|
|
|
146
147
|
readonly certainty: import("./linter-format").LintingRuleCertainty.OverApproximative;
|
|
147
148
|
readonly description: "Checks whether the symbols conform to a certain naming convention";
|
|
148
149
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Style, import("./linter-tags").LintingRuleTag.QuickFix];
|
|
150
|
+
readonly activeByDefault: false;
|
|
149
151
|
readonly defaultConfig: {
|
|
150
152
|
readonly caseing: "auto";
|
|
151
153
|
readonly ignoreNonAlpha: true;
|
|
@@ -359,13 +361,8 @@ export declare const LintingRules: {
|
|
|
359
361
|
};
|
|
360
362
|
readonly 'undefined-symbol': {
|
|
361
363
|
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("
|
|
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
|
-
}[];
|
|
364
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/undefined-symbol").UndefinedSymbolConfig, data: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>) => Promise<{
|
|
365
|
+
results: import("./rules/undefined-symbol").UndefinedSymbolResult[];
|
|
369
366
|
'.meta': import("./rules/undefined-symbol").UndefinedSymbolMetadata;
|
|
370
367
|
}>;
|
|
371
368
|
readonly prettyPrint: {
|
|
@@ -375,9 +372,13 @@ export declare const LintingRules: {
|
|
|
375
372
|
readonly info: {
|
|
376
373
|
readonly name: "Undefined Symbol";
|
|
377
374
|
readonly certainty: import("./linter-format").LintingRuleCertainty.OverApproximative;
|
|
378
|
-
readonly description: "Flags
|
|
375
|
+
readonly description: "Flags functions and variables that are neither defined locally, a base R builtin, nor exported by a loaded package.";
|
|
379
376
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Experimental];
|
|
380
|
-
readonly defaultConfig: {
|
|
377
|
+
readonly defaultConfig: {
|
|
378
|
+
readonly checkFunctions: true;
|
|
379
|
+
readonly checkVariables: true;
|
|
380
|
+
readonly checkSubscripts: false;
|
|
381
|
+
};
|
|
381
382
|
};
|
|
382
383
|
};
|
|
383
384
|
};
|
|
@@ -74,6 +74,7 @@ export declare const NAMING_CONVENTION: {
|
|
|
74
74
|
readonly certainty: LintingRuleCertainty.OverApproximative;
|
|
75
75
|
readonly description: "Checks whether the symbols conform to a certain naming convention";
|
|
76
76
|
readonly tags: readonly [LintingRuleTag.Style, LintingRuleTag.QuickFix];
|
|
77
|
+
readonly activeByDefault: false;
|
|
77
78
|
readonly defaultConfig: {
|
|
78
79
|
readonly caseing: "auto";
|
|
79
80
|
readonly ignoreNonAlpha: true;
|
|
@@ -197,6 +197,8 @@ exports.NAMING_CONVENTION = {
|
|
|
197
197
|
certainty: linter_format_1.LintingRuleCertainty.OverApproximative,
|
|
198
198
|
description: 'Checks whether the symbols conform to a certain naming convention',
|
|
199
199
|
tags: [linter_tags_1.LintingRuleTag.Style, linter_tags_1.LintingRuleTag.QuickFix],
|
|
200
|
+
// heuristic and noisy on real package code, so only run when requested explicitly
|
|
201
|
+
activeByDefault: false,
|
|
200
202
|
defaultConfig: {
|
|
201
203
|
caseing: 'auto',
|
|
202
204
|
ignoreNonAlpha: true
|
|
@@ -5,7 +5,6 @@ const linter_format_1 = require("../linter-format");
|
|
|
5
5
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
6
6
|
const range_1 = require("../../util/range");
|
|
7
7
|
const linter_tags_1 = require("../linter-tags");
|
|
8
|
-
const assert_1 = require("../../util/assert");
|
|
9
8
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
10
9
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
11
10
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
@@ -54,7 +53,7 @@ exports.NO_LEAKED_CREDENTIALS = {
|
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
return [];
|
|
57
|
-
})
|
|
56
|
+
});
|
|
58
57
|
return { results, '.meta': { totalChecked } };
|
|
59
58
|
},
|
|
60
59
|
prettyPrint: {
|
|
@@ -53,9 +53,6 @@ exports.ROXYGEN_ARGS = {
|
|
|
53
53
|
const functionParamNames = getParameters(element.node).map(p => p.name.content.toString());
|
|
54
54
|
const inheritedParams = params.filter(tag => tag.inherited).map(tag => tag.value.name);
|
|
55
55
|
const roxygenParamNames = params.map(tag => tag.value.name);
|
|
56
|
-
if (functionParamNames === null || roxygenParamNames == null) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
56
|
const result = calculateArgumentDiff(inheritedParams ?? [], functionParamNames, roxygenParamNames);
|
|
60
57
|
if (result === false) {
|
|
61
58
|
return false;
|
|
@@ -76,8 +73,8 @@ exports.ROXYGEN_ARGS = {
|
|
|
76
73
|
};
|
|
77
74
|
},
|
|
78
75
|
prettyPrint: {
|
|
79
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `
|
|
80
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `
|
|
76
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`,
|
|
77
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`
|
|
81
78
|
},
|
|
82
79
|
info: {
|
|
83
80
|
name: 'Roxygen Arguments',
|
|
@@ -90,4 +87,20 @@ exports.ROXYGEN_ARGS = {
|
|
|
90
87
|
function getParameters(node) {
|
|
91
88
|
return r_function_definition_1.RFunctionDefinition.is(node) ? node.parameters : [];
|
|
92
89
|
}
|
|
90
|
+
function quoteAll(names) {
|
|
91
|
+
return names.map(name => `'${name}'`).join(', ');
|
|
92
|
+
}
|
|
93
|
+
/** Describes the concrete mismatch between roxygen `@param` documentation and the actual function arguments. */
|
|
94
|
+
function describeArgumentDiff(result) {
|
|
95
|
+
const parts = [];
|
|
96
|
+
const under = result.underDocumented ?? [];
|
|
97
|
+
const over = result.overDocumented ?? [];
|
|
98
|
+
if (under.length > 0) {
|
|
99
|
+
parts.push(`undocumented argument${under.length > 1 ? 's' : ''} ${quoteAll(under)}`);
|
|
100
|
+
}
|
|
101
|
+
if (over.length > 0) {
|
|
102
|
+
parts.push(`documented @param${over.length > 1 ? 's' : ''} with no matching argument: ${quoteAll(over)}`);
|
|
103
|
+
}
|
|
104
|
+
return parts.join(', and ');
|
|
105
|
+
}
|
|
93
106
|
//# sourceMappingURL=roxygen-arguments.js.map
|
|
@@ -59,8 +59,8 @@ exports.STOP_WITH_CALL_ARG = {
|
|
|
59
59
|
};
|
|
60
60
|
},
|
|
61
61
|
prettyPrint: {
|
|
62
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result =>
|
|
63
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result =>
|
|
62
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `\`stop()\` without \`call. = FALSE\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
63
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => `\`stop()\` at ${range_1.SourceLocation.format(result.loc)} is called without \`call. = FALSE\`; the originating call is then appended to the error message, which is usually not intended - pass \`call. = FALSE\` to suppress it`,
|
|
64
64
|
},
|
|
65
65
|
info: {
|
|
66
66
|
name: 'Stop without call.=False argument',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DataflowGraph } from '../../dataflow/graph/graph';
|
|
2
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
|
+
/**
|
|
4
|
+
* Path heuristic for an R package `inst/` resource (installed verbatim, not namespace source). Fallback for
|
|
5
|
+
* the authoritative `FileRole.Install`, covering requests that bypass the file-role plugins.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isInstalledResourceFile(file: string | undefined): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the variable use `id` resolves to a local definition, a parameter, or a built-in (function or
|
|
10
|
+
* constant such as `T`, `pi`). Broader than `getOriginInDfg`, which misses built-in constants.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useResolvesToDefinitionOrBuiltin(graph: DataflowGraph, id: NodeId): boolean;
|
|
13
|
+
/** Whether any edge incident to `id` marks it as non-standard-evaluated (quoted), e.g. `quote`/`substitute`. */
|
|
14
|
+
export declare function isNonStandardEvaluated(graph: DataflowGraph, id: NodeId): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the use `id` sits inside a `[`/`[[` subscript (not the accessed object). `data.table`'s
|
|
17
|
+
* `DT[i, j, by]` masks the subscript symbols as columns, but flowR cannot tell this apart from ordinary
|
|
18
|
+
* indexing (`x[i]`), so the rule suppresses subscript symbols by default. Stops at the enclosing function.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isInSubscript(graph: DataflowGraph, id: NodeId): boolean;
|
|
21
|
+
/** The lexical scope a definition/use belongs to: the id of the enclosing function definition, or the top level. */
|
|
22
|
+
export type Scope = NodeId | 'top';
|
|
23
|
+
/** Names bound unconditionally within each lexical scope, see {@link collectScopeDefinedNames}. */
|
|
24
|
+
export type ScopeDefinedNames = ReadonlyMap<Scope, ReadonlySet<string>>;
|
|
25
|
+
/**
|
|
26
|
+
* Per scope, the names it binds unconditionally. flowR's static resolution does not always link a use in a
|
|
27
|
+
* nested function to a binding introduced later in an enclosing scope; the rule consults this as a fallback.
|
|
28
|
+
* Only unconditional bindings are recorded: one assigned solely inside an `if`/loop is not guaranteed to
|
|
29
|
+
* exist, so suppressing an unresolved use of it would hide a real possibly-undefined access.
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectScopeDefinedNames(graph: DataflowGraph): ScopeDefinedNames;
|
|
32
|
+
/**
|
|
33
|
+
* Whether `name` is bound in the scope of `useId` or an enclosing scope (up to the top level), per
|
|
34
|
+
* {@link collectScopeDefinedNames}. Suppresses forward-referenced closure variables flowR did not link.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isDefinedInEnclosingScope(graph: DataflowGraph, defined: ScopeDefinedNames, useId: NodeId, name: string): boolean;
|
|
@@ -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
|