@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
@@ -23,6 +23,25 @@ const syntactically_valid_1 = require("./rules/syntactically-valid");
23
23
  const unclosed_connection_1 = require("./rules/unclosed-connection");
24
24
  const unescaped_arguments_1 = require("./rules/unescaped-arguments");
25
25
  const namespace_access_1 = require("./rules/namespace-access");
26
+ const class_string_comparison_1 = require("./rules/cmd-check/class-string-comparison");
27
+ const description_metadata_1 = require("./rules/cmd-check/description-metadata");
28
+ const documentation_mismatch_1 = require("./rules/cmd-check/documentation-mismatch");
29
+ const non_ascii_code_1 = require("./rules/cmd-check/non-ascii-code");
30
+ const true_false_abbreviation_1 = require("./rules/cmd-check/true-false-abbreviation");
31
+ const bogus_return_1 = require("./rules/cmd-check/bogus-return");
32
+ const package_hooks_1 = require("./rules/cmd-check/package-hooks");
33
+ const package_structure_1 = require("./rules/cmd-check/package-structure");
34
+ const global_environment_modification_1 = require("./rules/cmd-check/global-environment-modification");
35
+ const namespace_tampering_1 = require("./rules/cmd-check/namespace-tampering");
36
+ const s_three_method_consistency_1 = require("./rules/cmd-check/s-three-method-consistency");
37
+ const foreign_function_calls_1 = require("./rules/cmd-check/foreign-function-calls");
38
+ const dependency_declaration_1 = require("./rules/cmd-check/dependency-declaration");
39
+ const call_arguments_1 = require("./rules/cmd-check/call-arguments");
40
+ const compiled_code_1 = require("./rules/cmd-check/compiled-code");
41
+ const package_metafiles_1 = require("./rules/cmd-check/package-metafiles");
42
+ const rd_files_1 = require("./rules/cmd-check/rd-files");
43
+ const package_data_1 = require("./rules/cmd-check/package-data");
44
+ const package_runtime_1 = require("./rules/cmd-check/package-runtime");
26
45
  /**
27
46
  * The registry of currently supported linting rules.
28
47
  * A linting rule can be executed on a dataflow pipeline result using {@link executeLintingRule}.
@@ -49,6 +68,25 @@ exports.LintingRules = {
49
68
  'syntactically-valid': syntactically_valid_1.SYNTACTICALLY_VALID,
50
69
  'unclosed-connection': unclosed_connection_1.UNCLOSED_CONNECTION,
51
70
  'unescaped-arguments': unescaped_arguments_1.UNESCAPED_ARGUMENTS,
52
- 'namespace-access': namespace_access_1.NAMESPACE_ACCESS
71
+ 'namespace-access': namespace_access_1.NAMESPACE_ACCESS,
72
+ 'class-string-comparison': class_string_comparison_1.CLASS_STRING_COMPARISON,
73
+ 'description-metadata': description_metadata_1.DESCRIPTION_METADATA,
74
+ 'documentation-mismatch': documentation_mismatch_1.DOCUMENTATION_MISMATCH,
75
+ 'non-ascii-code': non_ascii_code_1.NON_ASCII_CODE,
76
+ 'true-false-abbreviation': true_false_abbreviation_1.TRUE_FALSE_ABBREVIATION,
77
+ 'bogus-return': bogus_return_1.BOGUS_RETURN,
78
+ 'package-hooks': package_hooks_1.PACKAGE_HOOKS,
79
+ 'global-environment-modification': global_environment_modification_1.GLOBAL_ENVIRONMENT_MODIFICATION,
80
+ 'namespace-tampering': namespace_tampering_1.NAMESPACE_TAMPERING,
81
+ 's3-method-consistency': s_three_method_consistency_1.S3_METHOD_CONSISTENCY,
82
+ 'foreign-function-calls': foreign_function_calls_1.FOREIGN_FUNCTION_CALLS,
83
+ 'dependency-declaration': dependency_declaration_1.DEPENDENCY_DECLARATION,
84
+ 'call-arguments': call_arguments_1.CALL_ARGUMENTS,
85
+ 'package-structure': package_structure_1.PACKAGE_STRUCTURE,
86
+ 'compiled-code': compiled_code_1.COMPILED_CODE,
87
+ 'package-metafiles': package_metafiles_1.PACKAGE_METAFILES,
88
+ 'rd-files': rd_files_1.RD_FILES,
89
+ 'package-data': package_data_1.PACKAGE_DATA,
90
+ 'package-runtime': package_runtime_1.PACKAGE_RUNTIME
53
91
  };
54
92
  //# sourceMappingURL=linter-rules.js.map
@@ -73,6 +73,12 @@ export declare enum LintingRuleTag {
73
73
  * For example, missing or incorrect error handling, or missing or incorrect user interface elements.
74
74
  */
75
75
  Usability = "usability",
76
+ /**
77
+ * This rule ports a check of `R CMD check` (see the "Checking packages" section of the "Writing R Extensions" manual),
78
+ * so it only makes sense for an R package. Rules with this tag are only part of the default rule set when the
79
+ * analyzed project is a package (see the `linter.disabledTags` option of the flowR config).
80
+ */
81
+ CmdCheck = "cmd-check",
76
82
  /**
77
83
  * This rule may provide quickfixes to automatically fix the issues it detects.
78
84
  */
@@ -77,6 +77,12 @@ var LintingRuleTag;
77
77
  * For example, missing or incorrect error handling, or missing or incorrect user interface elements.
78
78
  */
79
79
  LintingRuleTag["Usability"] = "usability";
80
+ /**
81
+ * This rule ports a check of `R CMD check` (see the "Checking packages" section of the "Writing R Extensions" manual),
82
+ * so it only makes sense for an R package. Rules with this tag are only part of the default rule set when the
83
+ * analyzed project is a package (see the `linter.disabledTags` option of the flowR config).
84
+ */
85
+ LintingRuleTag["CmdCheck"] = "cmd-check";
80
86
  /**
81
87
  * This rule may provide quickfixes to automatically fix the issues it detects.
82
88
  */
@@ -19,6 +19,7 @@ const dependencies_query_format_1 = require("../../queries/catalog/dependencies-
19
19
  const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
20
20
  const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
21
21
  const other_path_functions_1 = require("../../queries/catalog/dependencies-query/function-info/other-path-functions");
22
+ const identifier_1 = require("../../dataflow/environments/identifier");
22
23
  function inferWd(file, wd, ctx) {
23
24
  if (wd === '@script') {
24
25
  return file;
@@ -34,7 +35,7 @@ function inferWd(file, wd, ctx) {
34
35
  }
35
36
  }
36
37
  // this can be improved by respecting raw strings and supporting more scenarios
37
- function buildQuickFix(str, filePath, wd) {
38
+ function quickFixForPath(str, filePath, wd) {
38
39
  const loc = range_1.SourceLocation.fromNode(str);
39
40
  if (!wd || !str || !r_string_1.RString.is(str) || loc === undefined) {
40
41
  /* a fix that names no place cannot be carried out, so none is offered */
@@ -117,7 +118,7 @@ exports.ABSOLUTE_PATH = {
117
118
  certainty,
118
119
  filePath,
119
120
  loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
120
- quickFix: buildQuickFix(node, filePath, wd)
121
+ quickFix: quickFixForPath(node, filePath, wd)
121
122
  });
122
123
  return {
123
124
  results: withoutNested(elements.getElements().flatMap(element => {
@@ -148,7 +149,7 @@ exports.ABSOLUTE_PATH = {
148
149
  const vertex = graph.getVertex(node.info.id);
149
150
  if (vertex_1.DfgVertex.isFunctionCall(vertex)) {
150
151
  /* `file.path` is the only supported function that returns a file path */
151
- const strings = vertex.name === 'file.path' ? filePathStrings(graph, vertex, ctx) : [];
152
+ const strings = identifier_1.Identifier.getName(vertex.name) === 'file.path' ? filePathStrings(graph, vertex, ctx) : [];
152
153
  if (strings) {
153
154
  return strings.map(absolute).filter(assert_1.isNotUndefined).map(path => finding(linter_format_1.LintingResultCertainty.Uncertain, path, node));
154
155
  }
@@ -0,0 +1,29 @@
1
+ import { LintingRuleCertainty } from '../../linter-format';
2
+ import type { MergeableRecord } from '../../../util/objects';
3
+ import { LintingRuleTag } from '../../linter-tags';
4
+ import { type CmdCheckResult } from './cmd-check-util';
5
+ export interface BogusReturnResult extends CmdCheckResult {
6
+ /** the name of the function the bare `return` is in, if it is bound to one */
7
+ readonly function?: string;
8
+ }
9
+ export type BogusReturnConfig = MergeableRecord;
10
+ export type BogusReturnMetadata = MergeableRecord;
11
+ /** Port of the `R CMD check` note "Possibly missing '()' after 'return'". */
12
+ export declare const BOGUS_RETURN: {
13
+ readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["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>[]>>>;
14
+ 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: MergeableRecord, data: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>) => Promise<{
15
+ results: BogusReturnResult[];
16
+ '.meta': {};
17
+ }>;
18
+ readonly prettyPrint: {
19
+ query: (r: BogusReturnResult) => string;
20
+ full: (r: BogusReturnResult) => string;
21
+ };
22
+ readonly info: {
23
+ readonly name: "Bogus Return";
24
+ readonly tags: readonly [LintingRuleTag.CmdCheck, LintingRuleTag.Bug, LintingRuleTag.QuickFix];
25
+ readonly certainty: LintingRuleCertainty.Exact;
26
+ readonly description: "Finds a bare `return` (without `()`), which evaluates to the function `return` instead of returning. Offers `return()` as a quick fix.";
27
+ readonly defaultConfig: () => {};
28
+ };
29
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BOGUS_RETURN = void 0;
4
+ const linter_format_1 = require("../../linter-format");
5
+ const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
6
+ const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
7
+ const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
8
+ const linter_tags_1 = require("../../linter-tags");
9
+ const range_1 = require("../../../util/range");
10
+ const identifier_1 = require("../../../dataflow/environments/identifier");
11
+ const vertex_1 = require("../../../dataflow/graph/vertex");
12
+ const edge_1 = require("../../../dataflow/graph/edge");
13
+ const df_helper_1 = require("../../../dataflow/graph/df-helper");
14
+ const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
15
+ const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
16
+ const r_function_definition_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
17
+ const cmd_check_util_1 = require("./cmd-check-util");
18
+ /** Port of the `R CMD check` note "Possibly missing '()' after 'return'". */
19
+ exports.BOGUS_RETURN = {
20
+ createSearch: () => flowr_search_builder_1.Q.all().filter(type_1.RType.Symbol),
21
+ processSearchResult: async (elements, _config, data) => {
22
+ const { graph } = await data.dataflow();
23
+ const idMap = (await data.normalize()).idMap;
24
+ const pkg = (0, cmd_check_util_1.packageInfo)(data.inspectContext());
25
+ const results = [];
26
+ for (const { node } of elements.getElements()) {
27
+ if (!r_symbol_1.RSymbol.is(node) || identifier_1.Identifier.getName(node.content) !== 'return' || !pkg.isPackageCode(node.info.file)) {
28
+ continue;
29
+ }
30
+ /* a call of `return` has a call vertex, a bare read is a use that resolves to the built-in */
31
+ const vertex = graph.getVertex(node.info.id);
32
+ const loc = range_1.SourceLocation.fromNode(node);
33
+ if (!vertex_1.DfgVertex.isUse(vertex) || loc === undefined || (0, cmd_check_util_1.isQuoted)(graph, node.info.id, idMap)) {
34
+ continue;
35
+ }
36
+ const targets = df_helper_1.Dataflow.targetsOf(graph, node.info.id, edge_1.EdgeType.Reads);
37
+ if (targets.some(t => !node_id_1.NodeId.isBuiltIn(t))) {
38
+ continue;
39
+ }
40
+ const fn = idMap.get(model_1.RNode.findEnclosing(node.info.id, idMap, r_function_definition_1.RFunctionDefinition.is) ?? '');
41
+ if (fn === undefined) {
42
+ continue;
43
+ }
44
+ const name = (0, cmd_check_util_1.boundName)(fn, idMap);
45
+ results.push({
46
+ ...(0, cmd_check_util_1.at)(node),
47
+ function: name,
48
+ message: `Possibly missing '()' after 'return'${name ? ` in ${name}` : ''}, a bare return evaluates to the function itself`,
49
+ quickFix: [{ type: 'replace', description: 'Call `return()`', replacement: 'return()', loc }]
50
+ });
51
+ }
52
+ return { results, '.meta': {} };
53
+ },
54
+ prettyPrint: (0, cmd_check_util_1.printer)(() => 'Bare `return`'),
55
+ info: {
56
+ name: 'Bogus Return',
57
+ tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.QuickFix],
58
+ certainty: linter_format_1.LintingRuleCertainty.Exact,
59
+ description: 'Finds a bare `return` (without `()`), which evaluates to the function `return` instead of returning. Offers `return()` as a quick fix.',
60
+ defaultConfig: () => ({})
61
+ }
62
+ };
63
+ //# sourceMappingURL=bogus-return.js.map
@@ -0,0 +1,63 @@
1
+ import { LintingRuleCertainty } from '../../linter-format';
2
+ import type { MergeableRecord } from '../../../util/objects';
3
+ import { LintingRuleTag } from '../../linter-tags';
4
+ import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
+ import { type CmdCheckResult } from './cmd-check-util';
6
+ export type CallArgumentsKind =
7
+ /** a named argument no formal of the called function takes */
8
+ 'unused-named'
9
+ /** more positional arguments than the called function takes */
10
+ | 'unused-positional'
11
+ /** a named argument that only matches a formal by a prefix of its name */
12
+ | 'partial-match'
13
+ /** a named argument whose name is a prefix of several formals */
14
+ | 'ambiguous-match'
15
+ /** `...` (or `..1`) used in a function that takes no `...` */
16
+ | 'dots-out-of-context'
17
+ /** a local function bound to one name twice, with different formals */
18
+ | 'conflicting-definitions';
19
+ export interface CallArgumentsResult extends CmdCheckResult {
20
+ readonly kind: CallArgumentsKind;
21
+ /** the function called or defined */
22
+ readonly function?: string;
23
+ /** the argument concerned, if any */
24
+ readonly argument?: string;
25
+ }
26
+ export interface CallArgumentsConfig extends MergeableRecord {
27
+ /** report arguments that only match a formal by a prefix of its name (default `true`, as `R CMD check` does) */
28
+ readonly reportPartialMatches: boolean;
29
+ /** also check calls of functions from other packages, whose formals the signature database states (default `true`) */
30
+ readonly checkPackageFunctions: boolean;
31
+ }
32
+ export interface CallArgumentsMetadata extends MergeableRecord {
33
+ /** calls whose target(s) flowR knows the formals of */
34
+ readonly checkedCalls: number;
35
+ }
36
+ /**
37
+ * Port of the `codetools` checks `R CMD check` runs in `checking R code for possible problems`: "possible error in
38
+ * f(...): unused argument", "partial argument match of 'a' to 'abc'", "... may be used in an incorrect context", and
39
+ * "multiple local function definitions for 'f' with different formal arguments".
40
+ */
41
+ export declare const CALL_ARGUMENTS: {
42
+ readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"from", [], ParentInformation, import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
43
+ readonly processSearchResult: (_elements: import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: CallArgumentsConfig, data: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>) => Promise<{
44
+ results: CallArgumentsResult[];
45
+ '.meta': {
46
+ checkedCalls: number;
47
+ };
48
+ }>;
49
+ readonly prettyPrint: {
50
+ query: (r: CallArgumentsResult) => string;
51
+ full: (r: CallArgumentsResult) => string;
52
+ };
53
+ readonly info: {
54
+ readonly name: "Call Arguments";
55
+ readonly tags: readonly [LintingRuleTag.CmdCheck, LintingRuleTag.Bug, LintingRuleTag.Robustness];
56
+ readonly certainty: LintingRuleCertainty.BestEffort;
57
+ readonly description: "Finds calls with arguments the called function does not take, names that match a formal only partially or match several formals, `...` used in a function without `...`, and local functions defined twice with different formals. Calls are resolved through the dataflow graph.";
58
+ readonly defaultConfig: () => {
59
+ reportPartialMatches: true;
60
+ checkPackageFunctions: true;
61
+ };
62
+ };
63
+ };
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CALL_ARGUMENTS = void 0;
4
+ const linter_format_1 = require("../../linter-format");
5
+ const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
6
+ const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
7
+ const linter_tags_1 = require("../../linter-tags");
8
+ const identifier_1 = require("../../../dataflow/environments/identifier");
9
+ const vertex_1 = require("../../../dataflow/graph/vertex");
10
+ const df_helper_1 = require("../../../dataflow/graph/df-helper");
11
+ const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
12
+ const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
13
+ const r_parameter_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
14
+ const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
15
+ const r_function_definition_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
16
+ const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
17
+ const cmd_check_util_1 = require("./cmd-check-util");
18
+ const Dots = '...';
19
+ /** the formals of a package function, if the signature database knows them: flowR's own built-ins merely state the ones they model */
20
+ function packageFormals(name, ctx) {
21
+ const info = (0, query_fn_props_1.fnInfo)(name, ctx);
22
+ return info?.entry === undefined || info.entry.signature.length === 0 ? undefined : [...info.parameters];
23
+ }
24
+ /**
25
+ * The formals of what a call may reach: the definitions of the code, or a package function the signature database
26
+ * knows (whose formals may belong to another version, so they are uncertain). A definition the call reaches
27
+ * through a function factory may have its formals rewritten (`formals(f) <- ...`), so it is not trusted when the
28
+ * code rewrites formals anywhere.
29
+ */
30
+ function targetsOf(id, name, df, idMap, ctx, packages, rewritesFormals) {
31
+ /* a built-in also calls the functions it is handed (`lapply(x, f)`), so only the origins tell what is called */
32
+ const origins = df_helper_1.Dataflow.origin(df.graph, id) ?? [];
33
+ if (!origins.some(o => o.type === 3 /* OriginType.BuiltInFunctionOrigin */)) {
34
+ const defs = (0, cmd_check_util_1.calledDefinitions)(df.graph, id, idMap);
35
+ if (defs.length > 0) {
36
+ const direct = defs.every(d => (0, cmd_check_util_1.boundName)(d, idMap) === identifier_1.Identifier.getName(name));
37
+ return !direct && rewritesFormals ? undefined : { formals: defs.map(cmd_check_util_1.formalNames), certain: direct };
38
+ }
39
+ }
40
+ /* a call reaching nothing of the code binds to what the packages offer, unless it may reach an unknown function */
41
+ if (!packages || origins.some(o => o.type !== 3 /* OriginType.BuiltInFunctionOrigin */)) {
42
+ return undefined;
43
+ }
44
+ const known = packageFormals(origins.length === 1 && origins[0].type === 3 /* OriginType.BuiltInFunctionOrigin */ ? origins[0].fn.name : name, ctx);
45
+ return known === undefined ? undefined : { formals: [known], certain: false };
46
+ }
47
+ /** the replacement functions that rewrite a function, after which its formals are no longer those of its definition */
48
+ const FormalsRewriters = new Set(['formals<-', 'body<-', 'args<-']);
49
+ /** how R would match the arguments of `call` to `formals`, the problems it would run into */
50
+ function mismatchesOf(call, formals, partial) {
51
+ const dots = formals.indexOf(Dots);
52
+ /* only the formals before `...` match by a prefix of their name */
53
+ const prefixable = dots < 0 ? formals : formals.slice(0, dots);
54
+ const result = [];
55
+ const bound = new Set();
56
+ let positional = 0;
57
+ let spreads = false;
58
+ for (const arg of call.arguments) {
59
+ if (arg === r_function_call_1.EmptyArgument) {
60
+ positional++;
61
+ continue;
62
+ }
63
+ const name = arg.name === undefined ? undefined : identifier_1.Identifier.getName(arg.name.content);
64
+ if (name === undefined) {
65
+ if (r_symbol_1.RSymbol.is(arg.value) && identifier_1.Identifier.getName(arg.value.content) === Dots) {
66
+ spreads = true;
67
+ }
68
+ else {
69
+ positional++;
70
+ }
71
+ continue;
72
+ }
73
+ if (formals.includes(name)) {
74
+ bound.add(name);
75
+ continue;
76
+ }
77
+ const candidates = prefixable.filter(f => f.startsWith(name) && !bound.has(f));
78
+ if (candidates.length === 1) {
79
+ bound.add(candidates[0]);
80
+ if (partial) {
81
+ result.push({ kind: 'partial-match', argument: name, message: `partial argument match of '${name}' to '${candidates[0]}'` });
82
+ }
83
+ }
84
+ else if (candidates.length > 1) {
85
+ result.push({ kind: 'ambiguous-match', argument: name, message: `argument '${name}' matches multiple formal arguments (${candidates.join(', ')})` });
86
+ }
87
+ else if (dots < 0) {
88
+ result.push({ kind: 'unused-named', argument: name, message: `unused argument (${name} = ...)` });
89
+ }
90
+ }
91
+ if (dots < 0 && !spreads) {
92
+ const free = formals.filter(f => !bound.has(f)).length;
93
+ if (positional > free) {
94
+ result.push({ kind: 'unused-positional', message: `unused argument${positional - free > 1 ? 's' : ''}: ${positional} positional arguments for ${free} remaining formal${free === 1 ? '' : 's'}` });
95
+ }
96
+ }
97
+ return result;
98
+ }
99
+ /** the given function definition and all definitions enclosing it */
100
+ function enclosingFunctions(fn, idMap) {
101
+ const result = [fn];
102
+ for (let cur = idMap.get(fn.info.parent ?? ''); cur !== undefined; cur = idMap.get(cur.info.parent ?? '')) {
103
+ if (r_function_definition_1.RFunctionDefinition.is(cur)) {
104
+ result.push(cur);
105
+ }
106
+ }
107
+ return result;
108
+ }
109
+ /**
110
+ * Port of the `codetools` checks `R CMD check` runs in `checking R code for possible problems`: "possible error in
111
+ * f(...): unused argument", "partial argument match of 'a' to 'abc'", "... may be used in an incorrect context", and
112
+ * "multiple local function definitions for 'f' with different formal arguments".
113
+ */
114
+ exports.CALL_ARGUMENTS = {
115
+ createSearch: () => flowr_search_builder_1.Q.from([]),
116
+ processSearchResult: async (_elements, config, data) => {
117
+ const df = await data.dataflow();
118
+ const ast = await data.normalize();
119
+ const idMap = ast.idMap;
120
+ const ctx = data.inspectContext();
121
+ const pkg = (0, cmd_check_util_1.packageInfo)(ctx);
122
+ const results = [];
123
+ let checkedCalls = 0;
124
+ const add = (node, r, certain = true) => results.push({ ...(0, cmd_check_util_1.at)(node, certain), ...r });
125
+ const calls = [...df.graph.verticesOfType(vertex_1.VertexType.FunctionCall)];
126
+ const rewritesFormals = calls.some(([, v]) => FormalsRewriters.has(identifier_1.Identifier.getName(v.name)));
127
+ for (const [id, vertex] of calls) {
128
+ const node = idMap.get(id);
129
+ /* quoted code is data, as codetools sees it too */
130
+ if (!r_function_call_1.RFunctionCall.isNamed(node) || !pkg.isPackageCode(node.info.file) || (0, cmd_check_util_1.isQuoted)(df.graph, id, idMap)) {
131
+ continue;
132
+ }
133
+ const targets = targetsOf(id, vertex.name, df, idMap, ctx, config.checkPackageFunctions, rewritesFormals);
134
+ if (targets === undefined) {
135
+ continue;
136
+ }
137
+ checkedCalls++;
138
+ const perTarget = targets.formals.map(f => mismatchesOf(node, f, config.reportPartialMatches));
139
+ const fn = identifier_1.Identifier.toString(vertex.name);
140
+ /* a mismatch with every possible target is certain, with only some of them it is not */
141
+ const keys = new Map();
142
+ for (const mismatches of perTarget) {
143
+ for (const m of mismatches) {
144
+ const key = `${m.kind}:${m.argument ?? ''}`;
145
+ const entry = keys.get(key);
146
+ keys.set(key, { m, count: (entry?.count ?? 0) + 1 });
147
+ }
148
+ }
149
+ for (const { m, count } of keys.values()) {
150
+ add(node, { kind: m.kind, function: fn, ...(m.argument !== undefined ? { argument: m.argument } : {}), message: `possible error in ${fn}(): ${m.message}` }, targets.certain && count === targets.formals.length);
151
+ }
152
+ }
153
+ const nodes = (0, cmd_check_util_1.projectNodes)(ast);
154
+ for (const node of nodes) {
155
+ if (!pkg.isPackageCode(node.info.file)) {
156
+ continue;
157
+ }
158
+ const parent = idMap.get(node.info.parent ?? '');
159
+ /* the formal `...` and an argument named `...` (`switch(x, ... = 1)`, `alist(... = )`) use no dots */
160
+ if (!r_symbol_1.RSymbol.is(node) || r_parameter_1.RParameter.is(parent) || (r_argument_1.RArgument.is(parent) && parent.name === node) || (0, cmd_check_util_1.isQuoted)(df.graph, node.info.id, idMap)) {
161
+ continue;
162
+ }
163
+ const name = identifier_1.Identifier.getName(node.content);
164
+ if (name !== Dots && !/^\.\.[0-9]+$/.test(name)) {
165
+ continue;
166
+ }
167
+ /* `...` is looked up like any variable, so the closure of a function taking it may use it as well */
168
+ const fn = idMap.get(model_1.RNode.findEnclosing(node.info.id, idMap, r_function_definition_1.RFunctionDefinition.is) ?? '');
169
+ if (r_function_definition_1.RFunctionDefinition.is(fn) && !enclosingFunctions(fn, idMap).some(f => (0, cmd_check_util_1.formalNames)(f).includes(Dots))) {
170
+ const bound = (0, cmd_check_util_1.boundName)(fn, idMap);
171
+ add(node, { kind: 'dots-out-of-context', ...(bound !== undefined ? { function: bound } : {}), message: `${name} may be used in an incorrect context, ${bound ?? 'the function'} takes no '...'` });
172
+ }
173
+ }
174
+ /* functions bound to the same name twice within one function body, with other formals */
175
+ const scopes = new Map();
176
+ for (const node of nodes) {
177
+ if (!r_function_definition_1.RFunctionDefinition.is(node) || !pkg.isPackageCode(node.info.file)) {
178
+ continue;
179
+ }
180
+ const name = (0, cmd_check_util_1.boundName)(node, idMap);
181
+ const scope = model_1.RNode.strictlyEnclosingFunction(node.info.id, idMap);
182
+ if (name === undefined || scope === undefined) {
183
+ continue;
184
+ }
185
+ const perName = scopes.get(scope) ?? new Map();
186
+ scopes.set(scope, perName);
187
+ perName.set(name, [...perName.get(name) ?? [], node]);
188
+ }
189
+ for (const perName of scopes.values()) {
190
+ for (const [name, defs] of perName) {
191
+ const signatures = new Set(defs.map(d => (0, cmd_check_util_1.formalNames)(d).join(',')));
192
+ if (signatures.size > 1) {
193
+ add(defs[defs.length - 1], { kind: 'conflicting-definitions', function: name, message: `multiple local function definitions for '${name}' with different formal arguments` });
194
+ }
195
+ }
196
+ }
197
+ return { results, '.meta': { checkedCalls } };
198
+ },
199
+ prettyPrint: (0, cmd_check_util_1.printer)(r => `${r.kind}${r.function ? ` in ${r.function}` : ''}${r.argument ? ` (${r.argument})` : ''}`),
200
+ info: {
201
+ name: 'Call Arguments',
202
+ tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Robustness],
203
+ certainty: linter_format_1.LintingRuleCertainty.BestEffort,
204
+ description: 'Finds calls with arguments the called function does not take, names that match a formal only partially or match several formals, `...` used in a function without `...`, and local functions defined twice with different formals. Calls are resolved through the dataflow graph.',
205
+ defaultConfig: () => ({
206
+ reportPartialMatches: true,
207
+ checkPackageFunctions: true
208
+ })
209
+ }
210
+ };
211
+ //# sourceMappingURL=call-arguments.js.map
@@ -0,0 +1,48 @@
1
+ import { LintingRuleCertainty } from '../../linter-format';
2
+ import type { MergeableRecord } from '../../../util/objects';
3
+ import { LintingRuleTag } from '../../linter-tags';
4
+ import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
+ import { type CmdCheckResult } from './cmd-check-util';
6
+ export interface ClassStringComparisonResult extends CmdCheckResult {
7
+ /** the class name(s) the condition compares with */
8
+ readonly classes: readonly string[];
9
+ }
10
+ export interface ClassStringComparisonConfig extends MergeableRecord {
11
+ /** also check the conditions of `while` loops, which `R CMD check` does not (default `true`) */
12
+ readonly checkWhile: boolean;
13
+ /** also flag a comparison with a variable flowR resolves to a string, which `R CMD check` cannot see (default `true`) */
14
+ readonly resolveStrings: boolean;
15
+ }
16
+ export interface ClassStringComparisonMetadata extends MergeableRecord {
17
+ /** conditions inspected */
18
+ readonly consideredConditions: number;
19
+ }
20
+ /**
21
+ * Port of the `R CMD check` note "Found if() conditions comparing class() to string"
22
+ * (`checking R code for possible problems`, `_R_CHECK_CODE_CLASS_IS_STRING_`).
23
+ * As an object may have more than one class, `class(x) == "a"` gives a condition longer than one (an error since
24
+ * R 4.2) or misses a subclass; `inherits(x, "a")` is what is meant.
25
+ */
26
+ export declare const CLASS_STRING_COMPARISON: {
27
+ readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
28
+ readonly processSearchResult: (elements: import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: ClassStringComparisonConfig, data: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>) => Promise<{
29
+ results: ClassStringComparisonResult[];
30
+ '.meta': {
31
+ consideredConditions: number;
32
+ };
33
+ }>;
34
+ readonly prettyPrint: {
35
+ query: (r: ClassStringComparisonResult) => string;
36
+ full: (r: ClassStringComparisonResult) => string;
37
+ };
38
+ readonly info: {
39
+ readonly name: "Class String Comparison";
40
+ readonly tags: readonly [LintingRuleTag.CmdCheck, LintingRuleTag.Bug, LintingRuleTag.Robustness, LintingRuleTag.QuickFix];
41
+ readonly certainty: LintingRuleCertainty.BestEffort;
42
+ readonly description: "Finds `if`/`while` conditions comparing `class(x)` with a string, which fail for objects with several classes. Offers `inherits(x, ...)` as a quick fix.";
43
+ readonly defaultConfig: () => {
44
+ checkWhile: true;
45
+ resolveStrings: true;
46
+ };
47
+ };
48
+ };