@eagleoutice/flowr 2.17.5 → 2.17.6
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 +13 -51
- package/abstract-interpretation/absint-inference.d.ts +4 -4
- package/abstract-interpretation/absint-inference.js +11 -11
- package/abstract-interpretation/abstract-semantics.d.ts +2 -1
- package/abstract-interpretation/branch-paths-interpreter.d.ts +1 -0
- package/abstract-interpretation/branch-paths-interpreter.js +60 -0
- package/abstract-interpretation/branch-paths.d.ts +60 -0
- package/abstract-interpretation/branch-paths.js +120 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +6 -1
- package/abstract-interpretation/data-frame/dataframe-semantics.js +60 -1
- package/abstract-interpretation/data-frame/semantics.js +4 -10
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/cli/repl/core.js +51 -0
- package/control-flow/cfg-dead-code.js +12 -7
- package/data/packed.d.ts +10 -0
- package/data/packed.js +33 -0
- package/data/r-base-guards.generated.d.ts +7 -0
- package/data/r-base-guards.generated.js +12 -0
- package/data/r-datasets.generated.d.ts +4 -0
- package/data/r-datasets.generated.js +10 -0
- package/data/r-formals.generated.d.ts +4 -0
- package/data/r-formals.generated.js +10 -0
- package/data/r-group-method-guards.generated.d.ts +3 -0
- package/data/r-group-method-guards.generated.js +8 -0
- package/dataflow/environments/ambient-effect.d.ts +1000 -0
- package/dataflow/environments/ambient-effect.js +234 -0
- package/dataflow/environments/ambient-state-name.d.ts +45 -2
- package/dataflow/environments/ambient-state-name.js +61 -3
- package/dataflow/environments/apply-kill.js +11 -4
- package/dataflow/environments/built-in-kinds.d.ts +4 -46
- package/dataflow/environments/built-in-kinds.js +6 -2
- package/dataflow/environments/built-in-props.d.ts +16 -4
- package/dataflow/environments/built-in-props.js +11 -3
- package/dataflow/environments/built-in.d.ts +6 -1
- package/dataflow/environments/built-in.js +13 -36
- package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-functions.js +110 -52
- package/dataflow/environments/default-builtin-config/base-language.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-language.js +11 -8
- package/dataflow/environments/default-builtin-config/dev-tooling.js +1 -1
- package/dataflow/environments/default-builtin-config/file-io.js +6 -4
- package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/graphics-devices.js +24 -14
- package/dataflow/environments/default-builtin-config/guard-builders.d.ts +16 -0
- package/dataflow/environments/default-builtin-config/guard-builders.js +29 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.d.ts +15 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +228 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-ops.d.ts +11 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +154 -0
- package/dataflow/environments/default-builtin-config/guards.d.ts +9 -0
- package/dataflow/environments/default-builtin-config/guards.js +211 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +3 -3
- package/dataflow/environments/default-builtin-config/index.js +22 -7
- package/dataflow/environments/default-builtin-config/media-formats.js +4 -4
- package/dataflow/environments/default-builtin-config/package-spatial.js +2 -1
- package/dataflow/environments/default-builtin-config/package-tidyverse.js +3 -2
- package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/package-utils.js +5 -2
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/parallel-execution.js +3 -1
- package/dataflow/environments/default-builtin-config/r-formals.d.ts +13 -0
- package/dataflow/environments/default-builtin-config/r-formals.js +110 -0
- package/dataflow/environments/default-builtin-config/shared-configs.d.ts +138 -77
- package/dataflow/environments/default-builtin-config/shared-configs.js +52 -88
- package/dataflow/environments/default-builtin-config/statistics.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/statistics.js +4 -1
- package/dataflow/environments/diff.js +5 -2
- package/dataflow/environments/environment.d.ts +20 -0
- package/dataflow/environments/environment.js +39 -4
- package/dataflow/environments/group-generics.d.ts +5 -1
- package/dataflow/environments/group-generics.js +13 -3
- package/dataflow/environments/guard-facts.d.ts +169 -0
- package/dataflow/environments/guard-facts.js +26 -0
- package/dataflow/environments/identifier.d.ts +9 -1
- package/dataflow/environments/identifier.js +5 -0
- package/dataflow/environments/pkg-name.d.ts +1 -0
- package/dataflow/environments/query-fn-props.d.ts +3 -5
- package/dataflow/environments/query-fn-props.js +44 -21
- package/dataflow/environments/removal-marker.d.ts +2 -0
- package/dataflow/environments/removal-marker.js +5 -0
- package/dataflow/eval/resolve/resolve-strings.d.ts +2 -5
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/extractor.js +24 -15
- package/dataflow/fn/condition-handlers.d.ts +2 -0
- package/dataflow/fn/condition-handlers.js +3 -1
- package/dataflow/fn/frame-reflection.d.ts +4 -2
- package/dataflow/fn/frame-reflection.js +16 -0
- package/dataflow/fn/function-props.js +15 -22
- package/dataflow/fn/function-semantics.d.ts +31 -1
- package/dataflow/fn/function-semantics.js +15 -0
- package/dataflow/fn/guards/built-in-guards.d.ts +112 -0
- package/dataflow/fn/guards/built-in-guards.js +199 -0
- package/dataflow/fn/guards/call-contracts.d.ts +97 -0
- package/dataflow/fn/guards/call-contracts.js +331 -0
- package/dataflow/fn/guards/condition-grouping.d.ts +20 -0
- package/dataflow/fn/guards/condition-grouping.js +135 -0
- package/dataflow/fn/guards/function-guards.d.ts +112 -0
- package/dataflow/fn/guards/function-guards.js +1549 -0
- package/dataflow/fn/guards/group-method-guards.d.ts +28 -0
- package/dataflow/fn/guards/group-method-guards.js +56 -0
- package/dataflow/fn/guards/guard-claims.d.ts +125 -0
- package/dataflow/fn/guards/guard-claims.js +678 -0
- package/dataflow/fn/guards/guard-knowledge.d.ts +41 -0
- package/dataflow/fn/guards/guard-knowledge.js +180 -0
- package/dataflow/fn/guards/guard-term-syntax.d.ts +9 -0
- package/dataflow/fn/guards/guard-term-syntax.js +210 -0
- package/dataflow/fn/guards/guard-term.d.ts +136 -0
- package/dataflow/fn/guards/guard-term.js +550 -0
- package/dataflow/fn/guards/stated-guards.d.ts +13 -0
- package/dataflow/fn/guards/stated-guards.js +35 -0
- package/dataflow/fn/higher-order-function.d.ts +2 -0
- package/dataflow/fn/higher-order-function.js +1 -0
- package/dataflow/fn/strict-function.d.ts +4 -0
- package/dataflow/fn/strict-function.js +66 -17
- package/dataflow/graph/ambient-access.d.ts +4 -1
- package/dataflow/graph/ambient-access.js +8 -2
- package/dataflow/graph/closure-frames.js +1 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +2 -2
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +15 -0
- package/dataflow/graph/graph.d.ts +12 -6
- package/dataflow/graph/graph.js +21 -28
- package/dataflow/info.d.ts +2 -1
- package/dataflow/info.js +3 -1
- package/dataflow/internal/dispatch-linking.d.ts +3 -1
- package/dataflow/internal/dispatch-linking.js +1 -0
- package/dataflow/internal/linker.d.ts +2 -0
- package/dataflow/internal/linker.js +115 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -57
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +471 -295
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +13 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +106 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +24 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +33 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +23 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +19 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +347 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +110 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +28 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +16 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +37 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +55 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +11 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +64 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +160 -20
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +6 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +142 -4
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +23 -4
- package/dataflow/processor.d.ts +2 -0
- package/documentation/data/dfg/doc-ambient.d.ts +4 -0
- package/documentation/data/dfg/doc-ambient.js +74 -0
- package/documentation/wiki-dataflow-graph.js +10 -4
- package/documentation/wiki-linter.js +12 -0
- package/documentation/wiki-query.js +112 -1
- package/linter/linter-rules.d.ts +41 -1
- package/linter/linter-rules.js +5 -1
- package/linter/rules/call-contracts.d.ts +40 -0
- package/linter/rules/call-contracts.js +56 -0
- package/linter/rules/cmd-check/bogus-return.js +1 -1
- package/linter/rules/cmd-check/call-arguments.js +5 -6
- package/linter/rules/cmd-check/cmd-check-util.d.ts +0 -6
- package/linter/rules/cmd-check/cmd-check-util.js +0 -28
- package/linter/rules/cmd-check/package-hooks.js +2 -1
- package/linter/rules/cmd-check/s-three-method-consistency.js +1 -1
- package/linter/rules/interactive-functions.d.ts +30 -0
- package/linter/rules/interactive-functions.js +87 -0
- package/linter/rules/process-state-in-session.js +1 -1
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +8 -2
- package/linter/rules/undefined-symbol.js +18 -7
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +1 -1
- package/project/context/flowr-analyzer-dependencies-context.js +2 -1
- package/project/flowr-analyzer.d.ts +1 -0
- package/project/flowr-analyzer.js +5 -5
- package/project/sigdb/build.js +14 -4
- package/project/sigdb/decode.d.ts +3 -0
- package/project/sigdb/decode.js +10 -1
- package/project/sigdb/guarded-source.d.ts +6 -0
- package/project/sigdb/guarded-source.js +29 -0
- package/project/sigdb/reader.d.ts +5 -0
- package/project/sigdb/reader.js +27 -1
- package/project/sigdb/schema.d.ts +24 -2
- package/queries/catalog/absint-query/absint-query-format.d.ts +6 -3
- package/queries/catalog/absint-query/absint-query-format.js +57 -2
- package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +6 -2
- package/queries/catalog/ambient-access-query/ambient-access-query-format.js +48 -3
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -2
- package/queries/catalog/cluster-query/cluster-query-format.js +19 -2
- package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +5 -2
- package/queries/catalog/code-clones-query/code-clones-query-format.js +34 -2
- package/queries/catalog/config-query/config-query-format.d.ts +5 -2
- package/queries/catalog/config-query/config-query-format.js +41 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +5 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.js +19 -2
- package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +72 -0
- package/queries/catalog/data-columns-query/data-columns-query-format.js +215 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +5 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +38 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +5 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.js +18 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +8 -3
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/tagged-functions.d.ts +11 -0
- package/queries/catalog/dependencies-query/function-info/tagged-functions.js +18 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +7 -2
- package/queries/catalog/dice-query/dice-query-format.js +34 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -4
- package/queries/catalog/does-call-query/does-call-query-format.js +114 -2
- package/queries/catalog/files-query/files-query-format.d.ts +5 -2
- package/queries/catalog/files-query/files-query-format.js +45 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +6 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +303 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +8 -4
- package/queries/catalog/happens-before-query/happens-before-query-format.js +37 -2
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +5 -2
- package/queries/catalog/id-map-query/id-map-query-format.js +18 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +5 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +29 -2
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +37 -0
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +125 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +54 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +23 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +15 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +8 -2
- package/queries/catalog/linter-query/linter-query-format.js +69 -4
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +7 -3
- package/queries/catalog/location-map-query/location-map-query-format.js +70 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +5 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +18 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +6 -3
- package/queries/catalog/origin-query/origin-query-format.js +29 -2
- package/queries/catalog/project-query/project-query-format.d.ts +6 -3
- package/queries/catalog/project-query/project-query-format.js +98 -2
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +6 -3
- package/queries/catalog/provenance-query/provenance-query-format.js +30 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +9 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +38 -2
- package/queries/catalog/search-query/search-query-format.d.ts +5 -2
- package/queries/catalog/search-query/search-query-format.js +23 -2
- package/queries/catalog/signature-query/signature-query-executor.js +3 -1
- package/queries/catalog/signature-query/signature-query-format.d.ts +3 -0
- package/queries/catalog/signature-query/signature-query-render.js +23 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +13 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +55 -2
- package/queries/catalog/taint-query/taint-query-format.d.ts +6 -3
- package/queries/catalog/taint-query/taint-query-format.js +28 -2
- package/queries/query.d.ts +48 -27
- package/queries/query.js +6 -4
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -0
- package/r-bridge/shell.js +7 -2
- package/reconstruct/reconstruct.js +18 -3
- package/slicing/static/removal-slice.js +4 -3
- package/slicing/static/slice-call.d.ts +11 -0
- package/slicing/static/slice-call.js +43 -2
- package/slicing/static/static-slicer.d.ts +2 -0
- package/slicing/static/static-slicer.js +137 -21
- package/slicing/static/visiting-queue.d.ts +2 -0
- package/slicing/static/visiting-queue.js +4 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/objects.d.ts +2 -0
- package/util/objects.js +5 -0
- package/util/r-datasets.d.ts +27 -0
- package/util/r-datasets.js +45 -0
- package/util/text/playground-link.d.ts +2 -0
- package/util/text/playground-link.js +2 -0
- package/queries/catalog/absint-query/absint-query-executor.d.ts +0 -6
- package/queries/catalog/absint-query/absint-query-executor.js +0 -61
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +0 -6
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +0 -50
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +0 -6
- package/queries/catalog/cluster-query/cluster-query-executor.js +0 -21
- package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +0 -6
- package/queries/catalog/code-clones-query/code-clones-query-executor.js +0 -38
- package/queries/catalog/config-query/config-query-executor.d.ts +0 -6
- package/queries/catalog/config-query/config-query-executor.js +0 -45
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +0 -6
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +0 -21
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +0 -6
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +0 -40
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +0 -6
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +0 -20
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +0 -9
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +0 -18
- package/queries/catalog/dice-query/dice-query-executor.d.ts +0 -8
- package/queries/catalog/dice-query/dice-query-executor.js +0 -37
- package/queries/catalog/does-call-query/does-call-query-executor.d.ts +0 -6
- package/queries/catalog/does-call-query/does-call-query-executor.js +0 -116
- package/queries/catalog/files-query/files-query-executor.d.ts +0 -6
- package/queries/catalog/files-query/files-query-executor.js +0 -47
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +0 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +0 -307
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +0 -7
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +0 -40
- package/queries/catalog/id-map-query/id-map-query-executor.d.ts +0 -6
- package/queries/catalog/id-map-query/id-map-query-executor.js +0 -20
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -6
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +0 -31
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +0 -4
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +0 -58
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +0 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +0 -25
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +0 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +0 -17
- package/queries/catalog/linter-query/linter-query-executor.d.ts +0 -9
- package/queries/catalog/linter-query/linter-query-executor.js +0 -62
- package/queries/catalog/location-map-query/location-map-query-executor.d.ts +0 -7
- package/queries/catalog/location-map-query/location-map-query-executor.js +0 -73
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +0 -6
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +0 -20
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -6
- package/queries/catalog/origin-query/origin-query-executor.js +0 -31
- package/queries/catalog/project-query/project-query-executor.d.ts +0 -6
- package/queries/catalog/project-query/project-query-executor.js +0 -103
- package/queries/catalog/provenance-query/provenance-query-executor.d.ts +0 -6
- package/queries/catalog/provenance-query/provenance-query-executor.js +0 -33
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +0 -10
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +0 -40
- package/queries/catalog/search-query/search-query-executor.d.ts +0 -6
- package/queries/catalog/search-query/search-query-executor.js +0 -25
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +0 -14
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +0 -59
- package/queries/catalog/taint-query/taint-query-executor.d.ts +0 -7
- package/queries/catalog/taint-query/taint-query-executor.js +0 -30
|
@@ -26,6 +26,7 @@ const happens_before_1 = require("../../../../../control-flow/happens-before");
|
|
|
26
26
|
const query_fn_props_1 = require("../../../../environments/query-fn-props");
|
|
27
27
|
const built_in_props_1 = require("../../../../environments/built-in-props");
|
|
28
28
|
const defaultmap_1 = require("../../../../../util/collections/defaultmap");
|
|
29
|
+
const built_in_ambient_state_1 = require("./built-in/built-in-ambient-state");
|
|
29
30
|
/** Calls capturing every argument as a language object, unlike `quote` marking the one it captures. */
|
|
30
31
|
exports.CapturingCalls = new Set(['expression']);
|
|
31
32
|
/** Calls capturing an expression as a promise, forced at some later read of the variable they bind. */
|
|
@@ -68,6 +69,12 @@ exports.Quoted = {
|
|
|
68
69
|
}
|
|
69
70
|
return [];
|
|
70
71
|
},
|
|
72
|
+
/** The variable a delaying call (`delayedAssign`) binds its promise to. */
|
|
73
|
+
promisedBinding(graph, id) {
|
|
74
|
+
const vertex = graph.getVertex(id);
|
|
75
|
+
return vertex_1.DfgVertex.isFunctionCall(vertex) && DelayingCalls.has(identifier_1.Identifier.getName(vertex.name))
|
|
76
|
+
? df_helper_1.Dataflow.sourcesOf(graph, id, edge_1.EdgeType.DefinedBy).find(target => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(target))) : undefined;
|
|
77
|
+
},
|
|
71
78
|
/** Links every name in `expr` against `environment` and hands back what stays unresolved. */
|
|
72
79
|
evaluateIn: linker_1.linkExpressionIn,
|
|
73
80
|
/** The finishing pass over a complete graph: it settles what a call really evaluates, which the call itself could not know. */
|
|
@@ -81,6 +88,7 @@ exports.Quoted = {
|
|
|
81
88
|
const cfgOnce = () => (cfg === null ? (cfg = controlFlow()) : cfg);
|
|
82
89
|
const masking = [];
|
|
83
90
|
const evaluated = [];
|
|
91
|
+
const promises = [];
|
|
84
92
|
let sideEffects;
|
|
85
93
|
let installers;
|
|
86
94
|
const installersOnce = () => installers ??= languageInstallersOf(graph, environment);
|
|
@@ -107,7 +115,7 @@ exports.Quoted = {
|
|
|
107
115
|
continue;
|
|
108
116
|
}
|
|
109
117
|
const promised = namesOnce();
|
|
110
|
-
const binding =
|
|
118
|
+
const binding = exports.Quoted.promisedBinding(graph, id);
|
|
111
119
|
const flow = binding === undefined ? undefined : cfgOnce();
|
|
112
120
|
const sites = flow === undefined || binding === undefined ? undefined : deferred_1.Deferred.forcedAt(graph, binding, flow, true);
|
|
113
121
|
/* the promise runs in `eval.env`, so whatever that environment holds may be what it reads */
|
|
@@ -120,7 +128,7 @@ exports.Quoted = {
|
|
|
120
128
|
const forces = flow !== undefined && sites?.length && binding !== undefined ? { cfg: flow, sites, binding } : undefined;
|
|
121
129
|
deferred_1.Deferred.link(graph, promise, candidates, idMap, forces);
|
|
122
130
|
if (binding !== undefined) {
|
|
123
|
-
|
|
131
|
+
promises.push([binding, promise]);
|
|
124
132
|
}
|
|
125
133
|
if (evalEnv !== undefined) {
|
|
126
134
|
graph.addEdge(promise, evalEnv.info.id, edge_1.EdgeType.Reads);
|
|
@@ -152,6 +160,11 @@ exports.Quoted = {
|
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
162
|
}
|
|
163
|
+
/* an evaluation reads a binding only once it is resolved (`eval(quote(v), e)`), so the reads of a promise are complete only now */
|
|
164
|
+
for (const [binding, promise] of promises) {
|
|
165
|
+
const flow = cfgOnce();
|
|
166
|
+
linkForcesToPromise(graph, binding, promise, flow === undefined ? [] : deferred_1.Deferred.forcedAt(graph, binding, flow, true));
|
|
167
|
+
}
|
|
155
168
|
for (const at of evaluated) {
|
|
156
169
|
nse_1.Nse.unmark(graph, at);
|
|
157
170
|
}
|
|
@@ -180,11 +193,15 @@ function forcesOf(graph, parameter, cfg, forcing, reachOf) {
|
|
|
180
193
|
return forces;
|
|
181
194
|
}
|
|
182
195
|
/** Every read of the delayed name takes the promised expression's value, so all of them get the link, not just whichever forces it first. */
|
|
183
|
-
function linkForcesToPromise(graph, binding, promise) {
|
|
196
|
+
function linkForcesToPromise(graph, binding, promise, sites) {
|
|
184
197
|
for (const reader of df_helper_1.Dataflow.sourcesOf(graph, binding, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall)) {
|
|
185
198
|
if (reader !== promise) {
|
|
186
199
|
graph.addEdge(reader, promise, edge_1.EdgeType.Reads);
|
|
187
200
|
}
|
|
201
|
+
/* a later read gets the value the read forcing the promise computed, with the state at that point */
|
|
202
|
+
for (const site of sites.includes(reader) ? [] : sites) {
|
|
203
|
+
graph.addEdge(reader, site, edge_1.EdgeType.Reads);
|
|
204
|
+
}
|
|
188
205
|
}
|
|
189
206
|
}
|
|
190
207
|
/** The tracked custom environment `evalEnv` names, if it is a single one. */
|
|
@@ -352,8 +369,10 @@ function mayConfigure(graph, expr, environment) {
|
|
|
352
369
|
}
|
|
353
370
|
/** An evaluation is assumed to write the options and graphics state until we know what it evaluates (see `evaluatesCapturedCode`); a captured call then no longer needs the evaluation either, `eval(quote(x <- 1))` slices to `x <- 1`. */
|
|
354
371
|
function forgetStateWrites(graph, id, evaluatedElsewhere) {
|
|
372
|
+
/* printing the value it hands back at the top level is no assumption */
|
|
373
|
+
const printed = built_in_ambient_state_1.PrintWrites.filter(state => graph.ambientAccessOf(id)?.writes.has(state));
|
|
355
374
|
for (const [from, edge] of graph.edgesTo(id)) {
|
|
356
|
-
if (edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.Reads) && vertex_1.DfgVertex.isFunctionCall(graph.getVertex(from)) && !evaluatedElsewhere.has(from)) {
|
|
375
|
+
if (edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.Reads) && vertex_1.DfgVertex.isFunctionCall(graph.getVertex(from)) && !evaluatedElsewhere.has(from) && !printed.some(state => graph.ambientAccessOf(from)?.reads.has(state))) {
|
|
357
376
|
graph.removeEdgeType(from, id, edge_1.EdgeType.Reads);
|
|
358
377
|
}
|
|
359
378
|
}
|
package/dataflow/processor.d.ts
CHANGED
|
@@ -72,6 +72,8 @@ export interface DataflowProcessorInformation<OtherInfo> {
|
|
|
72
72
|
};
|
|
73
73
|
/** Where the top-level statements of every file start and end running, see {@link DataflowGraph#statementOrder} */
|
|
74
74
|
readonly statementOrder?: Map<NodeId, [start: number, end: number]>;
|
|
75
|
+
/** The statements left unanalyzed as they follow one that always exits, so walks over the AST can skip what never runs */
|
|
76
|
+
readonly unreachable?: Set<NodeId>;
|
|
75
77
|
}
|
|
76
78
|
export type DataflowProcessor<OtherInfo, NodeType extends RNodeWithParent<OtherInfo>> = (node: NodeType, data: DataflowProcessorInformation<OtherInfo>) => DataflowInformation;
|
|
77
79
|
type NodeWithKey<OtherInfo, Key> = RNode<OtherInfo & ParentInformation> & {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GeneralDocContext } from '../../wiki-mk/doc-context';
|
|
2
|
+
import type { KnownParser } from '../../../r-bridge/parser';
|
|
3
|
+
/** The wiki section on how ambient state is declared in the built-in configuration and tracked in the dataflow graph. */
|
|
4
|
+
export declare function ambientStateSection(parser: KnownParser, ctx: GeneralDocContext): Promise<string>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ambientStateSection = ambientStateSection;
|
|
4
|
+
const doc_dfg_1 = require("../../doc-util/doc-dfg");
|
|
5
|
+
const doc_code_1 = require("../../doc-util/doc-code");
|
|
6
|
+
const ambient_effect_1 = require("../../../dataflow/environments/ambient-effect");
|
|
7
|
+
const default_builtin_config_1 = require("../../../dataflow/environments/default-builtin-config");
|
|
8
|
+
/** a function's ambient accesses as a list, generated from its declaration */
|
|
9
|
+
function summaryOf(stated, name) {
|
|
10
|
+
const families = (0, default_builtin_config_1.statedSignatureOf)(stated, name)?.ambient ?? [];
|
|
11
|
+
return families.map(f => `${f.label}: ${f.accesses.map(a => `${a.label}${a.members.length > 0 ? ` (${a.members.join(', ')})` : ''}${a.when.length > 0 ? ` ${a.when.join(', ')}` : ''}`).join('; ')}`).join(' / ');
|
|
12
|
+
}
|
|
13
|
+
/** The wiki section on how ambient state is declared in the built-in configuration and tracked in the dataflow graph. */
|
|
14
|
+
async function ambientStateSection(parser, ctx) {
|
|
15
|
+
const stated = (0, default_builtin_config_1.statedSignatures)();
|
|
16
|
+
const families = Object.entries(ambient_effect_1.AmbientFamilyInfo);
|
|
17
|
+
const verbs = Object.entries(ambient_effect_1.AmbientVerbInfo);
|
|
18
|
+
const examples = ['png', 'plot', 'points', 'curve', 'dev.off', 'par', 'palette', 'sink', 'print', 'paste', 'options', 'getOption', 'Sys.setenv', 'set.seed', 'runif', 'setwd'];
|
|
19
|
+
return `
|
|
20
|
+
#### Declaring Ambient State
|
|
21
|
+
|
|
22
|
+
Every built-in states what it does to the global state in the default built-in configuration (${ctx.link('DefaultBuiltinConfig')}) as a list of ${ctx.link('AmbientEffect')}s.
|
|
23
|
+
An effect names a part of the state (its family), what the call does to it (its verb), and optionally the entries it is about (its member) and the arguments it depends on (\`when\` and \`unless\`).
|
|
24
|
+
The shorthands in ${ctx.link('Ambient')} keep each declaration to one line, so \`points\` adds to the plot and reads the graphics parameters and the palette, and \`sink\` opens a diversion unless it has no file and closes one otherwise:
|
|
25
|
+
|
|
26
|
+
${(0, doc_code_1.codeBlock)('ts', `/* shared-configs.ts */
|
|
27
|
+
const BasePlot = [Ambient.par.reads, Ambient.palette.reads] as const;
|
|
28
|
+
export const AddsToPlot = [Ambient.plot.adds, ...BasePlot] as const;
|
|
29
|
+
export const MayAddToPlot = [{ ...Ambient.plot.adds, when: { flag: 'add' } }, { ...Ambient.plot.resets, unless: { flag: 'add' } }, ...BasePlot] as const;
|
|
30
|
+
/* graphics-devices.ts */
|
|
31
|
+
fn(pkg(PkgName.GrDevices, 'dev.off'), BuiltInProcName.Default, { ambient: Ambient.device.closes, ... })
|
|
32
|
+
/* base-functions.ts */
|
|
33
|
+
fn(base('getOption'), BuiltInProcName.Default, { ambient: { ...Ambient.option.reads, member: { from: 'parameter', signature: ['x', 'default'], names: ['x'] } }, ... })`)}
|
|
34
|
+
|
|
35
|
+
The families and verbs, with the words the signature browser shows for them (both come from ${ctx.link('AmbientFamilyInfo')} and ${ctx.link('AmbientVerbInfo')}):
|
|
36
|
+
|
|
37
|
+
| Family | Label | What it is |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
${families.map(([family, words]) => `| \`${family}\` | ${words.label} | ${words.description} |`).join('\n')}
|
|
40
|
+
|
|
41
|
+
| Verb | Label | What it means |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
${verbs.map(([verb, words]) => `| \`${verb}\` | ${words.label} | ${words.description} |`).join('\n')}
|
|
44
|
+
|
|
45
|
+
A member says which entries of a keyed family the call is about: a constant list (\`print\` reads \`digits\`, \`scipen\`, and others), the names of the arguments (\`Sys.setenv(A = "1")\`), the unnamed arguments, or the argument of a parameter (\`Sys.getenv("HOME")\`).
|
|
46
|
+
For an instance family, the member \`every\` stands for every open instance, as \`dev.cur()\` reports.
|
|
47
|
+
A condition is \`no-arguments\`, \`query\` (only unnamed strings, as in \`par("mar")\`), a logical flag (\`add = TRUE\`), an argument for a formal with given values (\`type = "message"\`), or arguments beyond the leading formals (a kind for \`set.seed\`).
|
|
48
|
+
What the arguments do not decide, as a flag held in a variable, makes the effect a maybe one.
|
|
49
|
+
Tags imply more effects (see ${ctx.link('withImpliedAmbient')}): a call tagged as reading or writing a file accesses the files its resource arguments name, an appending write (an \`append\` formal set to \`TRUE\`) reads them first, and a printing call adds to the output sink.
|
|
50
|
+
|
|
51
|
+
To declare a new function, add its effects to its \`ambient\` field. To add a family, give it an ${ctx.link('AmbientPart')}, a row in ${ctx.link('AmbientFamilyInfo')}, and the pseudo variable it lives in, in the table of families of ${ctx.linkFile('applyAmbientEffects')}.
|
|
52
|
+
${ctx.link('ambientSummaryOf')} turns the declaration back into words, which is how these declarations read:
|
|
53
|
+
|
|
54
|
+
${examples.map(name => `- \`${name}\`: ${summaryOf(stated, name)}`).join('\n')}
|
|
55
|
+
|
|
56
|
+
#### Tracking Ambient State
|
|
57
|
+
|
|
58
|
+
Each part lives in global pseudo variables whose names start with \`#\` (${ctx.link('AmbientStateName')}), so a read links to the calls that may have set it like any variable read does.
|
|
59
|
+
Writes to accumulating parts (the plot, the output of a sink, the files, all options at once) are maybe definitions, so merging branches and loops keeps every one of them, while a reset (a new plot) or a write of a single entry (\`options(digits = 3)\` writes \`#option:digits\`) replaces what came before.
|
|
60
|
+
The graphics devices, the output sinks, and the message sink are instance families (${ctx.link('GraphicsDevices')}, ${ctx.link('OutputSinks')}, ${ctx.link('MessageSinks')}): every open instance has its own copy of the states, opening one moves the current copy to \`:other\`, and closing it brings another one back.
|
|
61
|
+
A close reads everything the closed instance holds, its opener and every drawing or printing in between, and it records the states it ends as \`kills\`.
|
|
62
|
+
The opener in turn reads the close, so a slice keeping the call that names the file also keeps the call that finishes it:
|
|
63
|
+
|
|
64
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(parser, 'png("a.png")\nplot(1)\npoints(2)\ndev.off()', { ctx })}
|
|
65
|
+
|
|
66
|
+
A call through a parameter, \`do.call\`, or an apply function runs with arguments flowR cannot see. Then every condition may hold, a reset only adds, nothing is known to be removed, and a close may close any instance.
|
|
67
|
+
A call to a function flowR knows nothing about reads all options, the environment variables, the random number generator (which it may advance), and with a graphics tag the graphics state.
|
|
68
|
+
A built-in generic that dispatches to a method of the program (\`print(x)\` running \`print.foo\`) changes the state as the calls within that method do, which slicing follows.
|
|
69
|
+
\`getOption("k")\` hands back the value the option was surely set to before, so value resolution sees \`3\` after \`options(k = 3)\`.
|
|
70
|
+
|
|
71
|
+
The rules come from comparing slices with the original programs in R, among them: printing a value of a class with a method of the program prints what the method prints, messages and warnings go to a sink of their own, \`sink(type = "output")\` closes like \`sink()\`, an appending write keeps what was written before, and \`invisible(...)\` stays around a kept call so a slice prints no more than the program.
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=doc-ambient.js.map
|
|
@@ -37,6 +37,7 @@ const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
|
37
37
|
const flowr_analyzer_context_1 = require("../project/context/flowr-analyzer-context");
|
|
38
38
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
39
39
|
const flowr_analyzer_1 = require("../project/flowr-analyzer");
|
|
40
|
+
const doc_ambient_1 = require("./data/dfg/doc-ambient");
|
|
40
41
|
const dfg_1 = require("../util/mermaid/dfg");
|
|
41
42
|
const mermaid_1 = require("../util/mermaid/mermaid");
|
|
42
43
|
const r_number_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
@@ -1070,7 +1071,13 @@ as they see fit.
|
|
|
1070
1071
|
|
|
1071
1072
|
Calls reading or changing global state (options, environment variables, the working directory, graphics devices, files, ...) are recorded in the graph with the pseudo variables (\`#option:digits\`, \`#wd\`, ...) they read and write (\`_ambientAccess\` if serialized as JSON).
|
|
1072
1073
|
Use \`Dataflow.sideEffects.ambientAccess(graph, scope)\` to aggregate this for a file, a block, or any other set of ids (including what the functions called there access) and \`Dataflow.sideEffects.ambientAccessOfFunctions(graph)\` for every function. All of them, just like \`graph.ambientAccessOf(id)\` for a single call, answer with an \`AmbientAccess\` that maps the accessed state to the ids of the calls accessing it.
|
|
1073
|
-
Graphics calls are reported as \`draws\`.
|
|
1074
|
+
Graphics calls are reported as \`draws\`.
|
|
1075
|
+
Beside the state code \`reads\`, \`writes\` (only \`assumed\` to write for a body flowR cannot see, or \`local\` to the current frame), the access lists what it \`kills\`: the state it ends, like \`dev.off()\` the active device, \`sink()\` the last diversion, or \`Sys.unsetenv("A")\` the variable.
|
|
1076
|
+
The graphics devices form a family of states, one set per open device (see ${ctx.link('GraphicsDevices')}): \`#graphics\` holds the graphics parameters, \`#device\` the calls that opened the device and drew on it (a plot opens one if none is open), and \`#plot\` the calls drawing its current plot.
|
|
1077
|
+
A plot like \`plot\` starts a new \`#plot\`, an addon like \`points\` reads and adds to it, and closing the device with \`dev.off\` reads all of \`#device\`, so it links to the opening and everything drawn in between, while the other open devices keep their states in \`#graphics:other\`, \`#device:other\`, and \`#plot:other\`.
|
|
1078
|
+
Set ${ctx.linkConfig('semantics.ambient.drawingWritesDevice')} to also let them write the pseudo variable \`#canvas\`, which models what is drawn on the device.
|
|
1079
|
+
|
|
1080
|
+
${await (0, doc_ambient_1.ambientStateSection)(treeSitter, ctx)}
|
|
1074
1081
|
|
|
1075
1082
|
The \`load\` call above degrades to an unknown side effect only because the file could not be found.
|
|
1076
1083
|
When the referenced \`.rda\`/\`.rdata\` file _is_ resolvable, flowR instead parses it natively (see ${ctx.link('RDAParser')}, supporting \`gzip\`- and \`bzip2\`-compressed files) and ${ctx.link('processLoadCall')} injects the loaded variable names into the dataflow graph as definitions, so subsequent uses resolve against them.
|
|
@@ -1079,11 +1086,10 @@ You can disable this and always treat \`load\` as an unknown side effect with th
|
|
|
1079
1086
|
#### Linked Unknown Side Effects
|
|
1080
1087
|
|
|
1081
1088
|
Not all side effects are created equal in the sense that they stem from a specific function call.
|
|
1082
|
-
Consider
|
|
1083
|
-
implicitly draws on the current device and does not explicitly link a function like \`points\` to the last call opening a new graphic device. In such a scenario, we use a linked side effect to mark the relation:
|
|
1089
|
+
Consider \`sink\`, which diverts all later output to a file, without \`print\` explicitly naming it. In such a scenario, we use a linked side effect to mark the relation:
|
|
1084
1090
|
|
|
1085
1091
|
${await (async () => {
|
|
1086
|
-
const [result, df] = await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, '
|
|
1092
|
+
const [result, df] = await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'sink("out.txt")\nprint(data)', { exposeResult: true, ctx });
|
|
1087
1093
|
return `
|
|
1088
1094
|
${result}
|
|
1089
1095
|
|
|
@@ -69,6 +69,14 @@ theme(panel.grid = element_line(size = 1))
|
|
|
69
69
|
example: `
|
|
70
70
|
read.csv("https://example.com/data.csv")
|
|
71
71
|
download.file("https://foo.bar")
|
|
72
|
+
`
|
|
73
|
+
},
|
|
74
|
+
'interactive-functions': {
|
|
75
|
+
configType: 'InteractiveFunctionsConfig', ruleType: 'INTERACTIVE_FUNCTIONS', testfile: 'lint-interactive-functions',
|
|
76
|
+
example: `
|
|
77
|
+
p <- penguins
|
|
78
|
+
View(p)
|
|
79
|
+
if(interactive()) browser()
|
|
72
80
|
`
|
|
73
81
|
},
|
|
74
82
|
'file-path-validity': {
|
|
@@ -134,6 +142,10 @@ scale_it <- function(values) {
|
|
|
134
142
|
configType: 'UselessLoopConfig', ruleType: 'USELESS_LOOP', testfile: 'lint-useless-loop',
|
|
135
143
|
example: 'for(i in c(1)) { print(i) }'
|
|
136
144
|
},
|
|
145
|
+
'call-contracts': {
|
|
146
|
+
configType: 'CallContractsConfig', ruleType: 'CALL_CONTRACTS', testfile: 'lint-call-contracts',
|
|
147
|
+
example: 'f <- function(x, n) { stopifnot(length(x) >= n); x }\nf(1:3, 5)\ng <- function(how = c("fast", "exact")) match.arg(how)\ng("slow")\ncombn(4, -1)\nstrsplit(1, "a")'
|
|
148
|
+
},
|
|
137
149
|
'stop-call': {
|
|
138
150
|
configType: 'StopWithCallConfig', ruleType: 'STOP_WITH_CALL_ARG', testfile: 'lint-stop-call',
|
|
139
151
|
example: 'f <- function(x) stop(x)'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WikiQuery = void 0;
|
|
4
|
+
const r_base_guards_generated_1 = require("../data/r-base-guards.generated");
|
|
4
5
|
const clone_detector_1 = require("../clones/clone-detector");
|
|
5
6
|
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
6
7
|
const flowr_analyzer_1 = require("../project/flowr-analyzer");
|
|
@@ -290,6 +291,90 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'inspect-fn-prop
|
|
|
290
291
|
`;
|
|
291
292
|
}
|
|
292
293
|
});
|
|
294
|
+
(0, doc_query_1.registerQueryDocumentation)('inspect-fn-guards', {
|
|
295
|
+
type: 'active',
|
|
296
|
+
shortDescription: 'Infer what functions ask of the calls they return from',
|
|
297
|
+
buildExplanation: async (shell, ctx) => {
|
|
298
|
+
const exampleCode = 'f <- function(x, n, type = c("a", "b")) {\n type <- match.arg(type)\n if(!is.numeric(x) || x < 0) stop("invalid x")\n if(length(x) < n) stop("x is too short")\n sum(x)\n}';
|
|
299
|
+
const predicateConfig = `new FlowrAnalyzerBuilder().amendConfig(c => {
|
|
300
|
+
c.semantics.environment.overwriteBuiltIns.definitions = [{
|
|
301
|
+
type: 'function', names: ['is_text'], processor: BuiltInProcName.DefaultReadAllArgs,
|
|
302
|
+
config: { guards: { is_text: { predicate: { yes: RValueType.Character, exact: true } } } }
|
|
303
|
+
}];
|
|
304
|
+
})`;
|
|
305
|
+
return `
|
|
306
|
+
This query works out the *contract* of every function of a program: what a call has to fulfill to return normally, read off the checks in the body.
|
|
307
|
+
In the example below, \`f\` stops unless \`x\` is a non-negative number at least \`n\` long, and \`match.arg\` only lets \`type\` be \`"a"\` or \`"b"\`.
|
|
308
|
+
The query states exactly that: per formal what a call has to give and what holds of it, and what relates several formals, like \`length(x) >= n\`:
|
|
309
|
+
|
|
310
|
+
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'inspect-fn-guards' }], { showCode: true, ctx })}
|
|
311
|
+
|
|
312
|
+
### Where the contracts are used
|
|
313
|
+
|
|
314
|
+
- the \`call-contracts\` linting rule reports a call that cannot fulfill the contract of what it calls, like \`f(-1)\` or \`f("a")\`
|
|
315
|
+
- the ${(0, doc_query_1.linkToQueryOfName)('inspect-fn-props')} reports the formals a call has to supply (${ctx.linkE('ArgProp', 'Required')}) and those a condition reads (${ctx.linkE('ArgProp', 'Guarded')})
|
|
316
|
+
- the ${(0, doc_query_1.linkToQueryOfName)('signature')} and the [signature browser](https://flowr-analysis.github.io/flowr/wiki/sigdb/) show the contracts of the functions of R and of packages
|
|
317
|
+
- the playground shows the contract of the function under the cursor
|
|
318
|
+
|
|
319
|
+
### Reading the result
|
|
320
|
+
|
|
321
|
+
Each function the program defines gets ${ctx.link('FunctionGuards')}:
|
|
322
|
+
|
|
323
|
+
- ${ctx.link('FunctionGuards::clauses')}: one ${ctx.link('GuardClause')} per check, with the condition as R code and as a ${ctx.link('GuardTerm')} tree (\`succeeds(e)\` stands for \`e\` not raising an error), whether R checks it itself (\`implicit\`, like \`x + 1\` for a value that is no number) or the code does (\`explicit\`, like the \`stop\` above), and the message of the failure
|
|
324
|
+
- ${ctx.link('FunctionGuards::formals')}: what the conditions together claim of each formal, as a ${ctx.link('FormalClaim')}:
|
|
325
|
+
|
|
326
|
+
| field | a normal return makes sure that |
|
|
327
|
+
|---|---|
|
|
328
|
+
| \`types\` | \`typeof(x)\` is one of these |
|
|
329
|
+
| \`unclassedTypes\` | the same, but only for an \`x\` without a class (a classed one may bring its own method) |
|
|
330
|
+
| \`values\`, \`partial\` | \`x\` is one of these strings, or with \`partial\` abbreviates one (\`match.arg\`) |
|
|
331
|
+
| \`classes\` | \`x\` inherits from one of these |
|
|
332
|
+
| \`bounds\` | \`x\` (\`value\`), \`length(x)\`, \`nchar(x)\`, \`nrow(x)\`, ... lie in this range |
|
|
333
|
+
| \`whole\`, \`notNA\`, \`callable\` | \`trunc(x) == x\`, \`!anyNA(x)\`, \`x\` is or names a function |
|
|
334
|
+
| \`resolves\` | a name built from \`x\`, like \`paste0("f_", x)\`, exists |
|
|
335
|
+
| \`cases\` | what holds in each case a branch on \`x\` tells apart, like \`if(is.logical(center)) ... else ...\` |
|
|
336
|
+
|
|
337
|
+
- ${ctx.link('FunctionGuards::relations')}: what relates several formals, like \`length(x) >= n\`, each with the formals it speaks of and what lets a call through anyway (\`unless\`)
|
|
338
|
+
- ${ctx.link('FunctionGuards::conditional')}: what holds of a formal unless something about the others lets the call through, like \`m\` having to be a number unless \`x\` is no count
|
|
339
|
+
- ${ctx.link('FunctionGuards::returns')}: what holds of the value a call returns normally
|
|
340
|
+
- ${ctx.link('FunctionGuards::conditions')}: per formal the checks as they read in R, also those no claim has a word for, like \`stopifnot(x %% 2 == 0)\`
|
|
341
|
+
- ${ctx.link('FunctionGuards::required')}: the formals a call has to supply
|
|
342
|
+
- ${ctx.link('FunctionGuards::pure')}: the checks that fail before the function does anything but compute, so a call failing on them leaves nothing behind
|
|
343
|
+
|
|
344
|
+
The query takes \`kind\` (keep only \`implicit\` or \`explicit\` conditions), \`onlyPure\`, \`formals\` (only these formals), and \`builtIns\` (also state the contracts of the functions of R and of the packages flowR knows).
|
|
345
|
+
|
|
346
|
+
### What counts as a check
|
|
347
|
+
|
|
348
|
+
- \`stop\`, \`rlang::abort\`, and every other function that always fails, reached under \`if\`, \`&&\`, \`||\`, and \`switch\`, taking an earlier \`return\` into account: \`if(a) return(1); if(!is.numeric(x)) stop()\` asks \`a || is.numeric(x)\`
|
|
349
|
+
- \`stopifnot\`, \`assertthat::assert_that\`, \`match.arg\`, \`rlang::arg_match\`, and the \`assert_*\` functions of \`checkmate\`
|
|
350
|
+
- what R fails on by itself, like \`strsplit\` for anything but a character vector
|
|
351
|
+
- names that have to resolve, like \`do.call(paste0("f_", x), list())\`, and a \`UseMethod\` without a default method
|
|
352
|
+
- the methods a dispatch may run: a generic asks what its \`default\` method (or that of an implicit class like \`matrix\`) asks, unless \`is.object(x)\`
|
|
353
|
+
- the contracts of the functions a body surely calls, in terms of what it hands them, and predicates of the program like \`is_count <- function(v) is.numeric(v) && v >= 0\`
|
|
354
|
+
|
|
355
|
+
### Teaching flowR about more functions
|
|
356
|
+
|
|
357
|
+
A contract can only be as good as what flowR knows about the functions a body calls. There are three places to add that knowledge:
|
|
358
|
+
|
|
359
|
+
1. **A predicate or check of your own code base, without changing flowR.** Describe it in the configuration of the analyzer (the same \`overwriteBuiltIns\` works in a configuration file). With this, \`f <- function(x) { stopifnot(is_text(x)); x }\` claims that \`x\` is a character vector:
|
|
360
|
+
|
|
361
|
+
${(0, doc_code_1.codeBlock)('ts', predicateConfig)}
|
|
362
|
+
|
|
363
|
+
Besides \`predicate\`, the guard facts can state \`asks\` (what the function fails on per formal), \`required\` (formals a call has to give), \`check\` (the function fails unless its argument passes, like \`checkmate::assert_numeric\`), \`asserts\` (it fails unless every argument is \`TRUE\`, like \`stopifnot\`), and \`returns\`. All of them are typed in \`src/dataflow/environments/guard-facts.ts\`.
|
|
364
|
+
2. **A function of R or a package that flowR should know for everyone.** Add its guard facts to the built-in configuration: \`src/dataflow/environments/default-builtin-config/guards.ts\` for functions of base R and packages, \`guards-primitive-ops.ts\` for the operators and math primitives. For example \`'which': { asks: { x: fails(is('is.logical'), 'argument to \\'which\\' is not logical') } }\` makes every \`which(x)\` ask for a logical \`x\`.
|
|
365
|
+
3. **The closures of the base packages.** Their contracts are read off R itself with \`npx ts-node --transpile-only scripts/gen-base-guards.ts\`, which writes \`src/data/r-base-guards.generated.ts\` (currently from R ${r_base_guards_generated_1.RBaseGuardsVersion}). Rerun it after changing what flowR knows, as the base contracts are built on top of that knowledge.
|
|
366
|
+
|
|
367
|
+
### Limits
|
|
368
|
+
|
|
369
|
+
Every condition the query reports is *necessary*: a call that breaks one fails in R. What flowR cannot state exactly (a loop body, a variable with several definitions, a function it does not know) weakens a condition or drops it, it never makes one stronger than what the code asks for.
|
|
370
|
+
|
|
371
|
+
- A condition speaks of the value at the check, so a formal overwritten before it is read as what it was overwritten with.
|
|
372
|
+
- A default value claims nothing: \`function(n = 5L)\` still takes \`n = 1.5\`. Only \`match.arg\` and \`rlang::arg_match\` read the default, as the values they allow.
|
|
373
|
+
- What R fails on depends on the R version flowR assumes (\`solver.sigdb.assumedRVersion\`, else R ${r_base_guards_generated_1.RBaseGuardsVersion}): a condition of \`if\` longer than one only fails since R 4.2.0, an operand of \`&&\` longer than one since R 4.3.0.
|
|
374
|
+
- A missing argument handed on to another function written in R is only required if that function needs it, as R hands it on as a promise: \`matpoints(x)\` passes its missing \`y\` to \`matplot\`, which checks \`missing(y)\`.
|
|
375
|
+
`;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
293
378
|
(0, doc_query_1.registerQueryDocumentation)('inspect-exception', {
|
|
294
379
|
type: 'active',
|
|
295
380
|
shortDescription: 'Determine whether functions throw exceptions (known to flowR)',
|
|
@@ -590,7 +675,8 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({ inputSources: {
|
|
|
590
675
|
const DependencyRoles = [
|
|
591
676
|
['Inputs', ['library', 'remote', 'source', 'read']],
|
|
592
677
|
['Outputs', ['write', 'visualize']],
|
|
593
|
-
['What the script does with data', ['transform', 'statistics', 'test']]
|
|
678
|
+
['What the script does with data', ['transform', 'statistics', 'test']],
|
|
679
|
+
['What only works in an interactive session', ['interactive']]
|
|
594
680
|
];
|
|
595
681
|
/** the categories and the values they report, generated from the categories the query knows */
|
|
596
682
|
function dependencyOverview(ctx, categories) {
|
|
@@ -786,6 +872,31 @@ All locations are given as a ${ctx.link('SourceRange')} paired with the file id
|
|
|
786
872
|
`;
|
|
787
873
|
}
|
|
788
874
|
});
|
|
875
|
+
(0, doc_query_1.registerQueryDocumentation)('data-columns', {
|
|
876
|
+
type: 'active',
|
|
877
|
+
shortDescription: 'Returns the columns of a data frame that can be written at a position, as an editor offers them to complete.',
|
|
878
|
+
buildExplanation: async (shell, ctx) => {
|
|
879
|
+
const exampleCode = 'library(dplyr)\npenguins |> filter(year > 2008, bi)';
|
|
880
|
+
return `
|
|
881
|
+
Editors complete names, and within code that works on a data frame the names worth offering are often its columns:
|
|
882
|
+
after \`df$\`, but also in every argument a call evaluates within its data, as \`filter\`, \`mutate\`, \`subset\`, \`with\`, or \`aes\` do.
|
|
883
|
+
flowR knows which arguments a call evaluates that way (they are _quoted_ in the dataflow graph), so this works for every such call,
|
|
884
|
+
not just for a fixed list of them. The data frame is another argument of that call, the left side of a pipe into it, or, for a layer
|
|
885
|
+
like \`geom_point(aes(...))\`, an argument of what it is added to. Its columns come from the ${(0, doc_query_1.linkToQueryOfName)('absint')} of data frame shapes,
|
|
886
|
+
which also knows the data sets R finds as lazy data, like \`penguins\` of \`datasets\` or \`starwars\` of \`dplyr\` (once loaded, or as \`dplyr::starwars\`).
|
|
887
|
+
|
|
888
|
+
Consider the following code, with the cursor just after the \`bi\` (line 2, column 34):
|
|
889
|
+
|
|
890
|
+
${(0, doc_code_1.codeBlock)('r', exampleCode)}
|
|
891
|
+
|
|
892
|
+
The query asks for the columns at that position:
|
|
893
|
+
|
|
894
|
+
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'data-columns', positions: ['2:34'] }], { showCode: false, shorthand: (0, doc_query_1.sliceQueryShorthand)(['2:34'], (0, doc_escape_1.escapeNewline)(exampleCode)), ctx })}
|
|
895
|
+
|
|
896
|
+
The position has to fall within a node. An editor completing a name not typed yet, as in \`filter(penguins, )\`, inserts a placeholder name at the cursor first.
|
|
897
|
+
`;
|
|
898
|
+
}
|
|
899
|
+
});
|
|
789
900
|
(0, doc_query_1.registerQueryDocumentation)('dice', {
|
|
790
901
|
type: 'active',
|
|
791
902
|
shortDescription: 'Reduces the code to the parts that carry information from a given start point to a given end point.',
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -218,8 +218,8 @@ export declare const LintingRules: {
|
|
|
218
218
|
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, useLessLoopConfig: import("./rules/useless-loop").UselessLoopConfig, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
|
|
219
219
|
results: {
|
|
220
220
|
name: string;
|
|
221
|
-
certainty: import("./linter-format").LintingResultCertainty;
|
|
222
221
|
loc: import("..").SourceLocation;
|
|
222
|
+
certainty: import("./linter-format").LintingResultCertainty;
|
|
223
223
|
involvedId: import("..").NodeId | import("..").NodeId[] | undefined;
|
|
224
224
|
}[];
|
|
225
225
|
'.meta': {
|
|
@@ -1214,6 +1214,46 @@ export declare const LintingRules: {
|
|
|
1214
1214
|
};
|
|
1215
1215
|
};
|
|
1216
1216
|
};
|
|
1217
|
+
readonly 'call-contracts': {
|
|
1218
|
+
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
1219
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, _config: import("../util/objects").MergeableRecord, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
|
|
1220
|
+
results: import("./rules/call-contracts").CallContractsResult[];
|
|
1221
|
+
'.meta': {
|
|
1222
|
+
checkedCalls: number;
|
|
1223
|
+
};
|
|
1224
|
+
}>;
|
|
1225
|
+
readonly prettyPrint: {
|
|
1226
|
+
readonly query: (r: import("./rules/call-contracts").CallContractsResult, metadata: unknown) => string;
|
|
1227
|
+
readonly full: (r: import("./rules/call-contracts").CallContractsResult, metadata: unknown) => string;
|
|
1228
|
+
};
|
|
1229
|
+
readonly info: {
|
|
1230
|
+
readonly name: "Call Contracts";
|
|
1231
|
+
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Robustness];
|
|
1232
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
1233
|
+
readonly description: "Finds calls that hand a function a value its contract rules out, or leave out an argument it needs, so they fail whenever they run.";
|
|
1234
|
+
readonly defaultConfig: () => {};
|
|
1235
|
+
};
|
|
1236
|
+
};
|
|
1237
|
+
readonly 'interactive-functions': {
|
|
1238
|
+
readonly createSearch: (config: import("./rules/interactive-functions").InteractiveFunctionsConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
1239
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/interactive-functions").InteractiveFunctionsConfig, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
|
|
1240
|
+
results: import("./rules/function-finder-util").FunctionsResult[];
|
|
1241
|
+
'.meta': import("./rules/function-finder-util").FunctionsMetadata;
|
|
1242
|
+
}>;
|
|
1243
|
+
readonly prettyPrint: {
|
|
1244
|
+
readonly query: (r: import("./rules/function-finder-util").FunctionsResult, metadata: unknown) => string;
|
|
1245
|
+
readonly full: (r: import("./rules/function-finder-util").FunctionsResult, metadata: unknown) => string;
|
|
1246
|
+
};
|
|
1247
|
+
readonly info: {
|
|
1248
|
+
readonly name: "Interactive Functions";
|
|
1249
|
+
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Reproducibility, import("./linter-tags").LintingRuleTag.Smell, import("./linter-tags").LintingRuleTag.Robustness];
|
|
1250
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
1251
|
+
readonly description: "Finds calls that only do their job in an interactive session, such as `View`, `edit`, `browser`, or `debug`, left in a script, where `Rscript` skips or stops at them. A call in the branch an `interactive()` check takes is fine, one within a function is uncertain, as the function may only be meant for interactive use.";
|
|
1252
|
+
readonly defaultConfig: (ctx: import("../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext) => {
|
|
1253
|
+
fns: readonly import("..").Identifier[];
|
|
1254
|
+
};
|
|
1255
|
+
};
|
|
1256
|
+
};
|
|
1217
1257
|
};
|
|
1218
1258
|
export type LintingRuleNames = keyof typeof LintingRules;
|
|
1219
1259
|
/** the rule registered under the name, typed by what its name stands for */
|
package/linter/linter-rules.js
CHANGED
|
@@ -46,7 +46,9 @@ const package_data_1 = require("./rules/cmd-check/package-data");
|
|
|
46
46
|
const package_runtime_1 = require("./rules/cmd-check/package-runtime");
|
|
47
47
|
const secret_exfiltration_1 = require("./rules/secret-exfiltration");
|
|
48
48
|
const process_state_in_session_1 = require("./rules/process-state-in-session");
|
|
49
|
+
const interactive_functions_1 = require("./rules/interactive-functions");
|
|
49
50
|
const code_clones_1 = require("./rules/code-clones");
|
|
51
|
+
const call_contracts_1 = require("./rules/call-contracts");
|
|
50
52
|
/**
|
|
51
53
|
* The registry of currently supported linting rules.
|
|
52
54
|
* A linting rule can be executed on a dataflow pipeline result using {@link executeLintingRule}.
|
|
@@ -96,7 +98,9 @@ exports.LintingRules = {
|
|
|
96
98
|
'package-runtime': package_runtime_1.PACKAGE_RUNTIME,
|
|
97
99
|
'secret-exfiltration': secret_exfiltration_1.SECRET_EXFILTRATION,
|
|
98
100
|
'process-state-in-session': process_state_in_session_1.PROCESS_STATE_IN_SESSION,
|
|
99
|
-
'code-clones': code_clones_1.CODE_CLONES
|
|
101
|
+
'code-clones': code_clones_1.CODE_CLONES,
|
|
102
|
+
'call-contracts': call_contracts_1.CALL_CONTRACTS,
|
|
103
|
+
'interactive-functions': interactive_functions_1.INTERACTIVE_FUNCTIONS
|
|
100
104
|
};
|
|
101
105
|
/** the rule registered under the name, typed by what its name stands for */
|
|
102
106
|
function getLintingRule(name) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
2
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
3
|
+
import { LintingRuleTag } from '../linter-tags';
|
|
4
|
+
import { Identifier } from '../../dataflow/environments/identifier';
|
|
5
|
+
export interface CallContractsResult extends LintingResult {
|
|
6
|
+
/** the function called */
|
|
7
|
+
readonly function: Identifier;
|
|
8
|
+
/** what the call breaks of what the function asks for, each condition in R syntax with the values the call hands over, see {@link CallContracts.describe} */
|
|
9
|
+
readonly broken: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export type CallContractsConfig = MergeableRecord;
|
|
12
|
+
export interface CallContractsMetadata extends MergeableRecord {
|
|
13
|
+
/** calls of a function flowR knows a contract of */
|
|
14
|
+
readonly checkedCalls: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Finds calls that hand a function a value its contract rules out, like `combn(4, -1)` for `m >= 0`, or that leave out an
|
|
18
|
+
* argument it needs: such a call fails whenever it runs. The conditions of the guards of the callee are taken to the call
|
|
19
|
+
* as the guard analysis takes them to a caller, and are only reported if they fail for every value the arguments may hold.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CALL_CONTRACTS: {
|
|
22
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
23
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, _config: MergeableRecord, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
24
|
+
results: CallContractsResult[];
|
|
25
|
+
'.meta': {
|
|
26
|
+
checkedCalls: number;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
readonly prettyPrint: {
|
|
30
|
+
readonly query: (r: CallContractsResult, metadata: unknown) => string;
|
|
31
|
+
readonly full: (r: CallContractsResult, metadata: unknown) => string;
|
|
32
|
+
};
|
|
33
|
+
readonly info: {
|
|
34
|
+
readonly name: "Call Contracts";
|
|
35
|
+
readonly tags: readonly [LintingRuleTag.Bug, LintingRuleTag.Robustness];
|
|
36
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
37
|
+
readonly description: "Finds calls that hand a function a value its contract rules out, or leave out an argument it needs, so they fail whenever they run.";
|
|
38
|
+
readonly defaultConfig: () => {};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CALL_CONTRACTS = void 0;
|
|
4
|
+
const linter_format_1 = require("../linter-format");
|
|
5
|
+
const range_1 = require("../../util/range");
|
|
6
|
+
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
7
|
+
const linter_tags_1 = require("../linter-tags");
|
|
8
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
9
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
10
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
11
|
+
const call_contracts_1 = require("../../dataflow/fn/guards/call-contracts");
|
|
12
|
+
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
13
|
+
const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
|
|
14
|
+
/**
|
|
15
|
+
* Finds calls that hand a function a value its contract rules out, like `combn(4, -1)` for `m >= 0`, or that leave out an
|
|
16
|
+
* argument it needs: such a call fails whenever it runs. The conditions of the guards of the callee are taken to the call
|
|
17
|
+
* as the guard analysis takes them to a caller, and are only reported if they fail for every value the arguments may hold.
|
|
18
|
+
*/
|
|
19
|
+
exports.CALL_CONTRACTS = {
|
|
20
|
+
createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall).with(search_enrichers_1.Enrichment.CfgInformation, {
|
|
21
|
+
checkReachable: true,
|
|
22
|
+
simplificationPasses: [...cfg_simplification_1.DefaultCfgSimplificationOrder, 'analyze-dead-code']
|
|
23
|
+
}),
|
|
24
|
+
processSearchResult: async (elements, _config, data) => {
|
|
25
|
+
const { graph } = await data.dataflow();
|
|
26
|
+
const scope = call_contracts_1.CallContracts.of(graph, data.inspectContext(), graph.idMap ?? (await data.normalize()).idMap);
|
|
27
|
+
let checkedCalls = 0;
|
|
28
|
+
const results = [];
|
|
29
|
+
for (const element of elements.getElements()) {
|
|
30
|
+
const id = element.node.info.id;
|
|
31
|
+
const vertex = graph.getVertex(id);
|
|
32
|
+
if (!vertex_1.DfgVertex.isFunctionCall(vertex) || (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CfgInformation)?.isReachable === false || df_helper_1.Dataflow.isWithinQuoted(id, graph)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const checked = call_contracts_1.CallContracts.check(id, scope);
|
|
36
|
+
if (checked === undefined) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
checkedCalls++;
|
|
40
|
+
const loc = range_1.SourceLocation.fromNode(element.node);
|
|
41
|
+
if (checked.breaches.length > 0 && loc !== undefined) {
|
|
42
|
+
results.push({ certainty: linter_format_1.LintingResultCertainty.Uncertain, involvedId: id, loc, function: vertex.name, broken: checked.breaches.map(call_contracts_1.CallContracts.describe) });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { results, '.meta': { checkedCalls } };
|
|
46
|
+
},
|
|
47
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `call of \`${identifier_1.Identifier.toString(result.function)}\` fails its contract at ${range_1.SourceLocation.format(result.loc)}`, result => `The call of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)} fails whenever it runs: ${result.broken.join('; ')}.`),
|
|
48
|
+
info: {
|
|
49
|
+
name: 'Call Contracts',
|
|
50
|
+
tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Robustness],
|
|
51
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
52
|
+
description: 'Finds calls that hand a function a value its contract rules out, or leave out an argument it needs, so they fail whenever they run.',
|
|
53
|
+
defaultConfig: () => ({})
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=call-contracts.js.map
|
|
@@ -30,7 +30,7 @@ exports.BOGUS_RETURN = {
|
|
|
30
30
|
const vertex = graph.getVertex(node.info.id);
|
|
31
31
|
const loc = range_1.SourceLocation.fromNode(node);
|
|
32
32
|
const targets = vertex_1.DfgVertex.isUse(vertex) ? df_helper_1.Dataflow.targetsOf(graph, node.info.id, edge_1.EdgeType.Reads) : [];
|
|
33
|
-
if (loc === undefined || targets.length === 0 || !targets.every(t => node_id_1.NodeId.isBuiltIn(t) && node_id_1.NodeId.fromBuiltIn(t) === 'return') ||
|
|
33
|
+
if (loc === undefined || targets.length === 0 || !targets.every(t => node_id_1.NodeId.isBuiltIn(t) && node_id_1.NodeId.fromBuiltIn(t) === 'return') || df_helper_1.Dataflow.isWithinQuoted(node.info.id, graph)) {
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
const fn = idMap.get(model_1.RNode.findEnclosing(node.info.id, idMap, r_function_definition_1.RFunctionDefinition.is) ?? '');
|