@eagleoutice/flowr 2.16.6 → 2.16.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 -15
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
- package/abstract-interpretation/data-frame/resolve-args.js +2 -11
- package/cli/repl/commands/repl-cfg.js +5 -19
- package/cli/repl/commands/repl-code-command.d.ts +10 -0
- package/cli/repl/commands/repl-code-command.js +18 -0
- package/cli/repl/commands/repl-dataflow.js +34 -59
- package/cli/repl/commands/repl-normalize.js +24 -41
- package/cli/repl/commands/repl-query.js +10 -17
- package/config.js +3 -3
- package/control-flow/cfg-dead-code.js +15 -2
- package/control-flow/useless-loop.js +1 -2
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/dataflow/environments/ambient-state-name.d.ts +80 -0
- package/dataflow/environments/ambient-state-name.js +113 -0
- package/dataflow/environments/built-in-eval-name.d.ts +3 -1
- package/dataflow/environments/built-in-eval-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +27 -7
- package/dataflow/environments/built-in-props.js +59 -44
- package/dataflow/environments/built-in.d.ts +5 -2
- package/dataflow/environments/built-in.js +22 -5
- package/dataflow/environments/default-builtin-config.d.ts +538 -14
- package/dataflow/environments/default-builtin-config.js +189 -123
- package/dataflow/environments/environment.d.ts +7 -1
- package/dataflow/environments/environment.js +19 -1
- package/dataflow/environments/identifier.d.ts +11 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
- package/dataflow/eval/resolve/alias-tracking.js +66 -37
- package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
- package/dataflow/eval/resolve/resolve-argument.js +23 -11
- package/dataflow/eval/resolve/resolve.d.ts +5 -0
- package/dataflow/eval/resolve/resolve.js +25 -3
- package/dataflow/eval/values/r-value.d.ts +4 -2
- package/dataflow/eval/values/r-value.js +3 -1
- package/dataflow/eval/values/string/string-constants.d.ts +7 -1
- package/dataflow/eval/values/string/string-constants.js +38 -36
- package/dataflow/extractor.js +105 -2
- package/dataflow/fn/argument-roles.js +22 -8
- package/dataflow/fn/function-semantics.d.ts +3 -2
- package/dataflow/fn/strict-function.js +13 -2
- package/dataflow/graph/df-helper.d.ts +14 -1
- package/dataflow/graph/df-helper.js +37 -4
- package/dataflow/graph/graph.d.ts +6 -0
- package/dataflow/graph/graph.js +6 -0
- package/dataflow/internal/linker.d.ts +4 -1
- package/dataflow/internal/linker.js +11 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -44
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
- 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 +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +42 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
- package/dataflow/internal/process/functions/call/common.js +3 -4
- package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
- package/dataflow/internal/process/functions/call/deferred.js +17 -9
- package/dataflow/internal/process/functions/call/quoted.js +1 -1
- package/documentation/doc-capabilities.js +3 -2
- package/documentation/doc-readme.js +1 -2
- package/documentation/doc-util/doc-dfg.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +3 -1
- package/documentation/doc-util/doc-query.js +4 -4
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-linter.js +16 -206
- package/documentation/wiki-linting-and-testing.js +31 -64
- package/documentation/wiki-query.js +41 -0
- package/index.d.ts +1 -0
- package/index.js +5 -1
- package/linter/linter-format.d.ts +6 -0
- package/linter/linter-format.js +10 -0
- package/linter/linter-rules.d.ts +155 -103
- package/linter/linter-rules.js +2 -0
- package/linter/linter-util.d.ts +23 -0
- package/linter/linter-util.js +58 -0
- package/linter/rules/absolute-path.d.ts +2 -2
- package/linter/rules/absolute-path.js +1 -4
- package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
- package/linter/rules/cmd-check/bogus-return.js +3 -7
- package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.js +3 -7
- package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
- package/linter/rules/cmd-check/cmd-check-util.js +14 -26
- package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
- package/linter/rules/cmd-check/compiled-code.js +3 -13
- package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
- package/linter/rules/cmd-check/dependency-declaration.js +6 -7
- package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
- package/linter/rules/cmd-check/file-checks.d.ts +19 -6
- package/linter/rules/cmd-check/file-checks.js +13 -5
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.js +3 -2
- package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
- package/linter/rules/cmd-check/namespace-tampering.js +9 -9
- package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.d.ts +11 -5
- package/linter/rules/cmd-check/package-data.js +5 -12
- package/linter/rules/cmd-check/package-files.js +4 -10
- package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
- package/linter/rules/cmd-check/package-hooks.js +10 -8
- package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
- package/linter/rules/cmd-check/package-metafiles.js +3 -12
- package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
- package/linter/rules/cmd-check/package-runtime.js +64 -20
- package/linter/rules/cmd-check/package-structure.d.ts +11 -5
- package/linter/rules/cmd-check/package-structure.js +4 -12
- package/linter/rules/cmd-check/rd-files.d.ts +8 -3
- package/linter/rules/cmd-check/rd-files.js +4 -14
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
- package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.js +5 -8
- package/linter/rules/dead-code.d.ts +5 -4
- package/linter/rules/dead-code.js +25 -14
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/deprecated-functions.js +16 -23
- package/linter/rules/file-path-validity.d.ts +2 -2
- package/linter/rules/file-path-validity.js +3 -6
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +7 -14
- package/linter/rules/namespace-access.d.ts +2 -2
- package/linter/rules/namespace-access.js +6 -9
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +1 -4
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/no-leaked-credentials.d.ts +2 -2
- package/linter/rules/no-leaked-credentials.js +1 -4
- package/linter/rules/overwritten-file.d.ts +38 -0
- package/linter/rules/overwritten-file.js +102 -0
- package/linter/rules/problematic-inputs.d.ts +16 -6
- package/linter/rules/problematic-inputs.js +78 -34
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +1 -4
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +6 -23
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -4
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +1 -4
- package/linter/rules/stop-with-call-arg.d.ts +2 -2
- package/linter/rules/stop-with-call-arg.js +4 -11
- package/linter/rules/syntactically-valid.d.ts +4 -2
- package/linter/rules/syntactically-valid.js +29 -10
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +1 -4
- package/linter/rules/undefined-symbol.d.ts +2 -2
- package/linter/rules/undefined-symbol.js +25 -22
- package/linter/rules/unescaped-arguments.d.ts +2 -2
- package/linter/rules/unescaped-arguments.js +1 -4
- package/linter/rules/unused-definition.d.ts +2 -2
- package/linter/rules/unused-definition.js +37 -25
- package/linter/rules/unused-import.d.ts +2 -2
- package/linter/rules/unused-import.js +9 -14
- package/linter/rules/useless-loop.d.ts +7 -6
- package/linter/rules/useless-loop.js +4 -8
- package/package.json +5 -3
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +15 -11
- package/project/context/flowr-analyzer-files-context.d.ts +3 -0
- package/project/context/flowr-analyzer-files-context.js +6 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
- package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
- package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
- package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
- package/project/plugins/file-plugins/files/r-session.js +58 -0
- package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
- package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/spec-query.d.ts +73 -0
- package/project/sigdb/spec-query.js +339 -0
- package/queries/base-query-format.d.ts +1 -1
- package/queries/base-query-format.js +2 -2
- package/queries/catalog/absint-query/absint-query-executor.js +3 -6
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
- package/queries/catalog/config-query/config-query-format.d.ts +0 -1
- package/queries/catalog/config-query/config-query-format.js +1 -2
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
- package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
- package/queries/catalog/dice-query/dice-query-executor.js +2 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
- package/queries/catalog/files-query/files-query-executor.js +2 -3
- package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
- package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
- package/queries/catalog/origin-query/origin-query-executor.js +3 -11
- package/queries/catalog/project-query/project-query-executor.js +23 -7
- package/queries/catalog/project-query/project-query-format.d.ts +5 -0
- package/queries/catalog/project-query/project-query-format.js +20 -2
- package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
- package/queries/catalog/search-query/search-query-executor.js +2 -3
- package/queries/catalog/signature-query/signature-query-executor.js +39 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-format.js +15 -1
- package/queries/catalog/signature-query/signature-query-render.js +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
- package/queries/query-function-property.d.ts +28 -0
- package/queries/query-function-property.js +48 -0
- package/queries/query-meta.d.ts +3 -0
- package/queries/query-meta.js +8 -0
- package/queries/query.d.ts +13 -18
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
- 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 +9 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/type.js +3 -0
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
- package/reconstruct/reconstruct.js +35 -1
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/static/fingerprint.js +7 -3
- package/slicing/static/static-slicer.js +6 -0
- package/util/assert.js +2 -2
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +11 -0
- package/util/collections/defaultmap.d.ts +5 -1
- package/util/collections/defaultmap.js +6 -1
- package/util/files.js +26 -5
- package/util/flowr-version.d.ts +10 -0
- package/util/flowr-version.js +20 -0
- package/util/glob.js +6 -4
- package/util/r-regex.d.ts +6 -0
- package/util/r-regex.js +17 -0
- package/util/text/args.d.ts +5 -0
- package/util/text/args.js +28 -22
- package/util/text/name-rank.d.ts +2 -0
- package/util/text/name-rank.js +3 -1
- package/util/text/regex.d.ts +10 -0
- package/util/text/regex.js +29 -0
- package/util/version.d.ts +1 -6
- package/util/version.js +6 -14
- package/documentation/doc-util/doc-functions.d.ts +0 -24
- package/documentation/doc-util/doc-functions.js +0 -65
|
@@ -4,23 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WikiLinter = exports.LintingRuleExamples = void 0;
|
|
7
|
-
const r_string_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
8
7
|
const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
|
|
9
8
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
10
9
|
const conformance_1 = require("../linter/rules/cmd-check/conformance");
|
|
11
10
|
const linter_rules_1 = require("../linter/linter-rules");
|
|
12
11
|
const doc_code_1 = require("./doc-util/doc-code");
|
|
13
12
|
const doc_query_1 = require("./doc-util/doc-query");
|
|
13
|
+
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
14
14
|
const retriever_1 = require("../r-bridge/retriever");
|
|
15
15
|
const doc_types_1 = require("./doc-util/doc-types");
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const assert_1 = require("../util/assert");
|
|
18
|
-
const doc_repl_1 = require("./doc-util/doc-repl");
|
|
19
17
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
20
18
|
const linter_tags_1 = require("../linter/linter-tags");
|
|
21
19
|
const html_hover_over_1 = require("../util/html-hover-over");
|
|
22
20
|
const strings_1 = require("../util/text/strings");
|
|
23
|
-
const doc_functions_1 = require("./doc-util/doc-functions");
|
|
24
21
|
const linter_format_1 = require("../linter/linter-format");
|
|
25
22
|
const linter_fix_1 = require("../linter/linter-fix");
|
|
26
23
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
@@ -52,194 +49,6 @@ function getPageNameForLintingRule(name) {
|
|
|
52
49
|
const words = name.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1));
|
|
53
50
|
return '[Linting Rule] ' + words.join(' ');
|
|
54
51
|
}
|
|
55
|
-
/** how wide one line of an expected-result block may get before its entries are broken apart */
|
|
56
|
-
const ExpectedWidth = 160;
|
|
57
|
-
/**
|
|
58
|
-
* The expected results of a linter test case as they appear in the wiki: the source text of the array, with its
|
|
59
|
-
* layout dropped, one element per line, and everything that fits on one line kept there.
|
|
60
|
-
*/
|
|
61
|
-
function prettyPrintExpectedOutput(expected) {
|
|
62
|
-
const text = expected.trim();
|
|
63
|
-
if (text === '[]') {
|
|
64
|
-
return '* no lints';
|
|
65
|
-
}
|
|
66
|
-
const compact = collapseWhitespace(text);
|
|
67
|
-
if (compact.length <= ExpectedWidth || !compact.startsWith('[')) {
|
|
68
|
-
return compact;
|
|
69
|
-
}
|
|
70
|
-
const elements = splitTopLevel(compact.slice(1, -1));
|
|
71
|
-
return elements.length <= 1 ? compact : `[\n\t${elements.join(',\n\t')}\n]`;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The results a linter test case expects, as one line each: what the rule reports, where, and how sure it is.
|
|
75
|
-
* The source text of anything this cannot read stays a code block.
|
|
76
|
-
*/
|
|
77
|
-
function describeExpectedResults(expected) {
|
|
78
|
-
const text = collapseWhitespace(expected.trim());
|
|
79
|
-
if (text === '[]') {
|
|
80
|
-
return '* no lints';
|
|
81
|
-
}
|
|
82
|
-
if (!text.startsWith('[')) {
|
|
83
|
-
return (0, doc_code_1.codeBlock)('ts', text);
|
|
84
|
-
}
|
|
85
|
-
const described = splitTopLevel(text.slice(1, -1)).map(describeExpectedResult);
|
|
86
|
-
return described.every(assert_1.isNotUndefined) && described.length > 0
|
|
87
|
-
? described.map(line => `* ${line}`).join('\n')
|
|
88
|
-
: (0, doc_code_1.codeBlock)('ts', prettyPrintExpectedOutput(expected));
|
|
89
|
-
}
|
|
90
|
-
/** `{certainty: ..., name: 'x', loc: [1, 1, 1, 2]}` as `certain at 1.1-1.2: name = 'x'` */
|
|
91
|
-
function describeExpectedResult(element) {
|
|
92
|
-
const body = /^\{(.*)\}(?: as const)?$/.exec(element.trim())?.[1];
|
|
93
|
-
if (body === undefined) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
const fields = new Map();
|
|
97
|
-
for (const part of splitTopLevel(body)) {
|
|
98
|
-
const at = part.indexOf(':');
|
|
99
|
-
if (at < 0) {
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
fields.set(part.slice(0, at).trim(), part.slice(at + 1).trim());
|
|
103
|
-
}
|
|
104
|
-
const parts = [];
|
|
105
|
-
for (const [key, value] of fields) {
|
|
106
|
-
if (key === 'certainty' || key === 'loc' || value === 'undefined') {
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
else if (key === 'quickFix') {
|
|
110
|
-
const fixes = splitTopLevel(value.replace(/^\[/, '').replace(/]$/, '')).length;
|
|
111
|
-
parts.push(`${fixes} quick fix${fixes === 1 ? '' : 'es'}`);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
parts.push(`${key} = \`${value}\``);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const where = locationOf(fields.get('loc'));
|
|
118
|
-
const certainty = fields.get('certainty')?.split('.').at(-1)?.toLowerCase() ?? 'reported';
|
|
119
|
-
return `${certainty}${where ? ` at ${where}` : ''}${parts.length > 0 ? `: ${parts.join(', ')}` : ''}`;
|
|
120
|
-
}
|
|
121
|
-
/** `[1, 1, 1, 2]` as `1.1-1.2`, `undefined` for anything else */
|
|
122
|
-
function locationOf(loc) {
|
|
123
|
-
const at = /^\[\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)\s*]$/.exec(loc ?? '');
|
|
124
|
-
return at ? `${at[1]}.${at[2]}-${at[3]}.${at[4]}` : undefined;
|
|
125
|
-
}
|
|
126
|
-
/** the text with every run of whitespace outside a string literal reduced to one space */
|
|
127
|
-
function collapseWhitespace(text) {
|
|
128
|
-
let out = '';
|
|
129
|
-
let quote;
|
|
130
|
-
let space = false;
|
|
131
|
-
for (let i = 0; i < text.length; i++) {
|
|
132
|
-
const c = text[i];
|
|
133
|
-
if (quote !== undefined) {
|
|
134
|
-
out += c;
|
|
135
|
-
if (c === '\\') {
|
|
136
|
-
out += text[++i] ?? '';
|
|
137
|
-
}
|
|
138
|
-
else if (c === quote) {
|
|
139
|
-
quote = undefined;
|
|
140
|
-
}
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (/\s/.test(c)) {
|
|
144
|
-
space = out.length > 0;
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
if (space && !'}])'.includes(c) && !'{[('.includes(out[out.length - 1])) {
|
|
148
|
-
out += ' ';
|
|
149
|
-
}
|
|
150
|
-
space = false;
|
|
151
|
-
if (c === ',' && /[}\]]/.test(nextNonSpace(text, i + 1))) {
|
|
152
|
-
continue; /* a trailing comma the source needed for its layout says nothing here */
|
|
153
|
-
}
|
|
154
|
-
out += c;
|
|
155
|
-
if (c === '\'' || c === '"' || c === '`') {
|
|
156
|
-
quote = c;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return out;
|
|
160
|
-
}
|
|
161
|
-
/** the next character of `text` from `at` that is not a space */
|
|
162
|
-
function nextNonSpace(text, at) {
|
|
163
|
-
for (let i = at; i < text.length; i++) {
|
|
164
|
-
if (!/\s/.test(text[i])) {
|
|
165
|
-
return text[i];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return '';
|
|
169
|
-
}
|
|
170
|
-
/** the comma-separated parts of `text`, splitting only where no bracket or string is open */
|
|
171
|
-
function splitTopLevel(text) {
|
|
172
|
-
const parts = [];
|
|
173
|
-
let depth = 0;
|
|
174
|
-
let quote;
|
|
175
|
-
let start = 0;
|
|
176
|
-
for (let i = 0; i < text.length; i++) {
|
|
177
|
-
const c = text[i];
|
|
178
|
-
if (quote !== undefined) {
|
|
179
|
-
if (c === '\\') {
|
|
180
|
-
i++;
|
|
181
|
-
}
|
|
182
|
-
else if (c === quote) {
|
|
183
|
-
quote = undefined;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
else if (c === '\'' || c === '"' || c === '`') {
|
|
187
|
-
quote = c;
|
|
188
|
-
}
|
|
189
|
-
else if ('{[('.includes(c)) {
|
|
190
|
-
depth++;
|
|
191
|
-
}
|
|
192
|
-
else if ('}])'.includes(c)) {
|
|
193
|
-
depth--;
|
|
194
|
-
}
|
|
195
|
-
else if (c === ',' && depth === 0) {
|
|
196
|
-
parts.push(text.slice(start, i).trim());
|
|
197
|
-
start = i + 1;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
const rest = text.slice(start).trim();
|
|
201
|
-
if (rest !== '') {
|
|
202
|
-
parts.push(rest);
|
|
203
|
-
}
|
|
204
|
-
return parts;
|
|
205
|
-
}
|
|
206
|
-
function buildSamplesFromLinterTestCases(_parser, testFile) {
|
|
207
|
-
const reports = (0, doc_functions_1.getFunctionsFromFolder)({ files: [path_1.default.resolve('test/functionality/linter/' + testFile)], fname: /assertLinter/ });
|
|
208
|
-
if (reports.info.length === 0) {
|
|
209
|
-
return '';
|
|
210
|
-
}
|
|
211
|
-
let result = `#### Additional Examples
|
|
212
|
-
|
|
213
|
-
These examples are synthesized from the test cases in: ${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/linter/' + testFile)}\n\n`;
|
|
214
|
-
for (const report of reports.info) {
|
|
215
|
-
const args = report.arguments;
|
|
216
|
-
if (args.length < 5) {
|
|
217
|
-
console.error('Test case for linter rule ' + report.name + ' does not have enough arguments! Expected at least 5, got ' + args.length);
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
const testName = args[0].getText(report.source);
|
|
221
|
-
if (report.comments?.some(c => c.includes('@ignore-in-wiki'))) {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
// drop any quotes around the test name
|
|
225
|
-
const testNameClean = r_string_1.RString.unquote(testName);
|
|
226
|
-
result += `\n${(0, doc_structure_1.section)('Test Case: ' + testNameClean, 4)}
|
|
227
|
-
|
|
228
|
-
${report.comments ? report.comments.map(c => `> ${c}`).join('\n') + '\n' : ''}
|
|
229
|
-
Given the following input:
|
|
230
|
-
${(0, doc_code_1.codeBlock)('r', r_string_1.RString.unquote(args[2].getText(report.source)).replace(/\\n/g, '\n'))}
|
|
231
|
-
${args.length >= 7 ? `\nAnd using the following [configuration](#configuration): ${(0, doc_code_1.codeBlock)('ts', prettyPrintExpectedOutput(args[6].getText(report.source)))}` : ''}
|
|
232
|
-
|
|
233
|
-
We expect the linter to report the following:
|
|
234
|
-
|
|
235
|
-
${describeExpectedResults(args[4].getText(report.source))}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
See [here](${(0, doc_types_1.getTypePathLink)({ filePath: report.source.fileName, lineNumber: report.lineNumber })}) for the test-case implementation.
|
|
239
|
-
`;
|
|
240
|
-
}
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
52
|
const ExampleDescription = 'Package: pkg\nVersion: 1.0\nTitle: A Package\nLicense: MIT\n';
|
|
244
53
|
const ExampleRoot = '/pkg';
|
|
245
54
|
/** what the wiki shows for each linting rule: its configuration and implementation types, its tests, and an example with findings */
|
|
@@ -352,6 +161,10 @@ function(x) {
|
|
|
352
161
|
configType: 'UnclosedConnectionConfig', ruleType: 'UNCLOSED_CONNECTION', testfile: 'lint-unclosed-connection',
|
|
353
162
|
example: 'con <- file("data.csv")\nreadLines(con)'
|
|
354
163
|
},
|
|
164
|
+
'overwritten-file': {
|
|
165
|
+
configType: 'OverwrittenFileConfig', ruleType: 'OVERWRITTEN_FILE', testfile: 'lint-overwritten-file',
|
|
166
|
+
example: 'write.csv(cars, "out.csv")\nwrite.csv(iris, "out.csv")'
|
|
167
|
+
},
|
|
355
168
|
'unused-import': {
|
|
356
169
|
configType: 'UnusedImportConfig', ruleType: 'UNUSED_IMPORT', testfile: 'lint-unused-import',
|
|
357
170
|
example: 'library(stats)\nprint("no stats function is used")'
|
|
@@ -438,7 +251,7 @@ function(x) {
|
|
|
438
251
|
},
|
|
439
252
|
'package-runtime': {
|
|
440
253
|
configType: 'PackageRuntimeConfig', ruleType: 'PACKAGE_RUNTIME', testfile: 'cmd-check/lint-package-runtime',
|
|
441
|
-
example: { code: 'f <- function() 1', files: { DESCRIPTION: ExampleDescription, 'NAMESPACE': 'export(f)\nexport(g)\n' } }
|
|
254
|
+
example: { code: 'f <- function() 1', files: { DESCRIPTION: ExampleDescription, 'NAMESPACE': 'export(f)\nexport(g)\nexportPattern("^api_")\n' } }
|
|
442
255
|
}
|
|
443
256
|
};
|
|
444
257
|
/** the kinds of issue a rule finds, each rule carries at most one */
|
|
@@ -482,9 +295,10 @@ function registerRules(knownParser, tagTypes) {
|
|
|
482
295
|
}
|
|
483
296
|
function rule(parser, name, configType, ruleType, testfile, example, config, types) {
|
|
484
297
|
const rule = linter_rules_1.LintingRules[name];
|
|
298
|
+
const configKeys = Object.keys(rule.info.defaultConfig(documentedContext)).sort();
|
|
485
299
|
const tags = sortedTags(rule.info.tags).map(t => t === linter_tags_1.LintingRuleTag.CmdCheck ? cmdCheckBadge(name, types) : makeTagBadge(t, types)).join(' ');
|
|
486
300
|
const certaintyDoc = (0, doc_types_1.getDocumentationForType)(`LintingRuleCertainty::${rule.info.certainty}`, types, '', { fuzzy: true }).replaceAll('\n', ' ');
|
|
487
|
-
const certaintyText =
|
|
301
|
+
const certaintyText = (0, html_hover_over_1.textWithTooltip)(`<code>${rule.info.certainty}</code>`, certaintyDoc);
|
|
488
302
|
ruleExplanations.set(name, async () => `
|
|
489
303
|
|
|
490
304
|
${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'linter' })}
|
|
@@ -500,14 +314,14 @@ ${rule.info.description}\\
|
|
|
500
314
|
_This linting rule is implemented in ${(0, doc_types_1.shortLinkFile)(ruleType, types)}._
|
|
501
315
|
|
|
502
316
|
|
|
503
|
-
|
|
317
|
+
${configKeys.length === 0 ? '' : `### Configuration
|
|
504
318
|
|
|
505
319
|
Linting rules can be configured by passing a configuration object to the linter query as shown in the example below.
|
|
506
320
|
The \`${name}\` rule accepts the following configuration options:
|
|
507
321
|
|
|
508
|
-
${
|
|
322
|
+
${configKeys.map(key => `- ${(0, doc_types_1.shortLink)(`${configType}:::${key}`, types)}\\\n${(0, doc_types_1.getDocumentationForType)(`${configType}::${key}`, types)}${cmdCheckStepsOfOption(name, key)}`).join('\n')}
|
|
509
323
|
|
|
510
|
-
### Examples
|
|
324
|
+
`}### Examples
|
|
511
325
|
|
|
512
326
|
${typeof example === 'string' ? (0, doc_code_1.codeBlock)('r', example) : `A project with the code \`R/code.R\`:\n\n${(0, doc_code_1.codeBlock)('r', example.code)}\n\nand the files\n\n${Object.entries(example.files).map(([file, content]) => `\`${file}\`:\n\n${(0, doc_code_1.codeBlock)(file.endsWith('.R') ? 'r' : 'text', content.trimEnd())}`).join('\n\n')}`}
|
|
513
327
|
|
|
@@ -515,7 +329,7 @@ The linting query can be used to run this rule on the above example:
|
|
|
515
329
|
|
|
516
330
|
${await exampleQuery(parser, name, example, config)}
|
|
517
331
|
|
|
518
|
-
|
|
332
|
+
More examples are the test cases in ${(0, doc_files_1.linkFlowRSourceFile)(`test/functionality/linter/${testfile}.test.ts`)}.
|
|
519
333
|
|
|
520
334
|
`.trim());
|
|
521
335
|
}
|
|
@@ -524,9 +338,10 @@ ${rule.info.tags.includes(linter_tags_1.LintingRuleTag.CmdCheck) ? `More example
|
|
|
524
338
|
/** runs the linter query on a rule's wiki example, refusing an example that shows no finding or an error */
|
|
525
339
|
async function exampleQuery(parser, name, example, config = {}) {
|
|
526
340
|
const queries = [{ type: 'linter', rules: [{ name, config: config }] }];
|
|
527
|
-
const shown = typeof example === 'string' ? await (0, doc_query_1.showQuery)(parser, example, queries, { collapseQuery: true })
|
|
341
|
+
const shown = typeof example === 'string' ? await (0, doc_query_1.showQuery)(parser, example, queries, { collapseQuery: true, withJson: false })
|
|
528
342
|
: await (0, doc_query_1.showQuery)(parser, `${retriever_1.fileProtocol}${ExampleRoot}/R/code.R`, queries, {
|
|
529
343
|
collapseQuery: true,
|
|
344
|
+
withJson: false,
|
|
530
345
|
files: [['R/code.R', example.code], ...Object.entries(example.files)].map(([file, content]) => ({ name: `${ExampleRoot}/${file}`, content }))
|
|
531
346
|
});
|
|
532
347
|
if (shown.includes('_no findings_') || shown.includes('Error during execution of rule') || shown.includes('rules failed to execute')) {
|
|
@@ -603,15 +418,10 @@ For example:
|
|
|
603
418
|
${await (async () => {
|
|
604
419
|
const code = 'read.csv("/root/x.txt")';
|
|
605
420
|
const res = await (0, doc_query_1.showQuery)(knownParser, code, [{ type: 'linter' }], { showCode: false, collapseQuery: true, collapseResult: false });
|
|
606
|
-
return
|
|
607
|
-
command: `:query @linter ${JSON.stringify(code)}`,
|
|
608
|
-
description: `
|
|
609
|
-
The linter will analyze the code and return any issues found.
|
|
421
|
+
return `Running ${(0, doc_cli_option_1.getReplCommand)('query')} with \`@linter ${JSON.stringify(code)}\` analyzes the code and returns any issues found.
|
|
610
422
|
Formatted more nicely, this returns:
|
|
611
423
|
|
|
612
|
-
${res}
|
|
613
|
-
`
|
|
614
|
-
}]);
|
|
424
|
+
${res}`;
|
|
615
425
|
})()}
|
|
616
426
|
|
|
617
427
|
${(0, doc_structure_1.section)('Linting Rules', 2, 'linting-rules')}
|
|
@@ -11,6 +11,13 @@ const resolve_helper_1 = require("../dataflow/environments/resolve-helper");
|
|
|
11
11
|
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
12
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
13
13
|
const r_mutations_1 = require("../../test/functionality/_helper/r-mutations");
|
|
14
|
+
const doc_query_1 = require("./doc-util/doc-query");
|
|
15
|
+
/** the categories of the passes, the passes of each in a collapsed list with what each does */
|
|
16
|
+
function mutationCategories() {
|
|
17
|
+
const categories = Object.values(r_mutations_1.MutationCategory);
|
|
18
|
+
const list = categories.map(c => `\`${c}\``).join(', ');
|
|
19
|
+
return `The passes fall into ${categories.length} categories: ${list}.\n\n` + categories.map(category => (0, doc_structure_1.details)(`${category} (${r_mutations_1.MutationPasses.filter(p => p.category === category).length})`, r_mutations_1.MutationPasses.filter(p => p.category === category).map(p => `- \`${p.name}\`: ${p.description}`).join('\n'))).join('\n');
|
|
20
|
+
}
|
|
14
21
|
/**
|
|
15
22
|
* https://github.com/flowr-analysis/flowr/wiki/Linting-and-Testing
|
|
16
23
|
*/
|
|
@@ -203,76 +210,36 @@ checkup\`, where \`npm run checkup -- mutations\` runs just this job.
|
|
|
203
210
|
|
|
204
211
|
The suite has three pieces:
|
|
205
212
|
|
|
206
|
-
- the passes, in ${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/_helper/
|
|
207
|
-
- the corpus of programs and the invariant checks run against their mutants, in ${(0, doc_files_1.linkFlowRSourceFile)('test/mutations/
|
|
213
|
+
- the ${r_mutations_1.MutationPasses.length} passes, ${ctx.link('MutationPasses')} in ${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/_helper/mutation')}.
|
|
214
|
+
- the corpus of programs and the invariant checks run against their mutants, in ${(0, doc_files_1.linkFlowRSourceFile)('test/mutations/counterexample-checks.ts')}.
|
|
208
215
|
- pass-level unit tests, in ${(0, doc_files_1.linkFlowRSourceFile)('test/mutations/r-mutations.test.ts')}, checking each pass on its own rather than against the corpus.
|
|
209
216
|
|
|
210
|
-
Every program in the corpus is a counterexample
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
tried
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
The passes fall into a few categories:
|
|
217
|
-
|
|
218
|
-
- formatting and noise: bindings nothing reads are added before or after the program (\`leading noise\`,
|
|
219
|
-
\`trailing noise\`), a comment or a blank line is interleaved between every line, and a trailing comment is
|
|
220
|
-
appended to each statement.
|
|
221
|
-
- assignment spelling: \`x <- 1\` becomes \`1 -> x\`, \`x = 1\`, \`x <<- 1\` (only where safe, see below), or
|
|
222
|
-
\`assign("x", 1)\`; the right-hand side of an assignment is wrapped in \`(...)\` or in \`{ ... }\`.
|
|
223
|
-
- naming: the variable the criterion points at is renamed to \`mut_v\`, or to a name only valid in backticks;
|
|
224
|
-
a string literal is split apart into \`paste0("v", "vv")\`.
|
|
225
|
-
- structure and braces: the first two statements (or a run of statements around the criterion's own line) are
|
|
226
|
-
joined with \`;\`, every statement or the whole program is wrapped in a \`{ ... }\` block, and braces are added
|
|
227
|
-
to the body of a single-line \`if\` (both arms of an \`if\`/\`else\`), \`for\` or \`while\`.
|
|
228
|
-
- function forms: \`function(x)\` becomes \`\\(x)\` where the R version supports the shorthand, and a call
|
|
229
|
-
nested inside another call is rewritten as a native pipe, e.g. \`f(g(x))\` becomes \`x |> g() |> f()\`.
|
|
230
|
-
- one pass, \`criterion value shifted by one\`, is the exception that deliberately changes the output: it adds
|
|
231
|
-
one to a printed number and updates the expected output to match, so the corpus also checks that a slice
|
|
232
|
-
tracks a value rather than just a name.
|
|
233
|
-
|
|
234
|
-
A pass is a \`MutationPass\`, an object naming what its mutants are called and a function rewriting the
|
|
235
|
-
target, or returning \`undefined\` where it does not apply:
|
|
236
|
-
|
|
237
|
-
${(0, doc_code_1.codeBlock)('typescript', `interface MutationPass {
|
|
238
|
-
name: string;
|
|
239
|
-
apply: (target: MutationTarget, occurrencesOf: Occurrences) =>
|
|
240
|
-
Promise<MutationTarget | undefined> | MutationTarget | undefined;
|
|
241
|
-
}`)}
|
|
242
|
-
|
|
243
|
-
${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/_helper/r-mutations.ts')} carries helpers most passes are built from,
|
|
244
|
-
notably \`rewriteAssignments\`, which rewrites every simple assignment a pass accepts and leaves the rest of the
|
|
245
|
-
program (and the criterion's line number) alone, and \`mapLines\`, which rewrites the lines of a program and
|
|
246
|
-
moves the criterion's line along with them.
|
|
217
|
+
Every program in the corpus is a counterexample flowR once sliced wrongly (a function called through a list, a
|
|
218
|
+
value read back through an environment, a closure over a super-assignment, and so on), or a representative program
|
|
219
|
+
of what the functionality tests cover. Each is run in R once for what it prints and once more for what its slice
|
|
220
|
+
prints. Every pass is then tried on it: a pass with nothing to rewrite skips the program, and every mutant it does
|
|
221
|
+
produce is checked the same way, and must leave the results of the queries unchanged.
|
|
247
222
|
|
|
248
|
-
${(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
- do not emit magrittr's \`%>%\`, which is not base R and fails on a clean R installation.
|
|
257
|
-
- \`T\`/\`F\` are ordinary bindings R initializes to \`TRUE\`/\`FALSE\`, not literals, so a pass abbreviating them
|
|
258
|
-
applies only where the program does not otherwise assign them.
|
|
259
|
-
- reordering arguments into named form is unsound in general, as R does partial matching on argument names.
|
|
260
|
-
- a pass must not join the criterion's own line with another line naming the same variable, or the
|
|
261
|
-
\`line@name\` criterion becomes ambiguous about which of the two occurrences it means.
|
|
262
|
-
`
|
|
263
|
-
})}
|
|
223
|
+
Every program and every mutant also goes through the ${ctx.linkPage('wiki/Interface', 'REPL', 'using-the-repl')}:
|
|
224
|
+
${ctx.replCmd('query')} with the ${(0, doc_query_1.linkToQueryOfName)('static-slice')} has to print a slice that prints what the program prints,
|
|
225
|
+
the ${(0, doc_query_1.linkToQueryOfName)('dependencies')} and the ${(0, doc_query_1.linkToQueryOfName)('linter')} have to give the same answer for the
|
|
226
|
+
mutant as for the program (a pass that adds code may only add linter findings), and for a pass that only renames
|
|
227
|
+
or moves code, ${(0, doc_query_1.linkToQueryOfName)('resolve-value')}, ${ctx.replCmd('dataflow')}, ${ctx.replCmd('normalize')} and
|
|
228
|
+
${ctx.replCmd('controlflow')} have to print the same, up to the positions and names the pass changed.
|
|
229
|
+
|
|
230
|
+
${mutationCategories()}
|
|
264
231
|
|
|
265
|
-
|
|
266
|
-
|
|
232
|
+
Besides, every mutant and every chain of a pass and the ${r_mutations_1.ChainedWith} passes after it is analyzed in full and asked
|
|
233
|
+
every query on tree-sitter, without R, in ${(0, doc_files_1.linkFlowRSourceFile)('test/mutations/robustness.ts')}: none of these
|
|
234
|
+
tens of thousands of programs may make flowR fail, overflow the stack, or hang.
|
|
267
235
|
|
|
268
|
-
A
|
|
269
|
-
|
|
270
|
-
${ctx.
|
|
271
|
-
(out of how many were possible), and the number of mutation tests.
|
|
236
|
+
A pass is a ${ctx.link('MutationPass')} and sees the program as a ${ctx.link('MutationProgram')}: its normalized
|
|
237
|
+
AST and dataflow graph, and what the built-in configuration states about each call. It edits the code through
|
|
238
|
+
a ${ctx.link('Rewrite')}, which moves the criterion along with the lines the edits add or remove.
|
|
272
239
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
240
|
+
A complete run writes how many passes, counterexamples and mutants it checked, and
|
|
241
|
+
${(0, doc_files_1.linkFlowRSourceFile)('scripts/test-label-counts.ts')} adds these numbers to the
|
|
242
|
+
${ctx.linkPage('flowr:benchmarks', 'benchmark page')}.
|
|
276
243
|
|
|
277
244
|
<a id='performance-tests'></a>
|
|
278
245
|
### 💃 Performance Tests
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WikiQuery = void 0;
|
|
4
|
+
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
5
|
+
const dependencies_query_format_1 = require("../queries/catalog/dependencies-query/dependencies-query-format");
|
|
4
6
|
const doc_dfg_1 = require("./doc-util/doc-dfg");
|
|
5
7
|
const query_1 = require("../queries/query");
|
|
6
8
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
@@ -541,6 +543,37 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({ inputSources: {
|
|
|
541
543
|
`;
|
|
542
544
|
}
|
|
543
545
|
});
|
|
546
|
+
/** what a script takes in, what it puts out, and what it does with data in between, by category of the dependencies query */
|
|
547
|
+
const DependencyRoles = [
|
|
548
|
+
['Inputs', ['library', 'remote', 'source', 'read']],
|
|
549
|
+
['Outputs', ['write', 'visualize']],
|
|
550
|
+
['What the script does with data', ['transform', 'statistics', 'test']]
|
|
551
|
+
];
|
|
552
|
+
/** the categories and the values they report, generated from the categories the query knows */
|
|
553
|
+
function dependencyOverview(ctx, categories) {
|
|
554
|
+
const examples = (c) => categories[c].functions.slice(0, 4).map(f => `\`${f.name}\``).join(', ');
|
|
555
|
+
const rows = DependencyRoles.map(([title, names]) => `| **${title}** | | | |\n` + names.map(c => `| \`${c}\` (${categories[c].queryDisplayName ?? c}) | ${categories[c].functions.length} | ${examples(c)} | ${categories[c].defaultValue === undefined ? '' : `\`${categories[c].defaultValue}\``} |`).join('\n')).join('\n');
|
|
556
|
+
return `
|
|
557
|
+
The query reports one list of entries per category, each entry a call and the \`value\` it reads or writes, like the
|
|
558
|
+
file of a \`read.csv\`:
|
|
559
|
+
|
|
560
|
+
| Category | Functions known | For example | Value where none is named |
|
|
561
|
+
|----------|----------------:|-------------|---------------------------|
|
|
562
|
+
${rows}
|
|
563
|
+
|
|
564
|
+
What the \`value\` of an entry tells, and the fields that say more:
|
|
565
|
+
|
|
566
|
+
| Entry | How to tell | Meaning |
|
|
567
|
+
|-------|-------------|---------|
|
|
568
|
+
| a file, package, or URL | \`value\` names it | the call reads or writes it, like \`"data.csv"\` |
|
|
569
|
+
| inline data | \`value\` is \`${dependencies_query_format_1.Constant}\` | ${ctx.doc('Constant')} |
|
|
570
|
+
| an unknown resource | \`value\` is \`${dependencies_query_format_1.Unknown}\` | ${ctx.doc('Unknown')} |
|
|
571
|
+
| console output | \`value\` is \`stdout\` or \`stderr\` | \`print\` and \`cat\` write to \`stdout\`, \`message\` and \`warning\` to \`stderr\` |
|
|
572
|
+
| auto-printed output | \`implicit\` is set | ${ctx.doc('DependencyInfo::implicit')} |
|
|
573
|
+
| through a call of the program | \`via\` is set | ${ctx.doc('DependencyInfo::via').replaceAll('\n', ' ')} |
|
|
574
|
+
| part of another output | its id is in another entry's \`parts\` | ${ctx.doc('DependencyInfo::parts').replaceAll('\n', ' ')} |
|
|
575
|
+
`;
|
|
576
|
+
}
|
|
544
577
|
(0, doc_query_1.registerQueryDocumentation)('dependencies', {
|
|
545
578
|
type: 'active',
|
|
546
579
|
shortDescription: 'Returns all direct dependencies (in- and outputs) of a given R script',
|
|
@@ -565,11 +598,14 @@ ggplot(data, aes(x=x, y=y)) + geom_point()
|
|
|
565
598
|
better::write.csv(data, "data2.csv")
|
|
566
599
|
print("hello world!")
|
|
567
600
|
`;
|
|
601
|
+
const categories = (0, dependencies_query_format_1.defaultDependencyCategories)((await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder().setParser(shell).build()).inspectContext());
|
|
568
602
|
return `
|
|
569
603
|
This query extracts all dependencies from an R script, using a combination of a ${(0, doc_query_1.linkToQueryOfName)('call-context')}
|
|
570
604
|
and more advanced tracking in the ${ctx.linkPage('wiki/Dataflow Graph', 'Dataflow Graph')}.
|
|
571
605
|
Loaded libraries are resolved against the ${ctx.linkPage('wiki/Signature Database', 'signature database')}.
|
|
572
606
|
|
|
607
|
+
${dependencyOverview(ctx, categories)}
|
|
608
|
+
|
|
573
609
|
For a script reading \`${exampleCode}\`, the following query returns the loaded library:
|
|
574
610
|
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'dependencies' }], { showCode: false, collapseQuery: true, ctx })}
|
|
575
611
|
|
|
@@ -600,6 +636,11 @@ convention and \`R_DEFAULT_PACKAGES\` (or \`options(defaultPackages=)\`) can dro
|
|
|
600
636
|
there and cannot be detached -- so it is never something the script could have asked for, and never something to
|
|
601
637
|
suggest a \`library\` call for.
|
|
602
638
|
|
|
639
|
+
To see what takes part in a dependency, ask the query to \`focus\` on it: \`.meta.focus\` then lists every node the
|
|
640
|
+
dependency depends on and every node that depends on it, so a client can gray out the rest. In the REPL, the
|
|
641
|
+
criteria go in parentheses, as with ${ctx.replCmd('query')} \`@dependencies (3@read.csv)\`, which prints the lines taking part:
|
|
642
|
+
${await (0, doc_query_1.showQuery)(shell, 'f <- "a.csv"\ng <- 2\nd <- read.csv(f)\nh <- g + 1\nprint(d)', [{ type: 'dependencies', focus: ['3@read.csv'], enabledCategories: ['read'] }], { showCode: true, collapseQuery: false, collapseResult: true, ctx })}
|
|
643
|
+
|
|
603
644
|
Beyond libraries, files and outputs, the query knows the \`visualize\` category (plots) and the \`transform\` category
|
|
604
645
|
(\`Data Transformations\`): the calls that reshape, filter, join or aggregate data, like \`dplyr::filter\`, \`tidyr::pivot_longer\`,
|
|
605
646
|
\`merge\`, \`aggregate\` or \`data.table::setDT\`. The category is read from the built-in configuration: every built-in labeled
|
package/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type { SourcePosition, SourceLocationLike } from './util/range';
|
|
|
25
25
|
export { Dataflow } from './dataflow/graph/df-helper';
|
|
26
26
|
export { DataflowGraph } from './dataflow/graph/graph';
|
|
27
27
|
export { DfgVertex, VertexType } from './dataflow/graph/vertex';
|
|
28
|
+
export { AmbientStateName, KeyedState } from './dataflow/environments/ambient-state-name';
|
|
28
29
|
export type { DataflowGraphVertexInfo } from './dataflow/graph/vertex';
|
|
29
30
|
export { DfEdge, EdgeType } from './dataflow/graph/edge';
|
|
30
31
|
export { FunctionSemantics } from './dataflow/fn/function-semantics';
|
package/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.retrieveVersionInformation = exports.flowrVersion = exports.TREE_SITTER_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = exports.TREE_SITTER_SLICING_PIPELINE = exports.TREE_SITTER_DATAFLOW_PIPELINE = exports.DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = exports.DEFAULT_SLICING_PIPELINE = exports.DEFAULT_DATAFLOW_PIPELINE = exports.PipelineExecutor = exports.SemanticCallTag = exports.CallProp = exports.ArgProp = exports.BuiltInProcName = exports.FlowrConfig = exports.TreeSitterExecutor = exports.RShell = exports.requestFromInput = exports.SlicingCriterion = exports.RNode = exports.FunctionSemantics = exports.EdgeType = exports.DfEdge = exports.VertexType = exports.DfgVertex = exports.DataflowGraph = exports.Dataflow = exports.SourceLocationView = exports.SourceLocation = exports.SourceRange = exports.IdentifierView = exports.Identifier = exports.FlowrAnalyzerBuilder = exports.FlowrAnalyzer = void 0;
|
|
19
|
+
exports.retrieveVersionInformation = exports.flowrVersion = exports.TREE_SITTER_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = exports.TREE_SITTER_SLICING_PIPELINE = exports.TREE_SITTER_DATAFLOW_PIPELINE = exports.DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = exports.DEFAULT_SLICING_PIPELINE = exports.DEFAULT_DATAFLOW_PIPELINE = exports.PipelineExecutor = exports.SemanticCallTag = exports.CallProp = exports.ArgProp = exports.BuiltInProcName = exports.FlowrConfig = exports.TreeSitterExecutor = exports.RShell = exports.requestFromInput = exports.SlicingCriterion = exports.RNode = exports.FunctionSemantics = exports.EdgeType = exports.DfEdge = exports.KeyedState = exports.AmbientStateName = exports.VertexType = exports.DfgVertex = exports.DataflowGraph = exports.Dataflow = exports.SourceLocationView = exports.SourceLocation = exports.SourceRange = exports.IdentifierView = exports.Identifier = exports.FlowrAnalyzerBuilder = exports.FlowrAnalyzer = void 0;
|
|
20
20
|
/* the analyzer, which is the front door: everything else here is what its methods hand you or take */
|
|
21
21
|
var flowr_analyzer_1 = require("./project/flowr-analyzer");
|
|
22
22
|
Object.defineProperty(exports, "FlowrAnalyzer", { enumerable: true, get: function () { return flowr_analyzer_1.FlowrAnalyzer; } });
|
|
@@ -39,6 +39,10 @@ Object.defineProperty(exports, "DataflowGraph", { enumerable: true, get: functio
|
|
|
39
39
|
var vertex_1 = require("./dataflow/graph/vertex");
|
|
40
40
|
Object.defineProperty(exports, "DfgVertex", { enumerable: true, get: function () { return vertex_1.DfgVertex; } });
|
|
41
41
|
Object.defineProperty(exports, "VertexType", { enumerable: true, get: function () { return vertex_1.VertexType; } });
|
|
42
|
+
/* the names of the global state (options, environment variables, devices, ...) calls change, see `Dataflow.sideEffects.ambientWrites` */
|
|
43
|
+
var ambient_state_name_1 = require("./dataflow/environments/ambient-state-name");
|
|
44
|
+
Object.defineProperty(exports, "AmbientStateName", { enumerable: true, get: function () { return ambient_state_name_1.AmbientStateName; } });
|
|
45
|
+
Object.defineProperty(exports, "KeyedState", { enumerable: true, get: function () { return ambient_state_name_1.KeyedState; } });
|
|
42
46
|
var edge_1 = require("./dataflow/graph/edge");
|
|
43
47
|
Object.defineProperty(exports, "DfEdge", { enumerable: true, get: function () { return edge_1.DfEdge; } });
|
|
44
48
|
Object.defineProperty(exports, "EdgeType", { enumerable: true, get: function () { return edge_1.EdgeType; } });
|
|
@@ -230,4 +230,10 @@ export declare enum LintingPrettyPrintContext {
|
|
|
230
230
|
Query = "query",
|
|
231
231
|
Full = "full"
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Builds the pretty printers of a rule, the `full` printer defaults to the `query` one.
|
|
235
|
+
*/
|
|
236
|
+
export declare function prettyPrint<R>(query: (r: R) => string, full?: (r: R) => string): {
|
|
237
|
+
readonly [C in LintingPrettyPrintContext]: (r: R, metadata: unknown) => string;
|
|
238
|
+
};
|
|
233
239
|
export {};
|
package/linter/linter-format.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LintingPrettyPrintContext = exports.LintingRuleCertainty = exports.LintingResultCertainty = exports.LintingResults = exports.LintQuickFix = void 0;
|
|
4
|
+
exports.prettyPrint = prettyPrint;
|
|
4
5
|
const range_1 = require("../util/range");
|
|
5
6
|
const assert_1 = require("../util/assert");
|
|
6
7
|
/**
|
|
@@ -143,4 +144,13 @@ var LintingPrettyPrintContext;
|
|
|
143
144
|
LintingPrettyPrintContext["Query"] = "query";
|
|
144
145
|
LintingPrettyPrintContext["Full"] = "full";
|
|
145
146
|
})(LintingPrettyPrintContext || (exports.LintingPrettyPrintContext = LintingPrettyPrintContext = {}));
|
|
147
|
+
/**
|
|
148
|
+
* Builds the pretty printers of a rule, the `full` printer defaults to the `query` one.
|
|
149
|
+
*/
|
|
150
|
+
function prettyPrint(query, full = query) {
|
|
151
|
+
return {
|
|
152
|
+
[LintingPrettyPrintContext.Query]: query,
|
|
153
|
+
[LintingPrettyPrintContext.Full]: full
|
|
154
|
+
};
|
|
155
|
+
}
|
|
146
156
|
//# sourceMappingURL=linter-format.js.map
|