@eagleoutice/flowr 2.15.9 → 2.16.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.
Files changed (244) hide show
  1. package/README.md +47 -41
  2. package/abstract-interpretation/absint-inference.d.ts +2 -2
  3. package/abstract-interpretation/absint-inference.js +32 -79
  4. package/abstract-interpretation/data-frame/arguments.js +11 -7
  5. package/benchmark/slicer.d.ts +0 -1
  6. package/benchmark/slicer.js +1 -2
  7. package/cli/repl/commands/repl-signature.js +12 -3
  8. package/config.d.ts +5 -1
  9. package/control-flow/cfg-properties.js +0 -22
  10. package/control-flow/happens-before.d.ts +7 -2
  11. package/control-flow/happens-before.js +55 -31
  12. package/control-flow/useless-loop.d.ts +1 -1
  13. package/control-flow/useless-loop.js +29 -42
  14. package/dataflow/environments/apply-kill.js +6 -2
  15. package/dataflow/environments/built-in-config.d.ts +2 -0
  16. package/dataflow/environments/built-in-props.d.ts +16 -1
  17. package/dataflow/environments/built-in-props.js +33 -20
  18. package/dataflow/environments/built-in.d.ts +8 -3
  19. package/dataflow/environments/built-in.js +52 -82
  20. package/dataflow/environments/default-builtin-config.d.ts +551 -21
  21. package/dataflow/environments/default-builtin-config.js +121 -45
  22. package/dataflow/environments/define.d.ts +3 -2
  23. package/dataflow/environments/define.js +4 -3
  24. package/dataflow/environments/deprecation-info.d.ts +45 -0
  25. package/dataflow/environments/deprecation-info.js +13 -0
  26. package/dataflow/environments/environment.d.ts +7 -5
  27. package/dataflow/environments/environment.js +55 -121
  28. package/dataflow/environments/identifier.d.ts +6 -2
  29. package/dataflow/environments/identifier.js +23 -69
  30. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  31. package/dataflow/environments/reference-to-maybe.js +23 -51
  32. package/dataflow/environments/resolve-by-name.js +37 -76
  33. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  34. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  35. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  36. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  37. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  38. package/dataflow/eval/resolve/resolve.js +23 -14
  39. package/dataflow/extractor.js +180 -58
  40. package/dataflow/fn/class-declaration.d.ts +8 -13
  41. package/dataflow/fn/class-declaration.js +95 -116
  42. package/dataflow/fn/exceptions-of-function.js +68 -37
  43. package/dataflow/fn/frame-reflection.d.ts +12 -4
  44. package/dataflow/fn/frame-reflection.js +51 -41
  45. package/dataflow/fn/function-props.js +15 -33
  46. package/dataflow/fn/function-semantics.d.ts +11 -3
  47. package/dataflow/fn/function-semantics.js +6 -0
  48. package/dataflow/fn/higher-order-function.d.ts +9 -1
  49. package/dataflow/fn/higher-order-function.js +27 -24
  50. package/dataflow/fn/strict-function.d.ts +13 -0
  51. package/dataflow/fn/strict-function.js +291 -123
  52. package/dataflow/graph/call-graph.d.ts +7 -6
  53. package/dataflow/graph/call-graph.js +35 -46
  54. package/dataflow/graph/graph.d.ts +13 -1
  55. package/dataflow/graph/graph.js +74 -66
  56. package/dataflow/graph/vertex.d.ts +1 -1
  57. package/dataflow/info.d.ts +8 -1
  58. package/dataflow/info.js +24 -30
  59. package/dataflow/internal/control-flow.d.ts +31 -4
  60. package/dataflow/internal/control-flow.js +61 -39
  61. package/dataflow/internal/linker.d.ts +17 -8
  62. package/dataflow/internal/linker.js +286 -213
  63. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
  65. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  66. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
  67. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
  69. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  70. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
  72. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  73. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +141 -146
  75. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
  76. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  79. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
  81. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
  83. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  84. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  85. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  90. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
  91. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
  93. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  94. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  95. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  96. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  97. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  98. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
  99. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  100. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  101. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  102. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  103. package/dataflow/internal/process/functions/call/common.d.ts +4 -4
  104. package/dataflow/internal/process/functions/call/common.js +49 -71
  105. package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
  106. package/dataflow/internal/process/functions/call/deferred.js +81 -63
  107. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  108. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  109. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  110. package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
  111. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  112. package/dataflow/internal/process/functions/call/quoted.js +257 -154
  113. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  114. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  115. package/dataflow/internal/process/process-symbol.js +4 -3
  116. package/dataflow/internal/program-order.d.ts +26 -0
  117. package/dataflow/internal/program-order.js +49 -0
  118. package/documentation/data/faq/faqs.js +3 -3
  119. package/documentation/data/interface/doc-writing-code.js +1 -2
  120. package/documentation/data/server/doc-data-server-messages.js +7 -7
  121. package/documentation/doc-capabilities.js +80 -34
  122. package/documentation/doc-util/doc-query.d.ts +0 -3
  123. package/documentation/doc-util/doc-query.js +4 -3
  124. package/documentation/wiki-analyzer.js +1 -1
  125. package/documentation/wiki-cfg.js +5 -6
  126. package/documentation/wiki-core.js +8 -8
  127. package/documentation/wiki-dataflow-graph.js +10 -11
  128. package/documentation/wiki-interface.js +2 -2
  129. package/documentation/wiki-linting-and-testing.js +3 -3
  130. package/documentation/wiki-overview.js +6 -6
  131. package/documentation/wiki-query.js +9 -101
  132. package/documentation/wiki-setup.js +23 -0
  133. package/documentation/wiki-signature-database.js +1 -1
  134. package/linter/linter-rules.d.ts +18 -9
  135. package/linter/rules/absolute-path.js +63 -87
  136. package/linter/rules/deprecated-functions.d.ts +1 -45
  137. package/linter/rules/deprecated-functions.js +24 -33
  138. package/linter/rules/file-path-validity.d.ts +4 -2
  139. package/linter/rules/file-path-validity.js +114 -80
  140. package/linter/rules/namespace-access.js +21 -33
  141. package/linter/rules/naming-convention.d.ts +1 -1
  142. package/linter/rules/naming-convention.js +60 -48
  143. package/linter/rules/network-functions.js +11 -7
  144. package/linter/rules/no-leaked-credentials.js +15 -18
  145. package/linter/rules/problematic-inputs.d.ts +2 -1
  146. package/linter/rules/problematic-inputs.js +39 -59
  147. package/linter/rules/roxygen-arguments.d.ts +9 -4
  148. package/linter/rules/roxygen-arguments.js +29 -48
  149. package/linter/rules/seeded-randomness.d.ts +7 -4
  150. package/linter/rules/seeded-randomness.js +128 -89
  151. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  152. package/linter/rules/stop-with-call-arg.js +25 -22
  153. package/linter/rules/unclosed-connection.js +31 -24
  154. package/linter/rules/undefined-symbol.d.ts +4 -6
  155. package/linter/rules/undefined-symbol.js +58 -75
  156. package/linter/rules/unescaped-arguments.js +18 -44
  157. package/linter/rules/unused-definition.d.ts +6 -0
  158. package/linter/rules/unused-definition.js +105 -145
  159. package/linter/rules/unused-import.d.ts +3 -0
  160. package/linter/rules/unused-import.js +25 -43
  161. package/package.json +5 -2
  162. package/project/flowr-analyzer.d.ts +2 -0
  163. package/project/flowr-analyzer.js +28 -1
  164. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  165. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  166. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
  167. package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
  168. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  169. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  170. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
  171. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
  172. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  173. package/project/sigdb/build.js +4 -0
  174. package/project/sigdb/manifest.d.ts +2 -0
  175. package/project/sigdb/manifest.js +10 -1
  176. package/project/sigdb/reader.js +23 -61
  177. package/project/sigdb/sigdb-download.d.ts +29 -6
  178. package/project/sigdb/sigdb-download.js +212 -64
  179. package/queries/base-query-format.js +1 -2
  180. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  181. package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
  182. package/queries/catalog/call-context-query/cascade-action.js +2 -0
  183. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
  184. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  185. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  186. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  187. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  188. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  189. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  190. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  191. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  192. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  193. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  194. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
  195. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  196. package/queries/catalog/origin-query/origin-query-executor.js +2 -2
  197. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
  198. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  199. package/queries/query.d.ts +1 -1
  200. package/r-bridge/data/data.d.ts +21 -14
  201. package/r-bridge/data/data.js +28 -20
  202. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  203. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  204. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  205. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  207. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  208. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  209. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  212. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  213. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  214. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  215. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  216. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  217. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  218. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  219. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  220. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  221. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  222. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  223. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  224. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  225. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  226. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  227. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
  228. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  229. package/r-bridge/shell.js +6 -0
  230. package/search/search-executor/search-enrichers.js +25 -37
  231. package/slicing/static/slice-call.d.ts +4 -3
  232. package/slicing/static/slice-call.js +56 -88
  233. package/slicing/static/static-slicer.js +115 -79
  234. package/slicing/static/visiting-queue.d.ts +4 -6
  235. package/slicing/static/visiting-queue.js +9 -13
  236. package/util/files.d.ts +2 -0
  237. package/util/files.js +3 -1
  238. package/util/mermaid/mermaid.js +6 -2
  239. package/util/proc.js +2 -1
  240. package/util/r-base-packages.d.ts +2 -0
  241. package/util/r-base-packages.js +23 -13
  242. package/util/text/playground-link.d.ts +12 -3
  243. package/util/text/playground-link.js +18 -27
  244. package/util/version.js +4 -10
@@ -206,6 +206,9 @@ function identifyLinkToLastCallRelationSync(from, cfg, graph, { callName, cascad
206
206
  if (act === cascade_action_1.CascadeAction.Skip) {
207
207
  return;
208
208
  }
209
+ else if (act === cascade_action_1.CascadeAction.Block) {
210
+ return true;
211
+ }
209
212
  const tar = satisfiesCallTargets(vertex, graph, CallTargets.MustIncludeGlobal);
210
213
  if (tar !== 'no') {
211
214
  found.push(node);
@@ -10,12 +10,12 @@ async function executeDataflowQuery({ analyzer }, queries) {
10
10
  log_1.log.warn('Dataflow query expects only up to one query, but got', queries.length);
11
11
  }
12
12
  const startTime = Date.now();
13
- const graph = (await analyzer.dataflow()).graph;
13
+ const { graph } = await analyzer.dataflow();
14
14
  return {
15
15
  '.meta': {
16
16
  timing: Date.now() - startTime
17
17
  },
18
- graph
18
+ graph: queries.every(q => q.environments === false) ? graph.withoutEnvironments() : graph
19
19
  };
20
20
  }
21
21
  //# sourceMappingURL=dataflow-query-executor.js.map
@@ -8,6 +8,8 @@ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/nod
8
8
  */
9
9
  export interface DataflowQuery extends BaseQueryFormat {
10
10
  readonly type: 'dataflow';
11
+ /** Whether to include the environments of the vertices and function definitions (default), see {@link DataflowGraph#withoutEnvironments}. */
12
+ readonly environments?: boolean;
11
13
  }
12
14
  export interface DataflowQueryResult extends BaseQueryResult {
13
15
  /** Please be aware that this is the graph in its JSON representation, use {@link DataflowGraph#fromJson} if the result is serialized */
@@ -22,7 +22,7 @@ exports.DataflowQueryDefinition = {
22
22
  result.push(` ╰ [Dataflow Graph](${url})`);
23
23
  }
24
24
  else {
25
- const vertices = Array.from(out.graph.vertices(true)).length;
25
+ const vertices = out.graph.vertices(true).toArray().length;
26
26
  const edges = Array.from(out.graph.edges()).length;
27
27
  result.push(` ╰ Dataflow Graph too large to link (${vertices} vertices, ${edges} edges, url would be ${url.length} chars); use ':df#' for more detail.`);
28
28
  }
@@ -30,14 +30,11 @@ exports.DataflowQueryDefinition = {
30
30
  },
31
31
  schema: joi_1.default.object({
32
32
  type: joi_1.default.string().valid('dataflow').required().description('The type of the query.'),
33
+ environments: joi_1.default.boolean().optional().description('Whether to include the environments of the vertices and function definitions (default: true). They make up most of the answer, so leave them out if only the graph itself is of interest.'),
33
34
  }).description('The dataflow query simply returns the dataflow graph, there is no need to pass it multiple times!'),
34
- flattenInvolvedNodes: queryResults => {
35
- const flattened = [];
35
+ flattenInvolvedNodes: (queryResults) => {
36
36
  const out = queryResults;
37
- for (const id of out.graph.idMap?.keys() ?? []) {
38
- flattened.push(id);
39
- }
40
- return flattened;
37
+ return [...out.graph.idMap?.keys() ?? []];
41
38
  }
42
39
  };
43
40
  //# sourceMappingURL=dataflow-query-format.js.map
@@ -23,7 +23,6 @@ const r_base_packages_1 = require("../../../util/r-base-packages");
23
23
  async function executeDependenciesQuery({ analyzer, }, queries) {
24
24
  let query = queries[0];
25
25
  if (queries.length !== 1) {
26
- // merge
27
26
  for (let i = 1; i < queries.length; i++) {
28
27
  const q = queries[i];
29
28
  query = {
@@ -46,15 +45,11 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
46
45
  const now = Date.now();
47
46
  const ignoreDefault = query.ignoreDefaultFunctions ?? false;
48
47
  const ctx = analyzer.inspectContext();
49
- const functions = new Map(Object.entries((0, dependencies_query_format_1.defaultDependencyCategories)(ctx)).map(([c, v]) => {
50
- return [c, getFunctionsToCheck(query[`${c}Functions`], c, query.enabledCategories, ignoreDefault, v.functions)];
51
- }));
52
- if (query.additionalCategories !== undefined) {
53
- for (const [category, value] of Object.entries(query.additionalCategories)) {
54
- // custom categories only use the "functions" collection and do not allow specifying additional functions in the object itself, so we "undefined" a lot here
55
- const custom = getFunctionsToCheck(undefined, category, undefined, false, value.functions);
56
- functions.set(category, [...(functions.get(category) ?? []), ...custom]);
57
- }
48
+ const functions = new Map(Object.entries((0, dependencies_query_format_1.defaultDependencyCategories)(ctx)).map(([c, v]) => [c, getFunctionsToCheck(query[`${c}Functions`], c, query.enabledCategories, ignoreDefault, v.functions)]));
49
+ for (const [category, value] of Object.entries(query.additionalCategories ?? {})) {
50
+ /* custom categories only use their "functions" collection and allow no additional functions in the object itself */
51
+ const custom = getFunctionsToCheck(undefined, category, undefined, false, value.functions);
52
+ functions.set(category, [...(functions.get(category) ?? []), ...custom]);
58
53
  }
59
54
  const queryResults = !functions.values().toArray().some(f => f.length > 0) ? { kinds: {}, '.meta': { timing: 0 } } :
60
55
  await (0, query_1.executeQueriesOfSameType)(data, functions.entries().flatMap(makeCallContextQuery).toArray());
@@ -62,8 +57,8 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
62
57
  const enabled = query.enabledCategories;
63
58
  const results = Object.fromEntries(await Promise.all(functions.entries().map(async ([c, f]) => {
64
59
  const results = getResults(g, { dataflow, config, normalize }, queryResults, c, f, data);
65
- // only default categories allow additional analyses, so we null-coalesce here!
66
- if (enabled === undefined || (enabled?.length > 0 && enabled.includes(c))) {
60
+ /* only default categories allow additional analyses */
61
+ if (enabled === undefined || enabled.includes(c)) {
67
62
  await g[c]?.additionalAnalysis?.(data, ignoreDefault, f, queryResults, results);
68
63
  }
69
64
  return [c, results];
@@ -74,8 +69,7 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
74
69
  }
75
70
  if (query.assumedPackages && (enabled === undefined || enabled.includes('library'))) {
76
71
  const explicit = new Set((results.library ?? []).map(r => r.value).filter((v) => v !== undefined && v !== dependencies_query_format_1.Unknown && v !== dependencies_query_format_1.Constant));
77
- const rVersion = ctx.resolvedRVersion;
78
- const assumed = assumedBasePackageEntries(dataflow.graph, rVersion, explicit);
72
+ const assumed = assumedBasePackageEntries(dataflow.graph, ctx.resolvedRVersion, explicit);
79
73
  if (assumed.length > 0) {
80
74
  results.library = [...(results.library ?? []), ...assumed];
81
75
  }
@@ -87,27 +81,22 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
87
81
  ...results,
88
82
  };
89
83
  }
84
+ /** One implicit `library` entry per attached base package that the graph uses but that is not loaded explicitly. */
90
85
  function assumedBasePackageEntries(dfg, rVersion, explicit) {
91
- const usedBy = new Map();
86
+ const used = [];
92
87
  for (const [id, qualified] of df_helper_1.Dataflow.qualifyAll(dfg, true)) {
93
- const pkg = qualified === undefined ? undefined : identifier_1.Identifier.getNamespace(qualified);
94
- if (pkg === undefined || explicit.has(pkg) || !r_base_packages_1.AttachedBasePackageSet.has(pkg)) {
95
- continue;
96
- }
97
- const known = usedBy.get(pkg);
98
- if (known) {
99
- known.push(id);
100
- }
101
- else {
102
- usedBy.set(pkg, [id]);
88
+ const pkg = identifier_1.Identifier.getNamespace(qualified);
89
+ if (pkg !== undefined && !explicit.has(pkg) && r_base_packages_1.AttachedBasePackageSet.has(pkg)) {
90
+ used.push({ id, pkg });
103
91
  }
104
92
  }
93
+ const usedBy = Map.groupBy(used, u => u.pkg);
105
94
  return (0, r_base_packages_1.attachedBasePackages)(rVersion).filter(pkg => usedBy.has(pkg)).map(pkg => (0, objects_1.compactRecord)({
106
95
  functionName: dependencies_query_format_1.Attached,
107
96
  value: pkg,
108
97
  implicit: true,
109
98
  alwaysAttached: pkg === "base" /* PkgName.Base */ ? true : undefined,
110
- linkedIds: usedBy.get(pkg)
99
+ linkedIds: usedBy.get(pkg)?.map(u => u.id)
111
100
  }));
112
101
  }
113
102
  function makeCallContextQuery([kind, functions]) {
@@ -122,12 +111,6 @@ function makeCallContextQuery([kind, functions]) {
122
111
  kind
123
112
  }));
124
113
  }
125
- function dropInfoOnLinkedIds(linkedIds) {
126
- if (!linkedIds) {
127
- return undefined;
128
- }
129
- return linkedIds.map(id => typeof id === 'object' ? id.id : id);
130
- }
131
114
  const readOnlyModes = new Set(['r', 'rt', 'rb']);
132
115
  const writeOnlyModes = new Set(['w', 'wt', 'wb', 'a', 'at', 'ab']);
133
116
  /**
@@ -148,16 +131,7 @@ function pickFunctionInfo(candidates, callNamespace, isLoaded) {
148
131
  function getResults(categories, { dataflow, config, normalize }, results, kind, functions, data) {
149
132
  const defaultValue = categories[kind].defaultValue;
150
133
  const vars = config.solver.variables;
151
- const functionMap = new Map();
152
- for (const f of functions) {
153
- const known = functionMap.get(f.name);
154
- if (known) {
155
- known.push(f);
156
- }
157
- else {
158
- functionMap.set(f.name, [f]);
159
- }
160
- }
134
+ const functionMap = Map.groupBy(functions, f => f.name);
161
135
  const kindEntries = Object.entries(results?.kinds[kind]?.subkinds ?? {});
162
136
  const finalResults = [];
163
137
  const ictx = data.analyzer.inspectContext();
@@ -170,36 +144,26 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
170
144
  for (const { id, linkedIds } of results) {
171
145
  const vertex = dfg.getVertex(id);
172
146
  const functionName = df_helper_1.Dataflow.qualify(id, dfg, false) ?? vertex.name;
173
- /* aliased into a const the nested checks can capture, as a hoisted declaration would not see the narrowing */
174
- const picked = pickFunctionInfo(functionMap.get(name), identifier_1.Identifier.getNamespace(functionName), isLoadedPackage);
175
- if (picked === undefined) {
147
+ const info = pickFunctionInfo(functionMap.get(name), identifier_1.Identifier.getNamespace(functionName), isLoadedPackage);
148
+ if (info === undefined) {
176
149
  continue;
177
150
  }
178
- const info = picked;
179
151
  const args = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, info.argIdx, info.argName, info.resolveValue, ictx);
180
152
  const linkedArgs = collectValuesFromLinks(args, { dataflow, config, ctx: ictx }, linkedIds);
181
- const linked = dropInfoOnLinkedIds(linkedIds);
182
- function ignoreOnArgVal() {
183
- if (info.ignoreIf === 'arg-true' || info.ignoreIf === 'arg-false') {
184
- const margs = info.additionalArgs?.val;
185
- (0, assert_1.guard)(margs, 'Need additional argument val when checking for arg-true');
186
- const valArgs = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, margs.argIdx, margs.argName, margs.resolveValue, data?.analyzer.inspectContext());
187
- const valValues = valArgs?.values().flatMap(v => Array.from(v)).toArray() ?? [];
188
- if (valValues.length === 0) {
189
- return false;
190
- }
191
- if (info.ignoreIf === 'arg-true' && valValues.every(v => v === 'TRUE')) {
192
- // all values are TRUE, so we can ignore this
193
- return true;
194
- }
195
- else if (info.ignoreIf === 'arg-false' && valValues.every(v => v === 'FALSE')) {
196
- // all values are FALSE, so we can ignore this
197
- return true;
198
- }
153
+ const linked = linkedIds?.map(linkedId => typeof linkedId === 'object' ? linkedId.id : linkedId);
154
+ const ignoreOnArgVal = () => {
155
+ if (info.ignoreIf !== 'arg-true' && info.ignoreIf !== 'arg-false') {
156
+ return false;
199
157
  }
200
- return false;
201
- }
202
- function ignoreOnArgSet() {
158
+ const margs = info.additionalArgs?.val;
159
+ (0, assert_1.guard)(margs, 'Need additional argument val when checking for arg-true');
160
+ const valArgs = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, margs.argIdx, margs.argName, margs.resolveValue, data?.analyzer.inspectContext());
161
+ const valValues = valArgs?.values().flatMap(v => Array.from(v)).toArray() ?? [];
162
+ /* ignore only if every value is the one the check asks for */
163
+ const ignoredValue = info.ignoreIf === 'arg-true' ? 'TRUE' : 'FALSE';
164
+ return valValues.length > 0 && valValues.every(v => v === ignoredValue);
165
+ };
166
+ const ignoreOnArgSet = () => {
203
167
  if (info.ignoreIf !== 'arg-set') {
204
168
  return;
205
169
  }
@@ -211,38 +175,28 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
211
175
  const margs = info.additionalArgs?.argSet;
212
176
  (0, assert_1.guard)(margs, 'Need additional argument argSet when checking for arg-set');
213
177
  return hasArg(margs.argName, margs.argIdx);
214
- }
178
+ };
215
179
  const foundValues = linkedArgs ?? args;
216
180
  if (!foundValues) {
217
- if (info.ignoreIf === 'arg-missing') {
218
- continue;
219
- }
220
- else if (ignoreOnArgVal()) {
221
- continue;
222
- }
223
- const record = (0, objects_1.compactRecord)({
224
- nodeId: id,
225
- functionName,
226
- lexemeOfArgument: undefined,
227
- linkedIds: linked?.length ? linked : undefined,
228
- value: info.defaultValue ?? defaultValue
229
- });
230
- if (record) {
231
- finalResults.push(record);
181
+ if (info.ignoreIf !== 'arg-missing' && !ignoreOnArgVal() && !ignoreOnArgSet()) {
182
+ finalResults.push((0, objects_1.compactRecord)({
183
+ nodeId: id,
184
+ functionName,
185
+ lexemeOfArgument: undefined,
186
+ linkedIds: linked?.length ? linked : undefined,
187
+ value: info.defaultValue ?? defaultValue
188
+ }));
232
189
  }
233
190
  continue;
234
191
  }
235
192
  else if (info.ignoreIf === 'mode-only-read' || info.ignoreIf === 'mode-only-write') {
236
193
  const margs = info.additionalArgs?.mode;
237
194
  (0, assert_1.guard)(margs, 'Need additional argument mode when checking for mode');
195
+ const modes = info.ignoreIf === 'mode-only-read' ? readOnlyModes : writeOnlyModes;
238
196
  const modeArgs = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, margs.argIdx, margs.argName, margs.resolveValue, data?.analyzer.inspectContext());
239
197
  const modeValues = modeArgs?.values().flatMap(v => Array.from(v)) ?? [];
240
- if (info.ignoreIf === 'mode-only-read' && modeValues.every(m => m && readOnlyModes.has(m))) {
241
- // all modes are read-only, so we can ignore this
242
- continue;
243
- }
244
- else if (info.ignoreIf === 'mode-only-write' && modeValues.every(m => m && writeOnlyModes.has(m))) {
245
- // all modes are write-only, so we can ignore this
198
+ /* all modes are read-only (resp. write-only), so we can ignore this */
199
+ if (modeValues.every(m => m && modes.has(m))) {
246
200
  continue;
247
201
  }
248
202
  }
@@ -252,8 +206,8 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
252
206
  for (const [arg, values] of foundValues.entries()) {
253
207
  for (const value of values) {
254
208
  let resolvedValue = value;
255
- if (info.stringReplacements && resolvedValue !== undefined && Object.hasOwn(info.stringReplacements, resolvedValue)) {
256
- resolvedValue = info.stringReplacements[resolvedValue];
209
+ if (info.stringReplacements && value !== undefined && Object.hasOwn(info.stringReplacements, value)) {
210
+ resolvedValue = info.stringReplacements[value];
257
211
  }
258
212
  const dep = resolvedValue ? d.getDependency(resolvedValue) ?? undefined : undefined;
259
213
  const lexeme = getLexeme(value, arg);
@@ -278,11 +232,7 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
278
232
  if ((argument && argument !== dependencies_query_format_1.Unknown && argument !== dependencies_query_format_1.Constant) || !id) {
279
233
  return undefined;
280
234
  }
281
- let get = normalize.idMap.get(id);
282
- if (r_argument_1.RArgument.is(get)) {
283
- get = get.value;
284
- }
285
- return model_1.RNode.lexeme(get);
235
+ return model_1.RNode.lexeme(r_argument_1.RArgument.valueOf(normalize.idMap.get(id)));
286
236
  }
287
237
  }
288
238
  function collectValuesFromLinks(args, data, linkedIds) {
@@ -296,38 +246,24 @@ function collectValuesFromLinks(args, data, linkedIds) {
296
246
  continue;
297
247
  }
298
248
  const info = linkedId.info;
299
- // do not collect this one
300
249
  if (hasAtLeastAValue && info.when !== function_info_1.DependencyInfoLinkConstraint.Always) {
301
250
  continue;
302
251
  }
303
- // collect this one!
304
252
  const vertex = data.dataflow.graph.getVertex(linkedId.id);
305
253
  if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
306
254
  continue;
307
255
  }
308
256
  const args = (0, resolve_argument_1.getArgumentStringValue)(data.config.solver.variables, data.dataflow.graph, vertex, info.argIdx, info.argName, info.resolveValue, data.ctx);
309
- if (args === undefined) {
310
- continue;
311
- }
312
- for (const [arg, values] of args.entries()) {
313
- const set = map.get(arg) ?? new Set();
314
- map.set(arg, set);
315
- for (const value of values) {
316
- set.add(value);
317
- }
257
+ for (const [arg, values] of args?.entries() ?? []) {
258
+ map.set(arg, (map.get(arg) ?? new Set()).union(values));
318
259
  }
319
260
  }
320
261
  return map.size ? map : undefined;
321
262
  }
322
263
  function getFunctionsToCheck(customFunctions, functionFlag, enabled, ignoreDefaultFunctions, defaultFunctions) {
323
- // "If unset or empty, all function types are searched for."
324
- if (enabled !== undefined && (enabled?.length === 0 || !enabled.includes(functionFlag))) {
264
+ if (enabled !== undefined && !enabled.includes(functionFlag)) {
325
265
  return [];
326
266
  }
327
- let functions = ignoreDefaultFunctions ? [] : defaultFunctions.slice();
328
- if (customFunctions) {
329
- functions = functions.concat(customFunctions);
330
- }
331
- return functions;
267
+ return [...(ignoreDefaultFunctions ? [] : defaultFunctions), ...(customFunctions ?? [])];
332
268
  }
333
269
  //# sourceMappingURL=dependencies-query-executor.js.map
@@ -1,14 +1,10 @@
1
1
  import type { FunctionInfo } from './function-info';
2
- /**
3
- * A loader of the `library` category, together with whether it attaches the package it names.
4
- * @see {@link LibraryFunctions}
5
- */
2
+ import type { DependencyInfo } from '../dependencies-query-format';
3
+ /** A loader of the {@link LibraryFunctions|`library` category}, together with whether it attaches the package it names. */
6
4
  export interface LibraryFunctionInfo extends FunctionInfo {
7
- /**
8
- * Whether the call makes the package's exports reachable by their bare name, which is what tells a package
9
- * that is loaded and used apart from one that is loaded and never touched. `false` for a loader that only
10
- * readies a namespace to reach as `pkg::fn`, and for one whose argument is not a package at all.
11
- */
5
+ /** Whether the call makes the package's exports reachable by their bare name, not only as `pkg::fn`. */
12
6
  attaches: boolean;
13
7
  }
14
8
  export declare const LibraryFunctions: LibraryFunctionInfo[];
9
+ /** Whether the known loader a `library`-category finding came from attaches the package (`base::require` as well as `require`). */
10
+ export declare function attachesPackage(info: DependencyInfo): boolean;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LibraryFunctions = void 0;
4
+ exports.attachesPackage = attachesPackage;
5
+ const identifier_1 = require("../../../../dataflow/environments/identifier");
4
6
  exports.LibraryFunctions = [
5
7
  { package: 'base', name: 'library', argIdx: 0, argName: 'package', resolveValue: 'library', attaches: true },
6
8
  { package: 'base', name: 'require', argIdx: 0, argName: 'package', resolveValue: 'library', attaches: true },
@@ -29,4 +31,8 @@ exports.LibraryFunctions = [
29
31
  /* a hook that runs when the package is loaded by someone else, which loads nothing itself */
30
32
  { package: 'rlang', name: 'on_package_load', argIdx: 0, argName: 'pkg', resolveValue: true, attaches: false }
31
33
  ];
34
+ /** Whether the known loader a `library`-category finding came from attaches the package (`base::require` as well as `require`). */
35
+ function attachesPackage(info) {
36
+ return exports.LibraryFunctions.some(loader => loader.attaches && identifier_1.Identifier.matches(loader.name, info.functionName));
37
+ }
32
38
  //# sourceMappingURL=library-functions.js.map
@@ -22,7 +22,7 @@ const ReadFunctionsWithMore = [
22
22
  { package: 'base', name: 'fifo', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
23
23
  { package: 'base', name: 'unz', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
24
24
  { package: 'base', name: 'matrix', argIdx: 0, argName: 'data', resolveValue: true },
25
- { package: 'utils', name: 'data', argIdx: 0, resolveValue: 'library', ignoreIf: 'arg-missing' },
25
+ { package: 'utils', name: 'data', argIdx: 'unnamed', argName: 'list', resolveValue: 'library', ignoreIf: 'arg-missing' },
26
26
  { package: 'readr', name: 'clipboard' },
27
27
  { package: 'sourcetools', name: 'tokenize', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
28
28
  { package: 'ape', name: 'read.tree', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
@@ -36,6 +36,13 @@ const WriteFunctionsWithMore = [
36
36
  { package: 'rlang', name: 'inform', linkTo: OutputRedirects, resolveValue: false },
37
37
  { package: 'cli', name: 'cli_warn', linkTo: OutputRedirects, resolveValue: false },
38
38
  { package: 'cli', name: 'cli_abort', linkTo: OutputRedirects, resolveValue: false },
39
+ { package: 'base', name: 'file.create', argIdx: 'unnamed', resolveValue: true },
40
+ { package: 'base', name: 'file.copy', argIdx: 1, argName: 'to', resolveValue: true },
41
+ { package: 'base', name: 'file.rename', argIdx: 1, argName: 'to', resolveValue: true },
42
+ { package: 'base', name: 'file.append', argIdx: 0, argName: 'file1', resolveValue: true },
43
+ { package: 'base', name: 'file.symlink', argIdx: 1, argName: 'to', resolveValue: true },
44
+ { package: 'base', name: 'file.link', argIdx: 1, argName: 'to', resolveValue: true },
45
+ { package: 'utils', name: 'download.file', argIdx: 1, argName: 'destfile', resolveValue: true },
39
46
  { package: 'base', name: 'file', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
40
47
  { package: 'base', name: 'url', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
41
48
  { package: 'grDevices', name: 'jpeg', argIdx: 0, argName: 'filename', resolveValue: true },
@@ -77,9 +84,6 @@ const WriteFunctionsWithMore = [
77
84
  { package: 'png', name: 'writePNG', argIdx: 1, argName: 'target', resolveValue: true, ignoreIf: 'arg-missing' },
78
85
  /* audio / video */
79
86
  { package: 'seewave', name: 'savewav', argName: 'filename', resolveValue: true, defaultValue: '<wave-name>' },
80
- /* geospatial */
81
- /* array / binary science formats */
82
- /* phylogeny / sequence */
83
87
  ];
84
88
  /** The write entries the given built-in definitions imply, together with the ones written down here. */
85
89
  function computeWriteFunctions(definitions, read = (0, read_functions_1.computeReadFunctions)(definitions)) {
@@ -24,12 +24,12 @@ export interface LinkedInputObject {
24
24
  readonly requires?: string;
25
25
  /** if given, only these fields are inputs (`session$clientData` is, `session$userData` is not) and the object itself is none */
26
26
  readonly fields?: readonly string[];
27
- /** how the framework declares the entries of this object, so a read of `input$n` links to the `textInput("n", …)` defining it */
27
+ /** how the framework declares the entries of this object, so a read of `input$n` links to the `textInput("n", ...)` defining it */
28
28
  readonly declaredBy?: LinkedInputDeclaration;
29
29
  }
30
30
  /** The calls that declare the entries of a {@link LinkedInputObject}, and where they carry the entry's name. */
31
31
  export interface LinkedInputDeclaration {
32
- /** the declaring calls, e.g. shiny's `textInput`, `selectInput`, … */
32
+ /** the declaring calls, e.g. shiny's `textInput`, `selectInput`, ... */
33
33
  readonly calls: readonly Identifier[];
34
34
  /** the name of the argument holding the entry's name */
35
35
  readonly argName: string;
@@ -81,11 +81,11 @@ export interface InputSource extends MergeableRecord {
81
81
  name?: string;
82
82
  /** the concrete scalar value when the source is a constant or a pure alias of one */
83
83
  value?: ConstantValue;
84
- /** where the framework entry this source reads is declared, e.g. the `textInput("n", …)` behind an `input$n` */
84
+ /** where the framework entry this source reads is declared, e.g. the `textInput("n", ...)` behind an `input$n` */
85
85
  declaredAt?: NodeId[];
86
86
  }
87
87
  /**
88
- * Map of input sources, keyed by the node id of the input source. Each input source is classified with an {@link InputSource} object.
88
+ * The input sources of a criterion, each classified with an {@link InputSource} object.
89
89
  */
90
90
  export type InputSources = InputSource[];
91
91
  /**