@eagleoutice/flowr 2.15.10 → 2.16.1

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 (213) hide show
  1. package/README.md +23 -26
  2. package/abstract-interpretation/data-frame/arguments.js +11 -7
  3. package/cli/flowr-main-options.d.ts +15 -0
  4. package/cli/flowr-main-options.js +18 -0
  5. package/cli/flowr.d.ts +18 -0
  6. package/cli/flowr.js +13 -2
  7. package/cli/repl/commands/repl-clipboard.js +2 -1
  8. package/cli/repl/commands/repl-commands.js +2 -0
  9. package/cli/repl/commands/repl-main.d.ts +5 -0
  10. package/cli/repl/commands/repl-signature.js +2 -0
  11. package/cli/repl/core.d.ts +7 -1
  12. package/cli/repl/core.js +17 -8
  13. package/cli/repl/execute.js +2 -0
  14. package/cli/repl/server/connection.js +2 -1
  15. package/cli/repl/server/net.d.ts +10 -0
  16. package/cli/repl/server/net.js +34 -1
  17. package/cli/slicer-app.js +2 -1
  18. package/config.d.ts +12 -2
  19. package/config.js +91 -14
  20. package/control-flow/happens-before.d.ts +5 -0
  21. package/control-flow/happens-before.js +48 -34
  22. package/control-flow/useless-loop.d.ts +1 -1
  23. package/control-flow/useless-loop.js +29 -42
  24. package/dataflow/environments/built-in-props.d.ts +9 -0
  25. package/dataflow/environments/built-in-props.js +25 -19
  26. package/dataflow/environments/built-in.d.ts +2 -2
  27. package/dataflow/environments/built-in.js +41 -77
  28. package/dataflow/environments/default-builtin-config.d.ts +181 -29
  29. package/dataflow/environments/default-builtin-config.js +38 -24
  30. package/dataflow/environments/environment.d.ts +6 -4
  31. package/dataflow/environments/environment.js +54 -121
  32. package/dataflow/environments/identifier.d.ts +4 -2
  33. package/dataflow/environments/identifier.js +23 -69
  34. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  35. package/dataflow/environments/reference-to-maybe.js +23 -51
  36. package/dataflow/environments/resolve-by-name.js +37 -76
  37. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  38. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  39. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  40. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  41. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  42. package/dataflow/eval/resolve/resolve.js +23 -14
  43. package/dataflow/extractor.js +185 -59
  44. package/dataflow/fn/class-declaration.d.ts +8 -2
  45. package/dataflow/fn/class-declaration.js +96 -97
  46. package/dataflow/fn/exceptions-of-function.js +68 -37
  47. package/dataflow/fn/frame-reflection.d.ts +12 -4
  48. package/dataflow/fn/frame-reflection.js +64 -42
  49. package/dataflow/fn/function-props.js +15 -33
  50. package/dataflow/fn/function-semantics.d.ts +11 -3
  51. package/dataflow/fn/function-semantics.js +6 -0
  52. package/dataflow/fn/higher-order-function.js +13 -17
  53. package/dataflow/fn/strict-function.d.ts +13 -0
  54. package/dataflow/fn/strict-function.js +285 -122
  55. package/dataflow/graph/call-graph.d.ts +7 -6
  56. package/dataflow/graph/call-graph.js +35 -46
  57. package/dataflow/graph/graph.d.ts +6 -1
  58. package/dataflow/graph/graph.js +57 -66
  59. package/dataflow/info.d.ts +8 -1
  60. package/dataflow/info.js +24 -30
  61. package/dataflow/internal/control-flow.d.ts +42 -4
  62. package/dataflow/internal/control-flow.js +76 -39
  63. package/dataflow/internal/linker.d.ts +15 -9
  64. package/dataflow/internal/linker.js +253 -241
  65. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
  66. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +441 -79
  67. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  68. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
  69. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
  70. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
  71. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  72. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
  74. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
  75. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +290 -252
  76. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  78. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
  80. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  81. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
  82. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  83. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  84. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  85. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  86. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  90. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
  91. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  92. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  93. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  94. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  95. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  96. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
  97. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  98. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  99. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  100. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +120 -93
  101. package/dataflow/internal/process/functions/call/common.d.ts +1 -3
  102. package/dataflow/internal/process/functions/call/common.js +36 -76
  103. package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
  104. package/dataflow/internal/process/functions/call/deferred.js +60 -58
  105. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  106. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  107. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  108. package/dataflow/internal/process/functions/call/named-call-handling.js +44 -21
  109. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  110. package/dataflow/internal/process/functions/call/quoted.js +162 -172
  111. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  112. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  113. package/dataflow/internal/process/process-symbol.js +3 -6
  114. package/dataflow/internal/program-order.d.ts +26 -0
  115. package/dataflow/internal/program-order.js +49 -0
  116. package/documentation/doc-capabilities.js +4 -1
  117. package/documentation/wiki-interface.js +4 -0
  118. package/documentation/wiki-setup.js +23 -0
  119. package/engines.js +11 -3
  120. package/linter/linter-executor.js +19 -1
  121. package/linter/linter-rules.d.ts +17 -8
  122. package/linter/rules/absolute-path.js +63 -87
  123. package/linter/rules/file-path-validity.d.ts +4 -2
  124. package/linter/rules/file-path-validity.js +117 -80
  125. package/linter/rules/namespace-access.js +21 -33
  126. package/linter/rules/naming-convention.d.ts +1 -1
  127. package/linter/rules/naming-convention.js +60 -48
  128. package/linter/rules/network-functions.js +11 -7
  129. package/linter/rules/no-leaked-credentials.js +15 -18
  130. package/linter/rules/problematic-inputs.d.ts +2 -1
  131. package/linter/rules/problematic-inputs.js +39 -59
  132. package/linter/rules/roxygen-arguments.d.ts +9 -4
  133. package/linter/rules/roxygen-arguments.js +29 -48
  134. package/linter/rules/seeded-randomness.d.ts +7 -4
  135. package/linter/rules/seeded-randomness.js +130 -89
  136. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  137. package/linter/rules/stop-with-call-arg.js +25 -22
  138. package/linter/rules/unclosed-connection.js +31 -24
  139. package/linter/rules/undefined-symbol.d.ts +4 -6
  140. package/linter/rules/undefined-symbol.js +58 -75
  141. package/linter/rules/unescaped-arguments.js +18 -44
  142. package/linter/rules/unused-definition.d.ts +6 -0
  143. package/linter/rules/unused-definition.js +105 -145
  144. package/linter/rules/unused-import.d.ts +3 -0
  145. package/linter/rules/unused-import.js +25 -43
  146. package/package.json +5 -2
  147. package/project/flowr-analyzer.js +6 -2
  148. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  149. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  150. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
  151. package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
  152. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  153. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  154. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +18 -42
  155. package/project/sigdb/decompress.js +3 -1
  156. package/project/sigdb/sigdb-download.js +9 -6
  157. package/queries/base-query-format.js +1 -2
  158. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  159. package/queries/catalog/config-query/config-query-executor.js +9 -2
  160. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  161. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  162. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  163. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  164. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  165. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  166. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  167. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  168. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  169. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  170. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  171. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  172. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  173. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  174. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  175. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  176. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  177. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  178. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  179. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  180. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  181. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  182. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  183. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  184. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  185. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  186. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  187. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  188. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  189. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  190. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  191. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  192. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  193. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  194. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  195. package/r-bridge/shell-executor.js +2 -0
  196. package/r-bridge/shell.js +8 -0
  197. package/search/search-executor/search-enrichers.js +25 -37
  198. package/slicing/static/slice-call.d.ts +4 -3
  199. package/slicing/static/slice-call.js +56 -88
  200. package/slicing/static/static-slicer.js +120 -79
  201. package/slicing/static/visiting-queue.d.ts +4 -6
  202. package/slicing/static/visiting-queue.js +9 -13
  203. package/util/files.d.ts +6 -0
  204. package/util/files.js +12 -0
  205. package/util/parallel.js +2 -0
  206. package/util/proc.js +2 -1
  207. package/util/r-base-packages.d.ts +2 -0
  208. package/util/r-base-packages.js +23 -13
  209. package/util/secure-mode.d.ts +42 -0
  210. package/util/secure-mode.js +70 -0
  211. package/util/text/playground-link.d.ts +12 -3
  212. package/util/text/playground-link.js +18 -27
  213. package/util/version.js +4 -10
@@ -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, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "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>[]>>>;
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>[]>>>;
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;
@@ -42,10 +42,13 @@ export declare const SEEDED_RANDOMNESS: {
42
42
  }>;
43
43
  readonly info: {
44
44
  readonly defaultConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => {
45
- randomnessProducers: {
46
- type: "function" | "assignment";
45
+ randomnessProducers: ({
46
+ readonly type: "function";
47
+ readonly name: string;
48
+ } | {
49
+ type: "assignment";
47
50
  name: string;
48
- }[];
51
+ })[];
49
52
  randomnessConsumers: string[];
50
53
  };
51
54
  readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility];
@@ -8,7 +8,6 @@ const search_enrichers_1 = require("../../search/search-executor/search-enricher
8
8
  const identifier_1 = require("../../dataflow/environments/identifier");
9
9
  const flowr_search_filters_1 = require("../../search/flowr-search-filters");
10
10
  const graph_1 = require("../../dataflow/graph/graph");
11
- const cascade_action_1 = require("../../queries/catalog/call-context-query/cascade-action");
12
11
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
13
12
  const linter_tags_1 = require("../linter-tags");
14
13
  const node_value_1 = require("../../dataflow/eval/resolve/node-value");
@@ -18,14 +17,16 @@ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-fun
18
17
  const r_value_1 = require("../../dataflow/eval/values/r-value");
19
18
  const info_1 = require("../../dataflow/info");
20
19
  const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
20
+ const edge_1 = require("../../dataflow/graph/edge");
21
+ const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
22
+ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
23
+ const function_semantics_1 = require("../../dataflow/fn/function-semantics");
24
+ const logic_1 = require("../../util/logic");
25
+ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
21
26
  const built_in_props_1 = require("../../dataflow/environments/built-in-props");
22
27
  const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
23
- const RandomnessProducers = [
24
- { type: 'function', name: 'set.seed' },
25
- { type: 'assignment', name: '.Random.seed' }
26
- ];
27
28
  exports.SEEDED_RANDOMNESS = {
28
- createSearch: (config, data) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
29
+ createSearch: config => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
29
30
  .with(search_enrichers_1.Enrichment.CallTargets, {
30
31
  onlyBuiltin: true,
31
32
  qualifyNames: false // we don't use qualified names for this rule yet
@@ -34,19 +35,16 @@ exports.SEEDED_RANDOMNESS = {
34
35
  name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
35
36
  args: {
36
37
  enrichment: search_enrichers_1.Enrichment.CallTargets,
37
- test: {
38
- targets: identifier_1.Identifier.regex(...config.randomnessConsumers)
39
- }
38
+ test: { targets: identifier_1.Identifier.regex(...config.randomnessConsumers) }
40
39
  }
41
- })
42
- .with(search_enrichers_1.Enrichment.LastCall, [
43
- { callName: config.randomnessProducers.filter(p => p.type === 'function').map(p => p.name) },
44
- { callName: data.inspectContext().env.deriveFromDefinitions(getDefaultAssignments).flatMap(b => b.names).map(identifier_1.Identifier.getName), cascadeIf: () => cascade_action_1.CascadeAction.Continue }
45
- ]),
40
+ }),
46
41
  processSearchResult: async (elements, config, data) => {
47
- const dataflow = await data.dataflow();
42
+ const { graph } = await data.dataflow();
43
+ const ctx = data.inspectContext();
44
+ const functionProducers = new Set(config.randomnessProducers.filter(p => p.type === 'function').map(p => p.name));
48
45
  const assignmentProducers = new Set(config.randomnessProducers.filter(p => p.type === 'assignment').map(p => p.name));
49
- const assignmentArgIndexes = new Map(data.inspectContext().env.deriveFromDefinitions(getDefaultAssignments).flatMap(a => a.names.map(n => ([identifier_1.Identifier.getName(n), a.config?.swapSourceAndTarget ? 1 : 0]))));
46
+ const consumers = new Set(config.randomnessConsumers);
47
+ const assignmentArgIndexes = ctx.env.deriveFromDefinitions(assignmentTargetIndexes);
50
48
  const metadata = {
51
49
  consumerCalls: 0,
52
50
  callsWithFunctionProducers: 0,
@@ -54,92 +52,126 @@ exports.SEEDED_RANDOMNESS = {
54
52
  callsWithNonConstantProducers: 0,
55
53
  callsWithOtherBranchProducers: 0
56
54
  };
57
- return {
58
- results: elements.getElements()
59
- // map and filter consumers
60
- .flatMap(element => (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CallTargets).targets.map(target => {
61
- metadata.consumerCalls++;
62
- return {
63
- involvedId: element.node.info.id,
64
- loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid(),
65
- target: target,
66
- searchElement: element
67
- };
68
- }))
69
- // filter by calls that aren't preceded by a randomness producer
70
- .flatMap(element => {
71
- const dfgElement = dataflow.graph.getVertex(element.searchElement.node.info.id);
72
- const cds = dfgElement ? new Set(dfgElement.cds) : new Set();
73
- const producers = (0, search_enrichers_1.enrichmentContent)(element.searchElement, search_enrichers_1.Enrichment.LastCall).linkedIds
74
- .map(e => dataflow.graph.getVertex(e.node.info.id));
75
- const { assignment, func } = Object.groupBy(producers, f => assignmentArgIndexes.has(identifier_1.Identifier.getName(f.name)) ? 'assignment' : 'func');
76
- let nonConstant = false;
77
- const cdsOfProduces = new Set();
78
- // function calls are already taken care of through the LastCall enrichment itself
79
- for (const f of func ?? []) {
80
- if (isConstantArgument(dataflow.graph, f, 0, data.inspectContext())) {
81
- const fCds = new Set(f.cds).difference(cds);
82
- metadata.callsWithFunctionProducers++;
83
- if (fCds.size <= 0 || (0, info_1.happensInEveryBranchSet)(fCds)) {
84
- return [];
85
- }
86
- else {
87
- for (const f of fCds) {
88
- cdsOfProduces.add(f);
89
- }
90
- }
91
- }
92
- else {
93
- nonConstant = true;
94
- }
55
+ const writerKind = (vertex) => {
56
+ const name = identifier_1.Identifier.getName(vertex.name);
57
+ if (functionProducers.has(name)) {
58
+ return { kind: 'function', constant: isConstantArgument(graph, vertex, 0, ctx) };
59
+ }
60
+ const argIdx = assignmentArgIndexes.get(name);
61
+ if (argIdx === undefined) {
62
+ return consumers.has(name) ? 'draw' : undefined;
63
+ }
64
+ const dest = graph_1.FunctionArgument.getReference(vertex.args[argIdx]);
65
+ if (dest === undefined || !assignmentProducers.has(node_id_1.NodeId.recoverName(dest, graph.idMap))) {
66
+ return undefined;
67
+ }
68
+ /* we either have arg index 0 or 1 for the destination, so the value is at 1-argIdx */
69
+ return { kind: 'assignment', constant: isConstantArgument(graph, vertex, 1 - argIdx, ctx) };
70
+ };
71
+ const idMap = graph.idMap;
72
+ const forcing = function_semantics_1.FunctionSemantics.promiseForcing(graph, { ctx });
73
+ const at = (n) => idMap?.get(n)?.location ?? [0, 0, 0, 0];
74
+ /** whether `writer` follows `reader` within a loop both run under, so it reaches the reader from the second iteration on */
75
+ const loopCarried = (reader, writer) => {
76
+ if (range_1.SourceRange.compare(at(writer), at(reader)) <= 0) {
77
+ return false;
78
+ }
79
+ const writerCds = graph.getVertex(writer)?.cds;
80
+ const loops = graph.getVertex(reader)?.cds?.filter(cd => info_1.ControlDependency.isIterated(cd, idMap)) ?? [];
81
+ return loops.some(loop => writerCds?.some(cd => info_1.ControlDependency.same(cd, loop)));
82
+ };
83
+ /** a call of a draw by another name, like a parameter `f` bound to `runif` */
84
+ const drawsThrough = (call) => (0, frame_reflection_1.edgeTargets)(graph, call, edge_1.EdgeType.Calls).some(t => node_id_1.NodeId.isBuiltIn(t) && consumers.has(node_id_1.NodeId.fromBuiltIn(t))) ? 'draw' : undefined;
85
+ /** the writes a draw reads the generator state from: its own, and those of the calls running the function it sits in, which link what was written before them */
86
+ const statesReadBy = (id) => {
87
+ const within = idMap === undefined ? undefined : model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is);
88
+ const callers = within === undefined ? [] : (0, frame_reflection_1.edgeSources)(graph, within, edge_1.EdgeType.Calls);
89
+ const ownReads = (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall);
90
+ return [...ownReads, ...callers.flatMap(c => (0, frame_reflection_1.edgeTargets)(graph, c, edge_1.EdgeType.DefinedByOnCall))];
91
+ };
92
+ /** follows the draws behind the generator state `id` reads back to where it was seeded */
93
+ const collectSeeding = (id, visiting, seeding) => {
94
+ const own = new Set(graph.getVertex(id)?.cds);
95
+ const cds = [];
96
+ let written = false;
97
+ let always = false;
98
+ for (const target of statesReadBy(id)) {
99
+ const writer = graph.getVertex(target);
100
+ const kind = vertex_1.DfgVertex.isFunctionCall(writer) && !visiting.has(target) ? writerKind(writer) ?? drawsThrough(target) : undefined;
101
+ if (kind === undefined) {
102
+ continue;
103
+ }
104
+ /* a write later in the same loop body reaches the call from the second iteration on only */
105
+ if (loopCarried(id, target)) {
106
+ seeding.otherBranch = seeding.unseeded = true;
95
107
  }
96
- // assignments have to be queried for their destination
97
- for (const a of assignment ?? []) {
98
- const argIdx = assignmentArgIndexes.get(identifier_1.Identifier.getName(a.name));
99
- const dest = graph_1.FunctionArgument.getReference(a.args[argIdx]);
100
- if (dest !== undefined && assignmentProducers.has(node_id_1.NodeId.recoverName(dest, dataflow.graph.idMap))) {
101
- // we either have arg index 0 or 1 for the assignmentProducers destination, so we select the assignment value as 1-argIdx here
102
- if (isConstantArgument(dataflow.graph, a, 1 - argIdx, data.inspectContext())) {
103
- const aCds = new Set(a.cds).difference(cds);
104
- if (aCds.size <= 0 || (0, info_1.happensInEveryBranchSet)(aCds)) {
105
- metadata.callsWithAssignmentProducers++;
106
- return [];
107
- }
108
- else {
109
- for (const f of aCds) {
110
- cdsOfProduces.add(f);
111
- }
112
- }
113
- }
114
- }
108
+ else {
109
+ written = true;
115
110
  }
116
- if ((0, info_1.happensInEveryBranchSet)(cdsOfProduces)) {
117
- // all producers happen in every branch, so we are good
111
+ /* a promise surely forced is no condition */
112
+ const conditions = new Set(writer?.cds?.filter(cd => cd.byPromise !== true || forcing(cd.id, target) !== logic_1.Ternary.Always)).difference(own);
113
+ always ||= conditions.size === 0;
114
+ cds.push(...conditions);
115
+ if (kind === 'draw') {
116
+ collectSeeding(target, new Set([...visiting, id]), seeding);
117
+ }
118
+ else if (kind.constant) {
119
+ seeding.seeds[kind.kind].add(target);
120
+ }
121
+ else {
122
+ seeding.nonConstant = seeding.unseeded = true;
123
+ }
124
+ }
125
+ /* the state the program starts with is seen wherever no write reaches for sure */
126
+ if (!written) {
127
+ seeding.unseeded = true;
128
+ }
129
+ else if (!always && !(0, info_1.happensInEveryBranch)(cds)) {
130
+ seeding.otherBranch = seeding.unseeded = true;
131
+ }
132
+ return seeding;
133
+ };
134
+ return {
135
+ results: elements.getElements().flatMap(element => (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CallTargets).targets.flatMap(target => {
136
+ metadata.consumerCalls++;
137
+ const id = element.node.info.id;
138
+ const seeding = collectSeeding(id, new Set(), {
139
+ seeds: { function: new Set(), assignment: new Set() },
140
+ nonConstant: false,
141
+ otherBranch: false,
142
+ unseeded: false
143
+ });
144
+ metadata.callsWithFunctionProducers += seeding.seeds.function.size;
145
+ metadata.callsWithAssignmentProducers += seeding.seeds.assignment.size;
146
+ if (!seeding.unseeded) {
118
147
  return [];
119
148
  }
120
- if (nonConstant) {
149
+ if (seeding.nonConstant) {
121
150
  metadata.callsWithNonConstantProducers++;
122
151
  }
123
- if (cdsOfProduces.size > 0) {
152
+ if (seeding.otherBranch) {
124
153
  metadata.callsWithOtherBranchProducers++;
125
154
  }
126
- /* a call within a function body is seeded by whatever its callers did first, which the control
127
- flow of this body does not show: `set.seed(1); sapply(1:3, function(i) runif(1))` is seeded.
128
- Only a call the program itself reaches can be stated as unseeded for certain. */
129
- const nested = !dataflow.graph.isRoot(element.searchElement.node.info.id);
155
+ /* a call in a function body is seeded by what its callers did first (`set.seed(1); sapply(1:3, function(i) runif(1))`),
156
+ so only a call the program itself reaches can be unseeded for certain */
157
+ const nested = !graph.isRoot(id);
158
+ const someSeed = seeding.seeds.function.size + seeding.seeds.assignment.size > 0;
130
159
  return [{
131
- involvedId: element.involvedId,
132
- certainty: cdsOfProduces.size > 0 || nested ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain,
133
- function: element.target,
134
- loc: element.loc
160
+ involvedId: id,
161
+ certainty: someSeed || nested ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain,
162
+ function: target,
163
+ loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid()
135
164
  }];
136
- }),
165
+ })),
137
166
  '.meta': metadata
138
167
  };
139
168
  },
140
169
  info: {
141
170
  defaultConfig: ctx => ({
142
- randomnessProducers: RandomnessProducers,
171
+ randomnessProducers: [
172
+ ...ctx.env.deriveFromIndex(randomnessSetters).map(name => ({ type: 'function', name })),
173
+ { type: 'assignment', name: '.Random.seed' }
174
+ ],
143
175
  randomnessConsumers: [
144
176
  ...ctx.env.deriveFromIndex(randomnessConsumers),
145
177
  'princomp', 'pointLabel', 'rbernoulli', 'rdunif', 'generateSeedVectors', 'rvonmises',
@@ -161,9 +193,18 @@ exports.SEEDED_RANDOMNESS = {
161
193
  function getDefaultAssignments(definitions) {
162
194
  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));
163
195
  }
196
+ function assignmentTargetIndexes(definitions) {
197
+ return new Map(getDefaultAssignments(definitions).flatMap(a => {
198
+ const targetIndex = a.config?.swapSourceAndTarget ? 1 : 0;
199
+ return a.names.map(n => [identifier_1.Identifier.getName(n), targetIndex]);
200
+ }));
201
+ }
202
+ function randomnessSetters(index) {
203
+ return index.withAll([built_in_props_1.SemanticCallTag.Random, built_in_props_1.CallProp.Configures]).map(identifier_1.Identifier.getName);
204
+ }
164
205
  function randomnessConsumers(index) {
165
- return index.with(built_in_props_1.SemanticCallTag.Random).map(identifier_1.Identifier.getName)
166
- .filter(n => !RandomnessProducers.some(p => p.name === n));
206
+ const setters = new Set(randomnessSetters(index));
207
+ return index.with(built_in_props_1.SemanticCallTag.Random).map(identifier_1.Identifier.getName).filter(n => !setters.has(n));
167
208
  }
168
209
  function isConstantArgument(graph, call, argIndex, ctx) {
169
210
  const args = call.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.FunctionArgument.getReference);
@@ -2,14 +2,16 @@ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import type { MergeableRecord } from '../../util/objects';
3
3
  import { LintingRuleTag } from '../linter-tags';
4
4
  import type { Writable } from 'ts-essentials';
5
+ import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
+ import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
5
7
  export type StopWithCallResult = LintingResult;
6
8
  export type StopWithCallConfig = MergeableRecord;
7
9
  export interface StopWithCallMetadata extends MergeableRecord {
8
10
  consideredNodes: number;
9
11
  }
10
12
  export declare const STOP_WITH_CALL_ARG: {
11
- readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"get", ["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>[]>>>;
12
- 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<{
13
+ readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
14
+ readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, _config: MergeableRecord, data: ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
13
15
  results: Writable<StopWithCallResult>[];
14
16
  '.meta': StopWithCallMetadata;
15
17
  }>;
@@ -8,6 +8,7 @@ const flowr_search_builder_1 = require("../../search/flowr-search-builder");
8
8
  const linter_tags_1 = require("../linter-tags");
9
9
  const assert_1 = require("../../util/assert");
10
10
  const vertex_1 = require("../../dataflow/graph/vertex");
11
+ const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
11
12
  const general_1 = require("../../dataflow/eval/values/general");
12
13
  const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
13
14
  const df_helper_1 = require("../../dataflow/graph/df-helper");
@@ -16,8 +17,17 @@ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes
16
17
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
17
18
  const identifier_1 = require("../../dataflow/environments/identifier");
18
19
  const ConditionConstructors = new Set(['simpleCondition', 'simpleError', 'simpleWarning', 'simpleMessage', 'errorCondition', 'warningCondition']);
20
+ /** whether the call builds a condition object, for which `stop` ignores `call.`: a constructor, or a class naming `condition` */
21
+ function isConditionObject(signaled, graph, data) {
22
+ if (ConditionConstructors.has(identifier_1.Identifier.getName(signaled.functionName.content))) {
23
+ return true;
24
+ }
25
+ const vertex = graph.getVertex(signaled.info.id);
26
+ const classes = vertex_1.DfgVertex.isFunctionCall(vertex) ? (0, resolve_argument_1.getArgumentStringValue)(data.flowrConfig.solver.variables, graph, vertex, undefined, 'class', true, data.inspectContext()) : undefined;
27
+ return classes?.values().some(c => c.has('condition')) ?? false;
28
+ }
19
29
  exports.STOP_WITH_CALL_ARG = {
20
- createSearch: () => flowr_search_builder_1.Q.var('stop').filter(vertex_1.VertexType.FunctionCall),
30
+ createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall),
21
31
  processSearchResult: async (elements, _config, data) => {
22
32
  const dataflow = await data.dataflow();
23
33
  const meta = {
@@ -27,37 +37,30 @@ exports.STOP_WITH_CALL_ARG = {
27
37
  results: elements.getElements()
28
38
  .filter(element => {
29
39
  const idMap = dataflow.graph.idMap;
40
+ const fCall = dataflow.graph.getVertex(element.node.info.id);
41
+ /* a call that hands over `stop` itself, like `do.call(stop, args)`, states its arguments elsewhere */
42
+ if (!r_function_call_1.RFunctionCall.is(element.node) || identifier_1.Identifier.getName(fCall.name) !== 'stop') {
43
+ return false;
44
+ }
30
45
  if (idMap !== undefined && model_1.RNode.findEnclosing(element.node.info.id, idMap, r_function_definition_1.RFunctionDefinition.is) === undefined) {
31
46
  return false;
32
47
  }
33
- //only built-in functions
34
- const origins = df_helper_1.Dataflow.origin(dataflow.graph, element.node.info.id);
35
- if ((0, assert_1.isNotUndefined)(origins)) {
36
- const builtIn = origins.every(e => e.type === 3 /* OriginType.BuiltInFunctionOrigin */);
37
- if (!builtIn) {
38
- return false;
39
- }
48
+ // only built-in functions
49
+ if (df_helper_1.Dataflow.origin(dataflow.graph, element.node.info.id)?.some(e => e.type !== 3 /* OriginType.BuiltInFunctionOrigin */)) {
50
+ return false;
40
51
  }
41
- const fCall = dataflow.graph.getVertex(element.node.info.id);
42
- //filter out function calls with argument "call." set to false
43
- const stopParamMap = {
44
- '...': '...',
45
- 'call.': 'call.',
46
- 'domain': 'domain'
47
- };
52
+ // filter out function calls with argument "call." set to false
53
+ const stopParamMap = { '...': '...', 'call.': 'call.', 'domain': 'domain' };
48
54
  const mapping = function_semantics_1.FunctionSemantics.call.match.toSpec(fCall.args, stopParamMap);
49
55
  const signaled = idMap?.get(mapping.get('...')?.[0]);
50
- if (r_function_call_1.RFunctionCall.isNamed(signaled) && ConditionConstructors.has(identifier_1.Identifier.getName(signaled.functionName.content))) {
56
+ if (r_function_call_1.RFunctionCall.isNamed(signaled) && isConditionObject(signaled, dataflow.graph, data)) {
51
57
  return false;
52
58
  }
53
- const mappedToStop = mapping.get('call.') ?? [];
54
- for (const argId of mappedToStop) {
59
+ for (const argId of mapping.get('call.') ?? []) {
55
60
  const res = resolve_helper_1.Resolve.toValue(argId, { graph: dataflow.graph, environment: fCall.environment, ctx: data.inspectContext() });
56
61
  const values = (0, general_1.valueSetGuard)(res);
57
- if (values?.type === 'set' && values.elements.length !== 0) {
58
- if (values.elements[0].type === 'logical') {
59
- return values.elements[0].value;
60
- }
62
+ if (values?.type === 'set' && values.elements.length !== 0 && values.elements[0].type === 'logical') {
63
+ return values.elements[0].value;
61
64
  }
62
65
  }
63
66
  return true;
@@ -11,12 +11,16 @@ const info_1 = require("../../dataflow/info");
11
11
  const built_in_props_1 = require("../../dataflow/environments/built-in-props");
12
12
  const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
13
13
  const identifier_1 = require("../../dataflow/environments/identifier");
14
+ const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
14
15
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
15
16
  const range_1 = require("../../util/range");
16
17
  const assert_1 = require("../../util/assert");
17
18
  const linter_format_1 = require("../linter-format");
18
19
  const linter_tags_1 = require("../linter-tags");
19
20
  const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
21
+ const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
22
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
23
+ const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
20
24
  /** the edges the connection flows along, from the call opening it to the argument of the call closing it */
21
25
  const ConnectionFlow = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall | edge_1.EdgeType.Returns | edge_1.EdgeType.Argument;
22
26
  /** The arguments holding the handle the call acts on, all of them if it does not state which. */
@@ -48,24 +52,15 @@ function openCallsReaching(graph, start, opens, out) {
48
52
  }
49
53
  /** The variable definition the opened connection is bound to, if it is bound to one. */
50
54
  function bindingOf(graph, open) {
51
- for (const [source, edge] of graph.edgesTo(open)) {
52
- if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy) && vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(source))) {
53
- return source;
54
- }
55
- }
56
- return undefined;
55
+ return (0, frame_reflection_1.edgeSources)(graph, open, edge_1.EdgeType.DefinedBy).find(source => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(source)));
57
56
  }
58
57
  /** The statement `id` belongs to, i.e. the ancestor that is an element of an expression list. */
59
58
  function enclosingStatement(idMap, id) {
60
- let node = idMap.get(id);
61
- while (node !== undefined) {
62
- const parent = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
63
- if (parent === undefined || r_expression_list_1.RExpressionList.is(parent)) {
64
- return node;
65
- }
66
- node = parent;
67
- }
68
- return undefined;
59
+ const statement = model_1.RNode.findEnclosing(id, idMap, n => {
60
+ const parent = model_1.RNode.directParent(n, idMap);
61
+ return parent === undefined || r_expression_list_1.RExpressionList.is(parent);
62
+ });
63
+ return statement === undefined ? undefined : idMap.get(statement);
69
64
  }
70
65
  function liftedOutOfLoops(idMap, id, definition) {
71
66
  let lifted = id;
@@ -84,8 +79,7 @@ function closeFix(graph, open) {
84
79
  if (idMap === undefined || definition === undefined || name === undefined) {
85
80
  return undefined;
86
81
  }
87
- const reads = (graph.edgesTo(definition)).entries()
88
- .filter(([, edge]) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)).map(([source]) => source);
82
+ const reads = (0, frame_reflection_1.edgeSources)(graph, definition, edge_1.EdgeType.Reads);
89
83
  const statements = [definition, ...reads]
90
84
  .map(id => range_1.SourceLocation.fromNode(enclosingStatement(idMap, liftedOutOfLoops(idMap, id, definition))))
91
85
  .filter(assert_1.isNotUndefined);
@@ -128,6 +122,22 @@ function unclosedCertainty(graph, open, closes) {
128
122
  /* the closes may still cover every branch between them, as in `if(p) close(c) else close(c)` */
129
123
  return uncovered.size > 0 && info_1.ControlDependency.happensInEveryBranchSet(uncovered) ? undefined : linter_format_1.LintingResultCertainty.Uncertain;
130
124
  }
125
+ /** Whether the call creates its connection unopened and hands it straight to a call reading or writing it, which opens and closes it. */
126
+ function consumedInPlace(dataflow, open, ctx) {
127
+ const { graph } = dataflow;
128
+ const vertex = graph.getVertex(open);
129
+ const node = graph.idMap?.get(open);
130
+ const arg = node && graph.idMap ? model_1.RNode.directParent(node, graph.idMap) : undefined;
131
+ const consumer = r_argument_1.RArgument.is(arg) && graph.idMap ? model_1.RNode.directParent(arg, graph.idMap) : undefined;
132
+ if (!vertex_1.DfgVertex.isFunctionCall(vertex) || !r_function_call_1.RFunctionCall.is(consumer)) {
133
+ return false;
134
+ }
135
+ const mode = (0, resolve_argument_1.boundArgumentIndex)(graph, vertex, undefined, 'open', ctx);
136
+ const stated = (0, query_fn_props_1.callFnProps)(consumer.info.id, dataflow);
137
+ return (mode === undefined ? vertex.args.length <= 1 : mode >= vertex.args.length)
138
+ && function_semantics_1.FunctionSemantics.call.props.hasAny(stated, [built_in_props_1.SemanticCallTag.Reads, built_in_props_1.SemanticCallTag.Writes])
139
+ && !function_semantics_1.FunctionSemantics.call.props.hasAny(stated, built_in_props_1.SemanticCallTag.Opens);
140
+ }
131
141
  /** The calls opening and the calls closing a connection, as the props state and the configuration adds. */
132
142
  function connectionCalls(elements, dataflow, config) {
133
143
  const opensByName = config.openFns.length > 0 ? identifier_1.Identifier.regex(...config.openFns) : undefined;
@@ -170,17 +180,14 @@ exports.UNCLOSED_CONNECTION = {
170
180
  }
171
181
  }
172
182
  for (const open of reached) {
173
- const known = closedBy.get(open);
174
- if (known) {
175
- known.push(close.id);
176
- }
177
- else {
178
- closedBy.set(open, [close.id]);
179
- }
183
+ closedBy.set(open, [...(closedBy.get(open) ?? []), close.id]);
180
184
  }
181
185
  }
182
186
  const results = [];
183
187
  for (const [open, loc] of opens) {
188
+ if (consumedInPlace(dataflow, open, data.inspectContext())) {
189
+ continue;
190
+ }
184
191
  const certainty = unclosedCertainty(graph, open, closedBy.get(open));
185
192
  if (certainty === undefined) {
186
193
  continue;
@@ -1,6 +1,4 @@
1
1
  import type { MergeableRecord } from '../../util/objects';
2
- import type { FlowrSearchElement } from '../../search/flowr-search';
3
- import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
2
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
5
3
  import { LintingRuleTag } from '../linter-tags';
6
4
  /** whether the flagged symbol is used in a function-call position or as a plain variable */
@@ -12,8 +10,6 @@ export interface UndefinedSymbolResult extends LintingResult {
12
10
  kind: UndefinedSymbolKind;
13
11
  /** packages that export this name - a hint that a `library()`/`::` might be missing (empty if none known) */
14
12
  availableInPackages?: readonly string[];
15
- /** an unresolved `library()` is in scope that could define this name; treat as low-confidence */
16
- mayBeProvidedByUnresolvedLibrary?: boolean;
17
13
  }
18
14
  export interface UndefinedSymbolConfig extends MergeableRecord {
19
15
  /** flag names used in a function-call position that cannot be resolved (default `true`) */
@@ -42,6 +38,8 @@ export interface SuppressionCounts {
42
38
  nonStandardEval: number;
43
39
  /** used as a `[`/`[[` subscript (muted `data.table`-style column masking) */
44
40
  subscript: number;
41
+ /** a bare name a `library()` flowR could not resolve may export */
42
+ unresolvedLibrary: number;
45
43
  }
46
44
  export interface UndefinedSymbolMetadata extends MergeableRecord {
47
45
  totalFunctionCalls: number;
@@ -57,8 +55,8 @@ export interface UndefinedSymbolMetadata extends MergeableRecord {
57
55
  * as a hint. Over-approximative: NSE beyond what flowR models can still cause false positives.
58
56
  */
59
57
  export declare const UNDEFINED_SYMBOL: {
60
- readonly createSearch: (_config: UndefinedSymbolConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | FlowrSearchElement<ParentInformation>[]>>>;
61
- readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, config: UndefinedSymbolConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
58
+ readonly createSearch: (_config: UndefinedSymbolConfig) => 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>[]>>>;
59
+ 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: UndefinedSymbolConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
62
60
  results: UndefinedSymbolResult[];
63
61
  '.meta': UndefinedSymbolMetadata;
64
62
  }>;