@eagleoutice/flowr 2.13.0 → 2.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -23
- package/cli/common/options.d.ts +10 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +10 -0
- package/cli/flowr.js +21 -5
- package/cli/repl/commands/repl-commands.d.ts +8 -0
- package/cli/repl/commands/repl-commands.js +27 -12
- package/cli/repl/commands/repl-query.js +9 -1
- package/cli/repl/commands/repl-signature.js +8 -1
- package/cli/repl/core.js +13 -10
- package/cli/repl/print-version.js +1 -1
- package/cli/repl/server/connection.d.ts +1 -1
- package/cli/repl/server/net.js +15 -0
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +31 -0
- package/config.js +55 -2
- package/data/sigdb/sigdb.remote.json +1 -1
- package/dataflow/environments/identifier.d.ts +9 -8
- package/dataflow/environments/identifier.js +21 -13
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
- package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/df-helper.d.ts +3 -2
- package/dataflow/graph/df-helper.js +11 -15
- package/dataflow/graph/diff-dataflow-graph.js +1 -1
- package/dataflow/graph/graph-helper.js +2 -6
- package/dataflow/graph/graph.d.ts +24 -0
- package/dataflow/graph/graph.js +25 -1
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-mk/doc-context.d.ts +10 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-query.js +4 -3
- package/documentation/wiki-signature-database.js +16 -6
- package/linter/linter-rules.d.ts +24 -2
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +4 -4
- package/linter/rules/absolute-path.js +7 -5
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/file-path-validity.js +48 -8
- package/linter/rules/function-finder-util.d.ts +2 -1
- package/linter/rules/syntactically-valid.d.ts +58 -0
- package/linter/rules/syntactically-valid.js +203 -0
- package/linter/rules/undefined-symbol.js +3 -2
- package/package.json +5 -4
- package/project/context/classify-project-kind.d.ts +40 -0
- package/project/context/classify-project-kind.js +76 -0
- package/project/context/flowr-analyzer-context.d.ts +2 -0
- package/project/context/flowr-analyzer-context.js +6 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +23 -4
- package/project/context/flowr-analyzer-dependencies-context.js +23 -1
- package/project/context/flowr-analyzer-files-context.d.ts +18 -8
- package/project/context/flowr-analyzer-files-context.js +66 -68
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/dependency-version-space.d.ts +3 -1
- package/project/dependency-version-space.js +26 -20
- package/project/flowr-analyzer.d.ts +3 -0
- package/project/flowr-analyzer.js +4 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +4 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +4 -1
- package/project/sigdb/manifest.js +60 -26
- package/project/sigdb/sigdb-download.d.ts +6 -7
- package/project/sigdb/sigdb-download.js +30 -9
- package/queries/catalog/config-query/config-query-executor.js +3 -0
- package/queries/catalog/config-query/config-query-format.d.ts +5 -3
- package/queries/catalog/config-query/config-query-format.js +31 -21
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +0 -10
- package/queries/catalog/dependencies-query/dependencies-query-format.js +0 -106
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +21 -5
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +4 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -3
- package/queries/catalog/linter-query/linter-query-format.js +9 -2
- package/queries/catalog/signature-query/signature-query-executor.js +3 -0
- package/queries/catalog/signature-query/signature-query-render.js +4 -4
- package/queries/query.d.ts +4 -4
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/retriever.js +6 -1
- package/r-bridge/shell.js +5 -0
- package/search/flowr-search-filters.d.ts +2 -1
- package/util/files.d.ts +6 -4
- package/util/files.js +30 -8
- package/util/mermaid/dfg.js +1 -1
- package/util/schema.d.ts +2 -0
- package/util/schema.js +13 -0
- package/util/text/ansi.d.ts +7 -3
- package/util/text/ansi.js +8 -5
- package/util/version.js +4 -4
package/config.js
CHANGED
|
@@ -6,9 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.FlowrConfig = exports.FlowrDefaultPlugins = exports.DefaultAssumedRVersion = exports.DropPathsOption = exports.InferWorkingDirectory = exports.VersionSelection = exports.VariableResolve = void 0;
|
|
7
7
|
exports.isSigDbEnabled = isSigDbEnabled;
|
|
8
8
|
exports.resolveAssumedRVersion = resolveAssumedRVersion;
|
|
9
|
+
exports.globalConfigFilePath = globalConfigFilePath;
|
|
10
|
+
exports.persistSigDbPathToGlobalConfig = persistSigDbPathToGlobalConfig;
|
|
9
11
|
const objects_1 = require("./util/objects");
|
|
10
12
|
const path_1 = __importDefault(require("path"));
|
|
11
13
|
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const os_1 = __importDefault(require("os"));
|
|
12
15
|
const log_1 = require("./util/log");
|
|
13
16
|
const files_1 = require("./util/files");
|
|
14
17
|
const joi_1 = __importDefault(require("joi"));
|
|
@@ -208,7 +211,8 @@ exports.FlowrConfig = {
|
|
|
208
211
|
showPlugins: false,
|
|
209
212
|
},
|
|
210
213
|
project: {
|
|
211
|
-
resolveUnknownPathsOnDisk: true
|
|
214
|
+
resolveUnknownPathsOnDisk: true,
|
|
215
|
+
failOnInaccessiblePath: false
|
|
212
216
|
},
|
|
213
217
|
linter: {
|
|
214
218
|
disabledRules: []
|
|
@@ -294,8 +298,24 @@ exports.FlowrConfig = {
|
|
|
294
298
|
}).description('Configuration options for the REPL.'),
|
|
295
299
|
project: joi_1.default.object({
|
|
296
300
|
resolveUnknownPathsOnDisk: joi_1.default.boolean().optional().description('Whether to resolve unknown paths loaded by the r project disk when trying to source/analyze files.'),
|
|
301
|
+
failOnInaccessiblePath: joi_1.default.boolean().optional().description('Whether a directory that cannot be traversed during file discovery (e.g. due to permissions) aborts the analysis; when false (the default) such paths are logged and skipped.'),
|
|
297
302
|
basePackages: joi_1.default.array().items(joi_1.default.string()).optional().description('The packages considered part of R itself (base and recommended); if unset, flowR uses its built-in list.'),
|
|
298
|
-
implicitSources: joi_1.default.array().items(joi_1.default.string()).optional().description('Files a framework loads on its own, without any source() call (e.g. global.R in a shiny app), in the order they are loaded; flowR orders the matching project files accordingly and analyzes them as one program. Entries are case-insensitive globs matched against the file path, a plain name matches any file with that name, and entries matching no project file are warned about. Usually set per project kind via specializeConfig.')
|
|
303
|
+
implicitSources: joi_1.default.array().items(joi_1.default.string()).optional().description('Files a framework loads on its own, without any source() call (e.g. global.R in a shiny app), in the order they are loaded; flowR orders the matching project files accordingly and analyzes them as one program. Entries are case-insensitive globs matched against the file path, a plain name matches any file with that name, and entries matching no project file are warned about. Usually set per project kind via specializeConfig.'),
|
|
304
|
+
useProjectType: joi_1.default.string().valid(...Object.values(project_kind_1.ProjectKind)).optional().description('Overwrite the project kind flowR would otherwise infer from the analyzed files, e.g. when auto-detection guesses wrong.'),
|
|
305
|
+
discovery: joi_1.default.object({
|
|
306
|
+
full: joi_1.default.boolean().optional().description('Collect every file below the project root (greedy) instead of only the files the detected project kind needs (default false).'),
|
|
307
|
+
perKind: joi_1.default.object().pattern(joi_1.default.string().valid(...Object.values(project_kind_1.ProjectKind)), joi_1.default.object({
|
|
308
|
+
include: joi_1.default.array().items(joi_1.default.string()).optional(),
|
|
309
|
+
exclude: joi_1.default.array().items(joi_1.default.string()).optional()
|
|
310
|
+
})).optional().description('Per-kind include/exclude glob overrides layered on the default scoping.'),
|
|
311
|
+
ignore: joi_1.default.array().items(joi_1.default.string()).optional().description('Case-insensitive globs that drop matching files from the intelligent discovery, regardless of kind (e.g. .Renviron to ignore environment files).')
|
|
312
|
+
}).optional().description('Scoping options for the default project discovery.'),
|
|
313
|
+
classification: joi_1.default.object({
|
|
314
|
+
shinyDescriptionTypes: joi_1.default.array().items(joi_1.default.string()).optional().description('DESCRIPTION Type: values that mark a shiny app.'),
|
|
315
|
+
shinyEntryFiles: joi_1.default.array().items(joi_1.default.string()).optional().description('File names a shiny app is assembled from.'),
|
|
316
|
+
shinyUsagePattern: joi_1.default.string().optional().description('Regex source evidencing shiny usage in an entry file.'),
|
|
317
|
+
notebookExtensions: joi_1.default.array().items(joi_1.default.string()).optional().description('File extensions marking a notebook.')
|
|
318
|
+
}).optional().description('Overrides for the signals flowR uses to classify the project kind.')
|
|
299
319
|
}).description('Project specific configuration options.'),
|
|
300
320
|
linter: joi_1.default.object({
|
|
301
321
|
disabledRules: joi_1.default.array().items(joi_1.default.string()).description('Linting rule names excluded from the default rule set (a rule requested explicitly via a linter query still runs). Usually set per project kind via specializeConfig.')
|
|
@@ -484,6 +504,31 @@ exports.FlowrConfig = {
|
|
|
484
504
|
object_path_1.default.set(config, key, value);
|
|
485
505
|
},
|
|
486
506
|
};
|
|
507
|
+
/** Path to the user-global `flowr.json`, read as a fallback when no project config is found. */
|
|
508
|
+
function globalConfigFilePath() {
|
|
509
|
+
const base = process.env.FLOWR_CONFIG_HOME
|
|
510
|
+
?? (process.env.XDG_CONFIG_HOME ? path_1.default.join(process.env.XDG_CONFIG_HOME, 'flowr') : undefined)
|
|
511
|
+
?? (process.env.APPDATA ? path_1.default.join(process.env.APPDATA, 'flowr') : undefined)
|
|
512
|
+
?? path_1.default.join(os_1.default.homedir?.() || os_1.default.tmpdir(), '.config', 'flowr');
|
|
513
|
+
return path_1.default.join(base, 'flowr.json');
|
|
514
|
+
}
|
|
515
|
+
/** Persist `dbPath` into `solver.sigdb.additionalPaths` in the global config (creating it, preserving the user's raw JSON); idempotent, returns the file written. */
|
|
516
|
+
function persistSigDbPathToGlobalConfig(dbPath) {
|
|
517
|
+
const file = globalConfigFilePath();
|
|
518
|
+
let raw = {};
|
|
519
|
+
try {
|
|
520
|
+
raw = fs_1.default.existsSync(file) ? JSON.parse(fs_1.default.readFileSync(file, 'utf-8')) : {};
|
|
521
|
+
}
|
|
522
|
+
catch (e) {
|
|
523
|
+
log_1.log.warn(`Could not read global config ${file}, recreating it: ${e.message}`);
|
|
524
|
+
}
|
|
525
|
+
const current = object_path_1.default.get(raw, 'solver.sigdb.additionalPaths');
|
|
526
|
+
const paths = Array.isArray(current) ? current : [];
|
|
527
|
+
object_path_1.default.set(raw, 'solver.sigdb.additionalPaths', [...new Set([...paths, dbPath])]);
|
|
528
|
+
fs_1.default.mkdirSync(path_1.default.dirname(file), { recursive: true });
|
|
529
|
+
fs_1.default.writeFileSync(file, JSON.stringify(raw, null, '\t') + '\n');
|
|
530
|
+
return file;
|
|
531
|
+
}
|
|
487
532
|
function loadConfigFromFile(configFile, workingDirectory) {
|
|
488
533
|
if (configFile !== undefined) {
|
|
489
534
|
if (path_1.default.isAbsolute(configFile) && fs_1.default.existsSync(configFile)) {
|
|
@@ -509,6 +554,14 @@ function loadConfigFromFile(configFile, workingDirectory) {
|
|
|
509
554
|
searchPath = (0, files_1.getParentDirectory)(searchPath);
|
|
510
555
|
} while (fs_1.default.existsSync(searchPath));
|
|
511
556
|
}
|
|
557
|
+
const global = globalConfigFilePath();
|
|
558
|
+
if (fs_1.default.existsSync(global)) {
|
|
559
|
+
const ret = exports.FlowrConfig.parse(fs_1.default.readFileSync(global, { encoding: 'utf-8' }));
|
|
560
|
+
if (ret) {
|
|
561
|
+
log_1.log.info(`Using global config ${global}`);
|
|
562
|
+
return ret;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
512
565
|
log_1.log.info('Using default config');
|
|
513
566
|
return exports.FlowrConfig.default();
|
|
514
567
|
}
|
|
@@ -112,17 +112,18 @@ export declare const Identifier: {
|
|
|
112
112
|
*/
|
|
113
113
|
readonly toArray: (this: void, id: Identifier) => [BrandedIdentifier, BrandedNamespace | undefined, boolean | undefined];
|
|
114
114
|
/**
|
|
115
|
-
* The qualified identifier of a call
|
|
116
|
-
*
|
|
117
|
-
*
|
|
115
|
+
* The package-qualified identifier of a call, resolved in order of decreasing certainty:
|
|
116
|
+
* 1. a package export the {@link Origin|origins} resolve to (`map()` with `purrr` loaded yields `purrr::map`),
|
|
117
|
+
* 2. an already-namespaced `name` returned unchanged (an explicit `pkg::fn` call),
|
|
118
|
+
* 3. with `qualifyBaseR`, a bare base-R call qualified from its exporting package via {@link baseRExportOwner}
|
|
119
|
+
* (`sd` yields `stats::sd`), needing no loaded database or graph edge and skipped when the call resolves to
|
|
120
|
+
* a user definition, so a local `sd()` stays bare.
|
|
118
121
|
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* precomputed {@link baseRExportOwner} store -- no loaded database, no graph edges. This is suppressed when
|
|
122
|
-
* the call resolves to a user definition or is already namespaced, so a local `sd()` is never `stats::sd`.
|
|
122
|
+
* Returns `undefined` when none apply. Steps 2 and 3 need the call's `name`.
|
|
123
|
+
* @param qualifyBaseR - whether to also qualify a bare base-R call from its exporting package (default `true`)
|
|
123
124
|
* @see {@link Dataflow.qualify} - the compact form, if you have the call's id and its graph
|
|
124
125
|
*/
|
|
125
|
-
readonly toQualified: (this: void, origins: readonly Origin[] | undefined, name?: Identifier) => Identifier | undefined;
|
|
126
|
+
readonly toQualified: (this: void, origins: readonly Origin[] | undefined, name?: Identifier, qualifyBaseR?: boolean) => Identifier | undefined;
|
|
126
127
|
};
|
|
127
128
|
/**
|
|
128
129
|
* Well-known R package names used in {@link DefaultBuiltinConfig}.
|
|
@@ -192,32 +192,40 @@ exports.Identifier = {
|
|
|
192
192
|
}
|
|
193
193
|
},
|
|
194
194
|
/**
|
|
195
|
-
* The qualified identifier of a call
|
|
196
|
-
*
|
|
197
|
-
*
|
|
195
|
+
* The package-qualified identifier of a call, resolved in order of decreasing certainty:
|
|
196
|
+
* 1. a package export the {@link Origin|origins} resolve to (`map()` with `purrr` loaded yields `purrr::map`),
|
|
197
|
+
* 2. an already-namespaced `name` returned unchanged (an explicit `pkg::fn` call),
|
|
198
|
+
* 3. with `qualifyBaseR`, a bare base-R call qualified from its exporting package via {@link baseRExportOwner}
|
|
199
|
+
* (`sd` yields `stats::sd`), needing no loaded database or graph edge and skipped when the call resolves to
|
|
200
|
+
* a user definition, so a local `sd()` stays bare.
|
|
198
201
|
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* precomputed {@link baseRExportOwner} store -- no loaded database, no graph edges. This is suppressed when
|
|
202
|
-
* the call resolves to a user definition or is already namespaced, so a local `sd()` is never `stats::sd`.
|
|
202
|
+
* Returns `undefined` when none apply. Steps 2 and 3 need the call's `name`.
|
|
203
|
+
* @param qualifyBaseR - whether to also qualify a bare base-R call from its exporting package (default `true`)
|
|
203
204
|
* @see {@link Dataflow.qualify} - the compact form, if you have the call's id and its graph
|
|
204
205
|
*/
|
|
205
|
-
toQualified(origins, name) {
|
|
206
|
+
toQualified(origins, name, qualifyBaseR = true) {
|
|
206
207
|
let sawUserDefinition = false;
|
|
207
208
|
for (const origin of origins ?? []) {
|
|
208
|
-
// an attached package export carries the target builtin id `built-in:pkg:func` in `proc`
|
|
209
209
|
if ('proc' in origin) {
|
|
210
|
-
const pkgFn = node_id_1.NodeId.toPkgFn(origin.proc);
|
|
210
|
+
const pkgFn = node_id_1.NodeId.toPkgFn(origin.proc);
|
|
211
211
|
if (pkgFn) {
|
|
212
212
|
return exports.Identifier.make(pkgFn[1], pkgFn[0]);
|
|
213
213
|
}
|
|
214
|
+
else if (exports.Identifier.getNamespace(origin.fn.name) !== undefined) {
|
|
215
|
+
return origin.fn.name;
|
|
216
|
+
}
|
|
214
217
|
}
|
|
215
218
|
else {
|
|
216
|
-
sawUserDefinition = true;
|
|
219
|
+
sawUserDefinition = true;
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
|
-
|
|
220
|
-
|
|
222
|
+
if (name === undefined) {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
if (exports.Identifier.getNamespace(name) !== undefined) {
|
|
226
|
+
return name;
|
|
227
|
+
}
|
|
228
|
+
if (qualifyBaseR && !sawUserDefinition) {
|
|
221
229
|
const bare = exports.Identifier.getName(name);
|
|
222
230
|
const owner = (0, r_base_packages_1.baseRExportOwner)(bare);
|
|
223
231
|
if (owner !== undefined) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { DataflowGraph } from '../../graph/graph';
|
|
3
|
+
import type { ControlFlowGraph } from '../../../control-flow/control-flow-graph';
|
|
4
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
5
|
+
import { type ControlDependency } from '../../info';
|
|
6
|
+
/** a resolved `setwd`-style call: its `dir` is `undefined` when it cannot be determined statically */
|
|
7
|
+
export interface WorkingDirectoryChange {
|
|
8
|
+
readonly id: NodeId;
|
|
9
|
+
readonly dir: string | undefined;
|
|
10
|
+
readonly cds: readonly ControlDependency[];
|
|
11
|
+
readonly iterated: boolean;
|
|
12
|
+
readonly enclosedInFunction: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** over-approximating candidate set (empty means unbounded), and whether exactly one directory is guaranteed */
|
|
15
|
+
export interface WorkingDirectoryResolution {
|
|
16
|
+
readonly candidates: readonly string[];
|
|
17
|
+
readonly certain: boolean;
|
|
18
|
+
}
|
|
19
|
+
type Guards = readonly ControlDependency[];
|
|
20
|
+
declare function resolveAt(target: NodeId, targetCds: Guards, baseWd: string, changes: readonly WorkingDirectoryChange[], cfg: ControlFlowGraph): WorkingDirectoryResolution;
|
|
21
|
+
declare function collect(graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext): WorkingDirectoryChange[];
|
|
22
|
+
/** Resolve R's process-global working directory (sensitive to `setwd`) at a program point; path-sensitive, unbounded rather than wrong under loops/functions. */
|
|
23
|
+
export declare const WorkingDirectory: {
|
|
24
|
+
readonly collect: typeof collect;
|
|
25
|
+
readonly resolveAt: typeof resolveAt;
|
|
26
|
+
/** reusable `(callId, scriptFile?) => candidate roots`, collecting the changes once for the whole graph */
|
|
27
|
+
readonly rootsResolver: (graph: DataflowGraph, cfg: ControlFlowGraph, ctx: ReadOnlyFlowrAnalyzerContext) => (id: NodeId, file?: string) => readonly string[];
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
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.WorkingDirectory = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const vertex_1 = require("../../graph/vertex");
|
|
9
|
+
const happens_before_1 = require("../../../control-flow/happens-before");
|
|
10
|
+
const logic_1 = require("../../../util/logic");
|
|
11
|
+
const identifier_1 = require("../../environments/identifier");
|
|
12
|
+
const resolve_argument_1 = require("./resolve-argument");
|
|
13
|
+
const dependencies_query_format_1 = require("../../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
14
|
+
const strings_1 = require("../../../util/text/strings");
|
|
15
|
+
const info_1 = require("../../info");
|
|
16
|
+
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
17
|
+
const edge_1 = require("../../graph/edge");
|
|
18
|
+
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
19
|
+
const files_1 = require("../../../util/files");
|
|
20
|
+
const built_in_source_1 = require("../../internal/process/functions/call/built-in/built-in-source");
|
|
21
|
+
/** functions recognized as changing the working directory; a registry so more (e.g. `withr::with_dir`) can be added */
|
|
22
|
+
const ChangeFunctions = [
|
|
23
|
+
{ name: 'setwd', namespace: 'base', argIdx: 0, argName: 'dir' }
|
|
24
|
+
];
|
|
25
|
+
const LoopTypes = new Set([type_1.RType.ForLoop, type_1.RType.WhileLoop, type_1.RType.RepeatLoop]);
|
|
26
|
+
const CandidateCap = 64;
|
|
27
|
+
function matchSpec(name) {
|
|
28
|
+
if (name === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const bare = identifier_1.Identifier.getName(name);
|
|
32
|
+
const ns = identifier_1.Identifier.getNamespace(name);
|
|
33
|
+
return ChangeFunctions.find(s => s.name === bare && (ns === undefined || ns === s.namespace));
|
|
34
|
+
}
|
|
35
|
+
function isAbsoluteDir(dir) {
|
|
36
|
+
return dir.startsWith('~') || (0, strings_1.isAbsolutePath)(dir, undefined);
|
|
37
|
+
}
|
|
38
|
+
/** apply one `setwd(dir)`: an absolute (or `~`-rooted) `dir` replaces `current`, a relative `dir` joins onto it */
|
|
39
|
+
function applyChange(current, dir) {
|
|
40
|
+
const d = (0, files_1.toPosixPath)(dir);
|
|
41
|
+
return isAbsoluteDir(dir) ? path_1.default.posix.normalize(d) : path_1.default.posix.join((0, files_1.toPosixPath)(current), d);
|
|
42
|
+
}
|
|
43
|
+
function guardIn(g, set) {
|
|
44
|
+
return set.some(b => b.id === g.id && b.when === g.when);
|
|
45
|
+
}
|
|
46
|
+
function subsumed(inner, outer) {
|
|
47
|
+
return inner.every(g => guardIn(g, outer));
|
|
48
|
+
}
|
|
49
|
+
function consistent(inner, outer) {
|
|
50
|
+
return inner.every(g => !outer.some(b => b.id === g.id && b.when !== g.when));
|
|
51
|
+
}
|
|
52
|
+
function mergeGuards(a, b) {
|
|
53
|
+
const out = [...a];
|
|
54
|
+
for (const g of b) {
|
|
55
|
+
if (!guardIn(g, out)) {
|
|
56
|
+
out.push(g);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** the changes ordered so predecessors come first; parallel branches keep an arbitrary relative order */
|
|
62
|
+
function topoOrder(changes, cfg) {
|
|
63
|
+
const remaining = [...changes];
|
|
64
|
+
const result = [];
|
|
65
|
+
while (remaining.length > 0) {
|
|
66
|
+
const idx = Math.max(0, remaining.findIndex(a => remaining.every(b => b === a || (0, happens_before_1.happensBefore)(cfg, b.id, a.id) === logic_1.Ternary.Never)));
|
|
67
|
+
result.push(remaining.splice(idx, 1)[0]);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
function enclosingFunction(idMap, id) {
|
|
72
|
+
let cursor = idMap?.get(id)?.info.parent;
|
|
73
|
+
while (cursor !== undefined) {
|
|
74
|
+
const node = idMap?.get(cursor);
|
|
75
|
+
if (node?.type === type_1.RType.FunctionDefinition) {
|
|
76
|
+
return node.info.id;
|
|
77
|
+
}
|
|
78
|
+
cursor = node?.info.parent;
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
function isIterated(cds, idMap) {
|
|
83
|
+
return cds.some(cd => cd.byIteration || LoopTypes.has(idMap?.get(cd.id)?.type));
|
|
84
|
+
}
|
|
85
|
+
function resolveAt(target, targetCds, baseWd, changes, cfg) {
|
|
86
|
+
const relevant = changes.filter(c => (0, happens_before_1.happensBefore)(cfg, c.id, target) !== logic_1.Ternary.Never);
|
|
87
|
+
// a setwd hidden in a function may still have run before target via a call happensBefore cannot see
|
|
88
|
+
if (changes.some(c => c.enclosedInFunction && !relevant.includes(c))) {
|
|
89
|
+
return { candidates: [], certain: false };
|
|
90
|
+
}
|
|
91
|
+
if (relevant.length === 0) {
|
|
92
|
+
return { candidates: [baseWd], certain: true };
|
|
93
|
+
}
|
|
94
|
+
if (relevant.some(c => c.dir === undefined || (c.iterated && !isAbsoluteDir(c.dir)))) {
|
|
95
|
+
return { candidates: [], certain: false };
|
|
96
|
+
}
|
|
97
|
+
let states = [{ wd: baseWd, guards: [] }];
|
|
98
|
+
for (const c of topoOrder(relevant, cfg)) {
|
|
99
|
+
const next = [];
|
|
100
|
+
for (const s of states) {
|
|
101
|
+
if (!consistent(c.cds, s.guards)) {
|
|
102
|
+
next.push(s);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const ran = { wd: applyChange(s.wd, c.dir), guards: mergeGuards(s.guards, c.cds) };
|
|
106
|
+
if (!c.iterated && subsumed(c.cds, s.guards)) {
|
|
107
|
+
next.push(ran);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const neg = c.cds.length === 1 ? [(0, info_1.negateControlDependency)(c.cds[0])] : [];
|
|
111
|
+
next.push({ wd: s.wd, guards: mergeGuards(s.guards, neg) });
|
|
112
|
+
next.push(ran);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
states = next;
|
|
116
|
+
if (states.length > CandidateCap) {
|
|
117
|
+
return { candidates: [], certain: false };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const candidates = [...new Set(states.filter(s => consistent(targetCds, s.guards)).map(s => s.wd))];
|
|
121
|
+
return { candidates, certain: candidates.length === 1 };
|
|
122
|
+
}
|
|
123
|
+
function collect(graph, ctx) {
|
|
124
|
+
const out = [];
|
|
125
|
+
const byFn = new defaultmap_1.DefaultMap(() => []);
|
|
126
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
127
|
+
const spec = matchSpec(vertex.name);
|
|
128
|
+
if (spec === undefined) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const resolved = (0, resolve_argument_1.getArgumentStringValue)(ctx.config.solver.variables, graph, vertex, spec.argIdx, spec.argName, true, ctx);
|
|
132
|
+
const values = resolved ? Array.from(resolved.values()).flatMap(s => Array.from(s)) : [];
|
|
133
|
+
const known = values.filter(v => v !== undefined && v !== dependencies_query_format_1.Unknown);
|
|
134
|
+
const dir = values.length > 0 && known.length === values.length && new Set(known).size === 1 ? known[0] : undefined;
|
|
135
|
+
const cds = vertex.cds ?? [];
|
|
136
|
+
const iterated = isIterated(cds, graph.idMap);
|
|
137
|
+
const fn = enclosingFunction(graph.idMap, id);
|
|
138
|
+
if (fn === undefined) {
|
|
139
|
+
out.push({ id, dir, cds, iterated, enclosedInFunction: false });
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
byFn.get(fn).push({ dir, cds, iterated });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// a function's setwd is propagated to its call sites; only a lone unconditional setwd has a site-independent effect
|
|
146
|
+
for (const [fn, setwds] of byFn.entries()) {
|
|
147
|
+
const net = setwds.length === 1 && setwds[0].cds.length === 0 && !setwds[0].iterated ? setwds[0].dir : undefined;
|
|
148
|
+
for (const [site, edge] of graph.ingoingEdges(fn) ?? []) {
|
|
149
|
+
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const cds = graph.getVertex(site)?.cds ?? [];
|
|
153
|
+
out.push({ id: site, dir: net, cds, iterated: isIterated(cds, graph.idMap), enclosedInFunction: enclosingFunction(graph.idMap, site) !== undefined });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
/** Resolve R's process-global working directory (sensitive to `setwd`) at a program point; path-sensitive, unbounded rather than wrong under loops/functions. */
|
|
159
|
+
exports.WorkingDirectory = {
|
|
160
|
+
collect,
|
|
161
|
+
resolveAt,
|
|
162
|
+
/** reusable `(callId, scriptFile?) => candidate roots`, collecting the changes once for the whole graph */
|
|
163
|
+
rootsResolver(graph, cfg, ctx) {
|
|
164
|
+
const changes = collect(graph, ctx);
|
|
165
|
+
return (id, file) => resolveAt(id, graph.getVertex(id)?.cds ?? [], file ? (0, built_in_source_1.platformDirname)(file) : '.', changes, cfg).candidates;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=resolve-working-directory.js.map
|
package/dataflow/extractor.js
CHANGED
|
@@ -15,6 +15,7 @@ const make_argument_1 = require("./internal/process/functions/call/argument/make
|
|
|
15
15
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
16
16
|
const built_in_source_1 = require("./internal/process/functions/call/built-in/built-in-source");
|
|
17
17
|
const built_in_library_1 = require("./internal/process/functions/call/built-in/built-in-library");
|
|
18
|
+
const graph_1 = require("./graph/graph");
|
|
18
19
|
const extract_cfg_1 = require("../control-flow/extract-cfg");
|
|
19
20
|
const edge_1 = require("./graph/edge");
|
|
20
21
|
const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
@@ -79,7 +80,7 @@ function resolveLinkToSideEffects(ast, graph, ctx) {
|
|
|
79
80
|
const killedRegexes = new Set();
|
|
80
81
|
const handled = new Set();
|
|
81
82
|
for (const s of graph.unknownSideEffects) {
|
|
82
|
-
if (
|
|
83
|
+
if (!graph_1.UnknownSideEffect.isLinked(s)) {
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
if (cf === undefined) {
|
|
@@ -85,7 +85,8 @@ export declare const Dataflow: {
|
|
|
85
85
|
readonly origin: typeof getOriginInDfg;
|
|
86
86
|
/**
|
|
87
87
|
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
88
|
-
* export (with `purrr` loaded, a `map()` call yields
|
|
88
|
+
* export and is not itself already namespaced (with `purrr` loaded, a `map()` call yields
|
|
89
|
+
* `Identifier.make('map', 'purrr')`; an explicit `pkg::fn()` call yields `pkg::fn` unchanged).
|
|
89
90
|
*
|
|
90
91
|
* This is the compact form of {@link Identifier.toQualified}, reconstructing both the
|
|
91
92
|
* {@link Dataflow.origin|origins} and the call's name from the graph.
|
|
@@ -93,7 +94,7 @@ export declare const Dataflow: {
|
|
|
93
94
|
* @param graph - The graph the call is part of
|
|
94
95
|
* @param qualifyBaseR - Whether to also qualify a bare base-R call from the package exporting it
|
|
95
96
|
* (`sd` yields `stats::sd`), which needs neither a loaded database nor graph edges.
|
|
96
|
-
* Set this to `false` to only qualify what the origins resolve to.
|
|
97
|
+
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
97
98
|
*/
|
|
98
99
|
readonly qualify: (this: void, id: NodeId, graph: DataflowGraph, qualifyBaseR?: boolean) => Identifier | undefined;
|
|
99
100
|
/**
|
|
@@ -56,7 +56,8 @@ exports.Dataflow = {
|
|
|
56
56
|
origin: dfg_get_origin_1.getOriginInDfg,
|
|
57
57
|
/**
|
|
58
58
|
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
59
|
-
* export (with `purrr` loaded, a `map()` call yields
|
|
59
|
+
* export and is not itself already namespaced (with `purrr` loaded, a `map()` call yields
|
|
60
|
+
* `Identifier.make('map', 'purrr')`; an explicit `pkg::fn()` call yields `pkg::fn` unchanged).
|
|
60
61
|
*
|
|
61
62
|
* This is the compact form of {@link Identifier.toQualified}, reconstructing both the
|
|
62
63
|
* {@link Dataflow.origin|origins} and the call's name from the graph.
|
|
@@ -64,12 +65,11 @@ exports.Dataflow = {
|
|
|
64
65
|
* @param graph - The graph the call is part of
|
|
65
66
|
* @param qualifyBaseR - Whether to also qualify a bare base-R call from the package exporting it
|
|
66
67
|
* (`sd` yields `stats::sd`), which needs neither a loaded database nor graph edges.
|
|
67
|
-
* Set this to `false` to only qualify what the origins resolve to.
|
|
68
|
+
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
68
69
|
*/
|
|
69
70
|
qualify(id, graph, qualifyBaseR = true) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id), (0, vertex_1.isFunctionCallVertex)(vertex) ? vertex.name : undefined);
|
|
71
|
+
const vertex = graph.getVertex(id);
|
|
72
|
+
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id), (0, vertex_1.isFunctionCallVertex)(vertex) ? vertex.name : undefined, qualifyBaseR);
|
|
73
73
|
},
|
|
74
74
|
/**
|
|
75
75
|
* Interprocedural propagation of escaped side effects (attached packages, `<<-` definitions) to their callers.
|
|
@@ -109,11 +109,9 @@ exports.Dataflow = {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
for (const u of graph.unknownSideEffects) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
else if (select.has(u)) {
|
|
116
|
-
df.markIdForUnknownSideEffects(u);
|
|
112
|
+
const id = graph_1.UnknownSideEffect.id(u);
|
|
113
|
+
if (select.has(id)) {
|
|
114
|
+
df.markIdForUnknownSideEffects(id, graph_1.UnknownSideEffect.linkTo(u));
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
return df;
|
|
@@ -142,11 +140,9 @@ exports.Dataflow = {
|
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
for (const u of graph.unknownSideEffects) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
else if (select.has(u)) {
|
|
149
|
-
df.markIdForUnknownSideEffects(u);
|
|
143
|
+
const id = graph_1.UnknownSideEffect.id(u);
|
|
144
|
+
if (select.has(id)) {
|
|
145
|
+
df.markIdForUnknownSideEffects(id, graph_1.UnknownSideEffect.linkTo(u));
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
return df;
|
|
@@ -58,7 +58,7 @@ function diffOutgoingEdges(ctx) {
|
|
|
58
58
|
}
|
|
59
59
|
function diffRootVertices(ctx) {
|
|
60
60
|
(0, diff_1.setDifference)(ctx.left.rootIds(), ctx.right.rootIds(), { ...ctx, position: `${ctx.position}Root vertices differ in graphs. ` });
|
|
61
|
-
(0, diff_1.setDifference)(new Set(
|
|
61
|
+
(0, diff_1.setDifference)(new Set(ctx.left.unknownSideEffects.values().map(graph_1.UnknownSideEffect.id)), new Set(ctx.right.unknownSideEffects.values().map(graph_1.UnknownSideEffect.id)), { ...ctx, position: `${ctx.position}Unknown side effects differ in graphs. ` });
|
|
62
62
|
}
|
|
63
63
|
function diffFunctionArgumentsReferences(fn, a, b, ctx) {
|
|
64
64
|
if (a === '<value>' || b === '<value>') {
|
|
@@ -93,12 +93,8 @@ exports.GraphHelper = {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
for (const unknown of graph.unknownSideEffects) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
resultGraph.markIdForUnknownSideEffects(resolve(unknown));
|
|
101
|
-
}
|
|
96
|
+
const { id, linkTo } = graph_1.UnknownSideEffect.split(unknown);
|
|
97
|
+
resultGraph.markIdForUnknownSideEffects(resolve(id), linkTo);
|
|
102
98
|
}
|
|
103
99
|
return resultGraph;
|
|
104
100
|
},
|
|
@@ -160,6 +160,30 @@ export type UnknownSideEffect = NodeId | {
|
|
|
160
160
|
id: NodeId;
|
|
161
161
|
linkTo: LinkTo<RegExp>;
|
|
162
162
|
};
|
|
163
|
+
/** A {@link UnknownSideEffect} that carries a {@link LinkTo} target. */
|
|
164
|
+
export type LinkedUnknownSideEffect = {
|
|
165
|
+
id: NodeId;
|
|
166
|
+
linkTo: LinkTo<RegExp>;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Helpers for the {@link UnknownSideEffect} union, which is either a plain {@link NodeId} or a
|
|
170
|
+
* `{ id, linkTo }` object. Use these instead of hand-rolling `typeof x === 'object' ? x.id : x`
|
|
171
|
+
* checks so the object/non-object discrimination lives in one place.
|
|
172
|
+
*/
|
|
173
|
+
export declare const UnknownSideEffect: {
|
|
174
|
+
readonly name: "UnknownSideEffect";
|
|
175
|
+
/** Whether the effect carries a {@link LinkTo} target (i.e., is the object variant). */
|
|
176
|
+
readonly isLinked: (this: void, effect: UnknownSideEffect) => effect is LinkedUnknownSideEffect;
|
|
177
|
+
/** The affected node id, regardless of whether the effect is plain or linked. */
|
|
178
|
+
readonly id: (this: void, effect: UnknownSideEffect) => NodeId;
|
|
179
|
+
/** The {@link LinkTo} target of the effect, or `undefined` if it is a plain (unlinked) one. */
|
|
180
|
+
readonly linkTo: (this: void, effect: UnknownSideEffect) => LinkTo<RegExp> | undefined;
|
|
181
|
+
/** Both {@link id} and {@link linkTo} in one pass (a single discrimination); use when you need both. */
|
|
182
|
+
readonly split: (this: void, effect: UnknownSideEffect) => {
|
|
183
|
+
id: NodeId;
|
|
184
|
+
linkTo: LinkTo<RegExp> | undefined;
|
|
185
|
+
};
|
|
186
|
+
};
|
|
163
187
|
/**
|
|
164
188
|
* The dataflow graph holds the dataflow information found within the given AST.
|
|
165
189
|
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}.
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataflowGraph = exports.FunctionArgument = void 0;
|
|
3
|
+
exports.DataflowGraph = exports.UnknownSideEffect = exports.FunctionArgument = void 0;
|
|
4
4
|
const assert_1 = require("../../util/assert");
|
|
5
5
|
const vertex_1 = require("./vertex");
|
|
6
6
|
const arrays_1 = require("../../util/collections/arrays");
|
|
@@ -121,6 +121,30 @@ exports.FunctionArgument = {
|
|
|
121
121
|
return exports.FunctionArgument.isNamed(arg) && arg.name === name;
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Helpers for the {@link UnknownSideEffect} union, which is either a plain {@link NodeId} or a
|
|
126
|
+
* `{ id, linkTo }` object. Use these instead of hand-rolling `typeof x === 'object' ? x.id : x`
|
|
127
|
+
* checks so the object/non-object discrimination lives in one place.
|
|
128
|
+
*/
|
|
129
|
+
exports.UnknownSideEffect = {
|
|
130
|
+
name: 'UnknownSideEffect',
|
|
131
|
+
/** Whether the effect carries a {@link LinkTo} target (i.e., is the object variant). */
|
|
132
|
+
isLinked(effect) {
|
|
133
|
+
return typeof effect === 'object';
|
|
134
|
+
},
|
|
135
|
+
/** The affected node id, regardless of whether the effect is plain or linked. */
|
|
136
|
+
id(effect) {
|
|
137
|
+
return typeof effect === 'object' ? effect.id : effect;
|
|
138
|
+
},
|
|
139
|
+
/** The {@link LinkTo} target of the effect, or `undefined` if it is a plain (unlinked) one. */
|
|
140
|
+
linkTo(effect) {
|
|
141
|
+
return typeof effect === 'object' ? effect.linkTo : undefined;
|
|
142
|
+
},
|
|
143
|
+
/** Both {@link id} and {@link linkTo} in one pass (a single discrimination); use when you need both. */
|
|
144
|
+
split(effect) {
|
|
145
|
+
return typeof effect === 'object' ? effect : { id: effect, linkTo: undefined };
|
|
146
|
+
}
|
|
147
|
+
};
|
|
124
148
|
/**
|
|
125
149
|
* The dataflow graph holds the dataflow information found within the given AST.
|
|
126
150
|
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}.
|
|
@@ -235,6 +235,7 @@ The schema below documents every option; the ones you most likely want are:
|
|
|
235
235
|
loaded. Entries are globs (e.g. \`R/*.R\`) matched against the file path ignoring capitalization; one matching no file is reported.
|
|
236
236
|
- ${ctx.linkConfig('specializeConfig')}: overwrite (parts of) the configuration depending on the kind of project _flowR_ detects
|
|
237
237
|
(e.g. \`shiny-app\`), which is how a shiny app gets its implicit sources by default. What you configure directly wins.
|
|
238
|
+
- ${ctx.linkConfig('project.useProjectType')}: skip that detection and force a project kind yourself, when auto-detection guesses wrong.
|
|
238
239
|
- ${ctx.linkConfig('defaultPlugins')} and ${ctx.linkConfig('repl.plugins')}: the plugins to load for a new ${ctx.link(flowr_analyzer_1.FlowrAnalyzer)} and in the REPL
|
|
239
240
|
(use \`flowr:default\` to reference the former).
|
|
240
241
|
|
|
@@ -133,6 +133,7 @@ function(x) {
|
|
|
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
135
|
rule(knownParser, 'undefined-symbol', 'UndefinedSymbolConfig', 'UNDEFINED_SYMBOL', 'lint-undefined-symbol', 'undefined_helper(42)', tagTypes);
|
|
136
|
+
rule(knownParser, 'syntactically-valid', 'SyntacticallyValidConfig', 'SYNTACTICALLY_VALID', 'lint-syntactically-valid', 'x <- c(1, 2', tagTypes);
|
|
136
137
|
function rule(parser, name, configType, ruleType, testfile, example, types) {
|
|
137
138
|
const rule = linter_rules_1.LintingRules[name];
|
|
138
139
|
const tags = rule.info.tags.toSorted((a, b) => {
|
|
@@ -145,6 +145,16 @@ export interface GeneralDocContext {
|
|
|
145
145
|
linkO<T extends object & {
|
|
146
146
|
name: string;
|
|
147
147
|
}>(obj: T, element: keyof T, fmt?: LinkFormat, filter?: ElementFilter): string;
|
|
148
|
+
/**
|
|
149
|
+
* Generate a hyperlink to an enum member. Enums have no runtime prototype ({@link GeneralDocContext#linkM|linkM})
|
|
150
|
+
* nor `name` ({@link GeneralDocContext#linkO|linkO}), so pass the enum type as the explicit type argument -- the
|
|
151
|
+
* member is then checked against its keys -- together with the enum's name.
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* linkE<typeof FnProp>('FnProp', 'NoDoc')
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
linkE<E>(enumName: string, element: keyof E, fmt?: LinkFormat, filter?: ElementFilter): string;
|
|
148
158
|
/**
|
|
149
159
|
* Generate a hyperlink to a type/element definition in the code base which is displayed using the file path as name
|
|
150
160
|
* @param element - The element to create a link for, the name can be qualified with `::` to specify the class.
|
|
@@ -79,6 +79,9 @@ function makeDocContextForTypes(shell, ...rootFolders) {
|
|
|
79
79
|
const fullName = `${obj.name}::${String(element)}`;
|
|
80
80
|
return this.link(fullName, fmt, filter);
|
|
81
81
|
},
|
|
82
|
+
linkE(enumName, element, fmt, filter) {
|
|
83
|
+
return this.link(`${enumName}::${String(element)}`, fmt, filter);
|
|
84
|
+
},
|
|
82
85
|
linkFile(element) {
|
|
83
86
|
return (0, doc_types_1.shortLinkFile)(getNameFromElementIdOrRef(element), info);
|
|
84
87
|
},
|