@eagleoutice/flowr 2.16.6 → 2.16.8

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 (321) hide show
  1. package/README.md +21 -15
  2. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
  3. package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
  4. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
  5. package/abstract-interpretation/data-frame/resolve-args.js +2 -11
  6. package/cli/repl/commands/repl-cfg.js +5 -19
  7. package/cli/repl/commands/repl-code-command.d.ts +10 -0
  8. package/cli/repl/commands/repl-code-command.js +18 -0
  9. package/cli/repl/commands/repl-dataflow.js +34 -59
  10. package/cli/repl/commands/repl-normalize.js +24 -41
  11. package/cli/repl/commands/repl-query.js +10 -17
  12. package/config.js +3 -3
  13. package/control-flow/cfg-dead-code.js +15 -2
  14. package/control-flow/useless-loop.js +1 -2
  15. package/data/r-base-packages.generated.d.ts +1 -1
  16. package/data/r-base-packages.generated.js +3 -3
  17. package/dataflow/environments/ambient-state-name.d.ts +80 -0
  18. package/dataflow/environments/ambient-state-name.js +113 -0
  19. package/dataflow/environments/built-in-eval-name.d.ts +3 -1
  20. package/dataflow/environments/built-in-eval-name.js +2 -0
  21. package/dataflow/environments/built-in-props.d.ts +27 -7
  22. package/dataflow/environments/built-in-props.js +59 -44
  23. package/dataflow/environments/built-in.d.ts +5 -2
  24. package/dataflow/environments/built-in.js +22 -5
  25. package/dataflow/environments/default-builtin-config.d.ts +538 -14
  26. package/dataflow/environments/default-builtin-config.js +189 -123
  27. package/dataflow/environments/environment.d.ts +7 -1
  28. package/dataflow/environments/environment.js +19 -1
  29. package/dataflow/environments/identifier.d.ts +12 -1
  30. package/dataflow/environments/reference-to-maybe.js +1 -6
  31. package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
  32. package/dataflow/eval/resolve/alias-tracking.js +66 -37
  33. package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
  34. package/dataflow/eval/resolve/resolve-argument.js +23 -11
  35. package/dataflow/eval/resolve/resolve.d.ts +5 -0
  36. package/dataflow/eval/resolve/resolve.js +25 -3
  37. package/dataflow/eval/values/r-value.d.ts +4 -2
  38. package/dataflow/eval/values/r-value.js +3 -1
  39. package/dataflow/eval/values/string/string-constants.d.ts +7 -1
  40. package/dataflow/eval/values/string/string-constants.js +38 -36
  41. package/dataflow/extractor.js +105 -2
  42. package/dataflow/fn/argument-roles.js +22 -8
  43. package/dataflow/fn/function-semantics.d.ts +3 -2
  44. package/dataflow/fn/strict-function.js +13 -2
  45. package/dataflow/graph/dataflowgraph-builder.d.ts +4 -4
  46. package/dataflow/graph/df-helper.d.ts +14 -1
  47. package/dataflow/graph/df-helper.js +37 -4
  48. package/dataflow/graph/graph.d.ts +6 -0
  49. package/dataflow/graph/graph.js +9 -10
  50. package/dataflow/graph/vertex.d.ts +1 -1
  51. package/dataflow/hooks.d.ts +1 -1
  52. package/dataflow/info.d.ts +3 -3
  53. package/dataflow/internal/linker.d.ts +4 -1
  54. package/dataflow/internal/linker.js +12 -8
  55. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
  56. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
  57. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +21 -46
  58. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
  59. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
  61. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
  62. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
  63. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
  64. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
  65. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
  66. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
  67. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
  68. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +8 -1
  70. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
  72. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
  73. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
  74. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  75. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
  77. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
  78. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +43 -7
  79. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
  80. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
  81. package/dataflow/internal/process/functions/call/common.js +3 -4
  82. package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
  83. package/dataflow/internal/process/functions/call/deferred.js +17 -9
  84. package/dataflow/internal/process/functions/call/quoted.js +1 -1
  85. package/dataflow/processor.d.ts +1 -1
  86. package/documentation/doc-capabilities.js +3 -2
  87. package/documentation/doc-readme.js +1 -2
  88. package/documentation/doc-util/doc-dfg.js +2 -2
  89. package/documentation/doc-util/doc-query.d.ts +3 -1
  90. package/documentation/doc-util/doc-query.js +4 -4
  91. package/documentation/wiki-create-linting-rules.js +1 -1
  92. package/documentation/wiki-linter.js +16 -206
  93. package/documentation/wiki-linting-and-testing.js +31 -64
  94. package/documentation/wiki-query.js +41 -0
  95. package/index.d.ts +1 -0
  96. package/index.js +5 -1
  97. package/linter/linter-format.d.ts +6 -0
  98. package/linter/linter-format.js +10 -0
  99. package/linter/linter-rules.d.ts +155 -103
  100. package/linter/linter-rules.js +2 -0
  101. package/linter/linter-util.d.ts +23 -0
  102. package/linter/linter-util.js +58 -0
  103. package/linter/rules/absolute-path.d.ts +2 -2
  104. package/linter/rules/absolute-path.js +1 -4
  105. package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
  106. package/linter/rules/cmd-check/bogus-return.js +3 -7
  107. package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
  108. package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
  109. package/linter/rules/cmd-check/class-string-comparison.js +3 -7
  110. package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
  111. package/linter/rules/cmd-check/cmd-check-util.js +14 -26
  112. package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
  113. package/linter/rules/cmd-check/compiled-code.js +3 -13
  114. package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
  115. package/linter/rules/cmd-check/dependency-declaration.js +6 -7
  116. package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
  117. package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
  118. package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
  119. package/linter/rules/cmd-check/file-checks.d.ts +19 -6
  120. package/linter/rules/cmd-check/file-checks.js +13 -5
  121. package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
  122. package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
  123. package/linter/rules/cmd-check/global-environment-modification.js +3 -2
  124. package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
  125. package/linter/rules/cmd-check/namespace-tampering.js +9 -9
  126. package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
  127. package/linter/rules/cmd-check/package-data.d.ts +11 -5
  128. package/linter/rules/cmd-check/package-data.js +5 -12
  129. package/linter/rules/cmd-check/package-files.js +4 -10
  130. package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
  131. package/linter/rules/cmd-check/package-hooks.js +10 -8
  132. package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
  133. package/linter/rules/cmd-check/package-metafiles.js +3 -12
  134. package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
  135. package/linter/rules/cmd-check/package-runtime.js +64 -20
  136. package/linter/rules/cmd-check/package-structure.d.ts +11 -5
  137. package/linter/rules/cmd-check/package-structure.js +4 -12
  138. package/linter/rules/cmd-check/rd-files.d.ts +8 -3
  139. package/linter/rules/cmd-check/rd-files.js +4 -14
  140. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
  141. package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
  142. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
  143. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  144. package/linter/rules/dataframe-access-validation.js +5 -8
  145. package/linter/rules/dead-code.d.ts +5 -4
  146. package/linter/rules/dead-code.js +25 -14
  147. package/linter/rules/deprecated-functions.d.ts +3 -3
  148. package/linter/rules/deprecated-functions.js +16 -23
  149. package/linter/rules/file-path-validity.d.ts +2 -2
  150. package/linter/rules/file-path-validity.js +3 -6
  151. package/linter/rules/function-finder-util.d.ts +3 -3
  152. package/linter/rules/function-finder-util.js +7 -14
  153. package/linter/rules/namespace-access.d.ts +2 -2
  154. package/linter/rules/namespace-access.js +6 -9
  155. package/linter/rules/naming-convention.d.ts +2 -2
  156. package/linter/rules/naming-convention.js +1 -4
  157. package/linter/rules/network-functions.d.ts +3 -3
  158. package/linter/rules/no-leaked-credentials.d.ts +2 -2
  159. package/linter/rules/no-leaked-credentials.js +1 -4
  160. package/linter/rules/overwritten-file.d.ts +38 -0
  161. package/linter/rules/overwritten-file.js +102 -0
  162. package/linter/rules/problematic-inputs.d.ts +16 -6
  163. package/linter/rules/problematic-inputs.js +78 -34
  164. package/linter/rules/roxygen-arguments.d.ts +2 -2
  165. package/linter/rules/roxygen-arguments.js +1 -4
  166. package/linter/rules/seeded-randomness.d.ts +3 -3
  167. package/linter/rules/seeded-randomness.js +6 -23
  168. package/linter/rules/software-has-license.d.ts +2 -2
  169. package/linter/rules/software-has-license.js +1 -4
  170. package/linter/rules/software-has-tests.d.ts +2 -2
  171. package/linter/rules/software-has-tests.js +1 -4
  172. package/linter/rules/stop-with-call-arg.d.ts +2 -2
  173. package/linter/rules/stop-with-call-arg.js +4 -11
  174. package/linter/rules/syntactically-valid.d.ts +4 -2
  175. package/linter/rules/syntactically-valid.js +29 -10
  176. package/linter/rules/unclosed-connection.d.ts +2 -2
  177. package/linter/rules/unclosed-connection.js +1 -4
  178. package/linter/rules/undefined-symbol.d.ts +2 -2
  179. package/linter/rules/undefined-symbol.js +25 -22
  180. package/linter/rules/unescaped-arguments.d.ts +2 -2
  181. package/linter/rules/unescaped-arguments.js +1 -4
  182. package/linter/rules/unused-definition.d.ts +2 -2
  183. package/linter/rules/unused-definition.js +37 -25
  184. package/linter/rules/unused-import.d.ts +2 -2
  185. package/linter/rules/unused-import.js +9 -14
  186. package/linter/rules/useless-loop.d.ts +7 -6
  187. package/linter/rules/useless-loop.js +4 -8
  188. package/package.json +5 -3
  189. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  190. package/project/cache/flowr-analyzer-cache.js +15 -11
  191. package/project/context/flowr-analyzer-files-context.d.ts +3 -0
  192. package/project/context/flowr-analyzer-files-context.js +6 -0
  193. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
  194. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
  195. package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
  196. package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
  197. package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
  198. package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
  199. package/project/plugins/file-plugins/files/r-session.js +58 -0
  200. package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
  201. package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
  202. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
  203. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
  204. package/project/plugins/plugin-registry.d.ts +2 -1
  205. package/project/plugins/plugin-registry.js +2 -0
  206. package/project/sigdb/spec-query.d.ts +73 -0
  207. package/project/sigdb/spec-query.js +339 -0
  208. package/queries/base-query-format.d.ts +1 -1
  209. package/queries/base-query-format.js +2 -2
  210. package/queries/catalog/absint-query/absint-query-executor.js +3 -6
  211. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
  212. package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
  213. package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
  214. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
  215. package/queries/catalog/config-query/config-query-format.d.ts +0 -1
  216. package/queries/catalog/config-query/config-query-format.js +1 -2
  217. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
  218. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
  219. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
  220. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
  221. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
  222. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
  223. package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
  224. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
  225. package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
  226. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
  227. package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
  228. package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
  229. package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
  230. package/queries/catalog/dice-query/dice-query-executor.js +2 -3
  231. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
  232. package/queries/catalog/files-query/files-query-executor.js +2 -3
  233. package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
  234. package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
  235. package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
  236. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
  237. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
  238. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
  239. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
  240. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
  241. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
  242. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
  243. package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
  244. package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
  245. package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
  246. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
  247. package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
  248. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
  249. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
  250. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
  251. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
  252. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
  253. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
  254. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
  255. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
  256. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
  257. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
  258. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
  259. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  260. package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
  261. package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
  262. package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
  263. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
  264. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
  265. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
  266. package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
  267. package/queries/catalog/origin-query/origin-query-executor.js +3 -11
  268. package/queries/catalog/project-query/project-query-executor.js +23 -7
  269. package/queries/catalog/project-query/project-query-format.d.ts +5 -0
  270. package/queries/catalog/project-query/project-query-format.js +20 -2
  271. package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
  272. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
  273. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
  274. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
  275. package/queries/catalog/search-query/search-query-executor.js +2 -3
  276. package/queries/catalog/signature-query/signature-query-executor.js +39 -0
  277. package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
  278. package/queries/catalog/signature-query/signature-query-format.js +15 -1
  279. package/queries/catalog/signature-query/signature-query-render.js +2 -1
  280. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
  281. package/queries/query-function-property.d.ts +28 -0
  282. package/queries/query-function-property.js +48 -0
  283. package/queries/query-meta.d.ts +3 -0
  284. package/queries/query-meta.js +8 -0
  285. package/queries/query.d.ts +13 -18
  286. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
  287. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
  288. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  289. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
  290. package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
  291. package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
  292. package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
  293. package/r-bridge/lang-4.x/ast/model/type.js +3 -0
  294. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
  295. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
  296. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
  297. package/reconstruct/reconstruct.js +35 -1
  298. package/search/search-executor/search-generators.js +1 -1
  299. package/slicing/static/fingerprint.js +7 -3
  300. package/slicing/static/static-slicer.js +6 -0
  301. package/util/assert.js +2 -2
  302. package/util/collections/arrays.d.ts +4 -0
  303. package/util/collections/arrays.js +11 -0
  304. package/util/collections/defaultmap.d.ts +5 -1
  305. package/util/collections/defaultmap.js +6 -1
  306. package/util/files.js +26 -5
  307. package/util/flowr-version.d.ts +10 -0
  308. package/util/flowr-version.js +20 -0
  309. package/util/glob.js +6 -4
  310. package/util/r-regex.d.ts +6 -0
  311. package/util/r-regex.js +17 -0
  312. package/util/text/args.d.ts +5 -0
  313. package/util/text/args.js +28 -22
  314. package/util/text/name-rank.d.ts +2 -0
  315. package/util/text/name-rank.js +3 -1
  316. package/util/text/regex.d.ts +10 -0
  317. package/util/text/regex.js +29 -0
  318. package/util/version.d.ts +1 -6
  319. package/util/version.js +6 -14
  320. package/documentation/doc-util/doc-functions.d.ts +0 -24
  321. package/documentation/doc-util/doc-functions.js +0 -65
@@ -30,7 +30,7 @@ export interface SeededRandomnessMeta extends MergeableRecord {
30
30
  callsWithOtherBranchProducers: number;
31
31
  }
32
32
  export declare const SEEDED_RANDOMNESS: {
33
- readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
33
+ readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
34
34
  readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
35
35
  results: {
36
36
  involvedId: NodeId;
@@ -57,7 +57,7 @@ export declare const SEEDED_RANDOMNESS: {
57
57
  readonly description: "Finds randomness-based function calls not preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like `set.seed`.";
58
58
  };
59
59
  readonly prettyPrint: {
60
- readonly query: (result: SeededRandomnessResult, _meta: SeededRandomnessMeta) => string;
61
- readonly full: (result: SeededRandomnessResult, _meta: SeededRandomnessMeta) => string;
60
+ readonly query: (r: SeededRandomnessResult, metadata: unknown) => string;
61
+ readonly full: (r: SeededRandomnessResult, metadata: unknown) => string;
62
62
  };
63
63
  };
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SEEDED_RANDOMNESS = void 0;
4
4
  const linter_format_1 = require("../linter-format");
5
+ const r_value_1 = require("../../dataflow/eval/values/r-value");
6
+ const function_finder_util_1 = require("./function-finder-util");
5
7
  const range_1 = require("../../util/range");
6
- const flowr_search_builder_1 = require("../../search/flowr-search-builder");
7
8
  const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
8
9
  const identifier_1 = require("../../dataflow/environments/identifier");
9
- const flowr_search_filters_1 = require("../../search/flowr-search-filters");
10
10
  const graph_1 = require("../../dataflow/graph/graph");
11
11
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
12
12
  const linter_tags_1 = require("../linter-tags");
@@ -14,7 +14,6 @@ const node_value_1 = require("../../dataflow/eval/resolve/node-value");
14
14
  const config_1 = require("../../config");
15
15
  const vertex_1 = require("../../dataflow/graph/vertex");
16
16
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
17
- const r_value_1 = require("../../dataflow/eval/values/r-value");
18
17
  const info_1 = require("../../dataflow/info");
19
18
  const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
20
19
  const edge_1 = require("../../dataflow/graph/edge");
@@ -26,18 +25,7 @@ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
26
25
  const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
27
26
  const df_helper_1 = require("../../dataflow/graph/df-helper");
28
27
  exports.SEEDED_RANDOMNESS = {
29
- createSearch: config => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
30
- .with(search_enrichers_1.Enrichment.CallTargets, {
31
- onlyBuiltin: true,
32
- qualifyNames: false // we don't use qualified names for this rule yet
33
- })
34
- .filter({
35
- name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
36
- args: {
37
- enrichment: search_enrichers_1.Enrichment.CallTargets,
38
- test: { targets: identifier_1.Identifier.regex(...config.randomnessConsumers) }
39
- }
40
- }),
28
+ createSearch: config => function_finder_util_1.functionFinderUtil.createSearch(config.randomnessConsumers, false),
41
29
  processSearchResult: async (elements, config, data) => {
42
30
  const { graph } = await data.dataflow();
43
31
  const ctx = data.inspectContext();
@@ -174,9 +162,7 @@ exports.SEEDED_RANDOMNESS = {
174
162
  ],
175
163
  randomnessConsumers: [
176
164
  ...ctx.env.deriveFromIndex(randomnessConsumers),
177
- 'princomp', 'pointLabel', 'rbernoulli', 'rdunif', 'generateSeedVectors', 'rvonmises',
178
- 'rxor', 'rmvnorm', 'randomForest',
179
- 'permuted', 'permute', 'shuffle', 'shuffleSet', 'data_shuffle', 'sample_frac', 'sample_n',
165
+ 'generateSeedVectors', 'rxor', 'permuted', 'data_shuffle',
180
166
  ],
181
167
  }),
182
168
  tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility],
@@ -185,10 +171,7 @@ exports.SEEDED_RANDOMNESS = {
185
171
  name: 'Seeded Randomness',
186
172
  description: 'Finds randomness-based function calls not preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like `set.seed`.'
187
173
  },
188
- prettyPrint: {
189
- [linter_format_1.LintingPrettyPrintContext.Query]: (result, _meta) => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)}`,
190
- [linter_format_1.LintingPrettyPrintContext.Full]: (result, _meta) => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)} is called without a preceding random seed function like \`set.seed\``
191
- }
174
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)}`, result => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)} is called without a preceding random seed function like \`set.seed\``)
192
175
  };
193
176
  function getDefaultAssignments(definitions) {
194
177
  return definitions.filter((b) => b.type === 'function' && (b.processor === built_in_proc_name_1.BuiltInProcName.Assignment || b.processor === built_in_proc_name_1.BuiltInProcName.AssignmentLike));
@@ -212,7 +195,7 @@ function isConstantArgument(graph, call, argIndex, ctx) {
212
195
  return values?.elements.every(v => v.type === 'number' ||
213
196
  v.type === 'logical' ||
214
197
  v.type === 'string' ||
215
- v.type === 'interval' && v.startInclusive && v.endInclusive && v.start.type === 'number' && v.end.type === 'number' && (0, r_value_1.asValue)(v.start.value).num === (0, r_value_1.asValue)(v.end.value).num)
198
+ r_value_1.RValue.numberOf(v) !== undefined)
216
199
  ?? false;
217
200
  }
218
201
  //# sourceMappingURL=seeded-randomness.js.map
@@ -16,8 +16,8 @@ export declare const SOFTWARE_HAS_LICENSE: {
16
16
  '.meta': {};
17
17
  };
18
18
  readonly prettyPrint: {
19
- readonly query: (result: SoftwareHasLicenseResult) => string;
20
- readonly full: (result: SoftwareHasLicenseResult) => string;
19
+ readonly query: (r: SoftwareHasLicenseResult, metadata: unknown) => string;
20
+ readonly full: (r: SoftwareHasLicenseResult, metadata: unknown) => string;
21
21
  };
22
22
  readonly info: {
23
23
  readonly name: "Software Has License";
@@ -29,10 +29,7 @@ exports.SOFTWARE_HAS_LICENSE = {
29
29
  }];
30
30
  return { results, '.meta': {} };
31
31
  },
32
- prettyPrint: {
33
- [linter_format_1.LintingPrettyPrintContext.Query]: (result) => result.message,
34
- [linter_format_1.LintingPrettyPrintContext.Full]: (result) => result.message
35
- },
32
+ prettyPrint: (0, linter_format_1.prettyPrint)((result) => result.message),
36
33
  info: {
37
34
  name: 'Software Has License',
38
35
  description: 'Finds software projects without a license (a LICENSE file or the License field of the DESCRIPTION).',
@@ -23,8 +23,8 @@ export declare const SOFTWARE_HAS_TESTS: {
23
23
  };
24
24
  };
25
25
  readonly prettyPrint: {
26
- readonly query: (result: SoftwareHasTestsResult) => string;
27
- readonly full: (result: SoftwareHasTestsResult) => string;
26
+ readonly query: (r: SoftwareHasTestsResult, metadata: unknown) => string;
27
+ readonly full: (r: SoftwareHasTestsResult, metadata: unknown) => string;
28
28
  };
29
29
  readonly info: {
30
30
  readonly name: "Software Has Tests";
@@ -31,10 +31,7 @@ exports.SOFTWARE_HAS_TESTS = {
31
31
  }
32
32
  };
33
33
  },
34
- prettyPrint: {
35
- [linter_format_1.LintingPrettyPrintContext.Query]: (result) => result.message,
36
- [linter_format_1.LintingPrettyPrintContext.Full]: (result) => result.message
37
- },
34
+ prettyPrint: (0, linter_format_1.prettyPrint)((result) => result.message),
38
35
  info: {
39
36
  name: 'Software Has Tests',
40
37
  description: 'Finds software projects without tests (test files in a test directory or test function calls in R code).',
@@ -16,8 +16,8 @@ export declare const STOP_WITH_CALL_ARG: {
16
16
  '.meta': StopWithCallMetadata;
17
17
  }>;
18
18
  readonly prettyPrint: {
19
- readonly query: (result: LintingResult) => string;
20
- readonly full: (result: LintingResult) => string;
19
+ readonly query: (r: LintingResult, metadata: unknown) => string;
20
+ readonly full: (r: LintingResult, metadata: unknown) => string;
21
21
  };
22
22
  readonly info: {
23
23
  readonly name: "Stop Without Call";
@@ -11,16 +11,16 @@ const vertex_1 = require("../../dataflow/graph/vertex");
11
11
  const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
12
12
  const general_1 = require("../../dataflow/eval/values/general");
13
13
  const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
14
- const df_helper_1 = require("../../dataflow/graph/df-helper");
15
14
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
16
15
  const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
17
16
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
18
17
  const r_logical_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-logical");
19
18
  const identifier_1 = require("../../dataflow/environments/identifier");
19
+ const linter_util_1 = require("../linter-util");
20
20
  const ConditionConstructors = new Set(['simpleCondition', 'simpleError', 'simpleWarning', 'simpleMessage', 'errorCondition', 'warningCondition']);
21
21
  /** whether the call builds a condition object, for which `stop` ignores `call.`: a constructor, or a class naming `condition` */
22
22
  function isConditionObject(signaled, graph, data) {
23
- if (ConditionConstructors.has(identifier_1.Identifier.getName(signaled.functionName.content))) {
23
+ if ((0, linter_util_1.callsBuiltIn)(graph, signaled.info.id, ConditionConstructors)) {
24
24
  return true;
25
25
  }
26
26
  const vertex = graph.getVertex(signaled.info.id);
@@ -55,16 +55,12 @@ exports.STOP_WITH_CALL_ARG = {
55
55
  const idMap = dataflow.graph.idMap;
56
56
  const fCall = dataflow.graph.getVertex(element.node.info.id);
57
57
  /* a call that hands over `stop` itself, like `do.call(stop, args)`, states its arguments elsewhere */
58
- if (!r_function_call_1.RFunctionCall.is(element.node) || identifier_1.Identifier.getName(fCall.name) !== 'stop') {
58
+ if (!r_function_call_1.RFunctionCall.is(element.node) || !(0, linter_util_1.callsBuiltIn)(dataflow.graph, element.node.info.id, 'stop')) {
59
59
  return false;
60
60
  }
61
61
  if (idMap !== undefined && model_1.RNode.findEnclosing(element.node.info.id, idMap, r_function_definition_1.RFunctionDefinition.is) === undefined) {
62
62
  return false;
63
63
  }
64
- // only built-in functions
65
- if (df_helper_1.Dataflow.origin(dataflow.graph, element.node.info.id)?.some(e => e.type !== 3 /* OriginType.BuiltInFunctionOrigin */)) {
66
- return false;
67
- }
68
64
  // filter out function calls with argument "call." set to false
69
65
  const stopParamMap = { '...': '...', 'call.': 'call.', 'domain': 'domain' };
70
66
  const mapping = function_semantics_1.FunctionSemantics.call.match.toSpec(fCall.args, stopParamMap);
@@ -91,10 +87,7 @@ exports.STOP_WITH_CALL_ARG = {
91
87
  '.meta': meta
92
88
  };
93
89
  },
94
- prettyPrint: {
95
- [linter_format_1.LintingPrettyPrintContext.Query]: result => `\`stop()\` without \`call. = FALSE\` at ${range_1.SourceLocation.format(result.loc)}`,
96
- [linter_format_1.LintingPrettyPrintContext.Full]: result => `\`stop()\` at ${range_1.SourceLocation.format(result.loc)} is called without \`call. = FALSE\`, so the error message names the call it was raised in, which is usually not intended. Pass \`call. = FALSE\` to leave it out.`,
97
- },
90
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `\`stop()\` without \`call. = FALSE\` at ${range_1.SourceLocation.format(result.loc)}`, result => `\`stop()\` at ${range_1.SourceLocation.format(result.loc)} is called without \`call. = FALSE\`, so the error message names the call it was raised in, which is usually not intended. Pass \`call. = FALSE\` to leave it out.`),
98
91
  info: {
99
92
  name: 'Stop Without Call',
100
93
  tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.QuickFix],
@@ -25,6 +25,8 @@ export interface RegionScan {
25
25
  readonly closers: readonly string[];
26
26
  /** Offset of every `%` outside a string or comment; an odd count means an unclosed `%...%` operator. */
27
27
  readonly percentAt: readonly number[];
28
+ /** Offset where the only missing `)` belongs: the end of a `for`/`while`/`if`/`function` head, right before its `{` body. */
29
+ readonly headAt?: number;
28
30
  }
29
31
  /** A `missing` (parser-inserted, zero-width) or `error` (un-parseable) tree-sitter node. */
30
32
  export interface SyntaxErrorFinding {
@@ -52,8 +54,8 @@ export declare const SYNTACTICALLY_VALID: {
52
54
  ".meta": SyntacticallyValidMetadata;
53
55
  }>;
54
56
  readonly prettyPrint: {
55
- readonly query: (result: SyntacticallyValidResult) => string;
56
- readonly full: (result: SyntacticallyValidResult) => string;
57
+ readonly query: (r: SyntacticallyValidResult, metadata: unknown) => string;
58
+ readonly full: (r: SyntacticallyValidResult, metadata: unknown) => string;
57
59
  };
58
60
  readonly info: {
59
61
  readonly name: "Syntactically Valid";
@@ -5,6 +5,8 @@ const linter_format_1 = require("../linter-format");
5
5
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
6
6
  const range_1 = require("../../util/range");
7
7
  const linter_tags_1 = require("../linter-tags");
8
+ /** what precedes the `(` of a control structure's head */
9
+ const ControlHead = /\b(?:for|while|if|function)\s*$/;
8
10
  const DelimiterInsert = new Map([[')', ')'], ['}', '}'], [']', ']'], [']]', ']]'], ['"', '"'], ['\'', '\''], ['`', '`'], [',', ','], [';', ';']]);
9
11
  const KeywordInsert = new Map([['in', ' in '], ['else', ' else ']]);
10
12
  const OperatorToken = /^([-+*/^:~!<>=&|@$]+|<-|<<-|->|->>|\|>|%[^%]*%)$/;
@@ -22,6 +24,8 @@ const isDanglingOperator = (n) => !!n && !n.isNamed && OperatorToken.test(n.type
22
24
  /** Read an error region: what it leaves open, and where its operators sit. */
23
25
  function scanRegion(text) {
24
26
  const stack = [];
27
+ /* for each open `(` that heads a control structure, where the `{` that follows it starts the body (once there is one) */
28
+ const heads = [];
25
29
  const percentAt = [];
26
30
  let quote;
27
31
  for (let i = 0; i < text.length; i++) {
@@ -47,26 +51,36 @@ function scanRegion(text) {
47
51
  }
48
52
  else if (c === '(') {
49
53
  stack.push(')');
54
+ heads.push(ControlHead.test(text.slice(Math.max(0, i - 24), i)) ? {} : undefined);
50
55
  }
51
56
  else if (c === '[') {
52
57
  stack.push(text[i + 1] === '[' ? (i++, ']]') : ']');
58
+ heads.push(undefined);
53
59
  }
54
60
  else if (c === '{') {
61
+ const head = heads[heads.length - 1];
62
+ if (head !== undefined && stack[stack.length - 1] === ')' && head.bodyAt === undefined) {
63
+ head.bodyAt = text.slice(0, i).trimEnd().length;
64
+ }
55
65
  stack.push('}');
66
+ heads.push(undefined);
56
67
  }
57
68
  else if ((c === ')' || c === '}') && stack[stack.length - 1] === c) {
58
69
  stack.pop();
70
+ heads.pop();
59
71
  }
60
72
  else if (c === ']') {
61
73
  if (stack[stack.length - 1] === ']') {
62
74
  stack.pop();
75
+ heads.pop();
63
76
  }
64
77
  else if (stack[stack.length - 1] === ']]') {
65
78
  stack[stack.length - 1] = ']';
66
79
  }
67
80
  }
68
81
  }
69
- return { closers: stack.reverse(), percentAt };
82
+ /* the one `)` that is missing belongs where the head ends, not after everything that came with the body */
83
+ return { closers: stack.reverse(), percentAt, headAt: stack.length === 1 && stack[0] === ')' ? heads[0]?.bodyAt : undefined };
70
84
  }
71
85
  /** Fuzzy-complete the `%...` operator at `at` to the nearest known one (else just close it). */
72
86
  function operatorCompletion(node, at) {
@@ -76,7 +90,9 @@ function operatorCompletion(node, at) {
76
90
  const column = node.startPosition.column + at;
77
91
  return { range: [node.startPosition.row + 1, column + 1, node.startPosition.row + 1, column + fragment.length], full };
78
92
  }
79
- const isMissingExpression = (f) => f.kind === 'missing' && !DelimiterInsert.has(f.node.type) && !KeywordInsert.has(f.node.type);
93
+ /** the grammar reports a missing string quote as `string_close`, which stands for whatever quote opened the string */
94
+ const missingToken = (node) => node.type === 'string_close' ? node.parent?.firstChild?.text ?? node.type : node.type;
95
+ const isMissingExpression = (f) => f.kind === 'missing' && !DelimiterInsert.has(missingToken(f.node)) && !KeywordInsert.has(missingToken(f.node));
80
96
  /** The built-in auto-fix patterns; append a {@link SyntaxErrorFixPattern} to add repairs. */
81
97
  exports.SyntaxErrorFixPatterns = [
82
98
  // first, because it judges the whole line: `[1] 1 2 3` errors on both `[` and `]`, and repairing those as
@@ -97,12 +113,12 @@ exports.SyntaxErrorFixPatterns = [
97
113
  name: 'insert-missing-token',
98
114
  description: 'Insert a delimiter, quote, or keyword the parser expected but did not find.',
99
115
  direction: 'add',
100
- appliesTo: f => f.kind === 'missing' && (DelimiterInsert.has(f.node.type) || KeywordInsert.has(f.node.type)),
116
+ appliesTo: f => f.kind === 'missing' && (DelimiterInsert.has(missingToken(f.node)) || KeywordInsert.has(missingToken(f.node))),
101
117
  quickFix: (f, file) => ({
102
118
  type: 'replace',
103
119
  loc: range_1.SourceLocation.from(point(f.node.startPosition), file),
104
- description: `Insert missing \`${f.node.type}\``,
105
- replacement: DelimiterInsert.get(f.node.type) ?? KeywordInsert.get(f.node.type)
120
+ description: `Insert missing \`${missingToken(f.node)}\``,
121
+ replacement: DelimiterInsert.get(missingToken(f.node)) ?? KeywordInsert.get(missingToken(f.node))
106
122
  })
107
123
  },
108
124
  {
@@ -126,6 +142,12 @@ exports.SyntaxErrorFixPatterns = [
126
142
  appliesTo: f => f.kind === 'error' && f.scan.closers.length > 0,
127
143
  quickFix: (f, file) => {
128
144
  const closers = f.scan.closers.join('');
145
+ if (f.scan.headAt !== undefined) {
146
+ /* the offset is in the region's text, which starts where the node does */
147
+ const before = f.node.text.slice(0, f.scan.headAt).split('\n');
148
+ const column = before.length === 1 ? f.node.startPosition.column + f.scan.headAt : before[before.length - 1].length;
149
+ return { type: 'replace', loc: range_1.SourceLocation.from(point({ row: f.node.startPosition.row + before.length - 1, column }), file), description: 'Add missing closing `)` after the head', replacement: ')' };
150
+ }
129
151
  return { type: 'replace', loc: range_1.SourceLocation.from(point(f.node.endPosition), file), description: `Add missing closing \`${closers}\``, replacement: closers };
130
152
  }
131
153
  },
@@ -205,7 +227,7 @@ function collectFindings(node, lines, out = []) {
205
227
  }
206
228
  function describe(finding) {
207
229
  if (finding.kind === 'missing') {
208
- return `Missing \`${finding.node.type}\``;
230
+ return `Missing \`${missingToken(finding.node)}\``;
209
231
  }
210
232
  const text = finding.node.text.replace(/\s+/g, ' ').trim();
211
233
  return `Unexpected \`${text.length > 30 ? text.slice(0, 27) + '...' : text}\``;
@@ -253,10 +275,7 @@ exports.SYNTACTICALLY_VALID = {
253
275
  }
254
276
  return { results, '.meta': { parser, errors: results.length, fixable: results.filter(r => r.quickFix !== undefined).length } };
255
277
  },
256
- prettyPrint: {
257
- [linter_format_1.LintingPrettyPrintContext.Query]: (result) => `${result.message} at ${range_1.SourceLocation.format(result.loc)}`,
258
- [linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Syntax error (${result.kind}): ${result.message} at ${range_1.SourceLocation.format(result.loc)}`
259
- },
278
+ prettyPrint: (0, linter_format_1.prettyPrint)((result) => `${result.message} at ${range_1.SourceLocation.format(result.loc)}`, (result) => `Syntax error (${result.kind}): ${result.message} at ${range_1.SourceLocation.format(result.loc)}`),
260
279
  info: {
261
280
  name: 'Syntactically Valid',
262
281
  description: 'Finds syntax errors with the configured (error-tolerant) parser. Offers extensible quick fixes to repair them.',
@@ -28,8 +28,8 @@ export declare const UNCLOSED_CONNECTION: {
28
28
  };
29
29
  }>;
30
30
  readonly prettyPrint: {
31
- readonly query: (result: LintingResult) => string;
32
- readonly full: (result: LintingResult) => string;
31
+ readonly query: (r: LintingResult, metadata: unknown) => string;
32
+ readonly full: (r: LintingResult, metadata: unknown) => string;
33
33
  };
34
34
  readonly info: {
35
35
  readonly name: "Unclosed Connection";
@@ -198,10 +198,7 @@ exports.UNCLOSED_CONNECTION = {
198
198
  }
199
199
  return { results, '.meta': { totalOpened: opens.size, totalClosed: closes.length } };
200
200
  },
201
- prettyPrint: {
202
- [linter_format_1.LintingPrettyPrintContext.Query]: result => `Unclosed connection at ${range_1.SourceLocation.format(result.loc)}`,
203
- [linter_format_1.LintingPrettyPrintContext.Full]: result => `The connection opened at ${range_1.SourceLocation.format(result.loc)} is not closed on every path that opens it`
204
- },
201
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `Unclosed connection at ${range_1.SourceLocation.format(result.loc)}`, result => `The connection opened at ${range_1.SourceLocation.format(result.loc)} is not closed on every path that opens it`),
205
202
  info: {
206
203
  name: 'Unclosed Connection',
207
204
  tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.QuickFix],
@@ -63,8 +63,8 @@ export declare const UNDEFINED_SYMBOL: {
63
63
  '.meta': UndefinedSymbolMetadata;
64
64
  }>;
65
65
  readonly prettyPrint: {
66
- readonly query: (result: UndefinedSymbolResult) => string;
67
- readonly full: (result: UndefinedSymbolResult) => string;
66
+ readonly query: (r: UndefinedSymbolResult, metadata: unknown) => string;
67
+ readonly full: (r: UndefinedSymbolResult, metadata: unknown) => string;
68
68
  };
69
69
  readonly info: {
70
70
  readonly name: "Undefined Symbol";
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UNDEFINED_SYMBOL = void 0;
4
+ const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
4
5
  const vertex_1 = require("../../dataflow/graph/vertex");
5
6
  const graph_1 = require("../../dataflow/graph/graph");
6
7
  const identifier_1 = require("../../dataflow/environments/identifier");
8
+ const linter_util_1 = require("../linter-util");
9
+ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
7
10
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
8
11
  const flowr_search_filters_1 = require("../../search/flowr-search-filters");
9
12
  const assert_1 = require("../../util/assert");
@@ -26,8 +29,9 @@ const DispatchVariables = ['.Generic', '.Method', '.Class'];
26
29
  */
27
30
  function declaredGlobalVariables(graph, ctx) {
28
31
  const names = new Set(DispatchVariables);
29
- for (const [, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
30
- const [name, ns] = identifier_1.Identifier.toArray(vertex.name);
32
+ for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
33
+ const callee = (0, linter_util_1.builtInOf)(graph, id);
34
+ const [name, ns] = callee === undefined ? [] : identifier_1.Identifier.toArray(callee);
31
35
  if (name !== 'globalVariables' || (ns !== undefined && ns !== 'utils')) {
32
36
  continue;
33
37
  }
@@ -48,9 +52,8 @@ const NameBindingFunctions = new Set(['assign', 'delayedAssign']);
48
52
  */
49
53
  function assignedNames(graph, ctx) {
50
54
  const names = new Set();
51
- for (const [, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
52
- const [name, ns] = identifier_1.Identifier.toArray(vertex.name);
53
- if (!NameBindingFunctions.has(name) || (ns !== undefined && ns !== 'base')) {
55
+ for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
56
+ if (!(0, linter_util_1.callsBuiltIn)(graph, id, NameBindingFunctions)) {
54
57
  continue;
55
58
  }
56
59
  const values = (0, resolve_argument_1.getArgumentStringValue)(ctx.config.solver.variables, graph, vertex, 0, 'x', true, ctx);
@@ -62,8 +65,10 @@ function assignedNames(graph, ctx) {
62
65
  }
63
66
  return names;
64
67
  }
65
- /** calls that load a package; an unresolved one means we cannot enumerate all exports in scope */
66
- const LibraryLoadFunctions = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'load_all', 'use', 'p_load']);
68
+ /** calls that load or attach a package (what flowR states, plus `pacman::p_load`); an unresolved one means we cannot enumerate all exports in scope */
69
+ function libraryLoadFunctions(index) {
70
+ return new Set([...(0, linter_util_1.namesWith)(index, built_in_props_1.SemanticCallTag.LoadsPackage), ...(0, linter_util_1.namesWith)(index, built_in_props_1.SemanticCallTag.AttachesPackage), 'p_load']);
71
+ }
67
72
  /** test frameworks whose namespace a test file runs under implicitly (e.g. `tests/testthat/test-*.R` sees testthat's exports without a `library()`) */
68
73
  const ImplicitTestFrameworks = ['testthat', 'tinytest', 'RUnit'];
69
74
  /** whether name is an export of a default-attached base package (needs no library()) */
@@ -108,8 +113,9 @@ exports.UNDEFINED_SYMBOL = {
108
113
  const isImplicitTestExport = (name, file) => file !== undefined && testFiles.has(file) && testExports.has(name);
109
114
  /* a library() we could not resolve could export any bare name, so such names are suppressed rather than guessed */
110
115
  const unknownIds = new Set([...graph.unknownSideEffects].map(e => graph_1.UnknownSideEffect.id(e)));
116
+ const libraryLoads = libraryLoadFunctions(ctx.env.builtInIndex);
111
117
  const unresolvedLibraryInScope = unknownIds.size > 0 && [...graph.verticesOfType(vertex_1.VertexType.FunctionCall)]
112
- .some(([id, v]) => unknownIds.has(id) && LibraryLoadFunctions.has(identifier_1.Identifier.getName(v.name)));
118
+ .some(([id, v]) => unknownIds.has(id) && libraryLoads.has(identifier_1.Identifier.getName(v.name)));
113
119
  // names a package declares global (`utils::globalVariables`) are no undefined symbols to R CMD check either
114
120
  const declaredGlobals = declaredGlobalVariables(graph, ctx);
115
121
  const boundByAssign = assignedNames(graph, ctx);
@@ -196,7 +202,7 @@ exports.UNDEFINED_SYMBOL = {
196
202
  const symbolOf = (node) => {
197
203
  const vtx = graph.getVertex(node.info.id);
198
204
  if (vertex_1.DfgVertex.isFunctionCall(vtx)) {
199
- return vtx.origin !== 'unnamed' && config.checkFunctions ? ['function', vtx.name] : undefined;
205
+ return !vertex_1.DfgVertex.hasOrigin(vtx, built_in_proc_name_1.BuiltInProcName.Unnamed) && config.checkFunctions ? ['function', vtx.name] : undefined;
200
206
  }
201
207
  const plainSymbol = r_symbol_1.RSymbol.is(node) && node.lexeme !== '...' && node.lexeme !== undefined;
202
208
  return vertex_1.DfgVertex.isUse(vtx) && config.checkVariables && plainSymbol ? ['variable', node.content] : undefined;
@@ -215,20 +221,17 @@ exports.UNDEFINED_SYMBOL = {
215
221
  }).filter(assert_1.isNotUndefined);
216
222
  return { results, '.meta': meta };
217
223
  },
218
- prettyPrint: {
219
- [linter_format_1.LintingPrettyPrintContext.Query]: result => `Undefined ${result.kind} \`${result.name}\` at ${range_1.SourceLocation.format(result.loc)}`,
220
- [linter_format_1.LintingPrettyPrintContext.Full]: result => {
221
- const where = range_1.SourceLocation.format(result.loc);
222
- if (result.availableInPackages && result.availableInPackages.length > 0) {
223
- const pkgs = result.availableInPackages.map(p => `\`${p}\``).join(', ');
224
- const hint = result.availableInPackages.length === 1 ? `with \`library(${result.availableInPackages[0]})\`` : 'from one of them';
225
- return `\`${result.name}\` at ${where} is used but not defined. It is exported by ${pkgs}, so it may only need loading, for example ${hint}.`;
226
- }
227
- return result.kind === 'function'
228
- ? `\`${result.name}\` at ${where} is called but is neither defined locally, a base R builtin, nor exported by a loaded package`
229
- : `\`${result.name}\` at ${where} is used as a variable but is never defined in scope`;
224
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `Undefined ${result.kind} \`${result.name}\` at ${range_1.SourceLocation.format(result.loc)}`, result => {
225
+ const where = range_1.SourceLocation.format(result.loc);
226
+ if (result.availableInPackages && result.availableInPackages.length > 0) {
227
+ const pkgs = result.availableInPackages.map(p => `\`${p}\``).join(', ');
228
+ const hint = result.availableInPackages.length === 1 ? `with \`library(${result.availableInPackages[0]})\`` : 'from one of them';
229
+ return `\`${result.name}\` at ${where} is used but not defined. It is exported by ${pkgs}, so it may only need loading, for example ${hint}.`;
230
230
  }
231
- },
231
+ return result.kind === 'function'
232
+ ? `\`${result.name}\` at ${where} is called but is neither defined locally, a base R builtin, nor exported by a loaded package`
233
+ : `\`${result.name}\` at ${where} is used as a variable but is never defined in scope`;
234
+ }),
232
235
  info: {
233
236
  name: 'Undefined Symbol',
234
237
  certainty: linter_format_1.LintingRuleCertainty.OverApproximative,
@@ -108,8 +108,8 @@ export declare const UNESCAPED_ARGUMENTS: {
108
108
  };
109
109
  }>;
110
110
  readonly prettyPrint: {
111
- readonly query: (result: UnescapedArgumentsResult) => string;
112
- readonly full: (result: UnescapedArgumentsResult) => string;
111
+ readonly query: (r: UnescapedArgumentsResult, metadata: unknown) => string;
112
+ readonly full: (r: UnescapedArgumentsResult, metadata: unknown) => string;
113
113
  };
114
114
  readonly info: {
115
115
  readonly name: "Unescaped Arguments";
@@ -321,10 +321,7 @@ exports.UNESCAPED_ARGUMENTS = {
321
321
  '.meta': { totalCriticalArguments: targets.length, totalEscapedArguments: escaped }
322
322
  };
323
323
  },
324
- prettyPrint: {
325
- [linter_format_1.LintingPrettyPrintContext.Query]: result => `Unescaped ${result.category} argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)}`,
326
- [linter_format_1.LintingPrettyPrintContext.Full]: result => `The argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)} reaches a ${result.category} call unescaped (input: ${result.input.join(', ')})`
327
- },
324
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `Unescaped ${result.category} argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)}`, result => `The argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)} reaches a ${result.category} call unescaped (input: ${result.input.join(', ')})`),
328
325
  info: {
329
326
  name: 'Unescaped Arguments',
330
327
  tags: [linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Shiny, linter_tags_1.LintingRuleTag.QuickFix],
@@ -33,8 +33,8 @@ export declare const UNUSED_DEFINITION: {
33
33
  ".meta": UnusedDefinitionMetadata;
34
34
  }>;
35
35
  readonly prettyPrint: {
36
- readonly query: (result: UnusedDefinitionResult) => string;
37
- readonly full: (result: UnusedDefinitionResult) => string;
36
+ readonly query: (r: UnusedDefinitionResult, metadata: unknown) => string;
37
+ readonly full: (r: UnusedDefinitionResult, metadata: unknown) => string;
38
38
  };
39
39
  readonly info: {
40
40
  readonly name: "Unused Definitions";