@eagleoutice/flowr 2.13.1 → 2.13.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 (158) hide show
  1. package/README.md +46 -44
  2. package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
  3. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
  4. package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
  5. package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
  6. package/cli/flowr.js +21 -5
  7. package/cli/repl/commands/repl-commands.js +11 -9
  8. package/cli/repl/commands/repl-query.js +1 -1
  9. package/cli/repl/commands/repl-signature.js +8 -1
  10. package/cli/repl/core.js +13 -10
  11. package/cli/repl/print-version.js +1 -1
  12. package/cli/repl/server/connection.d.ts +1 -1
  13. package/cli/repl/server/net.js +15 -0
  14. package/config.d.ts +37 -0
  15. package/config.js +63 -3
  16. package/control-flow/control-flow-graph.js +2 -1
  17. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  18. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  19. package/data/sigdb/sigdb.remote.json +1 -1
  20. package/dataflow/environments/append.d.ts +1 -1
  21. package/dataflow/environments/clone.d.ts +1 -1
  22. package/dataflow/environments/environment.d.ts +28 -4
  23. package/dataflow/environments/environment.js +66 -11
  24. package/dataflow/environments/identifier.d.ts +9 -8
  25. package/dataflow/environments/identifier.js +21 -13
  26. package/dataflow/environments/overwrite.d.ts +1 -1
  27. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  28. package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
  29. package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
  30. package/dataflow/extractor.js +2 -1
  31. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  32. package/dataflow/graph/df-helper.d.ts +3 -2
  33. package/dataflow/graph/df-helper.js +11 -15
  34. package/dataflow/graph/diff-dataflow-graph.js +1 -1
  35. package/dataflow/graph/graph-helper.js +2 -6
  36. package/dataflow/graph/graph.d.ts +24 -0
  37. package/dataflow/graph/graph.js +25 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  39. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
  40. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
  41. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
  42. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  43. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
  44. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  45. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
  46. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
  47. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  48. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  49. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
  50. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
  52. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  54. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
  55. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
  56. package/documentation/doc-readme.js +14 -12
  57. package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
  58. package/documentation/wiki-dataflow-graph.js +4 -24
  59. package/documentation/wiki-linter.js +1 -0
  60. package/documentation/wiki-mk/doc-context.d.ts +10 -0
  61. package/documentation/wiki-mk/doc-context.js +3 -0
  62. package/documentation/wiki-query.js +47 -0
  63. package/documentation/wiki-signature-database.js +18 -7
  64. package/linter/linter-rules.d.ts +24 -2
  65. package/linter/linter-rules.js +3 -1
  66. package/linter/rules/absolute-path.d.ts +4 -4
  67. package/linter/rules/absolute-path.js +7 -5
  68. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  69. package/linter/rules/file-path-validity.d.ts +1 -1
  70. package/linter/rules/file-path-validity.js +48 -8
  71. package/linter/rules/function-finder-util.d.ts +2 -1
  72. package/linter/rules/syntactically-valid.d.ts +58 -0
  73. package/linter/rules/syntactically-valid.js +203 -0
  74. package/linter/rules/undefined-symbol-util.js +3 -1
  75. package/linter/rules/undefined-symbol.js +6 -6
  76. package/package.json +25 -12
  77. package/project/context/classify-project-kind.d.ts +40 -0
  78. package/project/context/classify-project-kind.js +76 -0
  79. package/project/context/flowr-analyzer-context.d.ts +4 -4
  80. package/project/context/flowr-analyzer-context.js +3 -3
  81. package/project/context/flowr-analyzer-dependencies-context.d.ts +34 -9
  82. package/project/context/flowr-analyzer-dependencies-context.js +30 -3
  83. package/project/context/flowr-analyzer-files-context.d.ts +10 -8
  84. package/project/context/flowr-analyzer-files-context.js +26 -67
  85. package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
  86. package/project/context/flowr-file.d.ts +5 -0
  87. package/project/context/flowr-file.js +5 -0
  88. package/project/dependency-version-space.d.ts +118 -26
  89. package/project/dependency-version-space.js +343 -87
  90. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
  91. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
  92. package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
  93. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
  94. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
  95. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  96. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
  97. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
  98. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
  99. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
  100. package/project/plugins/package-version-plugins/package.d.ts +27 -10
  101. package/project/plugins/package-version-plugins/package.js +50 -25
  102. package/project/plugins/plugin-registry.d.ts +2 -1
  103. package/project/plugins/plugin-registry.js +4 -1
  104. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
  105. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
  106. package/project/sigdb/decompress.d.ts +1 -1
  107. package/project/sigdb/decompress.js +4 -1
  108. package/project/sigdb/manifest.js +60 -26
  109. package/project/sigdb/reader.d.ts +26 -16
  110. package/project/sigdb/reader.js +52 -21
  111. package/project/sigdb/sigdb-download.d.ts +6 -7
  112. package/project/sigdb/sigdb-download.js +30 -9
  113. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  114. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -12
  115. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -108
  116. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  117. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
  118. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
  119. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +54 -24
  120. package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
  121. package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
  122. package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
  123. package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
  124. package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
  125. package/queries/catalog/input-sources-query/input-types.js +64 -0
  126. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
  127. package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
  128. package/queries/catalog/linter-query/linter-query-format.js +9 -2
  129. package/queries/catalog/project-query/project-query-executor.js +1 -1
  130. package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
  131. package/queries/catalog/signature-query/signature-query-executor.js +115 -39
  132. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
  133. package/queries/catalog/signature-query/signature-query-format.js +1 -1
  134. package/queries/catalog/signature-query/signature-query-render.js +12 -7
  135. package/queries/query.js +9 -2
  136. package/r-bridge/data/data.d.ts +5 -0
  137. package/r-bridge/data/data.js +6 -0
  138. package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
  139. package/r-bridge/retriever.d.ts +1 -1
  140. package/r-bridge/retriever.js +6 -1
  141. package/r-bridge/shell.js +5 -0
  142. package/search/flowr-search-filters.d.ts +2 -1
  143. package/search/flowr-search-printer.js +10 -8
  144. package/slicing/static/static-slicer.d.ts +2 -2
  145. package/util/files.d.ts +6 -4
  146. package/util/files.js +30 -8
  147. package/util/mermaid/dfg.js +1 -1
  148. package/util/objects.js +6 -4
  149. package/util/r-base-packages.d.ts +2 -0
  150. package/util/r-base-packages.js +3 -0
  151. package/util/r-license.js +1 -4
  152. package/util/r-version.d.ts +12 -0
  153. package/util/r-version.js +16 -0
  154. package/util/range.d.ts +6 -2
  155. package/util/range.js +33 -15
  156. package/util/text/ansi.d.ts +7 -3
  157. package/util/text/ansi.js +8 -5
  158. package/util/version.js +4 -4
@@ -147,6 +147,20 @@ available for ${ctx.linkPage('flowr:vscode', 'VSCode')}, ${ctx.linkPage('flowr:p
147
147
  and ${ctx.linkPage('flowr:docker', 'Docker')}.
148
148
  It offers a wide variety of features, for example:
149
149
 
150
+ * 📚 **dependency analysis**\\
151
+ Given your analysis project, flowR offers a plethora of so-called ${ctx.linkPage('wiki/Query API', 'queries')} to get more information about your code.
152
+ An important query is the ${(0, doc_query_1.linkToQueryOfName)('dependencies', 'dependencies query')}, which shows you the library your project needs,
153
+ the data files it reads, the scripts it sources, and the data it outputs.
154
+ Building on it, the ${(0, doc_query_1.linkToQueryOfName)('guess-dep-versions', 'guess dependency versions query')} narrows down the version range each
155
+ of these libraries has to have, by combining the constraints your project declares with the functions your code actually calls.
156
+
157
+ ${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Dependency Analysis with flowR', `
158
+ The following showcases the dependency view of the ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')}:
159
+
160
+ ![Dependency Analysis](https://raw.githubusercontent.com/flowr-analysis/vscode-flowr/refs/heads/main/media/dependencies.png)
161
+
162
+ `), ' ')}
163
+
150
164
  * 🐞 **code linting**\\
151
165
  Analyze your R scripts for common issues and potential bugs (see the ${ctx.linkPage('wiki/Linter', 'wiki page')} for more information on the currently supported linters).
152
166
 
@@ -193,18 +207,6 @@ ${await (0, doc_repl_1.documentReplSession)(treeSitter, [{
193
207
 
194
208
  `), ' ')}
195
209
 
196
- * 📚 **dependency analysis**\\
197
- Given your analysis project, flowR offers a plethora of so-called ${ctx.linkPage('wiki/Query API', 'queries')} to get more information about your code.
198
- An important query is the ${(0, doc_query_1.linkToQueryOfName)('dependencies', 'dependencies query')}, which shows you the library your project needs,
199
- the data files it reads, the scripts it sources, and the data it outputs.
200
-
201
- ${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Dependency Analysis with flowR', `
202
- The following showcases the dependency view of the ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')}:
203
-
204
- ![Dependency Analysis](https://raw.githubusercontent.com/flowr-analysis/vscode-flowr/refs/heads/main/media/dependencies.png)
205
-
206
- `), ' ')}
207
-
208
210
  * 🚀 **fast call-graph, data-, and control-flow graphs**\\
209
211
  Within just [${'<i>' + (0, html_hover_over_1.textWithTooltip)((0, numbers_1.roundToDecimals)(await (0, doc_benchmarks_1.getLatestDfAnalysisTime)('"social-science" Benchmark Suite (tree-sitter)'), 1) + ' ms', 'This measurement is automatically fetched from the latest benchmark!') + '</i>'} (as of ${new Date(await (0, doc_benchmarks_1.getLastBenchmarkUpdate)()).toLocaleDateString('en-US', dateOptions)})](${doc_files_1.FlowrSiteBaseRef}/wiki/stats/benchmark),
210
212
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the ${ctx.linkPage('flowr:benchmarks', 'benchmarks')} for more information,
@@ -1,4 +1,4 @@
1
- import { type ParentInformation, type RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
1
+ import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
2
  import type { KnownParser } from '../../r-bridge/parser';
3
3
  import type { GeneralDocContext } from '../wiki-mk/doc-context';
4
4
  import type { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
@@ -1000,30 +1000,10 @@ Additionally, we get the information that the node with the id 2 was responsible
1000
1000
  Calling \`library(pkg)\` (or \`require\`) attaches a package to the search path.
1001
1001
  Mirroring R's \`search()\`, _flowR_ inserts the package's namespace and imports environments *below* the global environment (\`.GlobalEnv\`), so resolution walks **current scope -> enclosing scopes -> global -> attached packages -> built-ins**.
1002
1002
 
1003
- **A global binding shadows a package export** of the same name, exactly as in R:
1004
-
1005
- \`\`\`r
1006
- filter <- function(x) x # your global definition
1007
- library(stats) # stats also exports filter()
1008
- filter(1) # -> resolves to YOUR filter, not stats::filter
1009
- \`\`\`
1010
-
1011
- **Most recently attached is nearest, and re-attaching is a no-op:**
1012
-
1013
- \`\`\`r
1014
- library(A) # search path (top-down): A
1015
- library(B) # B, A
1016
- library(A) # no-op B, A (A is not moved or duplicated)
1017
- \`\`\`
1018
-
1019
- **Attaching inside a function propagates to the caller** (R attaches globally), and across branches every possibly-attached package is kept (a sound over-approximation of R's single runtime path):
1020
-
1021
- \`\`\`r
1022
- f <- function() library(A) # attaches A when called
1023
- f()
1024
- someExportOfA() # -> resolves against A
1025
- if (cond) library(B) # B is kept (may be attached)
1026
- \`\`\`
1003
+ A global binding shadows a package export of the same name, exactly as in R.
1004
+ The most recently attached package is the nearest one, and re-attaching neither moves nor duplicates it.
1005
+ The \`pos\` argument attaches further down the search path instead, given either as a position or as the name of an existing entry (an unknown position or name falls back to the default of 2, directly below the global environment).
1006
+ Attaching inside a function propagates to the caller (R attaches globally), and across branches every possibly-attached package is kept (a sound over-approximation of R's single runtime path).
1027
1007
 
1028
1008
  Last but not least, the information contains the single **entry point** (${JSON.stringify(result.entryPoint)}) and a set of **exit points** (${JSON.stringify(result.exitPoints.map(e => e.nodeId))}).
1029
1009
  Besides marking potential exits, the exit points also provide information about why the exit occurs and which control dependencies affect the exit.
@@ -133,6 +133,7 @@ function(x) {
133
133
  rule(knownParser, 'software-has-tests', 'SoftwareHasTestsConfig', 'SOFTWARE_HAS_TESTS', 'lint-software-has-tests', 'cat("hello")', tagTypes);
134
134
  rule(knownParser, 'no-leaked-credentials', 'NoLeakedCredentialsConfig', 'NO_LEAKED_CREDENTIALS', 'lint-no-leaked-credentials', 'password <- "s3cr3t"', tagTypes);
135
135
  rule(knownParser, 'undefined-symbol', 'UndefinedSymbolConfig', 'UNDEFINED_SYMBOL', 'lint-undefined-symbol', 'undefined_helper(42)', tagTypes);
136
+ rule(knownParser, 'syntactically-valid', 'SyntacticallyValidConfig', 'SYNTACTICALLY_VALID', 'lint-syntactically-valid', 'x <- c(1, 2', tagTypes);
136
137
  function rule(parser, name, configType, ruleType, testfile, example, types) {
137
138
  const rule = linter_rules_1.LintingRules[name];
138
139
  const tags = rule.info.tags.toSorted((a, b) => {
@@ -145,6 +145,16 @@ export interface GeneralDocContext {
145
145
  linkO<T extends object & {
146
146
  name: string;
147
147
  }>(obj: T, element: keyof T, fmt?: LinkFormat, filter?: ElementFilter): string;
148
+ /**
149
+ * Generate a hyperlink to an enum member. Enums have no runtime prototype ({@link GeneralDocContext#linkM|linkM})
150
+ * nor `name` ({@link GeneralDocContext#linkO|linkO}), so pass the enum type as the explicit type argument -- the
151
+ * member is then checked against its keys -- together with the enum's name.
152
+ * @example
153
+ * ```ts
154
+ * linkE<typeof FnProp>('FnProp', 'NoDoc')
155
+ * ```
156
+ */
157
+ linkE<E>(enumName: string, element: keyof E, fmt?: LinkFormat, filter?: ElementFilter): string;
148
158
  /**
149
159
  * Generate a hyperlink to a type/element definition in the code base which is displayed using the file path as name
150
160
  * @param element - The element to create a link for, the name can be qualified with `::` to specify the class.
@@ -79,6 +79,9 @@ function makeDocContextForTypes(shell, ...rootFolders) {
79
79
  const fullName = `${obj.name}::${String(element)}`;
80
80
  return this.link(fullName, fmt, filter);
81
81
  },
82
+ linkE(enumName, element, fmt, filter) {
83
+ return this.link(`${enumName}::${String(element)}`, fmt, filter);
84
+ },
82
85
  linkFile(element) {
83
86
  return (0, doc_types_1.shortLinkFile)(getNameFromElementIdOrRef(element), info);
84
87
  },
@@ -640,6 +640,11 @@ f <- function(x) {
640
640
  print(x)
641
641
  }`.trim();
642
642
  const criterion = '3@print';
643
+ const shinyCode = `
644
+ server <- function(input, output, session) {
645
+ system(paste("convert", input$file))
646
+ }`.trim();
647
+ const shinyCriterion = '2@system';
643
648
  return `
644
649
  Given a [slicing criterion](${doc_files_1.FlowrWikiBaseRef}/Terminology#slicing-criterion) to
645
650
  something like a function call, flowR classifies the types of all input sources (e.g., arguments).
@@ -652,6 +657,37 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
652
657
  type: 'input-sources',
653
658
  criterion
654
659
  }], { showCode: false, shorthand: (0, doc_query_1.sliceQueryShorthand)([criterion], (0, doc_escape_1.escapeNewline)(exampleCode)), ctx })}
660
+
661
+ Some objects are handed to the code by a framework rather than defined in it, like the \`input\` of a shiny
662
+ server function. The ${ctx.link('InputClassifierConfig::linkedObjects')} configuration lists them, so that reads
663
+ of such an object (and of its fields) classify as user input instead of stopping at a ${ctx.link('InputType::Parameter')}:
664
+ ${(0, doc_code_1.codeBlock)('r', shinyCode)}
665
+
666
+ ${await (0, doc_query_1.showQuery)(shell, shinyCode, [{
667
+ type: 'input-sources',
668
+ criterion: shinyCriterion
669
+ }], { showCode: false, shorthand: (0, doc_query_1.sliceQueryShorthand)([shinyCriterion], (0, doc_escape_1.escapeNewline)(shinyCode)), ctx })}
670
+
671
+ Every ${ctx.link('LinkedInputObject')} names the object, the ${ctx.link('InputType')} to use for it, and optionally
672
+ the parameters the binding function has to declare as well (${ctx.link('LinkedInputObject::withParams')}) - shiny's
673
+ \`input\` only counts as such if the function also takes an \`output\`, so that an ordinary function with a
674
+ parameter named \`input\` is left alone. Where the framework is handed the function instead of the code naming it,
675
+ a ${ctx.link('LinkedInputEntryPoint')} is exact: it says which object goes to which parameter *by position*, just
676
+ like R does, so \`shinyApp(ui, function(i, o, s))\` works no matter what those parameters are called.
677
+ With ${ctx.link('LinkedInputObject::declaredBy')} a read even links back to its definition - the \`textInput("n", …)\`
678
+ behind an \`input$n\` shows up as ${ctx.link('InputSource::declaredAt')}.
679
+
680
+ You do not have to pass any of this per query: the ${ctx.linkConfig('inputSources', true)} section of flowR's
681
+ ${ctx.linkPage('wiki/Interface', 'configuration file')} carries the same shape and is *added* to what flowR already
682
+ knows, so your framework joins shiny instead of replacing it (and \`specializeConfig\` can scope it to one
683
+ ${ctx.link('ProjectKind')}). Functions may be written as plain \`fn\` or namespaced \`pkg::fn\` strings; a bare call
684
+ only counts as the namespaced one while that package is attached, exactly as R would resolve it.
685
+
686
+ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({ inputSources: {
687
+ user: ['myframework::read_form'],
688
+ linkedObjects: [{ name: 'ctx', type: 'user', declaredBy: { calls: ['myframework::field'], argName: 'id', argIdx: 0 } }],
689
+ linkedEntryPoints: [{ call: 'myframework::serve', argName: 'handler', argIdx: 0, params: ['ctx', null] }]
690
+ } }, undefined, 2))}
655
691
  `;
656
692
  }
657
693
  });
@@ -981,6 +1017,17 @@ The guess can be narrowed further:
981
1017
  Packages can also be tied to one shared version (the base/R packages always are), and ${ctx.linkConfig('solver.versionManagement.linkedVersionGroups', true)}
982
1018
  declares further groups. Such a package reports its partners in \`linkedWith\`, because its range is then no longer independent of theirs.
983
1019
 
1020
+ What one dependency requires of another (\`transitive\` evidence) is read from *every* version of it still in play:
1021
+
1022
+ * all of them require it: the guess is narrowed, by the weakest of their bounds,
1023
+ * only some do: the evidence carries \`partial: true\` and never narrows, as another version avoids it.
1024
+
1025
+ A partial requirement still ties the two together. \`A 0.2.5\` needing \`B 0.2.1\` and \`A 0.3.0\` needing \`B 0.3.2\`
1026
+ shrinks neither range, yet the versions are not free. Each package lists its \`coupledWith\` partners, and
1027
+ \`runnableCombinations\` counts the tuples those couplings admit, against the plain product \`possibleCombinations\`
1028
+ and, where the project declares constraints, against \`declaredCombinations\` (what those alone leave, so the share
1029
+ says how much the guess added).
1030
+
984
1031
  ${(0, doc_structure_1.block)({
985
1032
  type: 'NOTE',
986
1033
  content: `This query needs the ${ctx.linkPage('wiki/Signature Database', 'signature database')}, and specifically a database carrying the _history_ of a package,
@@ -9,12 +9,15 @@ const path_1 = __importDefault(require("path"));
9
9
  const doc_maker_1 = require("./wiki-mk/doc-maker");
10
10
  const doc_files_1 = require("./doc-util/doc-files");
11
11
  const reader_1 = require("../project/sigdb/reader");
12
+ // FnProp is a const enum referenced only via `typeof` (for linkE's member typing); a type-only import would break `typeof`
13
+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
12
14
  const schema_1 = require("../project/sigdb/schema");
13
15
  const manifest_1 = require("../project/sigdb/manifest");
14
16
  const codec_1 = require("../project/sigdb/codec");
15
17
  const config_1 = require("../config");
16
18
  const flowr_analyzer_package_versions_sigdb_plugin_1 = require("../project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin");
17
19
  const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
20
+ const flowr_analyzer_dependencies_context_1 = require("../project/context/flowr-analyzer-dependencies-context");
18
21
  function cranDatabaseAvailable() {
19
22
  return (0, manifest_1.defaultSigDbPath)('current') !== undefined || (0, manifest_1.defaultSigDbPath)('full') !== undefined;
20
23
  }
@@ -136,7 +139,7 @@ function measureLoad(file) {
136
139
  }
137
140
  }
138
141
  /**
139
- * A table of the databases the default bundle actually ships, read -- at generation time, never hardcoded --
142
+ * A table of the databases the default bundle actually ships, read at generation time, never hardcoded,
140
143
  * from the manifests. Each shard becomes a row (contents, retained history, package and version counts, its
141
144
  * on-disk size, and the measured cost of decompressing it on first touch). Every bundled manifest is unioned
142
145
  * (deduped by shard/dictionary id), so the separate `history` manifest's shards show up alongside `current`,
@@ -231,17 +234,23 @@ Every function is a ${ctx.link('DecodedFunction')}:
231
234
 
232
235
  Per version the source also answers declared dependencies (${ctx.link('ResolvedDependency')}), release dates, the plain export view (${ctx.link('LibraryExports')}), and the versions it carries (${ctx.link('AvailableVersion')}).
233
236
 
234
- Beyond the flags above, ${ctx.link('DecodedFunction::props')} also carry ${ctx.link('FnProp::NoDoc')} (a documented package has no help page for this name), ${ctx.link('FnProp::S3Method')} (a registered S3 method, from the package NAMESPACE or base R's method table), and ${ctx.link('FnProp::S3Owner')} (an exported constructor for an S3 class this package OWNS: it also registers at least one S3 method for that class). The owned classes of a version are ${ctx.link('LibraryExports::s3Classes')}, and ${ctx.linkM(reader_1.SigDatabase, 'classOwner')} answers, for a class name, which package owns it (backed by a reverse index built once). This lets ${ctx.linkPage('wiki/Query API', 'version guessing')} mark a package used when the analyzed project's own NAMESPACE registers an S3 method for a class it owns, even with no direct call -- e.g. tseries's \`S3method("as.irts","zoo")\` marks \`zoo\` used.
237
+ Beyond the flags above, ${ctx.link('DecodedFunction::props')} also carry ${ctx.linkE('FnProp', 'NoDoc')} (a documented package has no help page for this name), ${ctx.linkE('FnProp', 'S3Method')} (a registered S3 method, from the package NAMESPACE or base R's method table), and ${ctx.linkE('FnProp', 'S3Owner')} (an exported constructor for an S3 class this package OWNS: it also registers at least one S3 method for that class). The owned classes of a version are ${ctx.link('LibraryExports::s3Classes')}, and ${ctx.linkM(reader_1.SigDatabase, 'classOwner')} answers, for a class name, which package owns it (backed by a reverse index built once). This lets ${ctx.linkPage('wiki/Query API', 'version guessing')} mark a package used when the analyzed project's own NAMESPACE registers an S3 method for a class it owns, even with no direct call, e.g. tseries's \`S3method("as.irts","zoo")\` marks \`zoo\` used.
235
238
 
236
239
  These are derived on demand by the ${ctx.linkPage('wiki/Query API', 'signature query')}, not stored:
237
- - the rdrr.io documentation link ${ctx.link('SignatureFunctionView::docUrl')} (base R \`/r/<pkg>/<topic>\`, CRAN \`/cran/<pkg>/man/<topic>\`), omitted for a ${ctx.link('FnProp::NoDoc')} function
238
- - the S3 method to generic backlink ${ctx.link('SignatureFunctionView::s3method')}, for a ${ctx.link('FnProp::S3Method')} function, resolving its generic
240
+ - the rdrr.io documentation link ${ctx.link('SignatureFunctionView::docUrl')} (base R \`/r/<pkg>/<topic>\`, CRAN \`/cran/<pkg>/man/<topic>\`), omitted for a ${ctx.linkE('FnProp', 'NoDoc')} function
241
+ - ${ctx.link('SignatureFunctionView::sourceUrl')} and ${ctx.link('SignatureFunctionView::manUrl')}: the definition and its \`.Rd\` help page at the queried version, on \`github.com/cran/<pkg>\` (CRAN) or \`github.com/wch/r-source\` (base R)
242
+ - the S3 method to generic backlink ${ctx.link('SignatureFunctionView::s3method')}, for a ${ctx.linkE('FnProp', 'S3Method')} function, resolving its generic
239
243
  - the transitive call graph ${ctx.linkM(reader_1.SigDatabase, 'transitiveCallees')}, expanding the stored local callees inside one version
240
244
 
241
245
  Read it back like this:
242
246
 
243
247
  ${ctx.code(accessTheDatabase, { dropLinesStart: 1 })}
244
248
 
249
+ To check what a project can resolve against without touching the raw sources, a ${ctx.linkPage('wiki/Analyzer', 'context')} exposes
250
+ ${ctx.linkM(flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext, 'hasSignatureDatabase')} (a cheap presence check) and
251
+ ${ctx.linkM(flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext, 'availableSignatureDatabases')} (the identifying names of the loaded databases), alongside the
252
+ richer ${ctx.linkM(flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext, 'loadedSignatureDatabases')} metadata.
253
+
245
254
  ## Configuration
246
255
 
247
256
  The exports come from ${pluginLink('versions:sigdb')}, which reads bundled databases. It is enabled by
@@ -263,16 +272,18 @@ So \`library(stats)\` attaches that release's exports, and a bare \`sd()\` quali
263
272
  without attaching the base namespaces to the graph. Set ${ctx.linkConfig('solver.sigdb.linkBaseR')} to also link them as
264
273
  dataflow edges.
265
274
 
266
- **No** signature shards are committed: the \`base.*\` floor (self-contained base-R signatures, a few hundred KB), the
275
+ Signature shards are not committed to the repository because of their size (the \`current.*\` and \`history.*\` scopes
276
+ span tens of megabytes): the \`base.*\` floor (self-contained base-R signatures, a few hundred KB), the
267
277
  \`current.*\` scope (every package's latest version) and \`history.*\` (every older version) all live as assets on the
268
278
  free ${ctx.linkConfig('solver.sigdb.downloadRepo')} GitHub release. The only committed file is a tiny **link file**,
269
279
  \`src/data/sigdb/sigdb.remote.json\`, which records the release tag and each shard's sha256 and size, so
270
- \`:signature download\` builds the direct release-CDN URL (no API rate limit), verifies every shard by content hash,
280
+ ${ctx.replCmd('signature')} download builds the direct release-CDN URL, verifies every shard by content hash,
271
281
  and skips any already cached. Because the link file is versioned, a \`git pull\` that updates it re-syncs only the
272
282
  shards whose hash changed &mdash; and with ${ctx.linkConfig('solver.sigdb.autoSync')} that check runs on startup and re-downloads in the
273
283
  background; \`npm run build\` bakes the shards in as well. The richest downloaded scope is used (order \`full\` >
274
284
  \`current\` > \`base\`), so once fetched \`library(stats)\` resolves. Any path in ${ctx.linkConfig('solver.sigdb.additionalPaths')} (or
275
285
  \`$FLOWR_SIGDB_DIR\`) is searched alongside the default, so a downloaded bundle stays mounted on every start.
286
+
276
287
  ${databases ? `
277
288
  ## Bundled Databases
278
289
 
@@ -291,7 +302,7 @@ shared dictionary that its shards depend on, so it is decompressed the first tim
291
302
  The flowR Docker images ship this dictionary already decompressed, so a container reads it in place and skips
292
303
  that step (the load column above is the cost a plain npm install pays).
293
304
 
294
- Every shard, dictionary, and manifest is published in both brotli (\`.br\`) and zstd (\`.zst\`, faster to decompress) compression, and flowR uses whichever the runtime supports: \`.zst\` when the Node version exposes [zstd](https://nodejs.org/api/zlib.html#zstd) (Node &ge; 22.15), otherwise \`.br\`. \`:signature download\` fetches only that one variant per file, and \`:version\` reports the format each loaded database resolved to.
305
+ Every shard, dictionary, and manifest is published in both brotli (\`.br\`) and zstd (\`.zst\`, faster to decompress) compression, and flowR uses whichever the runtime supports: \`.zst\` when the Node version exposes [zstd](https://nodejs.org/api/zlib.html#zstd) (Node &ge; 22.15), otherwise \`.br\`. ${ctx.replCmd('signature')} download fetches only that one variant per file, and ${ctx.replCmd('version')} reports the format each loaded database resolved to.
295
306
  ` : ''}
296
307
  ## Format
297
308
 
@@ -34,7 +34,7 @@ export declare const LintingRules: {
34
34
  readonly name: "File Path Validity";
35
35
  readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
36
36
  readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
37
- readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility, import("./linter-tags").LintingRuleTag.Bug];
37
+ readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility, import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.QuickFix];
38
38
  readonly defaultConfig: {
39
39
  readonly additionalReadFunctions: readonly [];
40
40
  readonly additionalWriteFunctions: readonly [];
@@ -101,7 +101,7 @@ export declare const LintingRules: {
101
101
  };
102
102
  readonly additionalPathFunctions: readonly [];
103
103
  readonly absolutePathRegex: undefined;
104
- readonly useAsWd: "@script";
104
+ readonly useAsWd: "@project";
105
105
  readonly ignoreUrls: true;
106
106
  };
107
107
  };
@@ -379,6 +379,28 @@ export declare const LintingRules: {
379
379
  };
380
380
  };
381
381
  };
382
+ readonly 'syntactically-valid': {
383
+ readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", [], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, 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>[]>>;
384
+ 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: import("./rules/syntactically-valid").SyntacticallyValidConfig, data: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>) => Promise<{
385
+ results: import("./rules/syntactically-valid").SyntacticallyValidResult[];
386
+ ".meta": import("./rules/syntactically-valid").SyntacticallyValidMetadata;
387
+ }>;
388
+ readonly prettyPrint: {
389
+ readonly query: (result: import("./rules/syntactically-valid").SyntacticallyValidResult) => string;
390
+ readonly full: (result: import("./rules/syntactically-valid").SyntacticallyValidResult) => string;
391
+ };
392
+ readonly info: {
393
+ readonly name: "Syntactically Valid";
394
+ readonly description: "Checks whether the code is free of syntax errors, using the configured (error-tolerant) parser, and offers extensible quick-fixes to repair them.";
395
+ readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.QuickFix];
396
+ readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
397
+ readonly activeByDefault: false;
398
+ readonly defaultConfig: {
399
+ readonly disabledFixes: readonly [];
400
+ readonly preferFix: "remove";
401
+ };
402
+ };
403
+ };
382
404
  };
383
405
  export type LintingRuleNames = keyof typeof LintingRules;
384
406
  export type LintingRuleMetadata<Name extends LintingRuleNames> = typeof LintingRules[Name] extends LintingRule<infer _Result, infer Metadata, infer _Config, infer _Info, infer _Elements> ? Metadata : never;
@@ -18,6 +18,7 @@ const software_has_license_1 = require("./rules/software-has-license");
18
18
  const software_has_tests_1 = require("./rules/software-has-tests");
19
19
  const no_leaked_credentials_1 = require("./rules/no-leaked-credentials");
20
20
  const undefined_symbol_1 = require("./rules/undefined-symbol");
21
+ const syntactically_valid_1 = require("./rules/syntactically-valid");
21
22
  /**
22
23
  * The registry of currently supported linting rules.
23
24
  * A linting rule can be executed on a dataflow pipeline result using {@link executeLintingRule}.
@@ -39,6 +40,7 @@ exports.LintingRules = {
39
40
  'software-has-license': software_has_license_1.SOFTWARE_HAS_LICENSE,
40
41
  'software-has-tests': software_has_tests_1.SOFTWARE_HAS_TESTS,
41
42
  'no-leaked-credentials': no_leaked_credentials_1.NO_LEAKED_CREDENTIALS,
42
- 'undefined-symbol': undefined_symbol_1.UNDEFINED_SYMBOL
43
+ 'undefined-symbol': undefined_symbol_1.UNDEFINED_SYMBOL,
44
+ 'syntactically-valid': syntactically_valid_1.SYNTACTICALLY_VALID
43
45
  };
44
46
  //# sourceMappingURL=linter-rules.js.map
@@ -5,7 +5,7 @@ import type { FunctionInfo } from '../../queries/catalog/dependencies-query/func
5
5
  export interface AbsoluteFilePathResult extends LintingResult {
6
6
  filePath: string;
7
7
  }
8
- type SupportedWd = '@script' | '@home' | string;
8
+ type SupportedWd = '@script' | '@home' | '@project' | string;
9
9
  export interface AbsoluteFilePathConfig extends MergeableRecord {
10
10
  /** Include paths that are built by functions, e.g., `file.path()` */
11
11
  include: {
@@ -22,8 +22,8 @@ export interface AbsoluteFilePathConfig extends MergeableRecord {
22
22
  */
23
23
  additionalPathFunctions: FunctionInfo[];
24
24
  /**
25
- * Which path should be considered to be the origin for relative paths.
26
- * This is only relevant with quickfixes. In the future we may be sensitive to setwd etc.
25
+ * Which path the relative-path quick fix is built against: `@project` (project root, falling back to the
26
+ * script when there is no root), `@script`, `@home`, or a literal directory.
27
27
  */
28
28
  useAsWd: SupportedWd;
29
29
  /** Automatically ignore URLs (http/https/ftp) so they are not reported as absolute paths. */
@@ -55,7 +55,7 @@ export declare const ABSOLUTE_PATH: {
55
55
  };
56
56
  readonly additionalPathFunctions: readonly [];
57
57
  readonly absolutePathRegex: undefined;
58
- readonly useAsWd: "@script";
58
+ readonly useAsWd: "@project";
59
59
  readonly ignoreUrls: true;
60
60
  };
61
61
  };
@@ -22,15 +22,16 @@ const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument
22
22
  const path_1 = __importDefault(require("path"));
23
23
  const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
24
24
  const other_path_functions_1 = require("../../queries/catalog/dependencies-query/function-info/other-path-functions");
25
- function inferWd(file, wd) {
25
+ function inferWd(file, wd, ctx) {
26
26
  if (wd === '@script') {
27
- // we can use the script path as the working directory
28
27
  return file;
29
28
  }
30
29
  else if (wd === '@home') {
31
- // we can use the home directory as the working directory
32
30
  return process.env.HOME || process.env.USERPROFILE || '';
33
31
  }
32
+ else if (wd === '@project') {
33
+ return ctx.files.root() ?? file;
34
+ }
34
35
  else {
35
36
  return wd;
36
37
  }
@@ -113,11 +114,12 @@ exports.ABSOLUTE_PATH = {
113
114
  const regex = config.absolutePathRegex ? new RegExp(config.absolutePathRegex) : undefined;
114
115
  const normalize = await data.normalize();
115
116
  const dataflow = await data.dataflow();
117
+ const ctx = data.inspectContext();
116
118
  return {
117
119
  results: elements.getElements().flatMap(element => {
118
120
  metadata.totalConsidered++;
119
121
  const node = element.node;
120
- const wd = inferWd(node.info.file, config.useAsWd);
122
+ const wd = inferWd(node.info.file, config.useAsWd, ctx);
121
123
  if (r_string_1.RString.is(node)) {
122
124
  const resolved = resolvePathForAbsoluteCheck(node.content.str, config.ignoreUrls);
123
125
  if (resolved !== undefined && resolved.length >= 3 && (0, strings_1.isAbsolutePath)(resolved, regex)) {
@@ -200,7 +202,7 @@ exports.ABSOLUTE_PATH = {
200
202
  },
201
203
  additionalPathFunctions: [],
202
204
  absolutePathRegex: undefined,
203
- useAsWd: '@script',
205
+ useAsWd: '@project',
204
206
  ignoreUrls: true
205
207
  }
206
208
  }
@@ -1,6 +1,6 @@
1
1
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
2
  import type { FlowrSearchElements } from '../../search/flowr-search';
3
- import { type MergeableRecord } from '../../util/objects';
3
+ import type { MergeableRecord } from '../../util/objects';
4
4
  import { LintingRuleCertainty, type LintingResult } from '../linter-format';
5
5
  import { LintingRuleTag } from '../linter-tags';
6
6
  export interface DataFrameAccessValidationResult extends LintingResult {
@@ -43,7 +43,7 @@ export declare const FILE_PATH_VALIDITY: {
43
43
  readonly name: "File Path Validity";
44
44
  readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
45
45
  readonly certainty: LintingRuleCertainty.BestEffort;
46
- readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility, LintingRuleTag.Bug];
46
+ readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility, LintingRuleTag.Bug, LintingRuleTag.QuickFix];
47
47
  readonly defaultConfig: {
48
48
  readonly additionalReadFunctions: readonly [];
49
49
  readonly additionalWriteFunctions: readonly [];
@@ -11,6 +11,11 @@ const logic_1 = require("../../util/logic");
11
11
  const happens_before_1 = require("../../control-flow/happens-before");
12
12
  const linter_tags_1 = require("../linter-tags");
13
13
  const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
14
+ const resolve_working_directory_1 = require("../../dataflow/eval/resolve/resolve-working-directory");
15
+ const config_1 = require("../../config");
16
+ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
17
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
18
+ const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
14
19
  async function urlExists(url) {
15
20
  try {
16
21
  const response = await fetch(url, { method: 'HEAD' });
@@ -36,6 +41,10 @@ exports.FILE_PATH_VALIDITY = {
36
41
  totalValid: 0
37
42
  };
38
43
  const results = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData).queries['dependencies'];
44
+ const ctx = data.inspectContext();
45
+ const dfg = (await data.dataflow()).graph;
46
+ const resolveSource = data.flowrConfig.solver.resolveSource;
47
+ const wdRootsFor = resolve_working_directory_1.WorkingDirectory.rootsResolver(dfg, cfg, ctx);
39
48
  const findings = await Promise.all(elements.getElements().map(async (element) => {
40
49
  const matchingRead = results.read.find(r => r.nodeId === element.node.info.id);
41
50
  if (!matchingRead) {
@@ -103,20 +112,25 @@ exports.FILE_PATH_VALIDITY = {
103
112
  metadata.totalWritesBeforeAlways++;
104
113
  return [];
105
114
  }
106
- // check if the file exists!
107
- const paths = (0, built_in_source_1.findSource)(data.flowrConfig.solver.resolveSource, matchingRead.value, {
108
- referenceChain: element.node.info.file ? [element.node.info.file] : [],
109
- ctx: data.inspectContext()
110
- });
115
+ // check if the file exists, resolving relative paths against the effective working directory
116
+ const value = matchingRead.value;
117
+ const referenceChain = element.node.info.file ? [element.node.info.file] : [];
118
+ const wdRoots = wdRootsFor(element.node.info.id, element.node.info.file);
119
+ const withWd = { ...resolveSource, searchPath: [...(resolveSource?.searchPath ?? []), ...wdRoots] };
120
+ const paths = (0, built_in_source_1.findSource)(withWd, value, { referenceChain, ctx });
111
121
  if (paths && paths.length) {
112
122
  metadata.totalValid++;
113
123
  return [];
114
124
  }
125
+ // a lax retry (drop leading dirs, ignore case) may surface a near match to offer as a quick fix
126
+ const near = (0, built_in_source_1.findSource)({ ...withWd, ignoreCapitalization: true, dropPaths: config_1.DropPathsOption.All }, value, { referenceChain, ctx });
127
+ const quickFix = dfg.idMap && near && near.length ? buildDidYouMeanFix(dfg.idMap, matchingRead.nodeId, value, near[0]) : undefined;
115
128
  return [{
116
129
  involvedId: matchingRead.nodeId,
117
130
  loc,
118
- filePath: matchingRead.value,
119
- certainty: writesBefore && writesBefore.length && writesBefore.every(w => w === logic_1.Ternary.Maybe) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain
131
+ filePath: value,
132
+ certainty: writesBefore && writesBefore.length && writesBefore.every(w => w === logic_1.Ternary.Maybe) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain,
133
+ ...(quickFix ? { quickFix } : {})
120
134
  }];
121
135
  }));
122
136
  return {
@@ -129,7 +143,7 @@ exports.FILE_PATH_VALIDITY = {
129
143
  description: 'Checks whether file paths used in read and write operations are valid and point to existing files.',
130
144
  // checks all found paths for whether they're valid to ensure correctness, but doesn't handle non-constant paths so not all will be returned
131
145
  certainty: linter_format_1.LintingRuleCertainty.BestEffort,
132
- tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.Bug],
146
+ tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.QuickFix],
133
147
  defaultConfig: {
134
148
  additionalReadFunctions: [],
135
149
  additionalWriteFunctions: [],
@@ -149,4 +163,30 @@ function samePath(a, b, ignoreCapitalization) {
149
163
  }
150
164
  return a === b;
151
165
  }
166
+ /** the string-literal path argument of a call whose resolved value is `value`, for anchoring a quick fix */
167
+ function pathArgStringNode(idMap, callId, value) {
168
+ const call = idMap.get(callId);
169
+ if (call?.type !== type_1.RType.FunctionCall) {
170
+ return undefined;
171
+ }
172
+ for (const arg of call.arguments) {
173
+ if (arg !== r_function_call_1.EmptyArgument && arg.value && r_string_1.RString.is(arg.value) && arg.value.content.str === value) {
174
+ return arg.value;
175
+ }
176
+ }
177
+ return undefined;
178
+ }
179
+ /** rewrite the read path to `found`, an existing file surfaced by the lax retry */
180
+ function buildDidYouMeanFix(idMap, callId, value, found) {
181
+ const str = pathArgStringNode(idMap, callId, value);
182
+ if (!str) {
183
+ return undefined;
184
+ }
185
+ return [{
186
+ type: 'replace',
187
+ loc: range_1.SourceLocation.fromNode(str) ?? range_1.SourceLocation.invalid(),
188
+ description: `Replace with existing path \`${found}\``,
189
+ replacement: str.content.quotes + found + str.content.quotes
190
+ }];
191
+ }
152
192
  //# sourceMappingURL=file-path-validity.js.map
@@ -3,6 +3,7 @@ import type { FlowrSearchElement, FlowrSearchElements } from '../../search/flowr
3
3
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { MergeableRecord } from '../../util/objects';
5
5
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
6
+ import type { Identifier } from '../../dataflow/environments/identifier';
6
7
  import { Ternary } from '../../util/logic';
7
8
  import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
8
9
  import type { AsyncOrSync } from 'ts-essentials';
@@ -17,7 +18,7 @@ export interface FunctionsToDetectConfig extends MergeableRecord {
17
18
  /**
18
19
  * The list of function names that should be marked in the given context.
19
20
  */
20
- fns: readonly string[];
21
+ fns: readonly Identifier[];
21
22
  }
22
23
  /**
23
24
  * This helper object collects utility functions used to create linting rules that search for specific functions.
@@ -0,0 +1,58 @@
1
+ import { type LintingResult, LintingRuleCertainty, type LintQuickFix } from '../linter-format';
2
+ import type { MergeableRecord } from '../../util/objects';
3
+ import { LintingRuleTag } from '../linter-tags';
4
+ import type { SyntaxNode } from 'web-tree-sitter';
5
+ /** The direction a fix takes to repair an error: add text, remove text, or comment the region out. */
6
+ export type FixDirection = 'add' | 'remove' | 'comment';
7
+ export interface SyntacticallyValidResult extends LintingResult {
8
+ readonly message: string;
9
+ readonly kind: 'missing' | 'error';
10
+ }
11
+ export interface SyntacticallyValidConfig extends MergeableRecord {
12
+ /** Names of {@link SyntaxErrorFixPatterns|auto-fix patterns} to disable (default none). */
13
+ readonly disabledFixes: readonly string[];
14
+ /** Preferred {@link FixDirection}; each error gets a single fix, favouring a candidate of this direction. */
15
+ readonly preferFix: FixDirection;
16
+ }
17
+ export interface SyntacticallyValidMetadata extends MergeableRecord {
18
+ readonly errors: number;
19
+ readonly fixable: number;
20
+ readonly parser: string;
21
+ }
22
+ /** A `missing` (parser-inserted, zero-width) or `error` (un-parseable) tree-sitter node. */
23
+ export interface SyntaxErrorFinding {
24
+ readonly kind: 'missing' | 'error';
25
+ readonly node: SyntaxNode;
26
+ }
27
+ /** An extensible auto-fix pattern; append to {@link SyntaxErrorFixPatterns} to teach the rule new repairs. */
28
+ export interface SyntaxErrorFixPattern {
29
+ readonly name: string;
30
+ readonly description: string;
31
+ readonly direction: FixDirection;
32
+ readonly appliesTo: (finding: SyntaxErrorFinding) => boolean;
33
+ readonly quickFix: (finding: SyntaxErrorFinding, file: string | undefined) => LintQuickFix;
34
+ }
35
+ /** The built-in auto-fix patterns; append a {@link SyntaxErrorFixPattern} to add repairs. */
36
+ export declare const SyntaxErrorFixPatterns: SyntaxErrorFixPattern[];
37
+ export declare const SYNTACTICALLY_VALID: {
38
+ readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", [], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, 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>[]>>;
39
+ 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: SyntacticallyValidConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
40
+ results: SyntacticallyValidResult[];
41
+ ".meta": SyntacticallyValidMetadata;
42
+ }>;
43
+ readonly prettyPrint: {
44
+ readonly query: (result: SyntacticallyValidResult) => string;
45
+ readonly full: (result: SyntacticallyValidResult) => string;
46
+ };
47
+ readonly info: {
48
+ readonly name: "Syntactically Valid";
49
+ readonly description: "Checks whether the code is free of syntax errors, using the configured (error-tolerant) parser, and offers extensible quick-fixes to repair them.";
50
+ readonly tags: readonly [LintingRuleTag.Bug, LintingRuleTag.Robustness, LintingRuleTag.QuickFix];
51
+ readonly certainty: LintingRuleCertainty.BestEffort;
52
+ readonly activeByDefault: false;
53
+ readonly defaultConfig: {
54
+ readonly disabledFixes: readonly [];
55
+ readonly preferFix: "remove";
56
+ };
57
+ };
58
+ };