@eagleoutice/flowr 2.10.5 → 2.10.7
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 +21 -21
- package/abstract-interpretation/absint-visitor.d.ts +1 -2
- package/abstract-interpretation/domains/state-domain-like.d.ts +2 -2
- package/config.d.ts +6 -0
- package/config.js +2 -0
- package/control-flow/basic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +4 -0
- package/dataflow/environments/built-in-proc-name.d.ts +27 -19
- package/dataflow/environments/built-in-proc-name.js +27 -19
- package/dataflow/environments/built-in.d.ts +24 -18
- package/dataflow/environments/built-in.js +6 -0
- package/dataflow/environments/default-builtin-config.d.ts +53 -1
- package/dataflow/environments/default-builtin-config.js +13 -3
- package/dataflow/environments/identifier.d.ts +19 -0
- package/dataflow/environments/reference-to-maybe.js +32 -6
- package/dataflow/eval/resolve/alias-tracking.js +5 -0
- package/dataflow/graph/graph.js +51 -30
- package/dataflow/graph/vertex.d.ts +18 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +145 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +15 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +54 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +75 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +196 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +57 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +27 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +27 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +97 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +23 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +90 -0
- package/documentation/doc-util/doc-types.d.ts +11 -2
- package/documentation/doc-util/doc-types.js +31 -9
- package/documentation/wiki-absint.d.ts +16 -0
- package/documentation/wiki-absint.js +50 -15
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-mk/doc-context.d.ts +14 -1
- package/documentation/wiki-mk/doc-context.js +6 -0
- package/documentation/wiki-normalized-ast.d.ts +0 -9
- package/documentation/wiki-normalized-ast.js +9 -60
- package/linter/linter-format.d.ts +4 -0
- package/linter/linter-rules.d.ts +7 -6
- package/linter/rules/absolute-path.d.ts +0 -2
- package/linter/rules/dataframe-access-validation.d.ts +4 -7
- package/linter/rules/dataframe-access-validation.js +3 -3
- package/linter/rules/dead-code.d.ts +4 -7
- package/linter/rules/file-path-validity.d.ts +0 -2
- package/linter/rules/function-finder-util.d.ts +1 -3
- package/linter/rules/function-finder-util.js +2 -2
- package/linter/rules/naming-convention.d.ts +0 -2
- package/linter/rules/network-functions.js +4 -1
- package/linter/rules/problematic-inputs.d.ts +9 -6
- package/linter/rules/problematic-inputs.js +108 -58
- package/linter/rules/roxygen-arguments.d.ts +0 -2
- package/linter/rules/seeded-randomness.d.ts +0 -2
- package/linter/rules/stop-with-call-arg.d.ts +3 -6
- package/linter/rules/unused-definition.d.ts +0 -2
- package/linter/rules/useless-loop.d.ts +0 -2
- package/package.json +4 -4
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +2 -0
- package/queries/catalog/dependencies-query/function-info/source-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +7 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +3 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +3 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +3 -1
- package/r-bridge/data/data.d.ts +28 -2
- package/r-bridge/data/data.js +34 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/model.js +0 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +16 -16
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +8 -0
- package/search/flowr-search-builder.d.ts +16 -2
- package/search/flowr-search-builder.js +10 -1
- package/search/flowr-search.d.ts +9 -0
- package/search/search-executor/search-generators.d.ts +1 -1
- package/search/search-executor/search-generators.js +28 -2
- package/slicing/static/static-slicer.js +2 -2
- package/util/range.d.ts +13 -1
- package/util/range.js +32 -2
- package/util/version.js +1 -1
- package/abstract-interpretation/normalized-ast-fold.d.ts +0 -119
- package/abstract-interpretation/normalized-ast-fold.js +0 -181
|
@@ -46,6 +46,7 @@ exports.visualizeMermaidClassDiagram = visualizeMermaidClassDiagram;
|
|
|
46
46
|
exports.getTypesFromFolder = getTypesFromFolder;
|
|
47
47
|
exports.printHierarchy = printHierarchy;
|
|
48
48
|
exports.printCodeOfElement = printCodeOfElement;
|
|
49
|
+
exports.printCodeOfFile = printCodeOfFile;
|
|
49
50
|
exports.shortLink = shortLink;
|
|
50
51
|
exports.shortLinkFile = shortLinkFile;
|
|
51
52
|
exports.getDocumentationForType = getDocumentationForType;
|
|
@@ -353,9 +354,9 @@ function getTypePathForTypeScript({ filePath }) {
|
|
|
353
354
|
* Return the link to the type in the source code.
|
|
354
355
|
* If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
|
|
355
356
|
*/
|
|
356
|
-
function getTypePathLink(elem,
|
|
357
|
+
function getTypePathLink(elem, relative = false) {
|
|
357
358
|
const fromSource = getTypePathForTypeScript(elem);
|
|
358
|
-
return `${
|
|
359
|
+
return `${relative ? '' : doc_files_1.RemoteFlowrFilePathBaseRef}${fromSource}#L${elem.lineNumber}`;
|
|
359
360
|
}
|
|
360
361
|
function generateMermaidClassDiagram(hierarchyList, rootName, options, visited = new Set()) {
|
|
361
362
|
const collect = { nodeLines: [], edgeLines: [] };
|
|
@@ -480,10 +481,10 @@ function implSnippet(node, program, showName = true, nesting = 0, open = false,
|
|
|
480
481
|
}
|
|
481
482
|
if (showImplSnippet) {
|
|
482
483
|
const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
|
|
483
|
-
text += `\n<details${open ? ' open' : ''}><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node,
|
|
484
|
+
text += `\n<details${open ? ' open' : ''}><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, true)}</a></summary>\n\n${(0, doc_code_1.codeBlock)('ts', code)}\n\n</details>\n`;
|
|
484
485
|
}
|
|
485
486
|
else {
|
|
486
|
-
text += `\n<br/><i>(Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node,
|
|
487
|
+
text += `\n<br/><i>(Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, true)}</a>)</i>\n`;
|
|
487
488
|
}
|
|
488
489
|
const init = showName ? `* ${bold}[${node.name}](${getTypePathLink(node)})${bold} ${sep}${indent}` : '';
|
|
489
490
|
return ` ${indent}${showName ? init : ''} ${text.replaceAll('\t', ' ').split(/\n/g).join(`\n${indent} `)}`;
|
|
@@ -535,13 +536,31 @@ function printHierarchy({ program, info, root, ignoredTypes, collapseFromNesting
|
|
|
535
536
|
*
|
|
536
537
|
* This is great to show examples that are directly taken from the source code.
|
|
537
538
|
*/
|
|
538
|
-
function printCodeOfElement(
|
|
539
|
-
const node = info.find(e => e.name === name);
|
|
539
|
+
function printCodeOfElement(info, name) {
|
|
540
|
+
const node = info.info.find(e => e.name === name);
|
|
540
541
|
if (!node) {
|
|
541
542
|
console.error(`Could not find node ${name} when resolving function!`);
|
|
542
543
|
return '';
|
|
543
544
|
}
|
|
544
|
-
|
|
545
|
+
const code = node.node.getFullText(info.program.getSourceFile(node.node.getSourceFile().fileName)).trim();
|
|
546
|
+
return printCode(info, code, getTypePathLink(node, true));
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Print a source file as code block.
|
|
550
|
+
* If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
|
|
551
|
+
*
|
|
552
|
+
* This is great to show examples that are directly taken from the source code.
|
|
553
|
+
*/
|
|
554
|
+
function printCodeOfFile(info, relativePath) {
|
|
555
|
+
const fullPath = path_1.default.resolve(__dirname, `../../../${relativePath}`);
|
|
556
|
+
const code = info.program.getSourceFile(fullPath)?.getFullText().trim();
|
|
557
|
+
if (!code) {
|
|
558
|
+
console.error(`Could not find source file ${relativePath}!`);
|
|
559
|
+
return '';
|
|
560
|
+
}
|
|
561
|
+
return printCode(info, code, relativePath);
|
|
562
|
+
}
|
|
563
|
+
function printCode({ dropLinesEnd = 0, dropLinesStart = 0, doNotAutoGobble, hideDefinedAt, skipImports }, code, definedAt) {
|
|
545
564
|
if (dropLinesStart > 0 || dropLinesEnd > 0) {
|
|
546
565
|
const lines = code.split(/\n/g);
|
|
547
566
|
if (dropLinesStart + dropLinesEnd >= lines.length) {
|
|
@@ -549,6 +568,9 @@ function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart =
|
|
|
549
568
|
}
|
|
550
569
|
code = lines.slice(dropLinesStart, lines.length - dropLinesEnd).join('\n');
|
|
551
570
|
}
|
|
571
|
+
if (skipImports) {
|
|
572
|
+
code = code.replaceAll(/^import\s.*\n/gm, '').trim();
|
|
573
|
+
}
|
|
552
574
|
if (!doNotAutoGobble) {
|
|
553
575
|
// gobble leading spaces
|
|
554
576
|
const lines = code.replaceAll('\t', ' ').split(/\n/g);
|
|
@@ -563,11 +585,11 @@ function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart =
|
|
|
563
585
|
code = lines.map(line => line.startsWith(' '.repeat(gobble)) ? line.slice(gobble) : line).join('\n');
|
|
564
586
|
}
|
|
565
587
|
}
|
|
566
|
-
if (hideDefinedAt) {
|
|
588
|
+
if (hideDefinedAt || !definedAt) {
|
|
567
589
|
return (0, doc_code_1.codeBlock)('ts', code);
|
|
568
590
|
}
|
|
569
591
|
else {
|
|
570
|
-
return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${
|
|
592
|
+
return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${doc_files_1.RemoteFlowrFilePathBaseRef}${definedAt}">${definedAt}</a></i>\n`;
|
|
571
593
|
}
|
|
572
594
|
}
|
|
573
595
|
function fuzzyCompare(a, b) {
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { type AbsintVisitorConfiguration, AbstractInterpretationVisitor } from '../abstract-interpretation/absint-visitor';
|
|
2
|
+
import { IntervalDomain } from '../abstract-interpretation/domains/interval-domain';
|
|
3
|
+
import { StateAbstractDomain } from '../abstract-interpretation/domains/state-abstract-domain';
|
|
4
|
+
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexValue } from '../dataflow/graph/vertex';
|
|
5
|
+
import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
|
|
6
|
+
import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
1
7
|
import { DocMaker, type DocMakerArgs } from './wiki-mk/doc-maker';
|
|
8
|
+
export declare class IntervalInferenceVisitor extends AbstractInterpretationVisitor<StateAbstractDomain<IntervalDomain>> {
|
|
9
|
+
constructor(config: AbsintVisitorConfiguration);
|
|
10
|
+
protected onNumberConstant({ vertex, node }: {
|
|
11
|
+
vertex: DataflowGraphVertexValue;
|
|
12
|
+
node: RNumber<ParentInformation>;
|
|
13
|
+
}): void;
|
|
14
|
+
protected onFunctionCall({ call }: {
|
|
15
|
+
call: DataflowGraphVertexFunctionCall;
|
|
16
|
+
}): void;
|
|
17
|
+
}
|
|
2
18
|
export declare class WikiAbsint extends DocMaker<'wiki/Abstract Interpretation.md'> {
|
|
3
19
|
constructor();
|
|
4
20
|
protected text({ ctx }: DocMakerArgs): Promise<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WikiAbsint = void 0;
|
|
3
|
+
exports.WikiAbsint = exports.IntervalInferenceVisitor = void 0;
|
|
4
4
|
const absint_visitor_1 = require("../abstract-interpretation/absint-visitor");
|
|
5
5
|
const abstract_domain_1 = require("../abstract-interpretation/domains/abstract-domain");
|
|
6
6
|
const bounded_set_domain_1 = require("../abstract-interpretation/domains/bounded-set-domain");
|
|
@@ -10,10 +10,11 @@ const multi_value_state_domain_1 = require("../abstract-interpretation/domains/m
|
|
|
10
10
|
const state_abstract_domain_1 = require("../abstract-interpretation/domains/state-abstract-domain");
|
|
11
11
|
const semantic_cfg_guided_visitor_1 = require("../control-flow/semantic-cfg-guided-visitor");
|
|
12
12
|
const identifier_1 = require("../dataflow/environments/identifier");
|
|
13
|
+
const graph_1 = require("../dataflow/graph/graph");
|
|
13
14
|
const cfg_kind_1 = require("../project/cfg-kind");
|
|
14
15
|
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
15
|
-
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
16
16
|
const doc_code_1 = require("./doc-util/doc-code");
|
|
17
|
+
const doc_files_1 = require("./doc-util/doc-files");
|
|
17
18
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
18
19
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
19
20
|
class IntervalInferenceVisitor extends absint_visitor_1.AbstractInterpretationVisitor {
|
|
@@ -27,7 +28,7 @@ class IntervalInferenceVisitor extends absint_visitor_1.AbstractInterpretationVi
|
|
|
27
28
|
}
|
|
28
29
|
onFunctionCall({ call }) {
|
|
29
30
|
super.onFunctionCall({ call });
|
|
30
|
-
if (call.args.length === 2 && call.args.every(
|
|
31
|
+
if (call.args.length === 2 && call.args.every(graph_1.FunctionArgument.isNotEmpty)) {
|
|
31
32
|
const left = this.getAbstractValue(call.args[0].nodeId, this.currentState);
|
|
32
33
|
const right = this.getAbstractValue(call.args[1].nodeId, this.currentState);
|
|
33
34
|
if (left === undefined || right === undefined) {
|
|
@@ -44,13 +45,14 @@ class IntervalInferenceVisitor extends absint_visitor_1.AbstractInterpretationVi
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
exports.IntervalInferenceVisitor = IntervalInferenceVisitor;
|
|
47
49
|
async function inferIntervals() {
|
|
48
50
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
|
|
49
51
|
.setEngine('tree-sitter')
|
|
50
52
|
.build();
|
|
51
53
|
analyzer.addRequest(`
|
|
52
54
|
x <- 42
|
|
53
|
-
y <- if (runif() < 0.5) 6 else 12
|
|
55
|
+
y <- if (runif(1) < 0.5) 6 else 12
|
|
54
56
|
z <- x + y
|
|
55
57
|
`.trim());
|
|
56
58
|
const ast = await analyzer.normalize();
|
|
@@ -103,19 +105,19 @@ In _flowR_, an abstract domain is represented by the class ${ctx.link(abstract_d
|
|
|
103
105
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'value')} the current abstract value of the abstract domain
|
|
104
106
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'top')} to get the top element (greatest element) of the abstract domain
|
|
105
107
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'bottom')} to get the bottom element (least element) of the abstract domain
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
|
|
109
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'isTop')} to check whether the current abstract value is top
|
|
110
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'isBottom')} to check whether the current abstract value is bottom
|
|
111
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'isValue')} to check whether the current abstract value is a value (can still be top or bottom)
|
|
112
|
+
|
|
111
113
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'leq')} to check whether two abstract values are ordered with respect to the partial order of the lattice
|
|
112
114
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'join')} to join two abstract values to get the least upper bound (LUB)
|
|
113
115
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'meet')} to meet two abstract values to get the greates lower bound (GLB)
|
|
114
116
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'widen')} to perform widening with another abstract value to ensure termination of the fixpoint iteration
|
|
115
117
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'narrow')} to perform narrowing with another abstract value to refine the abstract value after widening
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
|
|
119
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'concretize')} representing the concretization function of the abstract domain
|
|
120
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'abstract')} representing the abstraction function of the abstract domain
|
|
119
121
|
|
|
120
122
|
${(0, doc_structure_1.details)('Class Diagram', `
|
|
121
123
|
All boxes link to their respective implementation in the source code.
|
|
@@ -124,7 +126,7 @@ ${(0, doc_code_1.codeBlock)('mermaid', ctx.mermaid(abstract_domain_1.AbstractDom
|
|
|
124
126
|
|
|
125
127
|
The ${ctx.link('Top')} and ${ctx.link('Bottom')} symbols can be used to explicitly represent the top or bottom elment of an abstract domain. Additionally, for value abstract domains, there is the ${ctx.link('SatisfiableDomain')} interface that provides the function ${ctx.link('SatisfiableDomain:::satisfies')} to check whether the current abstract value of the abstract domain satisfies a concrete value (see also ${ctx.link('NumericalComparator')} and ${ctx.link('SetComparator')}).
|
|
126
128
|
|
|
127
|
-
_flowR_ already provides different abstract domains for abstract interpretation in
|
|
129
|
+
_flowR_ already provides different abstract domains for abstract interpretation in ${(0, doc_files_1.linkFlowRSourceFile)('src/abstract-interpretation/domains')}. Many of the abstract domains are generic and can be used for differend kinds of analyses. The existing abstract domains are presented in the following. Some of the listed abstract domains can be expanded to show the inherited abstract domains.
|
|
128
130
|
|
|
129
131
|
${ctx.hierarchy(abstract_domain_1.AbstractDomain, { collapseFromNesting: 2, skipNesting: 1, reverse: true })}
|
|
130
132
|
|
|
@@ -150,7 +152,7 @@ To implement a custom abstract interpretation analysis, we can just create a new
|
|
|
150
152
|
|
|
151
153
|
For example, if we want to perform a (very basic) interval analysis using abstract interpretation in _flowR_, we can implement the following ${ctx.link(IntervalInferenceVisitor)} that extends ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)} using a ${ctx.link(state_abstract_domain_1.StateAbstractDomain)} for the ${ctx.link(interval_domain_1.IntervalDomain)}:
|
|
152
154
|
|
|
153
|
-
${ctx.code(
|
|
155
|
+
${ctx.code(IntervalInferenceVisitor, { hideDefinedAt: true })}
|
|
154
156
|
|
|
155
157
|
The interval inference visitor first overrides the ${ctx.link(`${semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor.name}:::onNumberConstant`)} function to infer intervals for visited control flow vertices that represent numeric constants. For numeric constants, the resulting interval consists just of the number value of the constant. We then update the current abstract state of the visitor by setting the inferred abstract value of the currently visited control flow vertex to the new interval.
|
|
156
158
|
|
|
@@ -158,7 +160,7 @@ In this simple example, we only want to support the addition and subtraction of
|
|
|
158
160
|
|
|
159
161
|
If we now want to run the interval inference, we can write the following code:
|
|
160
162
|
|
|
161
|
-
${ctx.code(inferIntervals, { dropLinesStart: 1, dropLinesEnd: 5 })}
|
|
163
|
+
${ctx.code(inferIntervals, { dropLinesStart: 1, dropLinesEnd: 5, hideDefinedAt: true })}
|
|
162
164
|
|
|
163
165
|
We first need a ${ctx.linkPage('wiki/Analyzer', 'flowR analyzer')} (in this case, using the ${ctx.linkPage('wiki/Engines', 'tree-sitter engine')}). In this example, we want to analyze a small example code that assigns \`42\` to the variable \`x\`, randomly assigns \`6\` or \`12\` to the variable \`y\`, and assignes the sum of \`x\` and \`y\` to the variable \`z\`. For the abstract interpretation visitor, we need to retrieve the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}, ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graph')}, ${ctx.linkPage('wiki/Control Flow Graph', 'control flow graph')}, and context of the flowR anaylzer. For performance reasons, we construct the control flow graph without simplification passes, data flow information, and function definitions. We then create a new ${ctx.link(IntervalInferenceVisitor)} using the control flow graph, dataflow graph, normalized AST, and analyzer context, and start the visitor using ${ctx.linkM(absint_visitor_1.AbstractInterpretationVisitor, 'start', { hideClass: true })}. After the visitor is finished, we retrieve the inferred abstract state at the end of the program using ${ctx.linkM(absint_visitor_1.AbstractInterpretationVisitor, 'getEndState', { hideClass: true })}.
|
|
164
166
|
|
|
@@ -168,6 +170,39 @@ ${(0, doc_code_1.codeBlock)('ts', await inferIntervals())}
|
|
|
168
170
|
<i>The output has been prettified for better readability.</i>
|
|
169
171
|
|
|
170
172
|
The AST nodes are represented as slicing criteria for better readability in the format \`<line>@<lexeme>\`. Here, the constants \`42\`, \`0.5\`, \`6\`, and \`12\` of line 1 and 2 are mapped to the intervals \`[42, 42]\`, \`[0.5, 0.5]\`, \`[6, 6]\`, and \`[12, 12]\`, respectively. The variable \`x\` of line 1 is mapped to the interval \`[42, 42]\` of the assigned value and the variable \`y\` of line 2 is assigned to the interval \`[6, 12]\` representing a sound over-approximation of the actual value, as the assigned value can be \`6\` or \`12\`. After applying the abstract semantics of the addition of \`x\` and \`y\`, the addition operation \`+\` and the variable \`z\` of line 3 are mapped to the interval \`[48, 54]\`, resulting from the addition of the interval \`[42, 42]\` of \`x\` and \`[6, 12]\` of \`y\`.
|
|
173
|
+
|
|
174
|
+
${(0, doc_structure_1.section)('Testing', 2, 'testing')}
|
|
175
|
+
|
|
176
|
+
_flowR_ provides a generic testing framework for abstract interpretation in ${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/abstract-interpretation/inference.ts')}. The framework supports two kinds of tests for testing inferred abstract domain values at given source code locations (as ${ctx.link('SlicingCriteria')}):
|
|
177
|
+
|
|
178
|
+
1. **Assertion tests** — compare the inferred values against manually specified expected values (${ctx.link('assertInferredValues')}).
|
|
179
|
+
2. **Validation tests** — run the code to output the actual value at each location and compare the inferred values against the actual values (${ctx.link('validateInferredValues')}).
|
|
180
|
+
|
|
181
|
+
The test function ${ctx.link('testInferredValues')} combines both tests: it performs an assertion test when an ${ctx.link('InferenceTestCase')} record of expected values is provided, and a validation test (unless the option \`skipRun\` is set). When only a list of slicing criteria is provided instead of a ${ctx.link('InferenceTestCase')}, only the validation test is performed. For the validation test, it is required that all slicing criteria represent symbols, as the instrumentation of the code adds print statements for each symbol location after the code line of the symbol. The function takes the following arguments:
|
|
182
|
+
|
|
183
|
+
* \`name\` — the name or label of the test
|
|
184
|
+
* \`shell\` — the R shell to use for the validation test
|
|
185
|
+
* \`code\` — the R code to analyse and (for validation) to execute
|
|
186
|
+
* \`expected\` — an ${ctx.link('InferenceTestCase')} mapping slicing criteria to expected abstract values, or a list of slicing criteria for validation-only tests
|
|
187
|
+
* \`inference\` — a function that takes an ${ctx.link('AbsintVisitorConfiguration')} and returns an ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)} to perform the inference
|
|
188
|
+
* \`createOutputCode\` — a function \`(marker, symbol) => string\` that returns R code printing the analyzed properties of \`symbol\` in a line prefixed with \`marker\`
|
|
189
|
+
* \`parseOutput\` — a function \`(line) => Domain | undefined\` that parses the output line produced by \`createOutputCode\` into an abstract domain value
|
|
190
|
+
* \`options\` — optional inference test settings (_flowR_ configuration, additional project files, domain matching type, \`skipRun\`, etc.)
|
|
191
|
+
|
|
192
|
+
Additionally, ${ctx.link('assertInferredValues')} and ${ctx.link('validateInferredValues')} are available to only perform the assertions for assertion tests or validation tests without wrapping them into a test case.
|
|
193
|
+
|
|
194
|
+
When comparing inferred values with expected values, the framework supports two matching types via ${ctx.link('DomainMatchingType')}:
|
|
195
|
+
|
|
196
|
+
* ${ctx.link('DomainMatchingType::Equal')} — the inferred value must equal the expected value (default for assertion tests)
|
|
197
|
+
* ${ctx.link('DomainMatchingType::Overapproximation')} — the inferred value must be an over-approximation of the actual value via ${ctx.linkM(abstract_domain_1.AbstractDomain, 'leq')} (default for validation tests)
|
|
198
|
+
|
|
199
|
+
For example, to use the test framework for the ${ctx.link(IntervalInferenceVisitor)} defined above, we first define how to print the properties of an actual numeric scalar value in R using \`createOutputCode\` and how to parse it into an abstract domain value using \`parseOutput\`. Then, we can use ${ctx.link('testInferredValues')} to create a test for our code example by providing a test name, an R shell, the code to test, the test locations as slicing criteria with expected values, the inference visitor, and our \`createOutputCode\` and \`parseOutput\` function:
|
|
200
|
+
|
|
201
|
+
${ctx.codeFile('test/functionality/abstract-interpretation/wiki-absint.ts', { skipImports: true, hideDefinedAt: true })}
|
|
202
|
+
|
|
203
|
+
The assertion test verifies that the inferred intervals match the specified expected values exactly (using ${ctx.link('DomainMatchingType::Equal')}). The validation test instruments the code by inserting print statements after each tested location, executes the instrumented code with the R shell, and checks that each inferred interval at these locations is an over-approximation of the actual runtime value (using ${ctx.link('DomainMatchingType::Overapproximation')}). For example, the inferred interval \`[6, 12]\` for \`y\` is a sound over-approximation of the actual value \`6\` or \`12\`, depending on the random branch taken at runtime.
|
|
204
|
+
|
|
205
|
+
For an existing example of the test framework used in practice, see the data frame shape inference tests in ${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/abstract-interpretation/data-frame/inference.test.ts')}, which use a domain-specific wrapper ${ctx.link('testInferredDataFrameShape')} built on top of ${ctx.link('testInferredValues')}.
|
|
171
206
|
`;
|
|
172
207
|
}
|
|
173
208
|
}
|
|
@@ -257,6 +257,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
|
257
257
|
solver: {
|
|
258
258
|
variables: config_1.VariableResolve.Alias,
|
|
259
259
|
evalStrings: true,
|
|
260
|
+
trackEnvironments: true,
|
|
260
261
|
resolveSource: {
|
|
261
262
|
dropPaths: config_1.DropPathsOption.No,
|
|
262
263
|
ignoreCapitalization: true,
|
|
@@ -179,7 +179,7 @@ export interface GeneralDocContext {
|
|
|
179
179
|
* @param filter - An optional filter to further specify the element to get the code for, in case multiple elements with the same name exist.
|
|
180
180
|
* @example
|
|
181
181
|
* ```ts
|
|
182
|
-
* code(exampleFn.name, { dropLinesStart: 1, dropLinesEnd: 2
|
|
182
|
+
* code(exampleFn.name, { dropLinesStart: 1, dropLinesEnd: 2 })
|
|
183
183
|
* ```
|
|
184
184
|
*
|
|
185
185
|
* Creates a code snippet for the `exampleFn` function in the code base,
|
|
@@ -203,6 +203,19 @@ export interface GeneralDocContext {
|
|
|
203
203
|
* @see {@link printCodeOfElement} - for the underlying impl.
|
|
204
204
|
*/
|
|
205
205
|
code(element: ElementIdOrRef, fmt?: Omit<FnElementInfo, 'info' | 'program'>, filter?: ElementFilter): string;
|
|
206
|
+
/**
|
|
207
|
+
* Returns the code snippet for a code file as markdown string.
|
|
208
|
+
* @param path - The path to the file to create a code snippet for.
|
|
209
|
+
* @param fmt - Formatting options for the code snippet (see {@link FnElementInfo})
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* code('src/path/to/file.ts', { skipImports: true })
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* Creates a code snippet for the source file `src/path/to/file.ts`,
|
|
216
|
+
* dropping the lines with import statements of the source code.
|
|
217
|
+
*/
|
|
218
|
+
codeFile(path: string, fmt?: Omit<FnElementInfo, 'info' | 'program'>): string;
|
|
206
219
|
/**
|
|
207
220
|
* Returns the hierarchy (e.g., class inheritance) for a code element as markdown string,
|
|
208
221
|
* including their documentation and snippets.
|
|
@@ -88,6 +88,12 @@ function makeDocContextForTypes(shell, ...rootFolders) {
|
|
|
88
88
|
...fmt,
|
|
89
89
|
}, getNameFromElementIdOrRef(element));
|
|
90
90
|
},
|
|
91
|
+
codeFile(path, fmt) {
|
|
92
|
+
return (0, doc_types_1.printCodeOfFile)({
|
|
93
|
+
program, info,
|
|
94
|
+
...fmt,
|
|
95
|
+
}, path);
|
|
96
|
+
},
|
|
91
97
|
async header(filename, purpose) {
|
|
92
98
|
const rVersion = (await shell?.usedRVersion())?.format();
|
|
93
99
|
return (0, doc_auto_gen_1.autoGenHeader)({ filename, purpose, rVersion });
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { DefaultNormalizedAstFold } from '../abstract-interpretation/normalized-ast-fold';
|
|
2
1
|
import type { DocMakerArgs } from './wiki-mk/doc-maker';
|
|
3
2
|
import { DocMaker } from './wiki-mk/doc-maker';
|
|
4
|
-
import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
|
|
5
|
-
import { RBinaryOp } from '../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
|
|
6
|
-
export declare class MyMathFold<Info> extends DefaultNormalizedAstFold<number, Info> {
|
|
7
|
-
constructor();
|
|
8
|
-
protected concat(a: number, b: number): number;
|
|
9
|
-
foldRNumber(node: RNumber<Info>): number;
|
|
10
|
-
foldRBinaryOp(node: RBinaryOp<Info>): number;
|
|
11
|
-
}
|
|
12
3
|
/**
|
|
13
4
|
* https://github.com/flowr-analysis/flowr/wiki/Normalized-AST
|
|
14
5
|
*/
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WikiNormalizedAst =
|
|
3
|
+
exports.WikiNormalizedAst = void 0;
|
|
4
4
|
const doc_code_1 = require("./doc-util/doc-code");
|
|
5
5
|
const doc_normalized_ast_1 = require("./doc-util/doc-normalized-ast");
|
|
6
6
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
7
7
|
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
8
8
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
9
|
-
const normalized_ast_fold_1 = require("../abstract-interpretation/normalized-ast-fold");
|
|
10
9
|
const flowr_analyzer_1 = require("../project/flowr-analyzer");
|
|
11
10
|
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
12
11
|
const flowr_file_1 = require("../project/context/flowr-file");
|
|
@@ -16,6 +15,7 @@ const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op"
|
|
|
16
15
|
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
17
16
|
const r_project_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
18
17
|
const r_expression_list_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
18
|
+
const stateful_fold_1 = require("../r-bridge/lang-4.x/ast/model/processing/stateful-fold");
|
|
19
19
|
async function simpleNormalizedAst(code) {
|
|
20
20
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder().build();
|
|
21
21
|
analyzer.addRequest(code);
|
|
@@ -33,40 +33,6 @@ async function quickNormalizedAstMultipleFiles() {
|
|
|
33
33
|
const n = await analyzer.normalize();
|
|
34
34
|
return n;
|
|
35
35
|
}
|
|
36
|
-
class MyMathFold extends normalized_ast_fold_1.DefaultNormalizedAstFold {
|
|
37
|
-
constructor() {
|
|
38
|
-
/* use \`0\` as a placeholder empty for the monoid */
|
|
39
|
-
super(0);
|
|
40
|
-
}
|
|
41
|
-
concat(a, b) {
|
|
42
|
-
/* for this example, we ignore cases that we cannot handle */
|
|
43
|
-
return b;
|
|
44
|
-
}
|
|
45
|
-
foldRNumber(node) {
|
|
46
|
-
/* return the value of the number */
|
|
47
|
-
return node.content.num;
|
|
48
|
-
}
|
|
49
|
-
foldRBinaryOp(node) {
|
|
50
|
-
if (node.operator === '+') {
|
|
51
|
-
return this.fold(node.lhs) + this.fold(node.rhs);
|
|
52
|
-
}
|
|
53
|
-
else if (node.operator === '*') {
|
|
54
|
-
return this.fold(node.lhs) * this.fold(node.rhs);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
/* in case we cannot handle the operator we could throw an error, or just use the default behavior: */
|
|
58
|
-
return super.foldRBinaryOp(node);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.MyMathFold = MyMathFold;
|
|
63
|
-
async function useMyMathFoldExample() {
|
|
64
|
-
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder().build();
|
|
65
|
-
analyzer.addRequest('1 + 3 * 2');
|
|
66
|
-
const normalize = await analyzer.normalize();
|
|
67
|
-
const result = new MyMathFold().fold(normalize.ast);
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
36
|
/**
|
|
71
37
|
* https://github.com/flowr-analysis/flowr/wiki/Normalized-AST
|
|
72
38
|
*/
|
|
@@ -134,7 +100,7 @@ ${(0, doc_structure_1.details)('Normalized AST Node Types', ctx.hierarchy(model_
|
|
|
134
100
|
The following segments intend to give you an overview of how to work with the normalized AST:
|
|
135
101
|
|
|
136
102
|
* [How to get a Normalized AST](#how-to-get-a-normalized-ast)
|
|
137
|
-
* [
|
|
103
|
+
* [Traversing the Normalized AST](#traversing-the-normalized-ast)
|
|
138
104
|
|
|
139
105
|
> [!TIP]
|
|
140
106
|
> If you want to get more information on roxygen comments attached to AST nodes,
|
|
@@ -169,8 +135,8 @@ ${(0, doc_normalized_ast_1.printNormalizedAst)((await quickNormalizedAstMultiple
|
|
|
169
135
|
|
|
170
136
|
## Traversing the Normalized AST
|
|
171
137
|
|
|
172
|
-
We provide
|
|
173
|
-
Please note, that
|
|
138
|
+
We provide a visitor to traverse the normalized AST.
|
|
139
|
+
Please note, that it usually operates on the ${ctx.link('RExpressionList')} level, and it is up to
|
|
174
140
|
you to decide how you want to traverse multiple files with a ${ctx.link('RProject')} in the AST (you can, for example, simplify flat-map over the files).
|
|
175
141
|
The ${ctx.link('RProject')} node cannot appear nested within other nodes, so you can safely assume that any child of a node is not an ${ctx.link('RProject')}.
|
|
176
142
|
|
|
@@ -193,29 +159,12 @@ visitAst(nodes, node => {
|
|
|
193
159
|
ids.add(node.info.id);
|
|
194
160
|
});
|
|
195
161
|
return ids;
|
|
196
|
-
`)}
|
|
197
|
-
|
|
198
|
-
### Folds
|
|
199
|
-
|
|
200
|
-
We formulate a fold with the base class ${ctx.link(normalized_ast_fold_1.DefaultNormalizedAstFold)} in ${(0, doc_files_1.getFilePathMd)('../abstract-interpretation/normalized-ast-fold.ts')}.
|
|
201
|
-
Using this class, you can create your own fold behavior by overwriting the default methods.
|
|
202
|
-
By default, the class provides a monoid abstraction using the _empty_ from the constructor and the _concat_ method.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
${ctx.hierarchy(normalized_ast_fold_1.DefaultNormalizedAstFold)}
|
|
206
|
-
|
|
207
|
-
Now, of course, we could provide hundreds of examples here, but we use tests to verify that the fold behaves as expected
|
|
208
|
-
and happily point to them at ${(0, doc_files_1.getFilePathMd)('../../test/functionality/r-bridge/normalize-ast-fold.test.ts')}.
|
|
209
|
-
|
|
210
|
-
As a simple showcase, we want to use the fold to evaluate numeric expressions containing numbers, \`+\`, and \`*\` operators.
|
|
211
|
-
|
|
212
|
-
${ctx.code(MyMathFold, { dropLinesStart: 1 })}
|
|
162
|
+
`)}
|
|
213
163
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
${ctx.code(useMyMathFoldExample, { dropLinesStart: 1, dropLinesEnd: 2, hideDefinedAt: true })}
|
|
164
|
+
### Stateful Fold
|
|
217
165
|
|
|
218
|
-
|
|
166
|
+
A stateful fold over the normalized AST can be performed with the ${ctx.link(stateful_fold_1.foldAstStateful)} function.
|
|
167
|
+
It allows you to specify a down function which is called during the down-pass and can pass information to child nodes, and fold functions which are called after the down-pass in conventional fold-fashion.
|
|
219
168
|
`;
|
|
220
169
|
}
|
|
221
170
|
}
|
|
@@ -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;
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -234,12 +234,12 @@ export declare const LintingRules: {
|
|
|
234
234
|
cfg: import("../control-flow/control-flow-graph").ControlFlowInformation;
|
|
235
235
|
analyzer: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
236
236
|
}) => {
|
|
237
|
-
results: import("./
|
|
237
|
+
results: import("./linter-format").LintingResult[];
|
|
238
238
|
'.meta': import("./rules/dead-code").DeadCodeMetadata;
|
|
239
239
|
};
|
|
240
240
|
readonly prettyPrint: {
|
|
241
|
-
readonly query: (result: import("./
|
|
242
|
-
readonly full: (result: import("./
|
|
241
|
+
readonly query: (result: import("./linter-format").LintingResult) => string;
|
|
242
|
+
readonly full: (result: import("./linter-format").LintingResult) => string;
|
|
243
243
|
};
|
|
244
244
|
readonly info: {
|
|
245
245
|
readonly name: "Dead Code";
|
|
@@ -298,11 +298,12 @@ export declare const LintingRules: {
|
|
|
298
298
|
};
|
|
299
299
|
readonly info: {
|
|
300
300
|
readonly name: "Problematic inputs";
|
|
301
|
-
readonly description: "Detects uses of
|
|
301
|
+
readonly description: "Detects uses of dynamic calls (e.g. eval, system) with non-constant inputs, and graphics-device calls (pdf, postscript) where a filename starts with '|' indicating a pipe command injection.";
|
|
302
302
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Security, import("./linter-tags").LintingRuleTag.Smell, import("./linter-tags").LintingRuleTag.Readability, import("./linter-tags").LintingRuleTag.Performance];
|
|
303
303
|
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
304
304
|
readonly defaultConfig: {
|
|
305
305
|
readonly consider: readonly ["^eval$", "^system$", "^system2$", "^shell$"];
|
|
306
|
+
readonly pipeCommandFunctions: readonly import("./rules/problematic-inputs").PipeCommandFunctionSpec[];
|
|
306
307
|
};
|
|
307
308
|
};
|
|
308
309
|
};
|
|
@@ -318,8 +319,8 @@ export declare const LintingRules: {
|
|
|
318
319
|
'.meta': import("./rules/stop-with-call-arg").StopWithCallMetadata;
|
|
319
320
|
};
|
|
320
321
|
readonly prettyPrint: {
|
|
321
|
-
readonly query: (result: import("./
|
|
322
|
-
readonly full: (result: import("./
|
|
322
|
+
readonly query: (result: import("./linter-format").LintingResult) => string;
|
|
323
|
+
readonly full: (result: import("./linter-format").LintingResult) => string;
|
|
323
324
|
};
|
|
324
325
|
readonly info: {
|
|
325
326
|
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 {
|
|
@@ -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
|
-
|
|
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.
|
|
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.
|
|
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
|
|
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:
|
|
24
|
+
results: LintingResult[];
|
|
28
25
|
'.meta': DeadCodeMetadata;
|
|
29
26
|
};
|
|
30
27
|
readonly prettyPrint: {
|
|
31
|
-
readonly query: (result:
|
|
32
|
-
readonly full: (result:
|
|
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
|
/**
|
|
@@ -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:
|
|
37
|
+
requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, data: {
|
|
40
38
|
normalize: NormalizedAst;
|
|
41
39
|
dataflow: DataflowInformation;
|
|
42
40
|
analyzer: ReadonlyFlowrAnalysisProvider;
|