@eagleoutice/flowr 2.16.1 → 2.16.3

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 (459) hide show
  1. package/README.md +10 -10
  2. package/abstract-interpretation/data-frame/arguments.js +4 -3
  3. package/abstract-interpretation/data-frame/dataframe-semantics.js +1 -2
  4. package/abstract-interpretation/data-frame/semantics.d.ts +2 -2
  5. package/abstract-interpretation/data-frame/semantics.js +2 -6
  6. package/benchmark/slicer.js +1 -3
  7. package/benchmark/summarizer/first-phase/input.js +1 -12
  8. package/benchmark/summarizer/second-phase/process.d.ts +7 -0
  9. package/benchmark/summarizer/second-phase/process.js +15 -12
  10. package/cli/repl/commands/repl-cfg.js +18 -49
  11. package/cli/repl/commands/repl-clipboard.d.ts +2 -0
  12. package/cli/repl/commands/repl-clipboard.js +5 -0
  13. package/cli/repl/commands/repl-commands.js +2 -2
  14. package/cli/repl/commands/repl-dataflow.js +21 -55
  15. package/cli/repl/commands/repl-normalize.js +15 -28
  16. package/cli/repl/commands/repl-parse.js +2 -2
  17. package/cli/repl/commands/repl-query.js +10 -10
  18. package/cli/repl/commands/repl-signature.js +4 -4
  19. package/cli/repl/server/connection.d.ts +1 -0
  20. package/cli/repl/server/connection.js +8 -30
  21. package/cli/repl/server/messages/message-analysis.js +1 -1
  22. package/config.d.ts +6 -0
  23. package/config.js +7 -4
  24. package/control-flow/cfg-dead-code.js +5 -14
  25. package/control-flow/cfg-to-basic-blocks.js +1 -6
  26. package/control-flow/control-flow-graph.d.ts +2 -16
  27. package/control-flow/control-flow-graph.js +8 -66
  28. package/control-flow/diff-cfg.js +10 -23
  29. package/control-flow/semantic-cfg-guided-visitor.js +5 -11
  30. package/control-flow/simple-visitor.js +2 -2
  31. package/core/steps/pipeline/default-pipelines.d.ts +138 -138
  32. package/data/r-base-packages.generated.js +0 -1
  33. package/data/r-base-primitives.generated.js +0 -1
  34. package/data/r-s3-generics.generated.d.ts +5 -0
  35. package/data/r-s3-generics.generated.js +103 -0
  36. package/dataflow/cluster.js +2 -1
  37. package/dataflow/environments/append.d.ts +1 -0
  38. package/dataflow/environments/built-in-props.d.ts +15 -2
  39. package/dataflow/environments/built-in-props.js +31 -4
  40. package/dataflow/environments/built-in.js +15 -9
  41. package/dataflow/environments/clone.d.ts +1 -0
  42. package/dataflow/environments/clone.js +1 -0
  43. package/dataflow/environments/default-builtin-config.d.ts +385 -25
  44. package/dataflow/environments/default-builtin-config.js +186 -106
  45. package/dataflow/environments/define.d.ts +1 -0
  46. package/dataflow/environments/define.js +1 -0
  47. package/dataflow/environments/environment.d.ts +27 -0
  48. package/dataflow/environments/environment.js +37 -16
  49. package/dataflow/environments/frame-memory.d.ts +9 -1
  50. package/dataflow/environments/frame-memory.js +12 -1
  51. package/dataflow/environments/identifier.d.ts +1 -2
  52. package/dataflow/environments/identifier.js +5 -7
  53. package/dataflow/environments/overwrite.js +1 -0
  54. package/dataflow/environments/query-fn-props.d.ts +3 -0
  55. package/dataflow/environments/query-fn-props.js +7 -0
  56. package/dataflow/environments/resolve-by-name.js +11 -4
  57. package/dataflow/environments/scoping.d.ts +3 -0
  58. package/dataflow/environments/scoping.js +3 -0
  59. package/dataflow/eval/resolve/alias-tracking.js +3 -3
  60. package/dataflow/eval/resolve/resolve-argument.d.ts +7 -3
  61. package/dataflow/eval/resolve/resolve-argument.js +21 -12
  62. package/dataflow/eval/resolve/resolve-numbers.js +5 -2
  63. package/dataflow/eval/resolve/resolve-strings.d.ts +1 -1
  64. package/dataflow/eval/resolve/resolve-working-directory.js +2 -2
  65. package/dataflow/eval/resolve/resolve.js +1 -2
  66. package/dataflow/eval/values/intervals/interval-constants.js +1 -6
  67. package/dataflow/eval/values/r-value.js +1 -6
  68. package/dataflow/extractor.js +17 -17
  69. package/dataflow/fn/argument-roles.js +15 -15
  70. package/dataflow/fn/class-declaration.js +7 -7
  71. package/dataflow/fn/frame-reflection.d.ts +1 -23
  72. package/dataflow/fn/frame-reflection.js +8 -95
  73. package/dataflow/fn/function-props.d.ts +0 -3
  74. package/dataflow/fn/function-props.js +9 -11
  75. package/dataflow/fn/function-semantics.d.ts +1 -0
  76. package/dataflow/fn/strict-function.js +15 -14
  77. package/dataflow/graph/call-graph.d.ts +8 -0
  78. package/dataflow/graph/call-graph.js +40 -25
  79. package/dataflow/graph/dataflowgraph-builder.d.ts +0 -60
  80. package/dataflow/graph/dataflowgraph-builder.js +15 -135
  81. package/dataflow/graph/df-helper.d.ts +56 -4
  82. package/dataflow/graph/df-helper.js +116 -1
  83. package/dataflow/graph/diff-dataflow-graph.js +13 -15
  84. package/dataflow/graph/graph-helper.d.ts +20 -0
  85. package/dataflow/graph/graph-helper.js +18 -0
  86. package/dataflow/graph/graph.js +15 -8
  87. package/dataflow/graph/match-args.d.ts +1 -1
  88. package/dataflow/graph/match-args.js +3 -3
  89. package/dataflow/internal/linker.d.ts +4 -10
  90. package/dataflow/internal/linker.js +21 -29
  91. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -8
  92. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +5 -2
  93. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +39 -22
  94. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -21
  95. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -7
  96. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +6 -11
  97. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  98. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -13
  99. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +27 -13
  100. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -8
  101. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +33 -35
  102. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -5
  103. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +6 -7
  104. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -5
  105. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +3 -4
  106. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +7 -8
  107. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -6
  108. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +3 -4
  109. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -3
  110. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +14 -7
  111. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +6 -5
  112. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -2
  113. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -6
  114. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +4 -4
  115. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +7 -7
  116. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +1 -2
  117. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -3
  118. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  119. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +5 -7
  120. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  121. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +4 -5
  122. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -9
  123. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
  124. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +3 -3
  125. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +36 -38
  126. package/dataflow/internal/process/functions/call/common.d.ts +3 -1
  127. package/dataflow/internal/process/functions/call/common.js +6 -7
  128. package/dataflow/internal/process/functions/call/deferred.js +8 -8
  129. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +11 -4
  130. package/dataflow/internal/process/functions/call/known-call-handling.js +11 -7
  131. package/dataflow/internal/process/functions/call/named-call-handling.js +64 -11
  132. package/dataflow/internal/process/functions/call/nse.js +4 -4
  133. package/dataflow/internal/process/functions/call/quoted.js +16 -14
  134. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
  135. package/dataflow/internal/process/functions/process-parameter.js +2 -2
  136. package/dataflow/internal/process/process-named-call.js +1 -1
  137. package/dataflow/origin/dfg-get-origin.js +2 -2
  138. package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -0
  139. package/dataflow/origin/dfg-get-symbol-refs.js +3 -8
  140. package/documentation/data/faq/wiki-faq-store.js +2 -2
  141. package/documentation/doc-capabilities.js +2 -1
  142. package/documentation/doc-util/doc-functions.js +2 -2
  143. package/documentation/doc-util/doc-repl.js +4 -4
  144. package/documentation/doc-util/doc-types.js +2 -2
  145. package/documentation/wiki-absint.js +2 -1
  146. package/documentation/wiki-cfg.js +2 -1
  147. package/documentation/wiki-create-linting-rules.js +1 -1
  148. package/documentation/wiki-dataflow-graph.js +6 -6
  149. package/documentation/wiki-interface.js +3 -2
  150. package/documentation/wiki-linter.js +54 -4
  151. package/documentation/wiki-mk/doc-maker.js +1 -2
  152. package/documentation/wiki-query.js +25 -0
  153. package/documentation/wiki-search.js +2 -1
  154. package/documentation/wiki-signature-database.js +0 -2
  155. package/linter/linter-executor.js +4 -0
  156. package/linter/linter-rules.d.ts +526 -4
  157. package/linter/linter-rules.js +39 -1
  158. package/linter/linter-tags.d.ts +6 -0
  159. package/linter/linter-tags.js +6 -0
  160. package/linter/rules/absolute-path.js +4 -3
  161. package/linter/rules/cmd-check/bogus-return.d.ts +29 -0
  162. package/linter/rules/cmd-check/bogus-return.js +63 -0
  163. package/linter/rules/cmd-check/call-arguments.d.ts +63 -0
  164. package/linter/rules/cmd-check/call-arguments.js +211 -0
  165. package/linter/rules/cmd-check/class-string-comparison.d.ts +48 -0
  166. package/linter/rules/cmd-check/class-string-comparison.js +135 -0
  167. package/linter/rules/cmd-check/cmd-check-util.d.ts +67 -0
  168. package/linter/rules/cmd-check/cmd-check-util.js +169 -0
  169. package/linter/rules/cmd-check/compiled-code.d.ts +86 -0
  170. package/linter/rules/cmd-check/compiled-code.js +350 -0
  171. package/linter/rules/cmd-check/conformance.d.ts +47 -0
  172. package/linter/rules/cmd-check/conformance.js +166 -0
  173. package/linter/rules/cmd-check/dependency-declaration.d.ts +95 -0
  174. package/linter/rules/cmd-check/dependency-declaration.js +299 -0
  175. package/linter/rules/cmd-check/description-metadata.d.ts +63 -0
  176. package/linter/rules/cmd-check/description-metadata.js +393 -0
  177. package/linter/rules/cmd-check/documentation-mismatch.d.ts +54 -0
  178. package/linter/rules/cmd-check/documentation-mismatch.js +407 -0
  179. package/linter/rules/cmd-check/file-checks.d.ts +29 -0
  180. package/linter/rules/cmd-check/file-checks.js +34 -0
  181. package/linter/rules/cmd-check/foreign-function-calls.d.ts +54 -0
  182. package/linter/rules/cmd-check/foreign-function-calls.js +115 -0
  183. package/linter/rules/cmd-check/global-environment-modification.d.ts +61 -0
  184. package/linter/rules/cmd-check/global-environment-modification.js +237 -0
  185. package/linter/rules/cmd-check/namespace-tampering.d.ts +52 -0
  186. package/linter/rules/cmd-check/namespace-tampering.js +162 -0
  187. package/linter/rules/cmd-check/non-ascii-code.d.ts +51 -0
  188. package/linter/rules/cmd-check/non-ascii-code.js +112 -0
  189. package/linter/rules/cmd-check/package-code.d.ts +30 -0
  190. package/linter/rules/cmd-check/package-code.js +141 -0
  191. package/linter/rules/cmd-check/package-data.d.ts +49 -0
  192. package/linter/rules/cmd-check/package-data.js +181 -0
  193. package/linter/rules/cmd-check/package-files.d.ts +41 -0
  194. package/linter/rules/cmd-check/package-files.js +157 -0
  195. package/linter/rules/cmd-check/package-hooks.d.ts +57 -0
  196. package/linter/rules/cmd-check/package-hooks.js +165 -0
  197. package/linter/rules/cmd-check/package-metafiles.d.ts +49 -0
  198. package/linter/rules/cmd-check/package-metafiles.js +292 -0
  199. package/linter/rules/cmd-check/package-runtime.d.ts +67 -0
  200. package/linter/rules/cmd-check/package-runtime.js +284 -0
  201. package/linter/rules/cmd-check/package-structure.d.ts +85 -0
  202. package/linter/rules/cmd-check/package-structure.js +320 -0
  203. package/linter/rules/cmd-check/rd-files.d.ts +67 -0
  204. package/linter/rules/cmd-check/rd-files.js +621 -0
  205. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +72 -0
  206. package/linter/rules/cmd-check/s-three-method-consistency.js +206 -0
  207. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +45 -0
  208. package/linter/rules/cmd-check/true-false-abbreviation.js +121 -0
  209. package/linter/rules/deprecated-functions.js +4 -4
  210. package/linter/rules/function-finder-util.d.ts +1 -1
  211. package/linter/rules/function-finder-util.js +1 -3
  212. package/linter/rules/naming-convention.d.ts +1 -1
  213. package/linter/rules/naming-convention.js +13 -14
  214. package/linter/rules/network-functions.d.ts +4 -3
  215. package/linter/rules/network-functions.js +14 -12
  216. package/linter/rules/no-leaked-credentials.d.ts +8 -3
  217. package/linter/rules/no-leaked-credentials.js +134 -36
  218. package/linter/rules/problematic-inputs.d.ts +1 -1
  219. package/linter/rules/problematic-inputs.js +21 -14
  220. package/linter/rules/seeded-randomness.js +5 -5
  221. package/linter/rules/software-has-license.d.ts +1 -1
  222. package/linter/rules/software-has-license.js +1 -1
  223. package/linter/rules/unclosed-connection.js +3 -3
  224. package/linter/rules/undefined-symbol-util.js +16 -32
  225. package/linter/rules/undefined-symbol.d.ts +2 -0
  226. package/linter/rules/undefined-symbol.js +33 -3
  227. package/linter/rules/unescaped-arguments.d.ts +13 -2
  228. package/linter/rules/unescaped-arguments.js +104 -15
  229. package/linter/rules/unused-definition.js +13 -19
  230. package/package.json +1 -1
  231. package/project/cache/flowr-analyzer-cache.js +1 -1
  232. package/project/context/flowr-analyzer-context.js +1 -1
  233. package/project/context/flowr-analyzer-environment-context.d.ts +1 -1
  234. package/project/context/flowr-analyzer-files-context.d.ts +6 -0
  235. package/project/context/flowr-analyzer-files-context.js +3 -0
  236. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +0 -2
  237. package/project/context/flowr-analyzer-incremental-analysis-context.js +0 -4
  238. package/project/context/flowr-file.d.ts +4 -0
  239. package/project/context/flowr-file.js +4 -0
  240. package/project/flowr-analyzer-builder.js +1 -1
  241. package/project/plugins/file-plugins/files/flowr-description-file.js +2 -2
  242. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -0
  243. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +4 -0
  244. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +2 -0
  245. package/project/plugins/file-plugins/files/flowr-manifest-files.js +11 -14
  246. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +3 -0
  247. package/project/plugins/file-plugins/files/flowr-namespace-file.js +25 -15
  248. package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +44 -0
  249. package/project/plugins/file-plugins/files/flowr-rd-file.js +130 -61
  250. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -1
  251. package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -16
  252. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
  253. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +4 -0
  254. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +2 -0
  255. package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -0
  256. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +0 -1
  257. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -5
  258. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +2 -0
  259. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -0
  260. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +3 -7
  261. package/project/sigdb/build.js +16 -30
  262. package/project/sigdb/dict.d.ts +4 -6
  263. package/project/sigdb/dict.js +125 -31
  264. package/project/sigdb/reader.js +2 -18
  265. package/project/sigdb/sigdb-download.js +14 -23
  266. package/queries/base-query-format.d.ts +2 -0
  267. package/queries/base-query-format.js +10 -2
  268. package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
  269. package/queries/catalog/absint-query/absint-query-format.js +5 -7
  270. package/queries/catalog/call-context-query/call-context-query-executor.js +26 -33
  271. package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
  272. package/queries/catalog/call-context-query/call-context-query-format.js +1 -3
  273. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -4
  274. package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -4
  275. package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -3
  276. package/queries/catalog/config-query/config-query-format.js +3 -3
  277. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -3
  278. package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -3
  279. package/queries/catalog/dependencies-query/data-flow.d.ts +43 -0
  280. package/queries/catalog/dependencies-query/data-flow.js +173 -0
  281. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +18 -0
  282. package/queries/catalog/dependencies-query/dependencies-query-executor.js +108 -12
  283. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +17 -1
  284. package/queries/catalog/dependencies-query/dependencies-query-format.js +14 -11
  285. package/queries/catalog/dependencies-query/function-info/derived-functions.js +2 -1
  286. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
  287. package/queries/catalog/dependencies-query/function-info/library-functions.js +13 -13
  288. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  289. package/queries/catalog/dependencies-query/function-info/remote-functions.js +3 -3
  290. package/queries/catalog/dependencies-query/function-info/source-functions.js +2 -2
  291. package/queries/catalog/dependencies-query/function-info/test-functions.js +8 -8
  292. package/queries/catalog/dependencies-query/function-info/transform-functions.d.ts +8 -0
  293. package/queries/catalog/dependencies-query/function-info/transform-functions.js +17 -0
  294. package/queries/catalog/dependencies-query/function-info/write-functions.js +4 -0
  295. package/queries/catalog/dependencies-query/implicit-echo.d.ts +5 -3
  296. package/queries/catalog/dependencies-query/implicit-echo.js +33 -34
  297. package/queries/catalog/dependencies-query/link-devices.d.ts +3 -2
  298. package/queries/catalog/dependencies-query/link-devices.js +9 -6
  299. package/queries/catalog/dependencies-query/plot-description.d.ts +10 -0
  300. package/queries/catalog/dependencies-query/plot-description.js +119 -0
  301. package/queries/catalog/dependencies-query/plot-objects.d.ts +13 -0
  302. package/queries/catalog/dependencies-query/plot-objects.js +61 -0
  303. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -2
  304. package/queries/catalog/dice-query/dice-query-format.js +3 -40
  305. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  306. package/queries/catalog/does-call-query/does-call-query-format.js +2 -2
  307. package/queries/catalog/function-info-query/function-info-query-format.js +2 -2
  308. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +2 -1
  309. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  310. package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
  311. package/queries/catalog/id-map-query/id-map-query-format.js +1 -3
  312. package/queries/catalog/input-sources-query/input-source-functions.d.ts +6 -4
  313. package/queries/catalog/input-sources-query/input-source-functions.js +11 -6
  314. package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -3
  315. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -1
  316. package/queries/catalog/input-sources-query/input-sources-query-format.js +11 -5
  317. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +12 -4
  318. package/queries/catalog/input-sources-query/simple-input-classifier.js +237 -40
  319. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +4 -7
  320. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +1 -1
  321. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
  322. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
  323. package/queries/catalog/linter-query/linter-query-executor.js +10 -3
  324. package/queries/catalog/linter-query/linter-query-format.d.ts +4 -1
  325. package/queries/catalog/linter-query/linter-query-format.js +32 -21
  326. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  327. package/queries/catalog/location-map-query/location-map-query-format.js +1 -3
  328. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -3
  329. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  330. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  331. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  332. package/queries/catalog/origin-query/origin-query-format.js +4 -5
  333. package/queries/catalog/project-query/project-query-format.js +2 -2
  334. package/queries/catalog/provenance-query/provenance-query-format.js +2 -3
  335. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  336. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -4
  337. package/queries/catalog/search-query/search-query-format.js +1 -3
  338. package/queries/catalog/signature-query/signature-query-executor.js +3 -3
  339. package/queries/catalog/signature-query/signature-query-format.js +2 -2
  340. package/queries/catalog/slice-query-options.d.ts +16 -0
  341. package/queries/catalog/slice-query-options.js +28 -0
  342. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
  343. package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -42
  344. package/queries/query-print.d.ts +4 -0
  345. package/queries/query-print.js +17 -1
  346. package/queries/query.d.ts +3 -3
  347. package/queries/query.js +3 -4
  348. package/r-bridge/lang-4.x/ast/model/model.d.ts +27 -3
  349. package/r-bridge/lang-4.x/ast/model/model.js +28 -1
  350. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  351. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  352. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +20 -1
  355. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +25 -1
  356. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
  357. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  358. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
  359. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  360. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
  361. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  362. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
  363. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  364. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
  365. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  366. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +18 -2
  367. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +15 -6
  368. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
  369. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  370. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
  371. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  372. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
  373. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  374. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
  375. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  376. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
  377. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  378. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
  379. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +1 -0
  380. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
  381. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
  382. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
  383. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  384. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
  385. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  386. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +17 -0
  387. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +20 -0
  388. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
  389. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  390. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
  391. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  392. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
  393. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  394. package/r-bridge/lang-4.x/ast/model/operators.js +0 -2
  395. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -6
  396. package/r-bridge/lang-4.x/ast/model/processing/fold.js +1 -6
  397. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -3
  398. package/r-bridge/lang-4.x/ast/parser/json/format.js +2 -2
  399. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -5
  400. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -2
  401. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -20
  402. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -5
  403. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -5
  404. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -5
  405. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -9
  406. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
  407. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -10
  408. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -11
  409. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -11
  410. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -5
  411. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -5
  412. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -5
  413. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +6 -1
  414. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +7 -0
  415. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -10
  416. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +30 -82
  417. package/r-bridge/retriever.d.ts +0 -4
  418. package/r-bridge/retriever.js +0 -13
  419. package/r-bridge/roxygen2/documentation-provider.js +3 -7
  420. package/r-bridge/shell.js +3 -8
  421. package/reconstruct/auto-select/magic-comments.js +8 -7
  422. package/reconstruct/inline/source-inline-map.d.ts +3 -0
  423. package/reconstruct/inline/source-inline-map.js +8 -7
  424. package/reconstruct/reconstruct.d.ts +1 -1
  425. package/reconstruct/reconstruct.js +33 -109
  426. package/search/flowr-search-printer.js +4 -15
  427. package/search/search-executor/search-enrichers.js +5 -3
  428. package/search/search-executor/search-generators.js +1 -1
  429. package/slicing/criterion/filters/all-variables.js +1 -2
  430. package/slicing/static/fingerprint.js +11 -2
  431. package/slicing/static/slice-call.d.ts +2 -8
  432. package/slicing/static/slice-call.js +8 -18
  433. package/slicing/static/static-slicer.js +81 -6
  434. package/util/collections/arrays.js +1 -1
  435. package/util/collections/set.js +1 -1
  436. package/util/diff-graph.d.ts +4 -0
  437. package/util/diff-graph.js +12 -0
  438. package/util/files.js +2 -6
  439. package/util/json.js +1 -15
  440. package/util/mermaid/cfg.js +10 -17
  441. package/util/mermaid/dfg.js +6 -8
  442. package/util/objects.d.ts +1 -1
  443. package/util/quads.js +4 -13
  444. package/util/r-author.js +5 -5
  445. package/util/range.d.ts +9 -0
  446. package/util/range.js +11 -0
  447. package/util/schema.js +3 -3
  448. package/util/simple-df/dfg-view.js +2 -1
  449. package/util/text/ansi.js +1 -2
  450. package/util/text/playground-link.js +2 -1
  451. package/util/text/r-highlight.js +2 -1
  452. package/util/text/strings.d.ts +2 -0
  453. package/util/text/strings.js +5 -0
  454. package/util/text/time.js +1 -2
  455. package/util/version.js +4 -3
  456. package/dataflow/fn/recursive-function.d.ts +0 -6
  457. package/dataflow/fn/recursive-function.js +0 -32
  458. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +0 -16
  459. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +0 -27
@@ -13,6 +13,8 @@ const vertex_1 = require("../../../dataflow/graph/vertex");
13
13
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
14
14
  const edge_1 = require("../../../dataflow/graph/edge");
15
15
  const identifier_1 = require("../../../dataflow/environments/identifier");
16
+ const r_parameter_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
17
+ const r_comment_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-comment");
16
18
  const assert_1 = require("../../../util/assert");
17
19
  const arrays_1 = require("../../../util/collections/arrays");
18
20
  const built_in_proc_name_1 = require("../../../dataflow/environments/built-in-proc-name");
@@ -24,7 +26,10 @@ const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol"
24
26
  const convert_values_1 = require("../../../r-bridge/lang-4.x/convert-values");
25
27
  const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
26
28
  const r_function_definition_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
27
- const frame_reflection_1 = require("../../../dataflow/fn/frame-reflection");
29
+ const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
30
+ const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
31
+ const range_1 = require("../../../util/range");
32
+ const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
28
33
  /** how far a function handed to an entry point may be passed along before we give up resolving it */
29
34
  const MaxFunctionResolveDepth = 4;
30
35
  function isConstantLike(type) {
@@ -77,8 +82,10 @@ class InputClassifier {
77
82
  packages;
78
83
  cache = new Map();
79
84
  fullClassifier;
85
+ unsanitized;
80
86
  declarationIndex;
81
87
  entryPointIndex;
88
+ rebinding;
82
89
  /** `packages` are the packages attached in the analyzed program, `undefined` if that is not known (then everything may match) */
83
90
  constructor(dfg, config, fullDfg, packages) {
84
91
  this.dfg = dfg;
@@ -90,7 +97,12 @@ class InputClassifier {
90
97
  return this.fullDfg ?? this.dfg;
91
98
  }
92
99
  matches(call, list) {
93
- return list?.some(id => call.id === id || (identifier_1.Identifier.is(id) && callMeans(call.name, id, this.packages))) ?? false;
100
+ /* a call of a definition in the code does not mean the built-in of the same name */
101
+ return list?.some(id => call.id === id || (identifier_1.Identifier.is(id) && callMeans(call.name, id, this.packages) && !this.callsDefinition(call))) ?? false;
102
+ }
103
+ /** whether the callee is a definition of the code rather than one handed in as an argument */
104
+ callsDefinition(call) {
105
+ return df_helper_1.Dataflow.calleeIdsOf(this.whole, call.id).some(d => !df_helper_1.Dataflow.hasEdge(this.whole, call.id, d, edge_1.EdgeType.Argument));
94
106
  }
95
107
  /** whether the package the given entry needs is attached (unknown package information lets everything through) */
96
108
  hasPackage(name) {
@@ -98,7 +110,26 @@ class InputClassifier {
98
110
  }
99
111
  classifyAt(ref, graph = this.dfg) {
100
112
  const vtx = ref === undefined ? undefined : graph.getVertex(ref);
101
- return vtx ? this.classifyEntry(vtx) : undefined;
113
+ /* what the criterion's function reads through a template (`glue("{x}")`) is no node of its code */
114
+ return vtx ? this.classifyEntry(vtx) : ref !== undefined && graph === this.dfg ? this.classifyInFullGraph(ref) : undefined;
115
+ }
116
+ /** classifies an argument as written: the name a `get` looks up, the function `do.call` is handed */
117
+ classifyArgument(call, ref) {
118
+ const node = ref === undefined ? undefined : this.dfg.idMap?.get(ref);
119
+ const parent = node?.info.parent === undefined ? undefined : this.dfg.idMap?.get(node.info.parent);
120
+ const vtx = ref === undefined ? undefined : this.dfg.getVertex(ref);
121
+ if (ref === undefined || !r_symbol_1.RSymbol.is(node)) {
122
+ return this.classifyAt(ref);
123
+ }
124
+ else if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Get) && parent !== undefined && !r_argument_1.RArgument.is(parent)) {
125
+ const written = r_string_1.RString.is(parent) ? (0, objects_1.compactRecord)({ ...sourceOf(ref, input_types_1.InputType.Constant), value: parent.content.str }) : this.classifyAt(parent.info.id);
126
+ return written && { ...written, id: ref };
127
+ }
128
+ else if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Apply) && vertex_1.DfgVertex.isFunctionCall(vtx) && df_helper_1.Dataflow.targetsOf(this.dfg, ref, edge_1.EdgeType.Reads).every(t => node_id_1.NodeId.isBuiltIn(t) || !this.functionDefinitionsAt(t).next().done)) {
129
+ /* a name of a function the code defines or flowR knows */
130
+ return sourceOf(ref, input_types_1.InputType.Constant);
131
+ }
132
+ return this.classifyAt(ref);
102
133
  }
103
134
  /**
104
135
  * Returns the specification of the {@link LinkedInputObject|linked input object} the given id refers to
@@ -276,15 +307,22 @@ class InputClassifier {
276
307
  const parameters = new Set(enclosing.flatMap(fn => fn.parameters.map(p => identifier_1.Identifier.getName(p.name.content))));
277
308
  for (const arg of call.args) {
278
309
  const ref = graph_1.FunctionArgument.getReference(arg);
310
+ /* an evaluated argument (`parse_expr(text)`) is code only as far as its value is */
311
+ if (ref !== undefined && df_helper_1.Dataflow.hasEdge(this.whole, call.id, ref, edge_1.EdgeType.Reads)) {
312
+ if (!this.classifyAt(ref)?.types.every(isConstantLike)) {
313
+ return false;
314
+ }
315
+ continue;
316
+ }
279
317
  const within = model_1.RNode.collectAllIds(ref === undefined ? undefined : idMap.get(ref));
280
318
  for (const id of within) {
281
319
  const node = idMap.get(id);
282
320
  if (r_symbol_1.RSymbol.is(node) && parameters.has(identifier_1.Identifier.getName(node.content))) {
283
321
  return false;
284
322
  }
285
- for (const target of (0, frame_reflection_1.edgeTargets)(this.dfg, id, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall)) {
323
+ for (const target of df_helper_1.Dataflow.targetsOf(this.dfg, id, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall)) {
286
324
  /* the call evaluating the code is no input to it */
287
- if (!within.has(target) && !node_id_1.NodeId.isBuiltIn(target) && !(0, frame_reflection_1.hasEdgeOfType)(this.dfg, target, id, edge_1.EdgeType.Returns)) {
325
+ if (!within.has(target) && !node_id_1.NodeId.isBuiltIn(target) && !df_helper_1.Dataflow.hasEdge(this.dfg, target, id, edge_1.EdgeType.Returns)) {
288
326
  return false;
289
327
  }
290
328
  }
@@ -297,7 +335,7 @@ class InputClassifier {
297
335
  * carrying the accessed field as its {@link InputSource.name|name}.
298
336
  */
299
337
  classifyLinkedObjectAccess(call) {
300
- if (!call.origin.includes(built_in_proc_name_1.BuiltInProcName.Access)) {
338
+ if (!vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Access)) {
301
339
  return undefined;
302
340
  }
303
341
  const accessed = graph_1.FunctionArgument.getReference(call.args[0]);
@@ -323,49 +361,95 @@ class InputClassifier {
323
361
  }
324
362
  return undefined;
325
363
  }
326
- /** the argument a built-in hands on: the value of a block or `get` (then `renamed`), the condition of a branch or loop */
364
+ /** the argument a built-in hands on: the value of a block or `get` (then `renamed`), the condition of a loop */
327
365
  passedOn(call) {
328
- if (call.origin.includes(built_in_proc_name_1.BuiltInProcName.ExpressionList)) {
366
+ if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.ExpressionList)) {
329
367
  // `{ a; b }` evaluates to its last expression, just like in R
330
368
  return { via: call.args.findLast(a => !graph_1.FunctionArgument.isEmpty(a)), renamed: true };
331
369
  }
332
- else if (call.origin.includes(built_in_proc_name_1.BuiltInProcName.IfThenElse) || call.origin.includes(built_in_proc_name_1.BuiltInProcName.WhileLoop)) {
370
+ else if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.WhileLoop)) {
333
371
  return { via: call.args[0], renamed: false };
334
372
  }
335
- else if (call.origin.includes(built_in_proc_name_1.BuiltInProcName.ForLoop)) {
373
+ else if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.ForLoop)) {
336
374
  return { via: call.args[1], renamed: false };
337
375
  }
338
- else if (call.origin.includes(built_in_proc_name_1.BuiltInProcName.Get) && !this.whole.unknownSideEffects.has(node_id_1.NodeId.normalize(call.id))) {
376
+ else if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Get) && !this.whole.unknownSideEffects.has(node_id_1.NodeId.normalize(call.id))
377
+ && df_helper_1.Dataflow.targetsOf(this.whole, call.id, edge_1.EdgeType.Returns).length > 0) {
339
378
  // a statically resolved `get("x")` yields the value of the retrieved variable, read via its first argument
340
379
  return { via: call.args[0], renamed: true };
341
380
  }
342
381
  return undefined;
343
382
  }
383
+ /** an `if` or `switch` yields one of its branches (`NULL` without a matching one), its condition only picks which */
384
+ classifyBranches(call) {
385
+ const acc = new ClassificationAccumulator();
386
+ const isSwitch = vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Switch);
387
+ const condition = conditionArgument(call);
388
+ const branches = call.args.filter(a => a !== condition);
389
+ for (const ref of branches.map(graph_1.FunctionArgument.getReference)) {
390
+ /* a branch flowR found dead is in no graph */
391
+ const vtx = ref === undefined ? undefined : this.dfg.getVertex(ref) ?? this.whole.getVertex(ref);
392
+ if (vtx !== undefined) {
393
+ acc.merge(this.classifyEntry(vtx));
394
+ }
395
+ }
396
+ if (isSwitch || branches.length < 2 || branches.some(graph_1.FunctionArgument.isEmpty)) {
397
+ acc.push(input_types_1.InputType.Constant, null);
398
+ }
399
+ acc.cds.push(...condition === undefined ? [] : this.dependencies(graph_1.FunctionArgument.getReference(condition), []));
400
+ return acc.build(call.id);
401
+ }
402
+ /** the arguments of a sanitizer it takes as code rather than escaping, see {@link InputClassifierConfig.templates} */
403
+ templateArguments(call) {
404
+ return (this.config.templates ?? []).filter(t => this.matches(call, [t.call])).flatMap(t => t.argName === '...'
405
+ ? call.args.filter(a => !graph_1.FunctionArgument.isNamed(a)).map(graph_1.FunctionArgument.getReference)
406
+ : [this.argumentReference(call, t.argIdx, t.argName)]);
407
+ }
408
+ /** the types and control dependencies of what `ref` yields, `unknown` when it cannot be classified */
409
+ dependencies(ref, unknown = [input_types_1.InputType.Unknown]) {
410
+ const c = this.classifyAt(ref);
411
+ return c ? [...c.types, ...c.cds ?? []] : unknown;
412
+ }
413
+ /** what a control dependency on the given id depends on: the condition of an `if` or `switch`, else the id itself */
414
+ conditionOf(id) {
415
+ const vtx = this.dfg.getVertex(id);
416
+ const condition = vertex_1.DfgVertex.isFunctionCall(vtx) ? conditionArgument(vtx) : undefined;
417
+ return condition === undefined ? id : graph_1.FunctionArgument.getReference(condition);
418
+ }
344
419
  classifyFunctionCall(call) {
345
420
  const linkedAccess = this.classifyLinkedObjectAccess(call);
346
421
  if (linkedAccess) {
347
422
  return this.classifyCdsAndReturn(call, linkedAccess);
348
423
  }
424
+ if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.IfThenElse) || vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Switch)) {
425
+ return this.classifyCdsAndReturn(call, this.classifyBranches(call));
426
+ }
349
427
  const handed = this.passedOn(call);
350
428
  const passed = this.classifyAt(handed?.via === undefined ? undefined : graph_1.FunctionArgument.getReference(handed.via));
351
429
  if (passed) {
352
430
  return this.classifyCdsAndReturn(call, handed?.renamed ? { ...passed, id: call.id } : passed);
353
431
  }
354
- // a narrowing function returns a bounded value: either one of a specific argument's values (e.g. `match.arg`
355
- // -> its `choices`), or - with no bounding argument - a content-independent value like a count/index/logical
432
+ if (this.matches(call, this.config.sanitizers)) {
433
+ const acc = new ClassificationAccumulator();
434
+ acc.push(input_types_1.InputType.DerivedConstant);
435
+ this.templateArguments(call).forEach(t => acc.merge(this.classifyAt(t)));
436
+ return this.classifyCdsAndReturn(call, acc.build(call.id));
437
+ }
438
+ // a narrowing function returns one of a specific argument's values (e.g. `match.arg` -> its `choices`)
356
439
  for (const narrow of this.config.narrowing ?? []) {
357
440
  if (!this.matches(call, [narrow.call])) {
358
441
  continue;
359
442
  }
360
- if (narrow.argIdx === undefined) {
361
- return this.classifyCdsAndReturn(call, { id: call.id, types: [input_types_1.InputType.DerivedConstant], trace: input_types_1.InputTraceType.Pure });
362
- }
363
- const narrowed = this.classifyAt(this.argumentReference(call, narrow.argIdx, narrow.argName ?? ''));
443
+ const bound = this.argumentReference(call, narrow.argIdx, narrow.argName);
444
+ const narrowed = this.classifyAt(bound);
364
445
  if (narrowed) {
365
- return this.classifyCdsAndReturn(call, { ...narrowed, id: call.id });
446
+ /* which of the values it is depends on the other arguments */
447
+ const cds = call.args.map(graph_1.FunctionArgument.getReference).filter(a => a !== bound).flatMap(a => this.dependencies(a));
448
+ return this.classifyCdsAndReturn(call, { ...narrowed, id: call.id, cds: (0, arrays_1.uniqueArray)([...narrowed.cds ?? [], ...cds]) });
366
449
  }
367
450
  }
368
- if (!this.matches(call, this.config.pure)) {
451
+ const evaluates = this.matches(call, this.config.evaluating);
452
+ if (!evaluates && !this.matches(call, this.config.pure)) {
369
453
  const types = record_1.Record.values(input_types_1.InputType).filter(type => this.matches(call, this.config[type]));
370
454
  // if a File-typed call reads from a temp path, replace File with TempFile
371
455
  const readsFile = types.includes(input_types_1.InputType.File) && !types.includes(input_types_1.InputType.TempFile);
@@ -380,7 +464,20 @@ class InputClassifier {
380
464
  if (types.length === 0) {
381
465
  /* a call of something the code produced (a shiny `reactive()`) or defines yields what that produced or returns */
382
466
  const produced = this.classifyCallee(call) ?? this.classifyDefinitionResult(call);
383
- if (produced !== undefined) {
467
+ if (produced !== undefined && vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Try)) {
468
+ /* the handlers only answer for a failing block, which may just as well succeed */
469
+ const acc = new ClassificationAccumulator();
470
+ const block = this.argumentReference(call, 0, 'expr');
471
+ acc.merge(produced);
472
+ acc.merge(this.classifyAt(block));
473
+ /* and whether they answer depends on everything the block does */
474
+ const statements = block === undefined ? undefined : this.whole.getVertex(block);
475
+ for (const arg of vertex_1.DfgVertex.isFunctionCall(statements) && vertex_1.DfgVertex.hasOrigin(statements, built_in_proc_name_1.BuiltInProcName.ExpressionList) ? statements.args : []) {
476
+ acc.cds.push(...this.dependencies(graph_1.FunctionArgument.getReference(arg)));
477
+ }
478
+ return this.classifyCdsAndReturn(call, acc.build(call.id));
479
+ }
480
+ else if (produced !== undefined) {
384
481
  return this.classifyCdsAndReturn(call, { ...produced, id: call.id });
385
482
  }
386
483
  // if it is not pure, we cannot classify based on the inputs, in that case we do not know!
@@ -388,10 +485,18 @@ class InputClassifier {
388
485
  }
389
486
  return this.classifyCdsAndReturn(call, { id: call.id, types, trace: input_types_1.InputTraceType.Unknown });
390
487
  }
391
- const argTypes = [];
488
+ const argTypes = evaluates ? [input_types_1.InputType.Unknown] : [];
392
489
  const cdTypes = [];
393
- for (const arg of call.args.filter(graph_1.FunctionArgument.isNotEmpty)) {
394
- const classified = this.classifyAt(graph_1.FunctionArgument.getReference(arg));
490
+ const interpolated = this.templateReads(call);
491
+ /* cutting into what a sanitizer escaped undoes the escape */
492
+ const edits = this.matches(call, this.config.editing);
493
+ const of = edits && this.config.sanitizers !== undefined ? this.unsanitized ??= new InputClassifier(this.dfg, { ...this.config, sanitizers: undefined }, this.fullDfg, this.packages) : this;
494
+ for (const ref of (0, arrays_1.uniqueArray)([...call.args.filter(graph_1.FunctionArgument.isNotEmpty).map(graph_1.FunctionArgument.getReference), ...interpolated])) {
495
+ /* a function handed in (`sapply(x, function(i) runif(1))`) contributes what it returns */
496
+ const vtx = ref === undefined ? undefined : this.whole.getVertex(ref);
497
+ const fns = vtx === undefined || vertex_1.DfgVertex.isFunctionCall(vtx) ? [] : [...this.functionDefinitionsAt(ref)];
498
+ const classified = fns.length > 0 ? this.classifyExits(fns, ref)
499
+ : vertex_1.DfgVertex.isFunctionCall(vtx) && identifier_1.Identifier.getName(vtx.name) === '~' && df_helper_1.Dataflow.hasEdge(this.whole, call.id, vtx.id, edge_1.EdgeType.Calls) ? this.classifyFormula(vtx) : of.classifyAt(ref);
395
500
  argTypes.push(...classified?.types ?? [input_types_1.InputType.Unknown]);
396
501
  cdTypes.push(...classified?.cds ?? []);
397
502
  }
@@ -400,7 +505,7 @@ class InputClassifier {
400
505
  return this.classifyCdsAndReturn(call, (0, objects_1.compactRecord)({
401
506
  id: call.id,
402
507
  types: constLike ? [input_types_1.InputType.DerivedConstant] : (0, arrays_1.uniqueArray)([...argTypes, input_types_1.InputType.DerivedConstant]),
403
- trace: constLike ? input_types_1.InputTraceType.Pure : input_types_1.InputTraceType.Known,
508
+ trace: constLike ? input_types_1.InputTraceType.Pure : evaluates || edits || interpolated.length > 0 ? input_types_1.InputTraceType.Unknown : input_types_1.InputTraceType.Known,
404
509
  cds: cdTypes.length > 0 ? (0, arrays_1.uniqueArray)(cdTypes) : undefined
405
510
  }));
406
511
  }
@@ -410,8 +515,22 @@ class InputClassifier {
410
515
  * when the call names no definition here or when none of them says anything about what it returns.
411
516
  */
412
517
  classifyDefinitionResult(call) {
518
+ return this.classifyExits(this.functionDefinitionsAt(call.id), call.id);
519
+ }
520
+ /** what a string template like `glue("{x}")` evaluates and reads, which is no argument, but flows in all the same */
521
+ templateReads(call) {
522
+ return vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.StringTemplate) ? df_helper_1.Dataflow.targetsOf(this.whole, call.id, edge_1.EdgeType.Reads).filter(t => this.whole.hasVertex(t) && !vertex_1.DfgVertex.hasOrigin(this.whole.getVertex(t), built_in_proc_name_1.BuiltInProcName.Library)) : [];
523
+ }
524
+ /** a formula called as a function (`purrr::map(x, ~ runif(1))`) yields what its body does */
525
+ classifyFormula(formula) {
413
526
  const acc = new ClassificationAccumulator();
414
- for (const fn of this.functionDefinitionsAt(call.id)) {
527
+ formula.args.forEach(a => acc.merge(this.classifyAt(graph_1.FunctionArgument.getReference(a))));
528
+ return acc.build(formula.id);
529
+ }
530
+ /** what the exit points of the given function definitions yield, see {@link classifyDefinitionResult} */
531
+ classifyExits(fns, id) {
532
+ const acc = new ClassificationAccumulator();
533
+ for (const fn of fns) {
415
534
  const definition = this.whole.getVertex(fn);
416
535
  for (const { nodeId } of vertex_1.DfgVertex.isFunctionDefinition(definition) ? definition.exitPoints : []) {
417
536
  for (const value of this.exitValues(nodeId)) {
@@ -428,7 +547,7 @@ class InputClassifier {
428
547
  if (acc.values.length === 0) {
429
548
  return undefined;
430
549
  }
431
- const built = acc.build(call.id);
550
+ const built = acc.build(id);
432
551
  return built.types.includes(input_types_1.InputType.Unknown) ? undefined : built;
433
552
  }
434
553
  /**
@@ -442,12 +561,12 @@ class InputClassifier {
442
561
  yield id;
443
562
  return;
444
563
  }
445
- const isLoop = vtx.origin.includes(built_in_proc_name_1.BuiltInProcName.WhileLoop) || vtx.origin.includes(built_in_proc_name_1.BuiltInProcName.ForLoop)
446
- || vtx.origin.includes(built_in_proc_name_1.BuiltInProcName.RepeatLoop);
564
+ const isLoop = vertex_1.DfgVertex.hasOrigin(vtx, built_in_proc_name_1.BuiltInProcName.WhileLoop) || vertex_1.DfgVertex.hasOrigin(vtx, built_in_proc_name_1.BuiltInProcName.ForLoop)
565
+ || vertex_1.DfgVertex.hasOrigin(vtx, built_in_proc_name_1.BuiltInProcName.RepeatLoop);
447
566
  if (isLoop) {
448
567
  yield undefined;
449
568
  }
450
- else if (vtx.origin.includes(built_in_proc_name_1.BuiltInProcName.IfThenElse) && depth <= MaxFunctionResolveDepth) {
569
+ else if (vertex_1.DfgVertex.hasOrigin(vtx, built_in_proc_name_1.BuiltInProcName.IfThenElse) && depth <= MaxFunctionResolveDepth) {
451
570
  for (const branch of vtx.args.slice(1)) {
452
571
  const ref = graph_1.FunctionArgument.getReference(branch);
453
572
  if (ref === undefined) {
@@ -469,7 +588,11 @@ class InputClassifier {
469
588
  continue;
470
589
  }
471
590
  const classified = this.classifyAt(o.id) ?? this.classifyInFullGraph(o.id);
472
- if (classified !== undefined && !classified.types.includes(input_types_1.InputType.Unknown)) {
591
+ if (classified?.types.every(isConstantLike)) {
592
+ /* a constant held as a function (`get("readLines")`, a body set to quoted code) says nothing about what calling it yields */
593
+ return sourceOf(call.id, input_types_1.InputType.Unknown);
594
+ }
595
+ else if (classified !== undefined && !classified.types.includes(input_types_1.InputType.Unknown)) {
473
596
  return classified;
474
597
  }
475
598
  }
@@ -482,7 +605,7 @@ class InputClassifier {
482
605
  }
483
606
  const origins = df_helper_1.Dataflow.origin(this.dfg, vtx.id);
484
607
  if (origins === undefined || origins.length === 0) {
485
- if ((0, frame_reflection_1.edgeTargets)(this.whole, vtx.id, edge_1.EdgeType.DefinedByOnCall).length > 0) {
608
+ if (df_helper_1.Dataflow.targetsOf(this.whole, vtx.id, edge_1.EdgeType.DefinedByOnCall).length > 0) {
486
609
  return this.classifyCdsAndReturn(vtx, sourceOf(vtx.id, input_types_1.InputType.Scope));
487
610
  }
488
611
  // the definition is not part of the criterion's function, so it has to come from an enclosing scope
@@ -504,13 +627,35 @@ class InputClassifier {
504
627
  acc.merge(undefined);
505
628
  }
506
629
  }
630
+ if (this.mayBeRebound(vtx.id, origins.map(o => o.id))) {
631
+ acc.merge(undefined);
632
+ }
507
633
  return this.classifyCdsAndReturn(vtx, acc.build(vtx.id));
508
634
  }
635
+ /** what the default of a parameter yields when a call leaves the parameter out */
636
+ defaultTypes(id) {
637
+ const idMap = this.whole.idMap;
638
+ const param = idMap?.get(idMap.get(id)?.info.parent);
639
+ return r_parameter_1.RParameter.is(param) && param.defaultValue !== undefined ? this.classifyInFullGraph(param.defaultValue.info.id)?.types ?? [input_types_1.InputType.Unknown] : [];
640
+ }
509
641
  parameterType(id) {
510
642
  if (this.dfg.idMap?.get(id)?.info.role !== "param-n" /* RoleInParent.ParameterName */) {
511
643
  return undefined;
512
644
  }
513
- return this.matchWholeLinkedObject(id)?.type ?? input_types_1.InputType.Parameter;
645
+ return this.matchWholeLinkedObject(id)?.type ?? (this.isPlumberEndpointParameter(id) ? input_types_1.InputType.User : input_types_1.InputType.Parameter);
646
+ }
647
+ /** plumber hands each parameter of a function with a `#*` route annotation what a request sends */
648
+ isPlumberEndpointParameter(id) {
649
+ const idMap = this.whole.idMap;
650
+ for (const node of model_1.RNode.iterateParents(idMap.get(id), idMap)) {
651
+ if (node.info.adToks?.some(t => r_comment_1.RComment.is(t) && PlumberEndpoint.test(t.lexeme ?? ''))) {
652
+ return true;
653
+ }
654
+ else if (node.info.parent === undefined || (r_function_definition_1.RFunctionDefinition.is(node) && node.info.adToks?.length)) {
655
+ return false;
656
+ }
657
+ }
658
+ return false;
514
659
  }
515
660
  /**
516
661
  * Resolves a variable definition or use origin, handling the special cases of
@@ -524,12 +669,12 @@ class InputClassifier {
524
669
  }
525
670
  // if the referenced definition is linked via defined-by-on-call to another id (e.g., a parameter linked to a
526
671
  // caller argument), follow it into the caller; only if that leads nowhere is it an opaque Scope origin
527
- const onCall = (0, frame_reflection_1.edgeTargets)(this.whole, v.id, edge_1.EdgeType.DefinedByOnCall);
672
+ const onCall = df_helper_1.Dataflow.targetsOf(this.whole, v.id, edge_1.EdgeType.DefinedByOnCall);
528
673
  if (onCall.length > 0) {
529
674
  const callers = onCall.map(t => this.classifyInFullGraph(t)).filter(assert_1.isNotUndefined);
530
675
  const known = callers.filter(c => !c.types.includes(input_types_1.InputType.Unknown));
531
676
  known.forEach(c => acc.merge(c));
532
- if (known.length > 0 && known.length === callers.length) {
677
+ if (known.length > 0 && known.length === callers.length && !this.escapes(v.id)) {
533
678
  return;
534
679
  }
535
680
  acc.push(input_types_1.InputType.Scope);
@@ -538,15 +683,50 @@ class InputClassifier {
538
683
  const parameter = vertex_1.DfgVertex.isVariableDefinition(v) ? this.parameterType(v.id) : undefined;
539
684
  if (parameter !== undefined) {
540
685
  acc.push(parameter);
686
+ acc.types.push(...this.defaultTypes(v.id));
541
687
  }
542
688
  else {
543
689
  acc.merge(this.classifyEntry(v));
544
690
  }
545
691
  }
692
+ /** whether the function binding the parameter is used as a value, so it may be called with anything the visible callers do not pass */
693
+ escapes(parameter) {
694
+ const idMap = this.whole.idMap;
695
+ const fn = idMap === undefined ? undefined : model_1.RNode.iterateParents(idMap.get(parameter), idMap).find(r_function_definition_1.RFunctionDefinition.is);
696
+ const holders = fn === undefined ? [] : df_helper_1.Dataflow.sourcesOf(this.whole, fn.info.id, edge_1.EdgeType.DefinedBy);
697
+ return holders.length === 0 || holders.some(h => df_helper_1.Dataflow.sourcesOf(this.whole, h, edge_1.EdgeType.Reads)
698
+ .some(r => !r_function_call_1.RFunctionCall.is(idMap?.get(r)) || !df_helper_1.Dataflow.hasEdge(this.whole, r, fn?.info.id, edge_1.EdgeType.Calls)));
699
+ }
700
+ /** whether code flowR cannot follow (`load`, `eval`, `e$x <-`) may rebind the variable before the use */
701
+ mayBeRebound(use, definitions) {
702
+ const idMap = this.whole.idMap;
703
+ const node = idMap.get(use);
704
+ const fn = model_1.RNode.iterateParents(node, idMap).find(r_function_definition_1.RFunctionDefinition.is);
705
+ const within = (id) => fn !== undefined && model_1.RNode.iterateParents(idMap.get(id), idMap).some(p => p === fn);
706
+ const local = definitions.length > 0 && definitions.every(within);
707
+ /* an unconditional definition after the effect binds anew */
708
+ const overwritten = (e) => definitions.length > 0 && definitions.every(d => !this.whole.getVertex(d)?.cds?.length
709
+ && runsAfter(idMap.get(idMap.get(d)?.info.parent), idMap.get(e), idMap));
710
+ return this.rebinders().some(([e, fields]) => (fields === undefined || fields.some(f => f === undefined || f === model_1.RNode.lexeme(node)))
711
+ && (!local || within(e)) && !overwritten(e) && !((fn === undefined || local) && runsAfter(idMap.get(e), node, idMap)));
712
+ }
713
+ /** the unknown side effects, and the replacements `e$x <- v` with the names they may bind (`undefined` for any) */
714
+ rebinders() {
715
+ const name = (a) => {
716
+ const ref = graph_1.FunctionArgument.getReference(a);
717
+ return ref === undefined ? undefined : this.extractConstantValue(ref) ?? model_1.RNode.lexeme(this.whole.idMap?.get(ref));
718
+ };
719
+ return this.rebinding ??= [
720
+ ...[...this.whole.unknownSideEffects].filter(e => !graph_1.UnknownSideEffect.isLinked(e)).map(e => [graph_1.UnknownSideEffect.id(e), undefined]),
721
+ ...this.whole.verticesOfType(vertex_1.VertexType.FunctionCall)
722
+ .filter(([, c]) => vertex_1.DfgVertex.hasOrigin(c, built_in_proc_name_1.BuiltInProcName.Replacement) && FieldReplacements.has(identifier_1.Identifier.getName(c.name)))
723
+ .map(([id, c]) => [id, c.args.slice(1, -1).map(name)])
724
+ ];
725
+ }
546
726
  classifyVariableDefinition(vtx) {
547
727
  const parameter = this.parameterType(vtx.id);
548
728
  if (parameter !== undefined) {
549
- return this.classifyCdsAndReturn(vtx, sourceOf(vtx.id, parameter));
729
+ return this.classifyCdsAndReturn(vtx, { ...sourceOf(vtx.id, parameter), types: (0, arrays_1.uniqueArray)([parameter, ...this.defaultTypes(vtx.id)]) });
550
730
  }
551
731
  else if (!vtx.source?.length) {
552
732
  // fallback to unknown if we cannot find the value
@@ -559,10 +739,7 @@ class InputClassifier {
559
739
  classifyCdsAndReturn(vtx, src) {
560
740
  if (vtx.cds) {
561
741
  /* running only once a call forces it is no condition on the data */
562
- const cds = (0, arrays_1.uniqueArray)(vtx.cds.filter(c => c.byPromise !== true).flatMap(c => {
563
- const e = this.classifyAt(c.id);
564
- return e ? [...e.types, ...e.cds ?? []] : [];
565
- }).concat(src.cds ?? []));
742
+ const cds = (0, arrays_1.uniqueArray)(vtx.cds.filter(c => c.byPromise !== true).flatMap(c => this.dependencies(this.conditionOf(c.id), [])).concat(src.cds ?? []));
566
743
  if (cds.length > 0) {
567
744
  src.cds = cds;
568
745
  }
@@ -574,6 +751,13 @@ class InputClassifier {
574
751
  return src;
575
752
  }
576
753
  }
754
+ /** the condition of an `if` or `switch`; with named arguments to an `if`, we do not know which it is */
755
+ function conditionArgument(call) {
756
+ if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Switch)) {
757
+ return call.args.find(a => graph_1.FunctionArgument.hasName(a, 'EXPR')) ?? call.args.find(a => !graph_1.FunctionArgument.isNamed(a));
758
+ }
759
+ return vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.IfThenElse) && !call.args.some(graph_1.FunctionArgument.isNamed) ? call.args[0] : undefined;
760
+ }
577
761
  /** the function definitions the given node is nested in, innermost first */
578
762
  function* enclosingFunctions(node, idMap) {
579
763
  for (const parent of model_1.RNode.iterateParents(node, idMap)) {
@@ -595,6 +779,19 @@ function isBoundAsLinkedObject(node, obj, idMap) {
595
779
  }
596
780
  return false;
597
781
  }
782
+ const PlumberEndpoint = /^#\*\s*@(?:get|post|put|delete|patch|head|options|any|use)\b/i;
783
+ /** the replacements that may write a binding of an environment, as `e$x <- v` does */
784
+ const FieldReplacements = new Set(['$<-', '[[<-']);
785
+ const LoopTypes = new Set([type_1.RType.ForLoop, type_1.RType.WhileLoop, type_1.RType.RepeatLoop]);
786
+ /** whether `later` surely runs after `node`: later in the same file, in no shared loop, not deferred into a function apart from it */
787
+ function runsAfter(later, node, idMap) {
788
+ const [first, second] = [model_1.RNode.span(node), model_1.RNode.span(later)];
789
+ if (first === undefined || second === undefined || node?.info.file !== later?.info.file || !(range_1.SourceRange.startsCompletelyBefore(first, second) || range_1.SourceRange.isSubsetOf(first, second))) {
790
+ return false;
791
+ }
792
+ const around = new Set(model_1.RNode.iterateParents(later, idMap));
793
+ return model_1.RNode.iterateParents(node, idMap).every(p => r_function_definition_1.RFunctionDefinition.is(p) ? around.has(p) : !LoopTypes.has(p.type) || !around.has(p));
794
+ }
598
795
  function declarationKey(object, field) {
599
796
  return `${object}\u0000${field}`;
600
797
  }
@@ -632,7 +829,7 @@ function classifyInput(id, dfg, config, fullDfg, packages) {
632
829
  }
633
830
  const ret = [];
634
831
  for (const arg of vtx.args) {
635
- const entry = c.classifyAt(graph_1.FunctionArgument.getReference(arg));
832
+ const entry = c.classifyArgument(vtx, graph_1.FunctionArgument.getReference(arg));
636
833
  if (entry === undefined) {
637
834
  continue;
638
835
  }
@@ -19,17 +19,14 @@ exports.InspectExceptionQueryDefinition = {
19
19
  const out = queryResults;
20
20
  result.push(`Query: ${(0, ansi_1.bold)('inspect-exception', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
21
21
  const n = await processed.normalize();
22
- function getLoc(r) {
22
+ function locationOf(r) {
23
23
  const node = n.idMap.get(node_id_1.NodeId.normalize(r));
24
- return node ? range_1.SourceLocation.fromNode(node) : undefined;
25
- }
26
- function getLexeme(r) {
27
- return n.idMap.get(node_id_1.NodeId.normalize(r))?.lexeme ?? String(r);
24
+ return range_1.SourceLocation.fromNode(node);
28
25
  }
29
26
  for (const [r, v] of Object.entries(out.exceptions)) {
30
- result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${range_1.SourceLocation.format(getLoc(r))}) ${v.length > 0 ? 'throws exceptions:' : 'does not throw exceptions.'}`);
27
+ result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${range_1.SourceLocation.format(locationOf(r))}) ${v.length > 0 ? 'throws exceptions:' : 'does not throw exceptions.'}`);
31
28
  for (const { id: ex, cds } of v) {
32
- result.push(` - Exception ${(0, info_1.happensInEveryBranch)(cds) ? 'always ' : 'maybe '}thrown at id ${(0, ansi_1.bold)(String(ex), formatter)} "${getLexeme(ex)}" (${range_1.SourceLocation.format(getLoc(ex))}, cds: ${cds?.map(c => c.when + ':' + range_1.SourceLocation.format(getLoc(c.id))).join(', ') ?? 'none'})`);
29
+ result.push(` - Exception ${(0, info_1.happensInEveryBranch)(cds) ? 'always ' : 'maybe '}thrown at id ${(0, ansi_1.bold)(String(ex), formatter)} "${node_id_1.NodeId.recoverName(node_id_1.NodeId.normalize(ex), n.idMap) ?? String(ex)}" (${range_1.SourceLocation.format(locationOf(ex))}, cds: ${cds?.map(c => c.when + ':' + range_1.SourceLocation.format(locationOf(c.id))).join(', ') ?? 'none'})`);
33
30
  }
34
31
  }
35
32
  return true;
@@ -15,7 +15,7 @@ function keepRoles(all, graph, formals, mask) {
15
15
  for (const [id, roles] of Object.entries(all)) {
16
16
  const some = {};
17
17
  for (const [formal, props] of Object.entries(roles)) {
18
- const named = graph.idMap?.get(node_id_1.NodeId.normalize(formal))?.lexeme;
18
+ const named = node_id_1.NodeId.recoverName(node_id_1.NodeId.normalize(formal), graph.idMap);
19
19
  if ((formals === undefined || (named !== undefined && formals.has(named))) && (props & mask) !== 0) {
20
20
  some[formal] = props & mask;
21
21
  }
@@ -14,6 +14,7 @@ const range_1 = require("../../../util/range");
14
14
  const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
15
15
  const objects_1 = require("../../../util/objects");
16
16
  const argument_roles_1 = require("../../../dataflow/fn/argument-roles");
17
+ const arrays_1 = require("../../../util/collections/arrays");
17
18
  /** refuses a query that can only answer with nothing: `formals` narrowing an answer that carries none, or `props` naming only properties the single half it asks for cannot state */
18
19
  function rejectEmptyAnswer(query, helpers) {
19
20
  const { only, formals, props } = query;
@@ -39,7 +40,7 @@ exports.InspectFnPropsQueryDefinition = {
39
40
  const node = idMap.get(node_id_1.NodeId.normalize(id));
40
41
  const loc = node ? range_1.SourceLocation.fromNode(node) : undefined;
41
42
  const formals = Object.entries(out.roles[id] ?? {})
42
- .map(([formal, props]) => `${idMap.get(node_id_1.NodeId.normalize(formal))?.lexeme ?? formal}: ${function_semantics_1.FunctionSemantics.call.argument.words(props).join(', ')}`)
43
+ .map(([formal, props]) => `${node_id_1.NodeId.recoverName(node_id_1.NodeId.normalize(formal), idMap) ?? formal}: ${function_semantics_1.FunctionSemantics.call.argument.words(props).join(', ')}`)
43
44
  .join(', ');
44
45
  const states = function_semantics_1.FunctionSemantics.call.props.labels(out.props[id]).join(', ');
45
46
  result.push(` - Function ${(0, ansi_1.bold)(id, formatter)} (${range_1.SourceLocation.format(loc)}) ${formals}${states.length > 0 ? ` [${states}]` : ''}`);
@@ -58,7 +59,7 @@ exports.InspectFnPropsQueryDefinition = {
58
59
  }).custom(rejectEmptyAnswer).description('Either returns all function definitions alongside what they and their formals do, or just those matching the filters.'),
59
60
  flattenInvolvedNodes: (queryResults) => {
60
61
  const out = queryResults;
61
- return [...new Set([...Object.keys(out.roles), ...Object.keys(out.props)])];
62
+ return (0, arrays_1.uniqueArrayMerge)(Object.keys(out.roles), Object.keys(out.props));
62
63
  }
63
64
  };
64
65
  //# sourceMappingURL=inspect-fn-props-query-format.js.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeRecursionQuery = executeRecursionQuery;
4
- const recursive_function_1 = require("../../../dataflow/fn/recursive-function");
4
+ const call_graph_1 = require("../../../dataflow/graph/call-graph");
5
5
  const query_function_filter_1 = require("../../query-function-filter");
6
6
  /**
7
7
  * Execute recursion function inspection queries on the given analyzer.
@@ -11,7 +11,7 @@ async function executeRecursionQuery({ analyzer }, queries) {
11
11
  const { cg, fns } = await query_function_filter_1.QueryFunctionFilter.inCallGraph(queries, analyzer);
12
12
  const result = {};
13
13
  for (const [id] of fns) {
14
- result[id] = (0, recursive_function_1.isFunctionRecursive)(id, cg);
14
+ result[id] = call_graph_1.CallGraph.isRecursive(id, cg);
15
15
  }
16
16
  return {
17
17
  '.meta': {
@@ -16,11 +16,18 @@ const assert_1 = require("../../../util/assert");
16
16
  */
17
17
  async function executeLinterQuery({ analyzer }, queries) {
18
18
  // no explicit rules: run the rules that opt in via activeByDefault (default true), minus those the (project-kind
19
- // specialized) config disables -- e.g. software-has-license/-tests are off for a lone script or a notebook
19
+ // specialized) config disables by name or tag -- e.g. software-has-license/-tests are off for a lone script or a
20
+ // notebook, and the cmd-check rules for everything but a package
20
21
  const disabled = new Set(analyzer.flowrConfig.linter.disabledRules);
22
+ const disabledTags = new Set(analyzer.flowrConfig.linter.disabledTags ?? []);
21
23
  const defaultRules = Object.keys(linter_rules_1.LintingRules)
22
- .filter((name) => linter_rules_1.LintingRules[name].info.activeByDefault !== false && !disabled.has(name));
23
- const flattened = queries.flatMap(q => q.rules ?? defaultRules);
24
+ .filter((name) => {
25
+ const info = linter_rules_1.LintingRules[name].info;
26
+ return info.activeByDefault !== false && !disabled.has(name) && !info.tags.some(t => disabledTags.has(t));
27
+ });
28
+ const tagged = (tags) => Object.keys(linter_rules_1.LintingRules)
29
+ .filter(name => linter_rules_1.LintingRules[name].info.tags.some(t => tags.includes(t)));
30
+ const flattened = queries.flatMap(q => q.rules ?? (q.tags ? tagged(q.tags) : defaultRules));
24
31
  const distinct = new Set(flattened);
25
32
  if (distinct.size !== flattened.length) {
26
33
  const pretty = [...distinct].filter(r => flattened.indexOf(r) !== flattened.lastIndexOf(r)).map(r => typeof r === 'string' ? r : r.name).join(', ');
@@ -1,6 +1,7 @@
1
1
  import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import type { ParsedQueryLine } from '../../query';
3
3
  import Joi from 'joi';
4
+ import { LintingRuleTag } from '../../../linter/linter-tags';
4
5
  import { executeLinterQuery } from './linter-query-executor';
5
6
  import { type LintingRuleNames } from '../../../linter/linter-rules';
6
7
  import { type ConfiguredLintingRule, LintingResultCertainty } from '../../../linter/linter-format';
@@ -16,6 +17,8 @@ export interface LinterQuery extends BaseQueryFormat {
16
17
  * Optionally, a {@link ConfiguredLintingRule} can be provided, which additionally includes custom user-supplied values for the linting rules' configurations.
17
18
  */
18
19
  readonly rules?: readonly (LintingRuleNames | ConfiguredLintingRule)[];
20
+ /** Lint for every rule carrying one of these tags (e.g. `cmd-check` for the R CMD check rules), on by default or not. */
21
+ readonly tags?: readonly LintingRuleTag[];
19
22
  /** Print the findings in a machine-readable {@link LinterOutputFormat|format} instead of the human-readable summary. */
20
23
  readonly format?: LinterOutputFormat;
21
24
  }
@@ -35,7 +38,7 @@ export declare const LinterQueryDefinition: {
35
38
  readonly asciiSummarizer: (formatter: OutputFormatter, analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
36
39
  readonly completer: typeof linterQueryCompleter;
37
40
  readonly fromLine: typeof linterQueryLineParser;
38
- readonly syntax: "@linter [rules:<r1>,<r2>,...] [format:<fmt>] <code | file://path>";
41
+ readonly syntax: "@linter [rules:<r1>,<r2>,...] [tags:<t1>,...] [format:<fmt>] <code | file://path>";
39
42
  readonly schema: Joi.ObjectSchema<any>;
40
43
  readonly flattenInvolvedNodes: (queryResults: BaseQueryResult, _queries: readonly import("../../query").Query[], certainty: LintingResultCertainty | undefined) => ((string & {
41
44
  __brand?: "node-id";