@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.
- package/README.md +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/cli/flowr-main-options.d.ts +15 -0
- package/cli/flowr-main-options.js +18 -0
- package/cli/flowr.d.ts +18 -0
- package/cli/flowr.js +13 -2
- package/cli/repl/commands/repl-clipboard.js +2 -1
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-main.d.ts +5 -0
- package/cli/repl/commands/repl-signature.js +2 -0
- package/cli/repl/core.d.ts +7 -1
- package/cli/repl/core.js +17 -8
- package/cli/repl/execute.js +2 -0
- package/cli/repl/server/connection.js +2 -1
- package/cli/repl/server/net.d.ts +10 -0
- package/cli/repl/server/net.js +34 -1
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +12 -2
- package/config.js +91 -14
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +185 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +64 -42
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +42 -4
- package/dataflow/internal/control-flow.js +76 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +441 -79
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +290 -252
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +120 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +60 -58
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/doc-capabilities.js +4 -1
- package/documentation/wiki-interface.js +4 -0
- package/documentation/wiki-setup.js +23 -0
- package/engines.js +11 -3
- package/linter/linter-executor.js +19 -1
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +117 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +130 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
- package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +18 -42
- package/project/sigdb/decompress.js +3 -1
- package/project/sigdb/sigdb-download.js +9 -6
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-executor.js +9 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell-executor.js +2 -0
- package/r-bridge/shell.js +8 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +120 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +6 -0
- package/util/files.js +12 -0
- package/util/parallel.js +2 -0
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/secure-mode.d.ts +42 -0
- package/util/secure-mode.js +70 -0
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -47,29 +47,24 @@ function buildQuickFix(str, filePath, wd) {
|
|
|
47
47
|
replacement: `${str.content.quotes}${files_1.RPath.relative(wd, filePath)}${str.content.quotes}`
|
|
48
48
|
}];
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
results.push(argValues.join(val));
|
|
69
|
-
}
|
|
70
|
-
return results;
|
|
71
|
-
}]
|
|
72
|
-
]);
|
|
50
|
+
/** The paths `file.path(...)` builds, `undefined` if a part is unknown. */
|
|
51
|
+
function filePathStrings(graph, vtx, ctx) {
|
|
52
|
+
const variables = ctx.config.solver.variables;
|
|
53
|
+
// in the future we can access `.Platform$file.sep` here
|
|
54
|
+
const fsep = (0, resolve_argument_1.getArgumentStringValue)(variables, graph, vtx, undefined, 'fsep', true, ctx);
|
|
55
|
+
const seps = fsep?.values().flatMap(s => s.values().filter(assert_1.isNotUndefined)).toArray() ?? ['/'];
|
|
56
|
+
if (seps.includes(dependencies_query_format_1.Unknown)) {
|
|
57
|
+
// if we have no fsep, we cannot construct a path
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const unnamed = (0, resolve_argument_1.getArgumentStringValue)(variables, graph, vtx, 'unnamed', undefined, true, ctx);
|
|
61
|
+
const args = [...unnamed?.values() ?? []].flatMap(v => [...v]);
|
|
62
|
+
if (args.length === 0 || args.some(v => v === dependencies_query_format_1.Unknown || v === undefined)) {
|
|
63
|
+
// if we have no arguments, we cannot construct a path
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return seps.map(sep => args.join(sep));
|
|
67
|
+
}
|
|
73
68
|
/**
|
|
74
69
|
* Resolve a raw string value to the path that should be checked for absoluteness.
|
|
75
70
|
* - `file://` URIs: extract the local path (always checked, ignoreUrls has no effect)
|
|
@@ -83,24 +78,24 @@ function resolvePathForAbsoluteCheck(value, ignoreUrls) {
|
|
|
83
78
|
}
|
|
84
79
|
return ignoreUrls && (0, strings_1.isUrl)(value) ? undefined : value;
|
|
85
80
|
}
|
|
81
|
+
/** A path built within a call that already reports it, as `file.path` within `read.csv`, is one finding. */
|
|
82
|
+
function withoutNested(results) {
|
|
83
|
+
return results.filter((r, i) => !results.some((o, j) => i !== j && o.filePath === r.filePath
|
|
84
|
+
&& (range_1.SourceRange.isStrictSubsetOf(r.loc, o.loc) || (j < i && range_1.SourceRange.equals(r.loc, o.loc)))));
|
|
85
|
+
}
|
|
86
86
|
exports.ABSOLUTE_PATH = {
|
|
87
87
|
/* this can be done better once we have types */
|
|
88
88
|
createSearch: (config, data) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
ignoreDefaultFunctions: true,
|
|
98
|
-
readFunctions: (0, read_functions_1.readFunctions)(data.inspectContext()).concat((0, write_functions_1.writeFunctions)(data.inspectContext()), source_functions_1.SourceFunctions, other_path_functions_1.OtherPathFunctions, config.additionalPathFunctions),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
89
|
+
const ctx = data.inspectContext();
|
|
90
|
+
const pathFunctions = (0, read_functions_1.readFunctions)(ctx).concat((0, write_functions_1.writeFunctions)(ctx), source_functions_1.SourceFunctions, other_path_functions_1.OtherPathFunctions, config.additionalPathFunctions);
|
|
91
|
+
let q = config.include.allStrings ? flowr_search_builder_1.Q.all().filter(type_1.RType.String) : flowr_search_builder_1.Q.fromQuery({
|
|
92
|
+
type: 'dependencies',
|
|
93
|
+
// we use the dependencies query to give us all functions that take a file path as input
|
|
94
|
+
ignoreDefaultFunctions: true,
|
|
95
|
+
readFunctions: pathFunctions,
|
|
96
|
+
});
|
|
101
97
|
if (config.include.constructed) {
|
|
102
98
|
q = q.merge(flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall).with(search_enrichers_1.Enrichment.CallTargets));
|
|
103
|
-
/* in the future, we want to directly check whether this is one of the supported functions */
|
|
104
99
|
}
|
|
105
100
|
return q.unique();
|
|
106
101
|
},
|
|
@@ -111,76 +106,57 @@ exports.ABSOLUTE_PATH = {
|
|
|
111
106
|
};
|
|
112
107
|
const queryResults = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData)?.queries;
|
|
113
108
|
const regex = config.absolutePathRegex ? new RegExp(config.absolutePathRegex) : undefined;
|
|
114
|
-
const
|
|
115
|
-
const
|
|
109
|
+
const { idMap } = await data.normalize();
|
|
110
|
+
const { graph } = await data.dataflow();
|
|
116
111
|
const ctx = data.inspectContext();
|
|
112
|
+
const absolute = (value) => {
|
|
113
|
+
const path = resolvePathForAbsoluteCheck(value, config.ignoreUrls);
|
|
114
|
+
return path !== undefined && (0, strings_1.isAbsolutePath)(path, regex) ? path : undefined;
|
|
115
|
+
};
|
|
116
|
+
const finding = (certainty, filePath, node, wd) => (0, objects_1.compactRecord)({
|
|
117
|
+
certainty,
|
|
118
|
+
filePath,
|
|
119
|
+
loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
|
|
120
|
+
quickFix: buildQuickFix(node, filePath, wd)
|
|
121
|
+
});
|
|
117
122
|
return {
|
|
118
|
-
results: elements.getElements().flatMap(element => {
|
|
123
|
+
results: withoutNested(elements.getElements().flatMap(element => {
|
|
119
124
|
metadata.totalConsidered++;
|
|
120
125
|
const node = element.node;
|
|
121
126
|
const wd = inferWd(node.info.file, config.useAsWd, ctx);
|
|
127
|
+
const query = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.QueryData);
|
|
122
128
|
if (r_string_1.RString.is(node)) {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
return [{
|
|
126
|
-
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
127
|
-
filePath: resolved,
|
|
128
|
-
loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
|
|
129
|
-
quickFix: buildQuickFix(node, resolved, wd)
|
|
130
|
-
}];
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
129
|
+
const path = absolute(node.content.str);
|
|
130
|
+
return path !== undefined && path.length >= 3 ? [finding(linter_format_1.LintingResultCertainty.Uncertain, path, node, wd)] : [];
|
|
135
131
|
}
|
|
136
|
-
else if (
|
|
137
|
-
const result = queryResults[
|
|
138
|
-
const
|
|
132
|
+
else if (query) {
|
|
133
|
+
const result = queryResults[query.query];
|
|
134
|
+
const reads = result.read.filter(r => r.nodeId === node.info.id);
|
|
135
|
+
const found = reads.flatMap(r => {
|
|
139
136
|
if (r.value === undefined || r.value === dependencies_query_format_1.Unknown || r.nodeId === undefined) {
|
|
140
137
|
return [];
|
|
141
138
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
const elem = normalize.idMap.get(r.nodeId);
|
|
147
|
-
return [{
|
|
148
|
-
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
149
|
-
filePath: resolved,
|
|
150
|
-
loc: elem ? range_1.SourceLocation.fromNode(elem) ?? range_1.SourceLocation.invalid() : range_1.SourceLocation.invalid(),
|
|
151
|
-
quickFix: buildQuickFix(elem, resolved, wd)
|
|
152
|
-
}];
|
|
139
|
+
const path = absolute(r.value);
|
|
140
|
+
return path === undefined ? [] : [finding(linter_format_1.LintingResultCertainty.Certain, path, idMap.get(r.nodeId), wd)];
|
|
153
141
|
});
|
|
154
|
-
if
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
else if (result.read.every(r => r.value !== dependencies_query_format_1.Unknown)) {
|
|
158
|
-
// if we have no absolute paths, but all paths are known, we can return an empty array
|
|
159
|
-
return [];
|
|
142
|
+
// if we have no absolute paths, but all paths are known, we can return an empty array
|
|
143
|
+
if (found.length > 0 || reads.every(r => r.value !== dependencies_query_format_1.Unknown)) {
|
|
144
|
+
return found;
|
|
160
145
|
}
|
|
161
146
|
}
|
|
162
147
|
else {
|
|
163
|
-
const
|
|
164
|
-
if (vertex_1.DfgVertex.isFunctionCall(
|
|
165
|
-
|
|
166
|
-
const strings =
|
|
148
|
+
const vertex = graph.getVertex(node.info.id);
|
|
149
|
+
if (vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
150
|
+
/* `file.path` is the only supported function that returns a file path */
|
|
151
|
+
const strings = vertex.name === 'file.path' ? filePathStrings(graph, vertex, ctx) : [];
|
|
167
152
|
if (strings) {
|
|
168
|
-
return strings.
|
|
169
|
-
const resolved = resolvePathForAbsoluteCheck(s, config.ignoreUrls);
|
|
170
|
-
return resolved !== undefined && (0, strings_1.isAbsolutePath)(resolved, regex) ? [resolved] : [];
|
|
171
|
-
}).map(str => ({
|
|
172
|
-
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
173
|
-
filePath: str,
|
|
174
|
-
loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid(),
|
|
175
|
-
quickFix: undefined
|
|
176
|
-
}));
|
|
153
|
+
return strings.map(absolute).filter(assert_1.isNotUndefined).map(path => finding(linter_format_1.LintingResultCertainty.Uncertain, path, node));
|
|
177
154
|
}
|
|
178
155
|
}
|
|
179
|
-
// check whether the df node is a function call that returns a file path
|
|
180
156
|
}
|
|
181
157
|
metadata.totalUnknown++;
|
|
182
|
-
return
|
|
183
|
-
})
|
|
158
|
+
return [];
|
|
159
|
+
})),
|
|
184
160
|
'.meta': metadata
|
|
185
161
|
};
|
|
186
162
|
},
|
|
@@ -2,6 +2,8 @@ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
3
|
import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
|
|
4
4
|
import { LintingRuleTag } from '../linter-tags';
|
|
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 interface FilePathValidityResult extends LintingResult {
|
|
6
8
|
filePath: string;
|
|
7
9
|
}
|
|
@@ -34,8 +36,8 @@ export interface FilePathValidityMetadata extends MergeableRecord {
|
|
|
34
36
|
totalValid: number;
|
|
35
37
|
}
|
|
36
38
|
export declare const FILE_PATH_VALIDITY: {
|
|
37
|
-
readonly createSearch: (config: FilePathValidityConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["with"],
|
|
38
|
-
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<
|
|
39
|
+
readonly createSearch: (config: FilePathValidityConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["with"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
|
|
40
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: FilePathValidityConfig, data: ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
39
41
|
results: FilePathValidityResult[];
|
|
40
42
|
".meta": FilePathValidityMetadata;
|
|
41
43
|
}>;
|
|
@@ -9,25 +9,44 @@ const dependencies_query_format_1 = require("../../queries/catalog/dependencies-
|
|
|
9
9
|
const built_in_source_1 = require("../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
10
10
|
const logic_1 = require("../../util/logic");
|
|
11
11
|
const happens_before_1 = require("../../control-flow/happens-before");
|
|
12
|
+
const read_functions_1 = require("../../queries/catalog/dependencies-query/function-info/read-functions");
|
|
13
|
+
const library_functions_1 = require("../../queries/catalog/dependencies-query/function-info/library-functions");
|
|
14
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
12
15
|
const linter_tags_1 = require("../linter-tags");
|
|
13
16
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
14
17
|
const resolve_working_directory_1 = require("../../dataflow/eval/resolve/resolve-working-directory");
|
|
15
18
|
const config_1 = require("../../config");
|
|
16
19
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
17
20
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
21
|
+
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
22
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
23
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
24
|
+
const r_if_then_else_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else");
|
|
25
|
+
const r_while_loop_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-while-loop");
|
|
26
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
27
|
+
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
28
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
29
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
30
|
+
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
31
|
+
const r_base_packages_1 = require("../../util/r-base-packages");
|
|
32
|
+
const secure_mode_1 = require("../../util/secure-mode");
|
|
33
|
+
const DataSetExtensions = ['R', 'r', 'RData', 'rdata', 'rda', 'tab', 'txt', 'TXT', 'tab.gz', 'tab.bz2', 'tab.xz', 'txt.gz', 'txt.bz2', 'txt.xz', 'csv', 'CSV'];
|
|
34
|
+
function namesPackage(node) {
|
|
35
|
+
return r_function_call_1.RFunctionCall.is(node) && node.arguments.some(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && ['package', 'lib.loc'].includes(identifier_1.Identifier.getName(a.name.content)));
|
|
36
|
+
}
|
|
18
37
|
async function urlExists(url) {
|
|
38
|
+
secure_mode_1.SecureMode.guard('network access', url);
|
|
19
39
|
try {
|
|
20
|
-
|
|
21
|
-
return response.ok;
|
|
40
|
+
return (await fetch(url, { method: 'HEAD' })).ok;
|
|
22
41
|
}
|
|
23
42
|
catch {
|
|
24
43
|
return false;
|
|
25
44
|
}
|
|
26
45
|
}
|
|
27
46
|
exports.FILE_PATH_VALIDITY = {
|
|
28
|
-
createSearch:
|
|
47
|
+
createSearch: config => flowr_search_builder_1.Q.fromQuery({
|
|
29
48
|
type: 'dependencies',
|
|
30
|
-
enabledCategories: ['read', 'write'],
|
|
49
|
+
enabledCategories: ['read', 'write', 'library'],
|
|
31
50
|
readFunctions: config.additionalReadFunctions,
|
|
32
51
|
writeFunctions: config.additionalWriteFunctions
|
|
33
52
|
}).with(search_enrichers_1.Enrichment.CfgInformation),
|
|
@@ -41,96 +60,90 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
41
60
|
};
|
|
42
61
|
const results = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData).queries['dependencies'];
|
|
43
62
|
const ctx = data.inspectContext();
|
|
44
|
-
const
|
|
45
|
-
const
|
|
63
|
+
const df = await data.dataflow();
|
|
64
|
+
const dfg = df.graph;
|
|
65
|
+
const { resolveSource } = data.flowrConfig.solver;
|
|
46
66
|
const wdRootsFor = resolve_working_directory_1.WorkingDirectory.rootsResolver(dfg, cfg, ctx);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
/* `data("x")` names a data set, not a file */
|
|
68
|
+
const namesOnly = new Set((0, read_functions_1.readFunctions)(ctx).concat(config.additionalReadFunctions).filter(f => f.resolveValue === 'library').map(f => f.name));
|
|
69
|
+
const attached = (results.library ?? []).filter(library_functions_1.attachesPackage);
|
|
70
|
+
const atTopLevel = (id) => dfg.idMap === undefined || model_1.RNode.findEnclosing(id, dfg.idMap, r_function_definition_1.RFunctionDefinition.is) === undefined;
|
|
71
|
+
const librariesLoadedBefore = (read) => attached.some(l => l.nodeId === undefined || !atTopLevel(l.nodeId) || !atTopLevel(read)
|
|
72
|
+
|| !cfg.hasVertex(l.nodeId) || (0, happens_before_1.happensBefore)(cfg, l.nodeId, read) !== logic_1.Ternary.Never);
|
|
73
|
+
const uniqueElements = [...new Map(elements.getElements().map(e => [e.node.info.id, e])).values()];
|
|
74
|
+
const reads = uniqueElements.flatMap(element => results.read
|
|
75
|
+
.filter(r => r.nodeId === element.node.info.id)
|
|
76
|
+
.map(matchingRead => ({ element, matchingRead })));
|
|
77
|
+
const findings = await Promise.all(reads.map(async ({ element, matchingRead }) => {
|
|
78
|
+
const { nodeId, value } = matchingRead;
|
|
79
|
+
/* data built from constants, like `matrix(1:6, 2)`, reads no file */
|
|
80
|
+
if (nodeId === undefined || value === dependencies_query_format_1.Constant) {
|
|
50
81
|
return [];
|
|
51
82
|
}
|
|
52
|
-
|
|
83
|
+
const { id, file } = element.node.info;
|
|
53
84
|
const loc = range_1.SourceLocation.fromNode(element.node);
|
|
85
|
+
const referenceChain = file ? [file] : [];
|
|
86
|
+
const verdict = (valid, filePath, certainty, quickFix) => {
|
|
87
|
+
if (valid) {
|
|
88
|
+
metadata.totalValid++;
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
return [{ involvedId: nodeId, loc: loc, filePath, certainty, ...(quickFix ? { quickFix } : {}) }];
|
|
92
|
+
};
|
|
93
|
+
if (namesOnly.has(identifier_1.Identifier.getName(matchingRead.functionName))) {
|
|
94
|
+
if (!loc || typeof value !== 'string' || value === dependencies_query_format_1.Unknown
|
|
95
|
+
|| librariesLoadedBefore(id) || r_base_packages_1.BaseDatasets.has(value) || namesPackage(element.node)) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
metadata.totalReads++;
|
|
99
|
+
const find = finderAt(resolveSource, wdRootsFor(id, file), file, ctx);
|
|
100
|
+
const exists = DataSetExtensions.some(ext => find(`data/${value}.${ext}`).length);
|
|
101
|
+
return verdict(exists, `data/${value}`, linter_format_1.LintingResultCertainty.Uncertain);
|
|
102
|
+
}
|
|
103
|
+
metadata.totalReads++;
|
|
54
104
|
if (!loc) {
|
|
55
105
|
return [];
|
|
56
106
|
}
|
|
57
107
|
// check if we can't parse the file path statically
|
|
58
|
-
if (
|
|
108
|
+
if (value === dependencies_query_format_1.Unknown) {
|
|
59
109
|
metadata.totalUnknown++;
|
|
60
|
-
|
|
61
|
-
return [{
|
|
62
|
-
involvedId: matchingRead.nodeId,
|
|
63
|
-
loc,
|
|
64
|
-
filePath: dependencies_query_format_1.Unknown,
|
|
65
|
-
certainty: linter_format_1.LintingResultCertainty.Uncertain
|
|
66
|
-
}];
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
110
|
+
return config.includeUnknown ? [{ involvedId: nodeId, loc, filePath: dependencies_query_format_1.Unknown, certainty: linter_format_1.LintingResultCertainty.Uncertain }] : [];
|
|
71
111
|
}
|
|
112
|
+
const path = value;
|
|
72
113
|
// file:// URIs are local paths; resolve and check existence directly
|
|
73
|
-
const localFromFileUrl = (0, strings_1.fileUrlToPath)(
|
|
114
|
+
const localFromFileUrl = (0, strings_1.fileUrlToPath)(path);
|
|
74
115
|
if (localFromFileUrl !== undefined) {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
ctx: data.inspectContext()
|
|
78
|
-
});
|
|
79
|
-
if (paths && paths.length) {
|
|
80
|
-
metadata.totalValid++;
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
return [{
|
|
84
|
-
involvedId: matchingRead.nodeId,
|
|
85
|
-
loc,
|
|
86
|
-
filePath: localFromFileUrl,
|
|
87
|
-
certainty: linter_format_1.LintingResultCertainty.Certain
|
|
88
|
-
}];
|
|
116
|
+
const exists = !!(0, built_in_source_1.findSource)(resolveSource, localFromFileUrl, { referenceChain, ctx })?.length;
|
|
117
|
+
return verdict(exists, localFromFileUrl, linter_format_1.LintingResultCertainty.Certain);
|
|
89
118
|
}
|
|
90
119
|
// handle remote URLs separately from file paths
|
|
91
|
-
if ((0, strings_1.isUrl)(
|
|
92
|
-
if
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
const exists = await urlExists(matchingRead.value);
|
|
96
|
-
if (exists) {
|
|
97
|
-
metadata.totalValid++;
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
return [{
|
|
101
|
-
involvedId: matchingRead.nodeId,
|
|
102
|
-
loc,
|
|
103
|
-
filePath: matchingRead.value,
|
|
104
|
-
certainty: linter_format_1.LintingResultCertainty.Uncertain
|
|
105
|
-
}];
|
|
120
|
+
if ((0, strings_1.isUrl)(path)) {
|
|
121
|
+
// the secure mode forbids network access, so the URL stays unchecked as if checkUrls was off
|
|
122
|
+
return config.checkUrls && !secure_mode_1.SecureMode.isEnabled() ? verdict(await urlExists(path), path, linter_format_1.LintingResultCertainty.Uncertain) : [];
|
|
106
123
|
}
|
|
107
124
|
// check if any write to the same file happens before the read, and exclude this case if so
|
|
108
|
-
const writesToFile = results.write.filter((r) => r.nodeId !== undefined && samePath(r.value,
|
|
109
|
-
const writesBefore = writesToFile.map(w => (0, happens_before_1.happensBefore)(cfg, w.nodeId,
|
|
125
|
+
const writesToFile = results.write.filter((r) => r.nodeId !== undefined && samePath(r.value, path, resolveSource?.ignoreCapitalization));
|
|
126
|
+
const writesBefore = writesToFile.map(w => (0, happens_before_1.happensBefore)(cfg, w.nodeId, id));
|
|
110
127
|
if (writesBefore.includes(logic_1.Ternary.Always)) {
|
|
111
128
|
metadata.totalWritesBeforeAlways++;
|
|
112
129
|
return [];
|
|
113
130
|
}
|
|
114
131
|
// check if the file exists, resolving relative paths against the effective working directory
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const withWd = { ...resolveSource, searchPath: [...(resolveSource?.searchPath ?? []), ...wdRoots] };
|
|
119
|
-
const paths = (0, built_in_source_1.findSource)(withWd, value, { referenceChain, ctx });
|
|
120
|
-
if (paths && paths.length) {
|
|
121
|
-
metadata.totalValid++;
|
|
122
|
-
return [];
|
|
132
|
+
const wdRoots = wdRootsFor(id, file);
|
|
133
|
+
if (finderAt(resolveSource, wdRoots, file, ctx)(path).length) {
|
|
134
|
+
return verdict(true, path, linter_format_1.LintingResultCertainty.Certain);
|
|
123
135
|
}
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
/* a lax retry (drop leading dirs, ignore case) may surface a near match to offer as a quick fix */
|
|
137
|
+
const laxOptions = {
|
|
138
|
+
...searchingFrom(resolveSource, wdRoots.roots),
|
|
139
|
+
ignoreCapitalization: true,
|
|
140
|
+
dropPaths: config_1.DropPathsOption.All
|
|
141
|
+
};
|
|
142
|
+
const near = (0, built_in_source_1.findSource)(laxOptions, path, { referenceChain, ctx });
|
|
143
|
+
const quickFix = dfg.idMap && near?.length ? buildDidYouMeanFix(dfg.idMap, nodeId, path, near[0]) : undefined;
|
|
144
|
+
const maybeWrittenBefore = writesBefore.length > 0 && writesBefore.every(w => w === logic_1.Ternary.Maybe);
|
|
145
|
+
const uncertain = maybeWrittenBefore || guardedByFileQuery(df, id, path, data);
|
|
146
|
+
return verdict(false, path, uncertain ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain, quickFix);
|
|
134
147
|
}));
|
|
135
148
|
return {
|
|
136
149
|
results: findings.flat(),
|
|
@@ -155,6 +168,35 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
155
168
|
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Path \`${result.filePath}\` at ${range_1.SourceLocation.format(result.loc)} does not point to a valid file`
|
|
156
169
|
}
|
|
157
170
|
};
|
|
171
|
+
/** Whether the read only runs depending on a condition that queries the same file, as in `if(file.exists(p)) readLines(p)`. */
|
|
172
|
+
function guardedByFileQuery(df, read, path, data) {
|
|
173
|
+
const dfg = df.graph;
|
|
174
|
+
return (dfg.getVertex(read)?.cds ?? []).some(cd => {
|
|
175
|
+
const construct = dfg.idMap?.get(cd.id);
|
|
176
|
+
const condition = r_if_then_else_1.RIfThenElse.is(construct) || r_while_loop_1.RWhileLoop.is(construct) ? construct.condition : undefined;
|
|
177
|
+
return [...model_1.RNode.collectAllIds(condition)].some(id => {
|
|
178
|
+
const call = dfg.getVertex(id);
|
|
179
|
+
if (!vertex_1.DfgVertex.isFunctionCall(call) || !function_semantics_1.FunctionSemantics.call.props.hasAny((0, query_fn_props_1.callFnProps)(call.id, df), built_in_props_1.SemanticCallTag.File)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const args = (0, resolve_argument_1.getArgumentStringValue)(data.flowrConfig.solver.variables, dfg, call, 'unnamed', undefined, true, data.inspectContext());
|
|
183
|
+
return args?.values().some(v => v.has(path)) ?? false;
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function searchingFrom(resolveSource, roots) {
|
|
188
|
+
return { ...resolveSource, searchPath: [...(resolveSource?.searchPath ?? []), ...roots] };
|
|
189
|
+
}
|
|
190
|
+
/** looks a path up from the working directories a `setwd` pins down, and laxly along the configured search path if none does. */
|
|
191
|
+
function finderAt(resolveSource, { roots, pinned }, file, ctx) {
|
|
192
|
+
const referenceChain = file ? [file] : [];
|
|
193
|
+
if (!pinned) {
|
|
194
|
+
const lax = searchingFrom(resolveSource, roots);
|
|
195
|
+
return value => (0, built_in_source_1.findSource)(lax, value, { referenceChain, ctx }) ?? [];
|
|
196
|
+
}
|
|
197
|
+
const strict = { ...resolveSource, searchPath: [], dropPaths: config_1.DropPathsOption.No, inferWorkingDirectory: config_1.InferWorkingDirectory.No };
|
|
198
|
+
return value => roots.flatMap(root => (0, built_in_source_1.findSource)(strict, resolve_working_directory_1.WorkingDirectory.applyChange(root, value), { referenceChain, ctx }) ?? []);
|
|
199
|
+
}
|
|
158
200
|
function samePath(a, b, ignoreCapitalization) {
|
|
159
201
|
if (ignoreCapitalization === true) {
|
|
160
202
|
a = a.toLowerCase();
|
|
@@ -168,19 +210,14 @@ function pathArgStringNode(idMap, callId, value) {
|
|
|
168
210
|
if (!r_function_call_1.RFunctionCall.is(call)) {
|
|
169
211
|
return undefined;
|
|
170
212
|
}
|
|
171
|
-
|
|
172
|
-
if (arg !== r_function_call_1.EmptyArgument && arg.value && r_string_1.RString.is(arg.value) && arg.value.content.str === value) {
|
|
173
|
-
return arg.value;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return undefined;
|
|
213
|
+
return call.arguments.map(r_argument_1.RArgument.valueOf).find(v => r_string_1.RString.is(v) && v.content.str === value);
|
|
177
214
|
}
|
|
178
215
|
/** rewrite the read path to `found`, an existing file surfaced by the lax retry */
|
|
179
216
|
function buildDidYouMeanFix(idMap, callId, value, found) {
|
|
180
217
|
const str = pathArgStringNode(idMap, callId, value);
|
|
181
218
|
const loc = str === undefined ? undefined : range_1.SourceLocation.fromNode(str);
|
|
182
|
-
if (!str || loc === undefined) {
|
|
183
|
-
/* a fix that names no place cannot be carried out, so none is offered */
|
|
219
|
+
if (!str || loc === undefined || found === value) {
|
|
220
|
+
/* a fix that names no place or changes nothing cannot be carried out, so none is offered */
|
|
184
221
|
return undefined;
|
|
185
222
|
}
|
|
186
223
|
return [{
|
|
@@ -8,6 +8,7 @@ const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
|
8
8
|
const range_1 = require("../../util/range");
|
|
9
9
|
const linter_format_1 = require("../linter-format");
|
|
10
10
|
const linter_tags_1 = require("../linter-tags");
|
|
11
|
+
const schema_1 = require("../../project/sigdb/schema");
|
|
11
12
|
/**
|
|
12
13
|
* Cross-checks every `pkg::name`/`pkg:::name` against the signature database's exported bit.
|
|
13
14
|
* An absent entry (unknown package, unresolved version, uncatalogued name) is never read as "not exported" -
|
|
@@ -21,39 +22,26 @@ exports.NAMESPACE_ACCESS = {
|
|
|
21
22
|
const db = data.inspectContext().deps.signatures();
|
|
22
23
|
const results = [];
|
|
23
24
|
let unresolved = 0;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const loc = range_1.SourceLocation.fromNode(node);
|
|
46
|
-
if (loc === undefined) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
results.push({
|
|
50
|
-
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
51
|
-
involvedId: node.info.id,
|
|
52
|
-
loc,
|
|
53
|
-
pkg,
|
|
54
|
-
name,
|
|
55
|
-
kind
|
|
56
|
-
});
|
|
25
|
+
for (const { node } of db.available() ? elements.getElements() : []) {
|
|
26
|
+
if (!r_symbol_1.RSymbol.is(node)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const [name, pkg, internal] = identifier_1.Identifier.toArray(node.content);
|
|
30
|
+
if (pkg === undefined) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const raw = db.rawFunctionOf(node.content);
|
|
34
|
+
/* a registered S3 method counts as exported in the database although `::` does not reach it */
|
|
35
|
+
if (raw === undefined || (internal === true && raw.props.includes(schema_1.FnPropNames[512 /* FnProp.S3Method */]))) {
|
|
36
|
+
unresolved++;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const kind = internal === true
|
|
40
|
+
? (raw.exported ? 'unnecessary-internal' : undefined)
|
|
41
|
+
: (raw.exported ? undefined : 'not-exported');
|
|
42
|
+
const loc = range_1.SourceLocation.fromNode(node);
|
|
43
|
+
if (kind !== undefined && loc !== undefined) {
|
|
44
|
+
results.push({ certainty: linter_format_1.LintingResultCertainty.Certain, involvedId: node.info.id, loc, pkg, name, kind });
|
|
57
45
|
}
|
|
58
46
|
}
|
|
59
47
|
return { results, '.meta': { unresolved } };
|
|
@@ -57,7 +57,7 @@ export declare function fixCasing(identifier: string, convention: CasingConventi
|
|
|
57
57
|
*/
|
|
58
58
|
export declare function createNamingConventionQuickFixes(graph: DataflowGraph, nodeId: NodeId, replacement: string, conv: CasingConvention): LintQuickFixReplacement[] | undefined;
|
|
59
59
|
export declare const NAMING_CONVENTION: {
|
|
60
|
-
readonly createSearch: (
|
|
60
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
61
61
|
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: NamingConventionConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
62
62
|
results: NamingConventionResult[];
|
|
63
63
|
'.meta': {
|