@eagleoutice/flowr 2.10.6 → 2.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +9 -9
  2. package/abstract-interpretation/domains/multi-value-state-domain.d.ts +4 -10
  3. package/abstract-interpretation/domains/multi-value-state-domain.js +1 -6
  4. package/abstract-interpretation/domains/partial-product-domain.d.ts +6 -2
  5. package/abstract-interpretation/domains/partial-product-domain.js +7 -3
  6. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  7. package/dataflow/environments/built-in-proc-name.d.ts +22 -20
  8. package/dataflow/environments/built-in-proc-name.js +22 -20
  9. package/dataflow/environments/built-in.d.ts +19 -19
  10. package/dataflow/environments/identifier.d.ts +5 -0
  11. package/dataflow/environments/reference-to-maybe.js +32 -6
  12. package/dataflow/eval/resolve/alias-tracking.js +5 -0
  13. package/dataflow/graph/graph.js +51 -30
  14. package/dataflow/graph/vertex.d.ts +12 -11
  15. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +49 -12
  16. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -2
  17. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +12 -6
  18. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -8
  19. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +57 -1
  20. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  21. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
  22. package/documentation/wiki-linting-and-testing.js +1 -1
  23. package/documentation/wiki-mk/doc-context.d.ts +21 -1
  24. package/documentation/wiki-mk/doc-context.js +9 -0
  25. package/documentation/wiki-search.js +13 -2
  26. package/linter/linter-format.d.ts +4 -0
  27. package/linter/linter-rules.d.ts +9 -7
  28. package/linter/rules/absolute-path.d.ts +3 -2
  29. package/linter/rules/absolute-path.js +37 -12
  30. package/linter/rules/dataframe-access-validation.d.ts +4 -7
  31. package/linter/rules/dataframe-access-validation.js +3 -3
  32. package/linter/rules/dead-code.d.ts +4 -7
  33. package/linter/rules/file-path-validity.d.ts +9 -4
  34. package/linter/rules/file-path-validity.js +83 -36
  35. package/linter/rules/function-finder-util.d.ts +1 -3
  36. package/linter/rules/function-finder-util.js +2 -2
  37. package/linter/rules/naming-convention.d.ts +0 -2
  38. package/linter/rules/network-functions.js +4 -1
  39. package/linter/rules/problematic-inputs.d.ts +0 -2
  40. package/linter/rules/problematic-inputs.js +4 -1
  41. package/linter/rules/roxygen-arguments.d.ts +0 -2
  42. package/linter/rules/seeded-randomness.d.ts +0 -2
  43. package/linter/rules/stop-with-call-arg.d.ts +3 -6
  44. package/linter/rules/unused-definition.d.ts +0 -2
  45. package/linter/rules/useless-loop.d.ts +0 -2
  46. package/package.json +7 -6
  47. package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -2
  48. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
  49. package/queries/catalog/dependencies-query/function-info/read-functions.js +21 -1
  50. package/queries/catalog/dependencies-query/function-info/source-functions.js +1 -1
  51. package/queries/catalog/dependencies-query/function-info/write-functions.js +18 -1
  52. package/queries/catalog/input-sources-query/input-source-functions.d.ts +3 -1
  53. package/queries/catalog/input-sources-query/input-source-functions.js +322 -46
  54. package/queries/catalog/input-sources-query/input-sources-query-executor.js +14 -9
  55. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +4 -2
  56. package/queries/catalog/input-sources-query/input-sources-query-format.js +8 -4
  57. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +13 -6
  58. package/queries/catalog/input-sources-query/simple-input-classifier.js +33 -8
  59. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -2
  60. package/queries/catalog/linter-query/linter-query-format.js +9 -3
  61. package/queries/query.d.ts +3 -2
  62. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  63. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +16 -16
  64. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  65. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +8 -0
  66. package/search/flowr-search-builder.d.ts +64 -16
  67. package/search/flowr-search-builder.js +41 -16
  68. package/search/flowr-search-filters.d.ts +10 -1
  69. package/search/flowr-search-filters.js +10 -0
  70. package/search/flowr-search.d.ts +17 -3
  71. package/search/search-executor/search-generators.d.ts +3 -1
  72. package/search/search-executor/search-generators.js +30 -4
  73. package/slicing/static/static-slicer.js +2 -2
  74. package/util/range.d.ts +13 -1
  75. package/util/range.js +32 -2
  76. package/util/text/strings.d.ts +7 -0
  77. package/util/text/strings.js +23 -0
  78. package/util/version.js +1 -1
@@ -173,7 +173,27 @@ export interface GeneralDocContext {
173
173
  */
174
174
  doc(element: ElementIdOrRef, filter?: Omit<ElementFilter, 'file'>): string;
175
175
  /**
176
- * Returns the code snippet for a code element as markdown string.
176
+ * Returns the documentation for a member of a class as Markdown string.
177
+ * This is a convenience method around {@link GeneralDocContext#doc|doc}.
178
+ * @example
179
+ * ```ts
180
+ * docM(MyClass, 'myMethod')
181
+ * ```
182
+ *
183
+ * Creates the documentation for the `myMethod` member of the `MyClass` class in the code base.
184
+ * @see {@link GeneralDocContext#doc|doc} - for the underlying impl.
185
+ * @see {@link GeneralDocContext#docO|docO} - to get documentation using an object reference instead of a class and member name.
186
+ */
187
+ docM<T extends NamedPrototype>(cls: T, element: ProtoKeys<T> | StaticKeys<T>, filter?: Omit<ElementFilter, 'file'>): string;
188
+ /**
189
+ * Returns the documentation for a type/element definition which is retrieved from an object reference.
190
+ * This is similar to {@link GeneralDocContext#doc}, but it uses an object reference to identify the element.
191
+ */
192
+ docO<T extends object & {
193
+ name: string;
194
+ }>(obj: T, element: keyof T, filter?: Omit<ElementFilter, 'file'>): string;
195
+ /**
196
+ * Returns the code snippet for a code element as Markdown string.
177
197
  * @param element - The element to create a code snippet for, the name can be qualified with `::` to specify the class.
178
198
  * @param fmt - Formatting options for the code snippet (see {@link FnElementInfo})
179
199
  * @param filter - An optional filter to further specify the element to get the code for, in case multiple elements with the same name exist.
@@ -56,6 +56,15 @@ function makeDocContextForTypes(shell, ...rootFolders) {
56
56
  doc(element, filter) {
57
57
  return (0, doc_types_1.getDocumentationForType)(getNameFromElementIdOrRef(element), info, '', filter);
58
58
  },
59
+ docM(cls, element, filter) {
60
+ const className = cls.prototype.constructor.name;
61
+ const fullName = `${className}::${String(element)}`;
62
+ return this.doc(fullName, filter);
63
+ },
64
+ docO(obj, element, filter) {
65
+ const fullName = `${obj.name}::${String(element)}`;
66
+ return this.doc(fullName, filter);
67
+ },
59
68
  link(element, fmt, filter) {
60
69
  (0, assert_1.guard)(filter?.file === undefined, 'filtering for files is not yet supported for link');
61
70
  return (0, doc_types_1.shortLink)(getNameFromElementIdOrRef(element), info, fmt?.codeFont, fmt?.realNameWrapper, filter?.fuzzy, filter?.type);
@@ -38,16 +38,27 @@ and can be further refined with _transformers_ or _modifiers_.
38
38
  Such queries can be constructed starting from the ${ctx.link('Q')} object (backed by ${ctx.link('FlowrSearchGenerator')}) and
39
39
  are fully serializable so you can use them when communicating with the [Query API](${doc_files_1.FlowrWikiBaseRef}/Query%20API).
40
40
 
41
+ ## File Path Filtering
42
+
43
+ Many convenience functions and the \`get\` generator support filtering by file path using the \`filePathRegex\` parameter.
44
+ This is useful when you want to search for nodes only in specific files.
45
+ Additionally, inline code (code without a file path) is treated as having an empty path \`""\` for regex matching purposes.
46
+
47
+ The ${ctx.link(flowr_search_builder_1.FlowrSearchGenerator)} provides several convenience functions for searching variables with file path filtering.
48
+ ${ctx.linkO(flowr_search_builder_1.FlowrSearchGenerator, 'var')} and other functions like ${ctx.linkO(flowr_search_builder_1.FlowrSearchGenerator, 'get')}
49
+ also allow you to pass in a regex to only match files that fit your specified pattern!
50
+
51
+
41
52
  We offer the following generators:
42
53
 
43
- ${Object.keys(flowr_search_builder_1.Q).sort().map(key => `- ${ctx.link(`FlowrSearchGenerator::${key}`)}\\\n${ctx.doc(`FlowrSearchGenerator::${key}`)}`).join('\n')}
54
+ ${Object.keys(flowr_search_builder_1.Q).filter(n => n !== 'name').sort((a, b) => a.localeCompare(b)).map(key => `- ${ctx.linkO(flowr_search_builder_1.FlowrSearchGenerator, key)}\\\n${ctx.docO(flowr_search_builder_1.FlowrSearchGenerator, key)}`).join('\n')}
44
55
 
45
56
  Likewise, we have a palette of _transformers_ and _modifiers_:
46
57
 
47
58
  ${
48
59
  /* let's iterate over all methods of FlowrSearchBuilder */
49
60
  Object.getOwnPropertyNames(Object.getPrototypeOf(new flowr_search_builder_1.FlowrSearchBuilder(undefined)))
50
- .filter(n => n !== 'constructor').sort().map(key => `- ${ctx.link(`FlowrSearchBuilder::${key}`)}\\\n${ctx.doc(`FlowrSearchBuilder::${key}`)}`).join('\n')}
61
+ .filter(n => n !== 'constructor' && n !== 'name').sort().map(key => `- ${ctx.linkM(flowr_search_builder_1.FlowrSearchBuilder, key)}\\\n${ctx.docM(flowr_search_builder_1.FlowrSearchBuilder, key)}`).join('\n')}
51
62
 
52
63
  Every search (and consequently the search pipeline) works with an array of ${ctx.link('FlowrSearchElement')} (neatly wrapped in ${ctx.link(flowr_search_1.FlowrSearchElements)}).
53
64
  Hence, even operations such as \`.first\` or \`.last\` return an array of elements (albeit with a single or no element).
@@ -105,6 +105,10 @@ export interface LintingResult {
105
105
  * The node ID or IDs involved in this linting result, if applicable.
106
106
  */
107
107
  readonly involvedId: NodeId | NodeId[] | undefined;
108
+ /**
109
+ * The source location where this linting result occurs
110
+ */
111
+ readonly loc: SourceLocation;
108
112
  }
109
113
  export interface ConfiguredLintingRule<Name extends LintingRuleNames = LintingRuleNames> {
110
114
  readonly name: Name;
@@ -33,10 +33,10 @@ export declare const LintingRules: {
33
33
  dataflow: import("../dataflow/info").DataflowInformation;
34
34
  cfg: import("../control-flow/control-flow-graph").ControlFlowInformation;
35
35
  analyzer: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
36
- }) => {
36
+ }) => Promise<{
37
37
  results: import("./rules/file-path-validity").FilePathValidityResult[];
38
38
  ".meta": import("./rules/file-path-validity").FilePathValidityMetadata;
39
- };
39
+ }>;
40
40
  readonly info: {
41
41
  readonly name: "File Path Validity";
42
42
  readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
@@ -46,6 +46,7 @@ export declare const LintingRules: {
46
46
  readonly additionalReadFunctions: readonly [];
47
47
  readonly additionalWriteFunctions: readonly [];
48
48
  readonly includeUnknown: false;
49
+ readonly checkUrls: false;
49
50
  };
50
51
  };
51
52
  readonly prettyPrint: {
@@ -118,6 +119,7 @@ export declare const LintingRules: {
118
119
  readonly additionalPathFunctions: readonly [];
119
120
  readonly absolutePathRegex: undefined;
120
121
  readonly useAsWd: "@script";
122
+ readonly ignoreUrls: true;
121
123
  };
122
124
  };
123
125
  };
@@ -234,12 +236,12 @@ export declare const LintingRules: {
234
236
  cfg: import("../control-flow/control-flow-graph").ControlFlowInformation;
235
237
  analyzer: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
236
238
  }) => {
237
- results: import("./rules/dead-code").DeadCodeResult[];
239
+ results: import("./linter-format").LintingResult[];
238
240
  '.meta': import("./rules/dead-code").DeadCodeMetadata;
239
241
  };
240
242
  readonly prettyPrint: {
241
- readonly query: (result: import("./rules/dead-code").DeadCodeResult) => string;
242
- readonly full: (result: import("./rules/dead-code").DeadCodeResult) => string;
243
+ readonly query: (result: import("./linter-format").LintingResult) => string;
244
+ readonly full: (result: import("./linter-format").LintingResult) => string;
243
245
  };
244
246
  readonly info: {
245
247
  readonly name: "Dead Code";
@@ -319,8 +321,8 @@ export declare const LintingRules: {
319
321
  '.meta': import("./rules/stop-with-call-arg").StopWithCallMetadata;
320
322
  };
321
323
  readonly prettyPrint: {
322
- readonly query: (result: import("./rules/stop-with-call-arg").StopWithCallResult) => string;
323
- readonly full: (result: import("./rules/stop-with-call-arg").StopWithCallResult) => string;
324
+ readonly query: (result: import("./linter-format").LintingResult) => string;
325
+ readonly full: (result: import("./linter-format").LintingResult) => string;
324
326
  };
325
327
  readonly info: {
326
328
  readonly name: "Stop without call.=False argument";
@@ -1,11 +1,9 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import { type MergeableRecord } from '../../util/objects';
3
- import { SourceLocation } from '../../util/range';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
6
5
  export interface AbsoluteFilePathResult extends LintingResult {
7
6
  filePath: string;
8
- loc: SourceLocation;
9
7
  }
10
8
  type SupportedWd = '@script' | '@home' | string;
11
9
  export interface AbsoluteFilePathConfig extends MergeableRecord {
@@ -28,6 +26,8 @@ export interface AbsoluteFilePathConfig extends MergeableRecord {
28
26
  * This is only relevant with quickfixes. In the future we may be sensitive to setwd etc.
29
27
  */
30
28
  useAsWd: SupportedWd;
29
+ /** Automatically ignore URLs (http/https/ftp) so they are not reported as absolute paths. */
30
+ ignoreUrls: boolean;
31
31
  }
32
32
  export interface AbsoluteFilePathMetadata extends MergeableRecord {
33
33
  totalConsidered: number;
@@ -61,6 +61,7 @@ export declare const ABSOLUTE_PATH: {
61
61
  readonly additionalPathFunctions: readonly [];
62
62
  readonly absolutePathRegex: undefined;
63
63
  readonly useAsWd: "@script";
64
+ readonly ignoreUrls: true;
64
65
  };
65
66
  };
66
67
  };
@@ -69,6 +69,19 @@ const PathFunctions = new Map([
69
69
  return results;
70
70
  }]
71
71
  ]);
72
+ /**
73
+ * Resolve a raw string value to the path that should be checked for absoluteness.
74
+ * - `file://` URIs: extract the local path (always checked, ignoreUrls has no effect)
75
+ * - remote URLs (http/s3/...): `undefined` when ignoreUrls is true (skip)
76
+ * - everything else: the value itself
77
+ */
78
+ function resolvePathForAbsoluteCheck(value, ignoreUrls) {
79
+ const local = (0, strings_1.fileUrlToPath)(value);
80
+ if (local !== undefined) {
81
+ return local;
82
+ }
83
+ return ignoreUrls && (0, strings_1.isUrl)(value) ? undefined : value;
84
+ }
72
85
  exports.ABSOLUTE_PATH = {
73
86
  /* this can be done better once we have types */
74
87
  createSearch: (config) => {
@@ -103,12 +116,13 @@ exports.ABSOLUTE_PATH = {
103
116
  const node = element.node;
104
117
  const wd = inferWd(node.info.file, config.useAsWd);
105
118
  if (r_string_1.RString.is(node)) {
106
- if (node.content.str.length >= 3 && (0, strings_1.isAbsolutePath)(node.content.str, regex)) {
119
+ const resolved = resolvePathForAbsoluteCheck(node.content.str, config.ignoreUrls);
120
+ if (resolved !== undefined && resolved.length >= 3 && (0, strings_1.isAbsolutePath)(resolved, regex)) {
107
121
  return [{
108
122
  certainty: linter_format_1.LintingResultCertainty.Uncertain,
109
- filePath: node.content.str,
123
+ filePath: resolved,
110
124
  loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
111
- quickFix: buildQuickFix(node, node.content.str, wd)
125
+ quickFix: buildQuickFix(node, resolved, wd)
112
126
  }];
113
127
  }
114
128
  else {
@@ -117,14 +131,21 @@ exports.ABSOLUTE_PATH = {
117
131
  }
118
132
  else if ((0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.QueryData)) {
119
133
  const result = queryResults[(0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.QueryData).query];
120
- const mappedStrings = result.read.filter(r => r.value !== undefined && r.value !== dependencies_query_format_1.Unknown && (0, strings_1.isAbsolutePath)(r.value, regex)).map(r => {
134
+ const mappedStrings = result.read.flatMap(r => {
135
+ if (r.value === undefined || r.value === dependencies_query_format_1.Unknown) {
136
+ return [];
137
+ }
138
+ const resolved = resolvePathForAbsoluteCheck(r.value, config.ignoreUrls);
139
+ if (resolved === undefined || !(0, strings_1.isAbsolutePath)(resolved, regex)) {
140
+ return [];
141
+ }
121
142
  const elem = data.normalize.idMap.get(r.nodeId);
122
- return {
123
- certainty: linter_format_1.LintingResultCertainty.Certain,
124
- filePath: r.value,
125
- loc: elem ? range_1.SourceLocation.fromNode(elem) ?? range_1.SourceLocation.invalid() : range_1.SourceLocation.invalid(),
126
- quickFix: buildQuickFix(elem, r.value, wd)
127
- };
143
+ return [{
144
+ certainty: linter_format_1.LintingResultCertainty.Certain,
145
+ filePath: resolved,
146
+ loc: elem ? range_1.SourceLocation.fromNode(elem) ?? range_1.SourceLocation.invalid() : range_1.SourceLocation.invalid(),
147
+ quickFix: buildQuickFix(elem, resolved, wd)
148
+ }];
128
149
  });
129
150
  if (mappedStrings.length > 0) {
130
151
  return mappedStrings;
@@ -140,7 +161,10 @@ exports.ABSOLUTE_PATH = {
140
161
  const handler = dfNode.name ? PathFunctions.get(dfNode.name) : undefined;
141
162
  const strings = handler ? handler(data.dataflow.graph, dfNode, data.analyzer.inspectContext()) : [];
142
163
  if (strings) {
143
- return strings.filter(s => (0, strings_1.isAbsolutePath)(s, regex)).map(str => ({
164
+ return strings.flatMap(s => {
165
+ const resolved = resolvePathForAbsoluteCheck(s, config.ignoreUrls);
166
+ return resolved !== undefined && (0, strings_1.isAbsolutePath)(resolved, regex) ? [resolved] : [];
167
+ }).map(str => ({
144
168
  certainty: linter_format_1.LintingResultCertainty.Uncertain,
145
169
  filePath: str,
146
170
  loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid(),
@@ -173,7 +197,8 @@ exports.ABSOLUTE_PATH = {
173
197
  },
174
198
  additionalPathFunctions: [],
175
199
  absolutePathRegex: undefined,
176
- useAsWd: '@script'
200
+ useAsWd: '@script',
201
+ ignoreUrls: true
177
202
  }
178
203
  }
179
204
  };
@@ -1,20 +1,17 @@
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
3
  import { type MergeableRecord } from '../../util/objects';
4
- import { SourceRange } from '../../util/range';
5
4
  import { LintingRuleCertainty, type LintingResult } from '../linter-format';
6
5
  import { LintingRuleTag } from '../linter-tags';
7
6
  export interface DataFrameAccessValidationResult extends LintingResult {
8
7
  /** The type of the data frame access ("column" or "row") */
9
- type: 'column' | 'row';
8
+ readonly type: 'column' | 'row';
10
9
  /** The name or index of the column or row being accessed in the data frame */
11
- accessed: string | number;
10
+ readonly accessed: string | number;
12
11
  /** The name of the function/operation used for the access (e.g. `$`, `[`, `[[`, but also `filter`, `select`, ...) */
13
- access: string;
12
+ readonly access: string;
14
13
  /** The variable/symbol name of the accessed data frame operand (`undefined` if operand is no symbol) */
15
- operand?: string;
16
- /** The source range in the code where the access occurs */
17
- range: SourceRange;
14
+ readonly operand?: string;
18
15
  }
19
16
  export interface DataFrameAccessValidationConfig extends MergeableRecord {
20
17
  /** Whether data frame shapes should be extracted from loaded external data files, such as CSV files (defaults to the option in the flowR config if `undefined`) */
@@ -67,7 +67,7 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
67
67
  involvedId: node?.info.id,
68
68
  access: node?.lexeme ?? '???',
69
69
  ...(operand?.type === type_1.RType.Symbol ? { operand: identifier_1.Identifier.getName(operand.content) } : {}),
70
- range: range_1.SourceRange.fromNode(node) ?? range_1.SourceRange.invalid(),
70
+ loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
71
71
  certainty: linter_format_1.LintingResultCertainty.Certain
72
72
  }));
73
73
  return { results, '.meta': metadata };
@@ -75,10 +75,10 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
75
75
  prettyPrint: {
76
76
  [linter_format_1.LintingPrettyPrintContext.Query]: result => `Access of ${result.type} ` +
77
77
  (typeof result.accessed === 'string' ? `"${result.accessed}"` : result.accessed) + ' ' +
78
- (result.operand === undefined ? `at \`${result.access}\`` : `of \`${result.operand}\``) + ` at ${range_1.SourceRange.format(result.range)}`,
78
+ (result.operand === undefined ? `at \`${result.access}\`` : `of \`${result.operand}\``) + ` at ${range_1.SourceLocation.format(result.loc)}`,
79
79
  [linter_format_1.LintingPrettyPrintContext.Full]: result => `Accessed ${result.type} ` +
80
80
  (typeof result.accessed === 'string' ? `"${result.accessed}"` : result.accessed) + ' does not exist ' +
81
- (result.operand === undefined ? `at \`${result.access}\`` : `in \`${result.operand}\``) + ` at ${range_1.SourceRange.format(result.range)}`
81
+ (result.operand === undefined ? `at \`${result.access}\`` : `in \`${result.operand}\``) + ` at ${range_1.SourceLocation.format(result.loc)}`
82
82
  },
83
83
  info: {
84
84
  name: 'Dataframe Access Validation',
@@ -1,11 +1,8 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
- import { SourceLocation } from '../../util/range';
3
2
  import type { MergeableRecord } from '../../util/objects';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import { type CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
6
- export interface DeadCodeResult extends LintingResult {
7
- readonly loc: SourceLocation;
8
- }
5
+ export type DeadCodeResult = LintingResult;
9
6
  export interface DeadCodeConfig extends MergeableRecord {
10
7
  /**
11
8
  * The simplification passes that should be run on the extracted CFG.
@@ -24,12 +21,12 @@ export declare const DEAD_CODE: {
24
21
  cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
25
22
  analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
26
23
  }) => {
27
- results: DeadCodeResult[];
24
+ results: LintingResult[];
28
25
  '.meta': DeadCodeMetadata;
29
26
  };
30
27
  readonly prettyPrint: {
31
- readonly query: (result: DeadCodeResult) => string;
32
- readonly full: (result: DeadCodeResult) => string;
28
+ readonly query: (result: LintingResult) => string;
29
+ readonly full: (result: LintingResult) => string;
33
30
  };
34
31
  readonly info: {
35
32
  readonly name: "Dead Code";
@@ -1,11 +1,9 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import type { MergeableRecord } from '../../util/objects';
3
- import { SourceLocation } from '../../util/range';
4
3
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
5
4
  import { LintingRuleTag } from '../linter-tags';
6
5
  export interface FilePathValidityResult extends LintingResult {
7
6
  filePath: string;
8
- loc: SourceLocation;
9
7
  }
10
8
  export interface FilePathValidityConfig extends MergeableRecord {
11
9
  /**
@@ -22,6 +20,12 @@ export interface FilePathValidityConfig extends MergeableRecord {
22
20
  * Whether unknown file paths should be included as linting results.
23
21
  */
24
22
  includeUnknown: boolean;
23
+ /**
24
+ * Whether URLs should be validated by checking the endpoint exists.
25
+ * When `false` (default), URLs are silently ignored.
26
+ * When `true`, an HTTP HEAD request is made and the URL is reported if unreachable.
27
+ */
28
+ checkUrls: boolean;
25
29
  }
26
30
  export interface FilePathValidityMetadata extends MergeableRecord {
27
31
  totalReads: number;
@@ -36,10 +40,10 @@ export declare const FILE_PATH_VALIDITY: {
36
40
  dataflow: import("../../dataflow/info").DataflowInformation;
37
41
  cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
38
42
  analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
39
- }) => {
43
+ }) => Promise<{
40
44
  results: FilePathValidityResult[];
41
45
  ".meta": FilePathValidityMetadata;
42
- };
46
+ }>;
43
47
  readonly info: {
44
48
  readonly name: "File Path Validity";
45
49
  readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
@@ -49,6 +53,7 @@ export declare const FILE_PATH_VALIDITY: {
49
53
  readonly additionalReadFunctions: readonly [];
50
54
  readonly additionalWriteFunctions: readonly [];
51
55
  readonly includeUnknown: false;
56
+ readonly checkUrls: false;
52
57
  };
53
58
  };
54
59
  readonly prettyPrint: {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FILE_PATH_VALIDITY = void 0;
4
4
  const linter_format_1 = require("../linter-format");
5
+ const strings_1 = require("../../util/text/strings");
5
6
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
6
7
  const range_1 = require("../../util/range");
7
8
  const dependencies_query_format_1 = require("../../queries/catalog/dependencies-query/dependencies-query-format");
@@ -10,6 +11,15 @@ const logic_1 = require("../../util/logic");
10
11
  const happens_before_1 = require("../../control-flow/happens-before");
11
12
  const linter_tags_1 = require("../linter-tags");
12
13
  const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
14
+ async function urlExists(url) {
15
+ try {
16
+ const response = await fetch(url, { method: 'HEAD' });
17
+ return response.ok;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
13
23
  exports.FILE_PATH_VALIDITY = {
14
24
  createSearch: (config) => flowr_search_builder_1.Q.fromQuery({
15
25
  type: 'dependencies',
@@ -17,7 +27,7 @@ exports.FILE_PATH_VALIDITY = {
17
27
  readFunctions: config.additionalReadFunctions,
18
28
  writeFunctions: config.additionalWriteFunctions
19
29
  }).with(search_enrichers_1.Enrichment.CfgInformation),
20
- processSearchResult: (elements, config, data) => {
30
+ processSearchResult: async (elements, config, data) => {
21
31
  const cfg = elements.enrichmentContent(search_enrichers_1.Enrichment.CfgInformation).cfg.graph;
22
32
  const metadata = {
23
33
  totalReads: 0,
@@ -26,41 +36,35 @@ exports.FILE_PATH_VALIDITY = {
26
36
  totalValid: 0
27
37
  };
28
38
  const results = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData).queries['dependencies'];
29
- return {
30
- results: elements.getElements().flatMap(element => {
31
- const matchingRead = results.read.find(r => r.nodeId === element.node.info.id);
32
- if (!matchingRead) {
33
- return [];
39
+ const findings = await Promise.all(elements.getElements().map(async (element) => {
40
+ const matchingRead = results.read.find(r => r.nodeId === element.node.info.id);
41
+ if (!matchingRead) {
42
+ return [];
43
+ }
44
+ metadata.totalReads++;
45
+ const loc = range_1.SourceLocation.fromNode(element.node);
46
+ if (!loc) {
47
+ return [];
48
+ }
49
+ // check if we can't parse the file path statically
50
+ if (matchingRead.value === dependencies_query_format_1.Unknown) {
51
+ metadata.totalUnknown++;
52
+ if (config.includeUnknown) {
53
+ return [{
54
+ involvedId: matchingRead.nodeId,
55
+ loc,
56
+ filePath: dependencies_query_format_1.Unknown,
57
+ certainty: linter_format_1.LintingResultCertainty.Uncertain
58
+ }];
34
59
  }
35
- metadata.totalReads++;
36
- const loc = range_1.SourceLocation.fromNode(element.node);
37
- if (!loc) {
60
+ else {
38
61
  return [];
39
62
  }
40
- // check if we can't parse the file path statically
41
- if (matchingRead.value === dependencies_query_format_1.Unknown) {
42
- metadata.totalUnknown++;
43
- if (config.includeUnknown) {
44
- return [{
45
- involvedId: matchingRead.nodeId,
46
- loc,
47
- filePath: dependencies_query_format_1.Unknown,
48
- certainty: linter_format_1.LintingResultCertainty.Uncertain
49
- }];
50
- }
51
- else {
52
- return [];
53
- }
54
- }
55
- // check if any write to the same file happens before the read, and exclude this case if so
56
- const writesToFile = results.write.filter(r => samePath(r.value, matchingRead.value, data.analyzer.flowrConfig.solver.resolveSource?.ignoreCapitalization));
57
- const writesBefore = writesToFile.map(w => (0, happens_before_1.happensBefore)(cfg, w.nodeId, element.node.info.id));
58
- if (writesBefore.some(w => w === logic_1.Ternary.Always)) {
59
- metadata.totalWritesBeforeAlways++;
60
- return [];
61
- }
62
- // check if the file exists!
63
- const paths = (0, built_in_source_1.findSource)(data.analyzer.flowrConfig.solver.resolveSource, matchingRead.value, {
63
+ }
64
+ // file:// URIs are local paths; resolve and check existence directly
65
+ const localFromFileUrl = (0, strings_1.fileUrlToPath)(matchingRead.value);
66
+ if (localFromFileUrl !== undefined) {
67
+ const paths = (0, built_in_source_1.findSource)(data.analyzer.flowrConfig.solver.resolveSource, localFromFileUrl, {
64
68
  referenceChain: element.node.info.file ? [element.node.info.file] : [],
65
69
  ctx: data.analyzer.inspectContext()
66
70
  });
@@ -68,13 +72,55 @@ exports.FILE_PATH_VALIDITY = {
68
72
  metadata.totalValid++;
69
73
  return [];
70
74
  }
75
+ return [{
76
+ involvedId: matchingRead.nodeId,
77
+ loc,
78
+ filePath: localFromFileUrl,
79
+ certainty: linter_format_1.LintingResultCertainty.Certain
80
+ }];
81
+ }
82
+ // handle remote URLs separately from file paths
83
+ if ((0, strings_1.isUrl)(matchingRead.value)) {
84
+ if (!config.checkUrls) {
85
+ return [];
86
+ }
87
+ const exists = await urlExists(matchingRead.value);
88
+ if (exists) {
89
+ metadata.totalValid++;
90
+ return [];
91
+ }
71
92
  return [{
72
93
  involvedId: matchingRead.nodeId,
73
94
  loc,
74
95
  filePath: matchingRead.value,
75
- certainty: writesBefore && writesBefore.length && writesBefore.every(w => w === logic_1.Ternary.Maybe) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain
96
+ certainty: linter_format_1.LintingResultCertainty.Uncertain
76
97
  }];
77
- }),
98
+ }
99
+ // check if any write to the same file happens before the read, and exclude this case if so
100
+ const writesToFile = results.write.filter(r => samePath(r.value, matchingRead.value, data.analyzer.flowrConfig.solver.resolveSource?.ignoreCapitalization));
101
+ const writesBefore = writesToFile.map(w => (0, happens_before_1.happensBefore)(cfg, w.nodeId, element.node.info.id));
102
+ if (writesBefore.some(w => w === logic_1.Ternary.Always)) {
103
+ metadata.totalWritesBeforeAlways++;
104
+ return [];
105
+ }
106
+ // check if the file exists!
107
+ const paths = (0, built_in_source_1.findSource)(data.analyzer.flowrConfig.solver.resolveSource, matchingRead.value, {
108
+ referenceChain: element.node.info.file ? [element.node.info.file] : [],
109
+ ctx: data.analyzer.inspectContext()
110
+ });
111
+ if (paths && paths.length) {
112
+ metadata.totalValid++;
113
+ return [];
114
+ }
115
+ return [{
116
+ involvedId: matchingRead.nodeId,
117
+ 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
120
+ }];
121
+ }));
122
+ return {
123
+ results: findings.flat(),
78
124
  '.meta': metadata
79
125
  };
80
126
  },
@@ -87,7 +133,8 @@ exports.FILE_PATH_VALIDITY = {
87
133
  defaultConfig: {
88
134
  additionalReadFunctions: [],
89
135
  additionalWriteFunctions: [],
90
- includeUnknown: false
136
+ includeUnknown: false,
137
+ checkUrls: false
91
138
  }
92
139
  },
93
140
  prettyPrint: {
@@ -1,4 +1,3 @@
1
- import { SourceLocation } from '../../util/range';
2
1
  import { type LintingResult, LintingResultCertainty } from '../linter-format';
3
2
  import type { FlowrSearchElement, FlowrSearchElements } from '../../search/flowr-search';
4
3
  import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
@@ -9,7 +8,6 @@ import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer
9
8
  import { Ternary } from '../../util/logic';
10
9
  export interface FunctionsResult extends LintingResult {
11
10
  function: string;
12
- loc: SourceLocation;
13
11
  }
14
12
  export interface FunctionsMetadata extends MergeableRecord {
15
13
  totalCalls: number;
@@ -36,7 +34,7 @@ export declare const functionFinderUtil: {
36
34
  query: (result: FunctionsResult) => string;
37
35
  full: (result: FunctionsResult) => string;
38
36
  };
39
- requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: readonly FunctionInfo[], data: {
37
+ requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, data: {
40
38
  normalize: NormalizedAst;
41
39
  dataflow: DataflowInformation;
42
40
  analyzer: ReadonlyFlowrAnalysisProvider;
@@ -61,7 +61,7 @@ exports.functionFinderUtil = {
61
61
  };
62
62
  },
63
63
  requireArgumentValue(element, pool, data, requireValue) {
64
- const info = pool.find(f => f.name === element.node.lexeme);
64
+ const info = pool.get(element.node.lexeme ?? '');
65
65
  /* if we have no additional info, we assume they always access the network */
66
66
  if (info === undefined) {
67
67
  return logic_1.Ternary.Always;
@@ -70,7 +70,7 @@ exports.functionFinderUtil = {
70
70
  if ((0, vertex_1.isFunctionCallVertex)(vert)) {
71
71
  const args = (0, resolve_argument_1.getArgumentStringValue)(data.analyzer.flowrConfig.solver.variables, data.dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue, data.analyzer.inspectContext());
72
72
  // we obtain all values, at least one of them has to trigger for the request
73
- const argValues = args ? args.values().flatMap(v => [...v]).filter(assert_1.isNotUndefined).toArray() : [];
73
+ const argValues = args ? args.values().flatMap(s => Array.from(s)).filter(assert_1.isNotUndefined).toArray() : [];
74
74
  if (argValues.length === 0) {
75
75
  return logic_1.Ternary.Maybe;
76
76
  }
@@ -1,7 +1,6 @@
1
1
  import type { DataflowGraph } from '../../dataflow/graph/graph';
2
2
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  import type { MergeableRecord } from '../../util/objects';
4
- import { SourceLocation } from '../../util/range';
5
4
  import { type LintingResult, type LintQuickFixReplacement, LintingRuleCertainty } from '../linter-format';
6
5
  import { LintingRuleTag } from '../linter-tags';
7
6
  export declare enum CasingConvention {
@@ -16,7 +15,6 @@ export declare enum CasingConvention {
16
15
  export interface NamingConventionResult extends LintingResult {
17
16
  name: string;
18
17
  detectedCasing: CasingConvention;
19
- loc: SourceLocation;
20
18
  }
21
19
  /**
22
20
  * It is planned to have a config like ESLint
@@ -6,12 +6,15 @@ const function_finder_util_1 = require("./function-finder-util");
6
6
  const linter_tags_1 = require("../linter-tags");
7
7
  const read_functions_1 = require("../../queries/catalog/dependencies-query/function-info/read-functions");
8
8
  const logic_1 = require("../../util/logic");
9
+ const source_functions_1 = require("../../queries/catalog/dependencies-query/function-info/source-functions");
10
+ const write_functions_1 = require("../../queries/catalog/dependencies-query/function-info/write-functions");
11
+ const FnPool = new Map(read_functions_1.ReadFunctions.concat(source_functions_1.SourceFunctions, write_functions_1.WriteFunctions).map(f => [f.name, f]));
9
12
  exports.NETWORK_FUNCTIONS = {
10
13
  createSearch: (config) => function_finder_util_1.functionFinderUtil.createSearch(config.fns),
11
14
  processSearchResult: (e, c, d) => function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, es => {
12
15
  const res = [];
13
16
  for (const e of es) {
14
- const val = function_finder_util_1.functionFinderUtil.requireArgumentValue(e, read_functions_1.ReadFunctions, d, c.onlyTriggerWithArgument);
17
+ const val = function_finder_util_1.functionFinderUtil.requireArgumentValue(e, FnPool, d, c.onlyTriggerWithArgument);
15
18
  if (val === logic_1.Ternary.Never) {
16
19
  continue;
17
20
  }