@eagleoutice/flowr 2.13.1 → 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.
Files changed (74) hide show
  1. package/cli/flowr.js +21 -5
  2. package/cli/repl/commands/repl-commands.js +11 -9
  3. package/cli/repl/commands/repl-query.js +1 -1
  4. package/cli/repl/commands/repl-signature.js +8 -1
  5. package/cli/repl/core.js +13 -10
  6. package/cli/repl/print-version.js +1 -1
  7. package/cli/repl/server/connection.d.ts +1 -1
  8. package/cli/repl/server/net.js +15 -0
  9. package/config.d.ts +29 -0
  10. package/config.js +54 -2
  11. package/data/sigdb/sigdb.remote.json +1 -1
  12. package/dataflow/environments/identifier.d.ts +9 -8
  13. package/dataflow/environments/identifier.js +21 -13
  14. package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
  15. package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
  16. package/dataflow/extractor.js +2 -1
  17. package/dataflow/graph/df-helper.d.ts +3 -2
  18. package/dataflow/graph/df-helper.js +11 -15
  19. package/dataflow/graph/diff-dataflow-graph.js +1 -1
  20. package/dataflow/graph/graph-helper.js +2 -6
  21. package/dataflow/graph/graph.d.ts +24 -0
  22. package/dataflow/graph/graph.js +25 -1
  23. package/documentation/wiki-linter.js +1 -0
  24. package/documentation/wiki-mk/doc-context.d.ts +10 -0
  25. package/documentation/wiki-mk/doc-context.js +3 -0
  26. package/documentation/wiki-signature-database.js +16 -6
  27. package/linter/linter-rules.d.ts +24 -2
  28. package/linter/linter-rules.js +3 -1
  29. package/linter/rules/absolute-path.d.ts +4 -4
  30. package/linter/rules/absolute-path.js +7 -5
  31. package/linter/rules/file-path-validity.d.ts +1 -1
  32. package/linter/rules/file-path-validity.js +48 -8
  33. package/linter/rules/function-finder-util.d.ts +2 -1
  34. package/linter/rules/syntactically-valid.d.ts +58 -0
  35. package/linter/rules/syntactically-valid.js +203 -0
  36. package/linter/rules/undefined-symbol.js +3 -2
  37. package/package.json +5 -4
  38. package/project/context/classify-project-kind.d.ts +40 -0
  39. package/project/context/classify-project-kind.js +76 -0
  40. package/project/context/flowr-analyzer-dependencies-context.d.ts +23 -4
  41. package/project/context/flowr-analyzer-dependencies-context.js +23 -1
  42. package/project/context/flowr-analyzer-files-context.d.ts +10 -8
  43. package/project/context/flowr-analyzer-files-context.js +26 -67
  44. package/project/context/flowr-file.d.ts +5 -0
  45. package/project/context/flowr-file.js +5 -0
  46. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
  47. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
  48. package/project/plugins/plugin-registry.d.ts +2 -1
  49. package/project/plugins/plugin-registry.js +4 -1
  50. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
  51. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
  52. package/project/sigdb/decompress.d.ts +1 -1
  53. package/project/sigdb/decompress.js +4 -1
  54. package/project/sigdb/manifest.js +60 -26
  55. package/project/sigdb/sigdb-download.d.ts +6 -7
  56. package/project/sigdb/sigdb-download.js +30 -9
  57. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +0 -10
  58. package/queries/catalog/dependencies-query/dependencies-query-format.js +0 -106
  59. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
  60. package/queries/catalog/linter-query/linter-query-format.js +9 -2
  61. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  62. package/queries/catalog/signature-query/signature-query-render.js +4 -4
  63. package/queries/query.js +9 -2
  64. package/r-bridge/data/data.d.ts +5 -0
  65. package/r-bridge/data/data.js +6 -0
  66. package/r-bridge/retriever.js +6 -1
  67. package/r-bridge/shell.js +5 -0
  68. package/search/flowr-search-filters.d.ts +2 -1
  69. package/util/files.d.ts +6 -4
  70. package/util/files.js +30 -8
  71. package/util/mermaid/dfg.js +1 -1
  72. package/util/text/ansi.d.ts +7 -3
  73. package/util/text/ansi.js +8 -5
  74. package/util/version.js +4 -4
@@ -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 (typeof s !== 'object') {
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 `Identifier.make('map', 'purrr')`).
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 `Identifier.make('map', 'purrr')`).
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
- // only look the vertex up when its name is actually needed (base-R qualification)
71
- const vertex = qualifyBaseR ? graph.getVertex(id) : undefined;
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
- if (typeof u === 'object' && select.has(u.id)) {
113
- df.markIdForUnknownSideEffects(u.id, u.linkTo);
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
- if (typeof u === 'object' && select.has(u.id)) {
146
- df.markIdForUnknownSideEffects(u.id, u.linkTo);
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([...ctx.left.unknownSideEffects].map(n => typeof n === 'object' ? n.id : n)), new Set([...ctx.right.unknownSideEffects].map(n => typeof n === 'object' ? n.id : n)), { ...ctx, position: `${ctx.position}Unknown side effects differ in graphs. ` });
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
- if (typeof unknown === 'object') {
97
- resultGraph.markIdForUnknownSideEffects(resolve(unknown.id), unknown.linkTo);
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}.
@@ -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}.
@@ -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
  },
@@ -9,12 +9,15 @@ const path_1 = __importDefault(require("path"));
9
9
  const doc_maker_1 = require("./wiki-mk/doc-maker");
10
10
  const doc_files_1 = require("./doc-util/doc-files");
11
11
  const reader_1 = require("../project/sigdb/reader");
12
+ // FnProp is a const enum referenced only via `typeof` (for linkE's member typing); a type-only import would break `typeof`
13
+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
12
14
  const schema_1 = require("../project/sigdb/schema");
13
15
  const manifest_1 = require("../project/sigdb/manifest");
14
16
  const codec_1 = require("../project/sigdb/codec");
15
17
  const config_1 = require("../config");
16
18
  const flowr_analyzer_package_versions_sigdb_plugin_1 = require("../project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin");
17
19
  const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
20
+ const flowr_analyzer_dependencies_context_1 = require("../project/context/flowr-analyzer-dependencies-context");
18
21
  function cranDatabaseAvailable() {
19
22
  return (0, manifest_1.defaultSigDbPath)('current') !== undefined || (0, manifest_1.defaultSigDbPath)('full') !== undefined;
20
23
  }
@@ -231,17 +234,22 @@ Every function is a ${ctx.link('DecodedFunction')}:
231
234
 
232
235
  Per version the source also answers declared dependencies (${ctx.link('ResolvedDependency')}), release dates, the plain export view (${ctx.link('LibraryExports')}), and the versions it carries (${ctx.link('AvailableVersion')}).
233
236
 
234
- Beyond the flags above, ${ctx.link('DecodedFunction::props')} also carry ${ctx.link('FnProp::NoDoc')} (a documented package has no help page for this name), ${ctx.link('FnProp::S3Method')} (a registered S3 method, from the package NAMESPACE or base R's method table), and ${ctx.link('FnProp::S3Owner')} (an exported constructor for an S3 class this package OWNS: it also registers at least one S3 method for that class). The owned classes of a version are ${ctx.link('LibraryExports::s3Classes')}, and ${ctx.linkM(reader_1.SigDatabase, 'classOwner')} answers, for a class name, which package owns it (backed by a reverse index built once). This lets ${ctx.linkPage('wiki/Query API', 'version guessing')} mark a package used when the analyzed project's own NAMESPACE registers an S3 method for a class it owns, even with no direct call -- e.g. tseries's \`S3method("as.irts","zoo")\` marks \`zoo\` used.
237
+ Beyond the flags above, ${ctx.link('DecodedFunction::props')} also carry ${ctx.linkE('FnProp', 'NoDoc')} (a documented package has no help page for this name), ${ctx.linkE('FnProp', 'S3Method')} (a registered S3 method, from the package NAMESPACE or base R's method table), and ${ctx.linkE('FnProp', 'S3Owner')} (an exported constructor for an S3 class this package OWNS: it also registers at least one S3 method for that class). The owned classes of a version are ${ctx.link('LibraryExports::s3Classes')}, and ${ctx.linkM(reader_1.SigDatabase, 'classOwner')} answers, for a class name, which package owns it (backed by a reverse index built once). This lets ${ctx.linkPage('wiki/Query API', 'version guessing')} mark a package used when the analyzed project's own NAMESPACE registers an S3 method for a class it owns, even with no direct call -- e.g. tseries's \`S3method("as.irts","zoo")\` marks \`zoo\` used.
235
238
 
236
239
  These are derived on demand by the ${ctx.linkPage('wiki/Query API', 'signature query')}, not stored:
237
- - the rdrr.io documentation link ${ctx.link('SignatureFunctionView::docUrl')} (base R \`/r/<pkg>/<topic>\`, CRAN \`/cran/<pkg>/man/<topic>\`), omitted for a ${ctx.link('FnProp::NoDoc')} function
238
- - the S3 method to generic backlink ${ctx.link('SignatureFunctionView::s3method')}, for a ${ctx.link('FnProp::S3Method')} function, resolving its generic
240
+ - the rdrr.io documentation link ${ctx.link('SignatureFunctionView::docUrl')} (base R \`/r/<pkg>/<topic>\`, CRAN \`/cran/<pkg>/man/<topic>\`), omitted for a ${ctx.linkE('FnProp', 'NoDoc')} function
241
+ - the S3 method to generic backlink ${ctx.link('SignatureFunctionView::s3method')}, for a ${ctx.linkE('FnProp', 'S3Method')} function, resolving its generic
239
242
  - the transitive call graph ${ctx.linkM(reader_1.SigDatabase, 'transitiveCallees')}, expanding the stored local callees inside one version
240
243
 
241
244
  Read it back like this:
242
245
 
243
246
  ${ctx.code(accessTheDatabase, { dropLinesStart: 1 })}
244
247
 
248
+ To check what a project can resolve against without touching the raw sources, a ${ctx.linkPage('wiki/Analyzer', 'context')} exposes
249
+ ${ctx.linkM(flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext, 'hasSignatureDatabase')} (a cheap presence check) and
250
+ ${ctx.linkM(flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext, 'availableSignatureDatabases')} (the identifying names of the loaded databases), alongside the
251
+ richer ${ctx.linkM(flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext, 'loadedSignatureDatabases')} metadata.
252
+
245
253
  ## Configuration
246
254
 
247
255
  The exports come from ${pluginLink('versions:sigdb')}, which reads bundled databases. It is enabled by
@@ -263,16 +271,18 @@ So \`library(stats)\` attaches that release's exports, and a bare \`sd()\` quali
263
271
  without attaching the base namespaces to the graph. Set ${ctx.linkConfig('solver.sigdb.linkBaseR')} to also link them as
264
272
  dataflow edges.
265
273
 
266
- **No** signature shards are committed: the \`base.*\` floor (self-contained base-R signatures, a few hundred KB), the
274
+ Signature shards are not committed to the repository because of their size (the \`current.*\` and \`history.*\` scopes
275
+ span tens of megabytes): the \`base.*\` floor (self-contained base-R signatures, a few hundred KB), the
267
276
  \`current.*\` scope (every package's latest version) and \`history.*\` (every older version) all live as assets on the
268
277
  free ${ctx.linkConfig('solver.sigdb.downloadRepo')} GitHub release. The only committed file is a tiny **link file**,
269
278
  \`src/data/sigdb/sigdb.remote.json\`, which records the release tag and each shard's sha256 and size, so
270
- \`:signature download\` builds the direct release-CDN URL (no API rate limit), verifies every shard by content hash,
279
+ ${ctx.replCmd('signature')} download builds the direct release-CDN URL, verifies every shard by content hash,
271
280
  and skips any already cached. Because the link file is versioned, a \`git pull\` that updates it re-syncs only the
272
281
  shards whose hash changed &mdash; and with ${ctx.linkConfig('solver.sigdb.autoSync')} that check runs on startup and re-downloads in the
273
282
  background; \`npm run build\` bakes the shards in as well. The richest downloaded scope is used (order \`full\` >
274
283
  \`current\` > \`base\`), so once fetched \`library(stats)\` resolves. Any path in ${ctx.linkConfig('solver.sigdb.additionalPaths')} (or
275
284
  \`$FLOWR_SIGDB_DIR\`) is searched alongside the default, so a downloaded bundle stays mounted on every start.
285
+
276
286
  ${databases ? `
277
287
  ## Bundled Databases
278
288
 
@@ -291,7 +301,7 @@ shared dictionary that its shards depend on, so it is decompressed the first tim
291
301
  The flowR Docker images ship this dictionary already decompressed, so a container reads it in place and skips
292
302
  that step (the load column above is the cost a plain npm install pays).
293
303
 
294
- 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 &ge; 22.15), otherwise \`.br\`. \`:signature download\` fetches only that one variant per file, and \`:version\` reports the format each loaded database resolved to.
304
+ 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 &ge; 22.15), otherwise \`.br\`. ${ctx.replCmd('signature')} download fetches only that one variant per file, and ${ctx.replCmd('version')} reports the format each loaded database resolved to.
295
305
  ` : ''}
296
306
  ## Format
297
307
 
@@ -34,7 +34,7 @@ export declare const LintingRules: {
34
34
  readonly name: "File Path Validity";
35
35
  readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
36
36
  readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
37
- readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility, import("./linter-tags").LintingRuleTag.Bug];
37
+ readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility, import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.QuickFix];
38
38
  readonly defaultConfig: {
39
39
  readonly additionalReadFunctions: readonly [];
40
40
  readonly additionalWriteFunctions: readonly [];
@@ -101,7 +101,7 @@ export declare const LintingRules: {
101
101
  };
102
102
  readonly additionalPathFunctions: readonly [];
103
103
  readonly absolutePathRegex: undefined;
104
- readonly useAsWd: "@script";
104
+ readonly useAsWd: "@project";
105
105
  readonly ignoreUrls: true;
106
106
  };
107
107
  };
@@ -379,6 +379,28 @@ export declare const LintingRules: {
379
379
  };
380
380
  };
381
381
  };
382
+ readonly 'syntactically-valid': {
383
+ readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", [], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, 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>[]>>;
384
+ 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/syntactically-valid").SyntacticallyValidConfig, data: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>) => Promise<{
385
+ results: import("./rules/syntactically-valid").SyntacticallyValidResult[];
386
+ ".meta": import("./rules/syntactically-valid").SyntacticallyValidMetadata;
387
+ }>;
388
+ readonly prettyPrint: {
389
+ readonly query: (result: import("./rules/syntactically-valid").SyntacticallyValidResult) => string;
390
+ readonly full: (result: import("./rules/syntactically-valid").SyntacticallyValidResult) => string;
391
+ };
392
+ readonly info: {
393
+ readonly name: "Syntactically Valid";
394
+ readonly description: "Checks whether the code is free of syntax errors, using the configured (error-tolerant) parser, and offers extensible quick-fixes to repair them.";
395
+ readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.QuickFix];
396
+ readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
397
+ readonly activeByDefault: false;
398
+ readonly defaultConfig: {
399
+ readonly disabledFixes: readonly [];
400
+ readonly preferFix: "remove";
401
+ };
402
+ };
403
+ };
382
404
  };
383
405
  export type LintingRuleNames = keyof typeof LintingRules;
384
406
  export type LintingRuleMetadata<Name extends LintingRuleNames> = typeof LintingRules[Name] extends LintingRule<infer _Result, infer Metadata, infer _Config, infer _Info, infer _Elements> ? Metadata : never;
@@ -18,6 +18,7 @@ const software_has_license_1 = require("./rules/software-has-license");
18
18
  const software_has_tests_1 = require("./rules/software-has-tests");
19
19
  const no_leaked_credentials_1 = require("./rules/no-leaked-credentials");
20
20
  const undefined_symbol_1 = require("./rules/undefined-symbol");
21
+ const syntactically_valid_1 = require("./rules/syntactically-valid");
21
22
  /**
22
23
  * The registry of currently supported linting rules.
23
24
  * A linting rule can be executed on a dataflow pipeline result using {@link executeLintingRule}.
@@ -39,6 +40,7 @@ exports.LintingRules = {
39
40
  'software-has-license': software_has_license_1.SOFTWARE_HAS_LICENSE,
40
41
  'software-has-tests': software_has_tests_1.SOFTWARE_HAS_TESTS,
41
42
  'no-leaked-credentials': no_leaked_credentials_1.NO_LEAKED_CREDENTIALS,
42
- 'undefined-symbol': undefined_symbol_1.UNDEFINED_SYMBOL
43
+ 'undefined-symbol': undefined_symbol_1.UNDEFINED_SYMBOL,
44
+ 'syntactically-valid': syntactically_valid_1.SYNTACTICALLY_VALID
43
45
  };
44
46
  //# sourceMappingURL=linter-rules.js.map
@@ -5,7 +5,7 @@ import type { FunctionInfo } from '../../queries/catalog/dependencies-query/func
5
5
  export interface AbsoluteFilePathResult extends LintingResult {
6
6
  filePath: string;
7
7
  }
8
- type SupportedWd = '@script' | '@home' | string;
8
+ type SupportedWd = '@script' | '@home' | '@project' | string;
9
9
  export interface AbsoluteFilePathConfig extends MergeableRecord {
10
10
  /** Include paths that are built by functions, e.g., `file.path()` */
11
11
  include: {
@@ -22,8 +22,8 @@ export interface AbsoluteFilePathConfig extends MergeableRecord {
22
22
  */
23
23
  additionalPathFunctions: FunctionInfo[];
24
24
  /**
25
- * Which path should be considered to be the origin for relative paths.
26
- * This is only relevant with quickfixes. In the future we may be sensitive to setwd etc.
25
+ * Which path the relative-path quick fix is built against: `@project` (project root, falling back to the
26
+ * script when there is no root), `@script`, `@home`, or a literal directory.
27
27
  */
28
28
  useAsWd: SupportedWd;
29
29
  /** Automatically ignore URLs (http/https/ftp) so they are not reported as absolute paths. */
@@ -55,7 +55,7 @@ export declare const ABSOLUTE_PATH: {
55
55
  };
56
56
  readonly additionalPathFunctions: readonly [];
57
57
  readonly absolutePathRegex: undefined;
58
- readonly useAsWd: "@script";
58
+ readonly useAsWd: "@project";
59
59
  readonly ignoreUrls: true;
60
60
  };
61
61
  };
@@ -22,15 +22,16 @@ const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument
22
22
  const path_1 = __importDefault(require("path"));
23
23
  const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
24
24
  const other_path_functions_1 = require("../../queries/catalog/dependencies-query/function-info/other-path-functions");
25
- function inferWd(file, wd) {
25
+ function inferWd(file, wd, ctx) {
26
26
  if (wd === '@script') {
27
- // we can use the script path as the working directory
28
27
  return file;
29
28
  }
30
29
  else if (wd === '@home') {
31
- // we can use the home directory as the working directory
32
30
  return process.env.HOME || process.env.USERPROFILE || '';
33
31
  }
32
+ else if (wd === '@project') {
33
+ return ctx.files.root() ?? file;
34
+ }
34
35
  else {
35
36
  return wd;
36
37
  }
@@ -113,11 +114,12 @@ exports.ABSOLUTE_PATH = {
113
114
  const regex = config.absolutePathRegex ? new RegExp(config.absolutePathRegex) : undefined;
114
115
  const normalize = await data.normalize();
115
116
  const dataflow = await data.dataflow();
117
+ const ctx = data.inspectContext();
116
118
  return {
117
119
  results: elements.getElements().flatMap(element => {
118
120
  metadata.totalConsidered++;
119
121
  const node = element.node;
120
- const wd = inferWd(node.info.file, config.useAsWd);
122
+ const wd = inferWd(node.info.file, config.useAsWd, ctx);
121
123
  if (r_string_1.RString.is(node)) {
122
124
  const resolved = resolvePathForAbsoluteCheck(node.content.str, config.ignoreUrls);
123
125
  if (resolved !== undefined && resolved.length >= 3 && (0, strings_1.isAbsolutePath)(resolved, regex)) {
@@ -200,7 +202,7 @@ exports.ABSOLUTE_PATH = {
200
202
  },
201
203
  additionalPathFunctions: [],
202
204
  absolutePathRegex: undefined,
203
- useAsWd: '@script',
205
+ useAsWd: '@project',
204
206
  ignoreUrls: true
205
207
  }
206
208
  }
@@ -43,7 +43,7 @@ export declare const FILE_PATH_VALIDITY: {
43
43
  readonly name: "File Path Validity";
44
44
  readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
45
45
  readonly certainty: LintingRuleCertainty.BestEffort;
46
- readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility, LintingRuleTag.Bug];
46
+ readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility, LintingRuleTag.Bug, LintingRuleTag.QuickFix];
47
47
  readonly defaultConfig: {
48
48
  readonly additionalReadFunctions: readonly [];
49
49
  readonly additionalWriteFunctions: readonly [];
@@ -11,6 +11,11 @@ const logic_1 = require("../../util/logic");
11
11
  const happens_before_1 = require("../../control-flow/happens-before");
12
12
  const linter_tags_1 = require("../linter-tags");
13
13
  const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
14
+ const resolve_working_directory_1 = require("../../dataflow/eval/resolve/resolve-working-directory");
15
+ const config_1 = require("../../config");
16
+ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
17
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
18
+ const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
14
19
  async function urlExists(url) {
15
20
  try {
16
21
  const response = await fetch(url, { method: 'HEAD' });
@@ -36,6 +41,10 @@ exports.FILE_PATH_VALIDITY = {
36
41
  totalValid: 0
37
42
  };
38
43
  const results = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData).queries['dependencies'];
44
+ const ctx = data.inspectContext();
45
+ const dfg = (await data.dataflow()).graph;
46
+ const resolveSource = data.flowrConfig.solver.resolveSource;
47
+ const wdRootsFor = resolve_working_directory_1.WorkingDirectory.rootsResolver(dfg, cfg, ctx);
39
48
  const findings = await Promise.all(elements.getElements().map(async (element) => {
40
49
  const matchingRead = results.read.find(r => r.nodeId === element.node.info.id);
41
50
  if (!matchingRead) {
@@ -103,20 +112,25 @@ exports.FILE_PATH_VALIDITY = {
103
112
  metadata.totalWritesBeforeAlways++;
104
113
  return [];
105
114
  }
106
- // check if the file exists!
107
- const paths = (0, built_in_source_1.findSource)(data.flowrConfig.solver.resolveSource, matchingRead.value, {
108
- referenceChain: element.node.info.file ? [element.node.info.file] : [],
109
- ctx: data.inspectContext()
110
- });
115
+ // check if the file exists, resolving relative paths against the effective working directory
116
+ const value = matchingRead.value;
117
+ const referenceChain = element.node.info.file ? [element.node.info.file] : [];
118
+ const wdRoots = wdRootsFor(element.node.info.id, element.node.info.file);
119
+ const withWd = { ...resolveSource, searchPath: [...(resolveSource?.searchPath ?? []), ...wdRoots] };
120
+ const paths = (0, built_in_source_1.findSource)(withWd, value, { referenceChain, ctx });
111
121
  if (paths && paths.length) {
112
122
  metadata.totalValid++;
113
123
  return [];
114
124
  }
125
+ // a lax retry (drop leading dirs, ignore case) may surface a near match to offer as a quick fix
126
+ const near = (0, built_in_source_1.findSource)({ ...withWd, ignoreCapitalization: true, dropPaths: config_1.DropPathsOption.All }, value, { referenceChain, ctx });
127
+ const quickFix = dfg.idMap && near && near.length ? buildDidYouMeanFix(dfg.idMap, matchingRead.nodeId, value, near[0]) : undefined;
115
128
  return [{
116
129
  involvedId: matchingRead.nodeId,
117
130
  loc,
118
- filePath: matchingRead.value,
119
- certainty: writesBefore && writesBefore.length && writesBefore.every(w => w === logic_1.Ternary.Maybe) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain
131
+ filePath: value,
132
+ certainty: writesBefore && writesBefore.length && writesBefore.every(w => w === logic_1.Ternary.Maybe) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain,
133
+ ...(quickFix ? { quickFix } : {})
120
134
  }];
121
135
  }));
122
136
  return {
@@ -129,7 +143,7 @@ exports.FILE_PATH_VALIDITY = {
129
143
  description: 'Checks whether file paths used in read and write operations are valid and point to existing files.',
130
144
  // checks all found paths for whether they're valid to ensure correctness, but doesn't handle non-constant paths so not all will be returned
131
145
  certainty: linter_format_1.LintingRuleCertainty.BestEffort,
132
- tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.Bug],
146
+ tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.QuickFix],
133
147
  defaultConfig: {
134
148
  additionalReadFunctions: [],
135
149
  additionalWriteFunctions: [],
@@ -149,4 +163,30 @@ function samePath(a, b, ignoreCapitalization) {
149
163
  }
150
164
  return a === b;
151
165
  }
166
+ /** the string-literal path argument of a call whose resolved value is `value`, for anchoring a quick fix */
167
+ function pathArgStringNode(idMap, callId, value) {
168
+ const call = idMap.get(callId);
169
+ if (call?.type !== type_1.RType.FunctionCall) {
170
+ return undefined;
171
+ }
172
+ for (const arg of call.arguments) {
173
+ if (arg !== r_function_call_1.EmptyArgument && arg.value && r_string_1.RString.is(arg.value) && arg.value.content.str === value) {
174
+ return arg.value;
175
+ }
176
+ }
177
+ return undefined;
178
+ }
179
+ /** rewrite the read path to `found`, an existing file surfaced by the lax retry */
180
+ function buildDidYouMeanFix(idMap, callId, value, found) {
181
+ const str = pathArgStringNode(idMap, callId, value);
182
+ if (!str) {
183
+ return undefined;
184
+ }
185
+ return [{
186
+ type: 'replace',
187
+ loc: range_1.SourceLocation.fromNode(str) ?? range_1.SourceLocation.invalid(),
188
+ description: `Replace with existing path \`${found}\``,
189
+ replacement: str.content.quotes + found + str.content.quotes
190
+ }];
191
+ }
152
192
  //# sourceMappingURL=file-path-validity.js.map
@@ -3,6 +3,7 @@ import type { FlowrSearchElement, FlowrSearchElements } from '../../search/flowr
3
3
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { MergeableRecord } from '../../util/objects';
5
5
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
6
+ import type { Identifier } from '../../dataflow/environments/identifier';
6
7
  import { Ternary } from '../../util/logic';
7
8
  import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
8
9
  import type { AsyncOrSync } from 'ts-essentials';
@@ -17,7 +18,7 @@ export interface FunctionsToDetectConfig extends MergeableRecord {
17
18
  /**
18
19
  * The list of function names that should be marked in the given context.
19
20
  */
20
- fns: readonly string[];
21
+ fns: readonly Identifier[];
21
22
  }
22
23
  /**
23
24
  * This helper object collects utility functions used to create linting rules that search for specific functions.