@eagleoutice/flowr 2.16.2 → 2.16.3
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 +10 -10
- package/abstract-interpretation/data-frame/arguments.js +4 -3
- package/abstract-interpretation/data-frame/dataframe-semantics.js +1 -2
- package/abstract-interpretation/data-frame/semantics.d.ts +2 -2
- package/abstract-interpretation/data-frame/semantics.js +2 -6
- package/benchmark/slicer.js +1 -3
- package/benchmark/summarizer/first-phase/input.js +1 -12
- package/benchmark/summarizer/second-phase/process.d.ts +7 -0
- package/benchmark/summarizer/second-phase/process.js +15 -12
- package/cli/repl/commands/repl-cfg.js +18 -49
- package/cli/repl/commands/repl-clipboard.d.ts +2 -0
- package/cli/repl/commands/repl-clipboard.js +5 -0
- package/cli/repl/commands/repl-commands.js +2 -2
- package/cli/repl/commands/repl-dataflow.js +21 -55
- package/cli/repl/commands/repl-normalize.js +15 -28
- package/cli/repl/commands/repl-parse.js +2 -2
- package/cli/repl/commands/repl-query.js +10 -10
- package/cli/repl/commands/repl-signature.js +4 -4
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +8 -30
- package/cli/repl/server/messages/message-analysis.js +1 -1
- package/config.d.ts +6 -0
- package/config.js +7 -4
- package/control-flow/cfg-dead-code.js +5 -14
- package/control-flow/cfg-to-basic-blocks.js +1 -6
- package/control-flow/control-flow-graph.d.ts +2 -16
- package/control-flow/control-flow-graph.js +8 -66
- package/control-flow/diff-cfg.js +10 -23
- package/control-flow/semantic-cfg-guided-visitor.js +5 -11
- package/control-flow/simple-visitor.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +138 -138
- package/data/r-base-packages.generated.js +0 -1
- package/data/r-base-primitives.generated.js +0 -1
- package/data/r-s3-generics.generated.d.ts +5 -0
- package/data/r-s3-generics.generated.js +103 -0
- package/dataflow/cluster.js +2 -1
- package/dataflow/environments/append.d.ts +1 -0
- package/dataflow/environments/built-in-props.d.ts +10 -0
- package/dataflow/environments/built-in-props.js +25 -1
- package/dataflow/environments/built-in.js +15 -9
- package/dataflow/environments/clone.d.ts +1 -0
- package/dataflow/environments/clone.js +1 -0
- package/dataflow/environments/default-builtin-config.d.ts +188 -14
- package/dataflow/environments/default-builtin-config.js +125 -65
- package/dataflow/environments/define.d.ts +1 -0
- package/dataflow/environments/define.js +1 -0
- package/dataflow/environments/environment.d.ts +27 -0
- package/dataflow/environments/environment.js +37 -16
- package/dataflow/environments/frame-memory.d.ts +9 -1
- package/dataflow/environments/frame-memory.js +12 -1
- package/dataflow/environments/identifier.d.ts +0 -2
- package/dataflow/environments/identifier.js +5 -7
- package/dataflow/environments/overwrite.js +1 -0
- package/dataflow/environments/query-fn-props.js +2 -3
- package/dataflow/environments/scoping.d.ts +3 -0
- package/dataflow/environments/scoping.js +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +3 -3
- package/dataflow/eval/resolve/resolve-argument.d.ts +7 -3
- package/dataflow/eval/resolve/resolve-argument.js +16 -11
- package/dataflow/eval/resolve/resolve-numbers.js +5 -2
- package/dataflow/eval/resolve/resolve-strings.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -2
- package/dataflow/eval/resolve/resolve.js +1 -2
- package/dataflow/eval/values/intervals/interval-constants.js +1 -6
- package/dataflow/eval/values/r-value.js +1 -6
- package/dataflow/extractor.js +17 -17
- package/dataflow/fn/argument-roles.js +15 -15
- package/dataflow/fn/class-declaration.js +7 -7
- package/dataflow/fn/frame-reflection.d.ts +1 -23
- package/dataflow/fn/frame-reflection.js +8 -95
- package/dataflow/fn/function-props.d.ts +0 -3
- package/dataflow/fn/function-props.js +9 -11
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/fn/strict-function.js +15 -14
- package/dataflow/graph/call-graph.d.ts +8 -0
- package/dataflow/graph/call-graph.js +40 -25
- package/dataflow/graph/dataflowgraph-builder.d.ts +0 -60
- package/dataflow/graph/dataflowgraph-builder.js +15 -135
- package/dataflow/graph/df-helper.d.ts +56 -4
- package/dataflow/graph/df-helper.js +116 -1
- package/dataflow/graph/diff-dataflow-graph.js +13 -15
- package/dataflow/graph/graph-helper.d.ts +20 -0
- package/dataflow/graph/graph-helper.js +18 -0
- package/dataflow/graph/graph.js +3 -8
- package/dataflow/graph/match-args.d.ts +1 -1
- package/dataflow/graph/match-args.js +3 -3
- package/dataflow/internal/linker.d.ts +4 -10
- package/dataflow/internal/linker.js +21 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +39 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +6 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +27 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +33 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +7 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +5 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +36 -38
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +6 -7
- package/dataflow/internal/process/functions/call/deferred.js +8 -8
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +11 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +11 -7
- package/dataflow/internal/process/functions/call/named-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/nse.js +4 -4
- package/dataflow/internal/process/functions/call/quoted.js +16 -14
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
- package/dataflow/internal/process/functions/process-parameter.js +2 -2
- package/dataflow/internal/process/process-named-call.js +1 -1
- package/dataflow/origin/dfg-get-origin.js +2 -2
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -0
- package/dataflow/origin/dfg-get-symbol-refs.js +3 -8
- package/documentation/data/faq/wiki-faq-store.js +2 -2
- package/documentation/doc-capabilities.js +2 -1
- package/documentation/doc-util/doc-functions.js +2 -2
- package/documentation/doc-util/doc-repl.js +4 -4
- package/documentation/doc-util/doc-types.js +2 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-cfg.js +2 -1
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-dataflow-graph.js +6 -6
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.js +54 -4
- package/documentation/wiki-mk/doc-maker.js +1 -2
- package/documentation/wiki-query.js +25 -0
- package/documentation/wiki-search.js +2 -1
- package/documentation/wiki-signature-database.js +0 -2
- package/linter/linter-executor.js +4 -0
- package/linter/linter-rules.d.ts +518 -1
- package/linter/linter-rules.js +39 -1
- package/linter/linter-tags.d.ts +6 -0
- package/linter/linter-tags.js +6 -0
- package/linter/rules/absolute-path.js +4 -3
- package/linter/rules/cmd-check/bogus-return.d.ts +29 -0
- package/linter/rules/cmd-check/bogus-return.js +63 -0
- package/linter/rules/cmd-check/call-arguments.d.ts +63 -0
- package/linter/rules/cmd-check/call-arguments.js +211 -0
- package/linter/rules/cmd-check/class-string-comparison.d.ts +48 -0
- package/linter/rules/cmd-check/class-string-comparison.js +135 -0
- package/linter/rules/cmd-check/cmd-check-util.d.ts +67 -0
- package/linter/rules/cmd-check/cmd-check-util.js +169 -0
- package/linter/rules/cmd-check/compiled-code.d.ts +86 -0
- package/linter/rules/cmd-check/compiled-code.js +350 -0
- package/linter/rules/cmd-check/conformance.d.ts +47 -0
- package/linter/rules/cmd-check/conformance.js +166 -0
- package/linter/rules/cmd-check/dependency-declaration.d.ts +95 -0
- package/linter/rules/cmd-check/dependency-declaration.js +299 -0
- package/linter/rules/cmd-check/description-metadata.d.ts +63 -0
- package/linter/rules/cmd-check/description-metadata.js +393 -0
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +54 -0
- package/linter/rules/cmd-check/documentation-mismatch.js +407 -0
- package/linter/rules/cmd-check/file-checks.d.ts +29 -0
- package/linter/rules/cmd-check/file-checks.js +34 -0
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +54 -0
- package/linter/rules/cmd-check/foreign-function-calls.js +115 -0
- package/linter/rules/cmd-check/global-environment-modification.d.ts +61 -0
- package/linter/rules/cmd-check/global-environment-modification.js +237 -0
- package/linter/rules/cmd-check/namespace-tampering.d.ts +52 -0
- package/linter/rules/cmd-check/namespace-tampering.js +162 -0
- package/linter/rules/cmd-check/non-ascii-code.d.ts +51 -0
- package/linter/rules/cmd-check/non-ascii-code.js +112 -0
- package/linter/rules/cmd-check/package-code.d.ts +30 -0
- package/linter/rules/cmd-check/package-code.js +141 -0
- package/linter/rules/cmd-check/package-data.d.ts +49 -0
- package/linter/rules/cmd-check/package-data.js +181 -0
- package/linter/rules/cmd-check/package-files.d.ts +41 -0
- package/linter/rules/cmd-check/package-files.js +157 -0
- package/linter/rules/cmd-check/package-hooks.d.ts +57 -0
- package/linter/rules/cmd-check/package-hooks.js +165 -0
- package/linter/rules/cmd-check/package-metafiles.d.ts +49 -0
- package/linter/rules/cmd-check/package-metafiles.js +292 -0
- package/linter/rules/cmd-check/package-runtime.d.ts +67 -0
- package/linter/rules/cmd-check/package-runtime.js +284 -0
- package/linter/rules/cmd-check/package-structure.d.ts +85 -0
- package/linter/rules/cmd-check/package-structure.js +320 -0
- package/linter/rules/cmd-check/rd-files.d.ts +67 -0
- package/linter/rules/cmd-check/rd-files.js +621 -0
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +72 -0
- package/linter/rules/cmd-check/s-three-method-consistency.js +206 -0
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +45 -0
- package/linter/rules/cmd-check/true-false-abbreviation.js +121 -0
- package/linter/rules/deprecated-functions.js +4 -4
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +13 -14
- package/linter/rules/no-leaked-credentials.js +4 -4
- package/linter/rules/problematic-inputs.js +2 -1
- package/linter/rules/seeded-randomness.js +5 -5
- package/linter/rules/software-has-license.d.ts +1 -1
- package/linter/rules/software-has-license.js +1 -1
- package/linter/rules/unclosed-connection.js +3 -3
- package/linter/rules/undefined-symbol-util.js +16 -32
- package/linter/rules/undefined-symbol.d.ts +2 -0
- package/linter/rules/undefined-symbol.js +33 -3
- package/linter/rules/unescaped-arguments.js +10 -9
- package/linter/rules/unused-definition.js +13 -19
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.js +1 -1
- package/project/context/flowr-analyzer-context.js +1 -1
- package/project/context/flowr-analyzer-environment-context.d.ts +1 -1
- package/project/context/flowr-analyzer-files-context.d.ts +6 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +0 -2
- package/project/context/flowr-analyzer-incremental-analysis-context.js +0 -4
- package/project/context/flowr-file.d.ts +4 -0
- package/project/context/flowr-file.js +4 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +11 -14
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +3 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +25 -15
- package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +44 -0
- package/project/plugins/file-plugins/files/flowr-rd-file.js +130 -61
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -16
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +0 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +3 -7
- package/project/sigdb/build.js +16 -30
- package/project/sigdb/dict.d.ts +4 -6
- package/project/sigdb/dict.js +125 -31
- package/project/sigdb/reader.js +2 -18
- package/project/sigdb/sigdb-download.js +14 -23
- package/queries/base-query-format.d.ts +2 -0
- package/queries/base-query-format.js +10 -2
- package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
- package/queries/catalog/absint-query/absint-query-format.js +5 -7
- package/queries/catalog/call-context-query/call-context-query-executor.js +24 -32
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -3
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -4
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -4
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -3
- package/queries/catalog/config-query/config-query-format.js +3 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -3
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -3
- package/queries/catalog/dependencies-query/data-flow.d.ts +43 -0
- package/queries/catalog/dependencies-query/data-flow.js +173 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +18 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +108 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +17 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +14 -11
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.js +13 -13
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +3 -3
- package/queries/catalog/dependencies-query/function-info/source-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.js +8 -8
- package/queries/catalog/dependencies-query/function-info/transform-functions.d.ts +8 -0
- package/queries/catalog/dependencies-query/function-info/transform-functions.js +17 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.js +4 -0
- package/queries/catalog/dependencies-query/implicit-echo.d.ts +5 -3
- package/queries/catalog/dependencies-query/implicit-echo.js +33 -34
- package/queries/catalog/dependencies-query/link-devices.d.ts +3 -2
- package/queries/catalog/dependencies-query/link-devices.js +9 -6
- package/queries/catalog/dependencies-query/plot-description.d.ts +10 -0
- package/queries/catalog/dependencies-query/plot-description.js +119 -0
- package/queries/catalog/dependencies-query/plot-objects.d.ts +13 -0
- package/queries/catalog/dependencies-query/plot-objects.js +61 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -2
- package/queries/catalog/dice-query/dice-query-format.js +3 -40
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +2 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +2 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -3
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.js +28 -29
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +4 -7
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +1 -1
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/catalog/linter-query/linter-query-executor.js +10 -3
- package/queries/catalog/linter-query/linter-query-format.d.ts +4 -1
- package/queries/catalog/linter-query/linter-query-format.js +32 -21
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -3
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.js +4 -5
- package/queries/catalog/project-query/project-query-format.js +2 -2
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -4
- package/queries/catalog/search-query/search-query-format.js +1 -3
- package/queries/catalog/signature-query/signature-query-executor.js +3 -3
- package/queries/catalog/signature-query/signature-query-format.js +2 -2
- package/queries/catalog/slice-query-options.d.ts +16 -0
- package/queries/catalog/slice-query-options.js +28 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -42
- package/queries/query-print.d.ts +4 -0
- package/queries/query-print.js +17 -1
- package/queries/query.d.ts +3 -3
- package/queries/query.js +3 -4
- package/r-bridge/lang-4.x/ast/model/model.d.ts +27 -3
- package/r-bridge/lang-4.x/ast/model/model.js +28 -1
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +20 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +25 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +18 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +15 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +17 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +20 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/operators.js +0 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/fold.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -3
- package/r-bridge/lang-4.x/ast/parser/json/format.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -20
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -9
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +7 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -10
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +30 -82
- package/r-bridge/retriever.d.ts +0 -4
- package/r-bridge/retriever.js +0 -13
- package/r-bridge/roxygen2/documentation-provider.js +3 -7
- package/r-bridge/shell.js +3 -8
- package/reconstruct/auto-select/magic-comments.js +8 -7
- package/reconstruct/inline/source-inline-map.d.ts +3 -0
- package/reconstruct/inline/source-inline-map.js +8 -7
- package/reconstruct/reconstruct.d.ts +1 -1
- package/reconstruct/reconstruct.js +33 -109
- package/search/flowr-search-printer.js +4 -15
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/filters/all-variables.js +1 -2
- package/slicing/static/fingerprint.js +11 -2
- package/slicing/static/slice-call.d.ts +2 -8
- package/slicing/static/slice-call.js +8 -18
- package/slicing/static/static-slicer.js +81 -6
- package/util/collections/arrays.js +1 -1
- package/util/collections/set.js +1 -1
- package/util/diff-graph.d.ts +4 -0
- package/util/diff-graph.js +12 -0
- package/util/files.js +2 -6
- package/util/json.js +1 -15
- package/util/mermaid/cfg.js +10 -17
- package/util/mermaid/dfg.js +6 -8
- package/util/objects.d.ts +1 -1
- package/util/quads.js +4 -13
- package/util/r-author.js +5 -5
- package/util/range.d.ts +9 -0
- package/util/range.js +11 -0
- package/util/schema.js +3 -3
- package/util/simple-df/dfg-view.js +2 -1
- package/util/text/ansi.js +1 -2
- package/util/text/playground-link.js +2 -1
- package/util/text/r-highlight.js +2 -1
- package/util/text/strings.d.ts +2 -0
- package/util/text/strings.js +5 -0
- package/util/text/time.js +1 -2
- package/util/version.js +4 -3
- package/dataflow/fn/recursive-function.d.ts +0 -6
- package/dataflow/fn/recursive-function.js +0 -32
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +0 -16
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +0 -27
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DOCUMENTATION_MISMATCH = void 0;
|
|
7
|
+
const strings_1 = require("../../../util/text/strings");
|
|
8
|
+
const linter_format_1 = require("../../linter-format");
|
|
9
|
+
const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
|
|
10
|
+
const linter_tags_1 = require("../../linter-tags");
|
|
11
|
+
const range_1 = require("../../../util/range");
|
|
12
|
+
const flowr_file_1 = require("../../../project/context/flowr-file");
|
|
13
|
+
const flowr_rd_file_1 = require("../../../project/plugins/file-plugins/files/flowr-rd-file");
|
|
14
|
+
const flowr_namespace_file_1 = require("../../../project/plugins/file-plugins/files/flowr-namespace-file");
|
|
15
|
+
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
16
|
+
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
17
|
+
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
18
|
+
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
19
|
+
const r_number_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
20
|
+
const convert_values_1 = require("../../../r-bridge/lang-4.x/convert-values");
|
|
21
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
22
|
+
const path_1 = __importDefault(require("path"));
|
|
23
|
+
const package_files_1 = require("./package-files");
|
|
24
|
+
const cmd_check_util_1 = require("./cmd-check-util");
|
|
25
|
+
const Identifier_ = /^[A-Za-z.][\w.]*$/;
|
|
26
|
+
const CallHead = /^(`[^`]+`|"[^"]+"|'[^']+'|[A-Za-z.][\w.]*(?:,[^\s(]*-method)?)\s*\(/;
|
|
27
|
+
const NamedArg = /^(`[^`]+`|"[^"]*"|[A-Za-z.][\w.]*)\s*=(?!=)\s*([\s\S]*)$/;
|
|
28
|
+
function unquote(name) {
|
|
29
|
+
return /^[`"']/.test(name) ? name.slice(1, -1) : name;
|
|
30
|
+
}
|
|
31
|
+
/** the index of the bracket closing the one at `open`, string-aware */
|
|
32
|
+
function closing(text, open) {
|
|
33
|
+
let depth = 0;
|
|
34
|
+
let quote;
|
|
35
|
+
for (let i = open; i < text.length; i++) {
|
|
36
|
+
const c = text[i];
|
|
37
|
+
if (quote !== undefined) {
|
|
38
|
+
if (c === '\\') {
|
|
39
|
+
i++;
|
|
40
|
+
}
|
|
41
|
+
else if (c === quote) {
|
|
42
|
+
quote = undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (c === '"' || c === '\'' || c === '`') {
|
|
46
|
+
quote = c;
|
|
47
|
+
}
|
|
48
|
+
else if (c === '(' || c === '[' || c === '{') {
|
|
49
|
+
depth++;
|
|
50
|
+
}
|
|
51
|
+
else if ((c === ')' || c === ']' || c === '}') && --depth === 0) {
|
|
52
|
+
return i;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
/** splits `text` at the commas outside of brackets and strings */
|
|
58
|
+
function splitArgs(text) {
|
|
59
|
+
const parts = [];
|
|
60
|
+
let depth = 0;
|
|
61
|
+
let quote;
|
|
62
|
+
let from = 0;
|
|
63
|
+
for (let i = 0; i < text.length; i++) {
|
|
64
|
+
const c = text[i];
|
|
65
|
+
if (quote !== undefined) {
|
|
66
|
+
if (c === '\\') {
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
else if (c === quote) {
|
|
70
|
+
quote = undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (c === '"' || c === '\'' || c === '`') {
|
|
74
|
+
quote = c;
|
|
75
|
+
}
|
|
76
|
+
else if (c === '(' || c === '[' || c === '{') {
|
|
77
|
+
depth++;
|
|
78
|
+
}
|
|
79
|
+
else if (c === ')' || c === ']' || c === '}') {
|
|
80
|
+
depth--;
|
|
81
|
+
}
|
|
82
|
+
else if (c === ',' && depth === 0) {
|
|
83
|
+
parts.push(text.slice(from, i));
|
|
84
|
+
from = i + 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
parts.push(text.slice(from));
|
|
88
|
+
return parts.map(p => p.trim());
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* What a `\usage` entry states: a call (or replacement call) with its arguments, `'ignored'` for a bare variable or
|
|
92
|
+
* a `data()` call, and `undefined` for anything else (operators, indexing, ...), which is not understood.
|
|
93
|
+
*/
|
|
94
|
+
function parseUsageEntry(entry) {
|
|
95
|
+
const text = entry.trim();
|
|
96
|
+
if (Identifier_.test(text) || /^(`[^`]+`|"[^"]+")$/.test(text)) {
|
|
97
|
+
return 'ignored';
|
|
98
|
+
}
|
|
99
|
+
const head = CallHead.exec(text);
|
|
100
|
+
if (head === null) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const open = head[0].length - 1;
|
|
104
|
+
const close = closing(text, open);
|
|
105
|
+
if (close === undefined) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
const rest = text.slice(close + 1).trim();
|
|
109
|
+
const value = rest === '' ? undefined : /^<-\s*([A-Za-z.][\w.]*)$/.exec(rest)?.[1];
|
|
110
|
+
if (rest !== '' && value === undefined) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
const name = unquote(head[1]);
|
|
114
|
+
if (name === 'data' && value === undefined) {
|
|
115
|
+
return 'ignored';
|
|
116
|
+
}
|
|
117
|
+
const inner = text.slice(open + 1, close);
|
|
118
|
+
const args = [];
|
|
119
|
+
for (const part of inner.trim() === '' ? [] : splitArgs(inner)) {
|
|
120
|
+
if (part === '') {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const named = NamedArg.exec(part);
|
|
124
|
+
if (named !== null) {
|
|
125
|
+
args.push({ name: unquote(named[1]), default: named[2].trim() });
|
|
126
|
+
}
|
|
127
|
+
else if (Identifier_.test(part) || part === '...') {
|
|
128
|
+
args.push({ name: part });
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (value !== undefined) {
|
|
135
|
+
args.push({ name: value });
|
|
136
|
+
}
|
|
137
|
+
return { name: value === undefined ? name : name + '<-', args, entry: text, replace: value !== undefined };
|
|
138
|
+
}
|
|
139
|
+
const Escapes = { n: '\n', t: '\t', r: '\r', '0': '\0', a: '\x07', b: '\b', f: '\f', v: '\v' };
|
|
140
|
+
/** the value of the content of a string literal, i.e. with its escape sequences resolved */
|
|
141
|
+
function unescape(str, raw = false) {
|
|
142
|
+
return raw ? str : str.replace(/\\(.)/gs, (_, c) => Escapes[c] ?? c);
|
|
143
|
+
}
|
|
144
|
+
/** infinite numbers are written `Inf` and `-Inf` in R */
|
|
145
|
+
function infinite(num) {
|
|
146
|
+
return num === Infinity ? 'k:Inf' : num === -Infinity ? 'k:-Inf' : undefined;
|
|
147
|
+
}
|
|
148
|
+
function literalOfCode(node) {
|
|
149
|
+
switch (node?.type) {
|
|
150
|
+
case type_1.RType.String: return `s:${unescape(node.content.str, node.content.flag === 'raw')}`;
|
|
151
|
+
case type_1.RType.Logical: return `l:${node.content}`;
|
|
152
|
+
case type_1.RType.Number: return infinite(node.content.num) ?? `n:${node.content.num}`;
|
|
153
|
+
case type_1.RType.UnaryOp: {
|
|
154
|
+
const num = r_number_1.RNumber.literalValueOf(node);
|
|
155
|
+
return num === undefined ? undefined : infinite(num) ?? `n:${num}`;
|
|
156
|
+
}
|
|
157
|
+
case type_1.RType.Symbol: {
|
|
158
|
+
const name = identifier_1.Identifier.getName(node.content);
|
|
159
|
+
return ['NULL', 'NA', 'Inf', 'NaN'].includes(name) ? `k:${name}` : undefined;
|
|
160
|
+
}
|
|
161
|
+
default: return undefined;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function literalOfDocs(text) {
|
|
165
|
+
if (/^(["'])[\s\S]*\1$/.test(text)) {
|
|
166
|
+
try {
|
|
167
|
+
const value = convert_values_1.RStringValue.fromRLexeme(text);
|
|
168
|
+
return `s:${unescape(value.str, value.flag === 'raw')}`;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (/^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?L?$/.test(text)) {
|
|
175
|
+
return `n:${Number(text.replace(/L$/, ''))}`;
|
|
176
|
+
}
|
|
177
|
+
if (text === 'TRUE' || text === 'FALSE') {
|
|
178
|
+
return `l:${text === 'TRUE'}`;
|
|
179
|
+
}
|
|
180
|
+
return ['NULL', 'NA', 'Inf', '-Inf', 'NaN'].includes(text) ? `k:${text}` : undefined;
|
|
181
|
+
}
|
|
182
|
+
const show = (lit) => lit.startsWith('s:') ? JSON.stringify(lit.slice(2)) : lit.slice(2);
|
|
183
|
+
/** where in an Rd source the first of `needles` shows up at or after `from` (1-based line and column) */
|
|
184
|
+
function findIn(raw, from, needles) {
|
|
185
|
+
if (raw === undefined) {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
const start = from === undefined ? 0 : Math.max(0, raw.search(from));
|
|
189
|
+
let best;
|
|
190
|
+
for (const needle of needles) {
|
|
191
|
+
const m = needle.exec(raw.slice(start));
|
|
192
|
+
if (m !== null && (best === undefined || m.index < best.index)) {
|
|
193
|
+
best = { index: m.index, length: m[0].length };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (best === undefined) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
const before = raw.slice(0, start + best.index);
|
|
200
|
+
const line = before.split('\n').length;
|
|
201
|
+
return [line, start + best.index - before.lastIndexOf('\n'), best.length];
|
|
202
|
+
}
|
|
203
|
+
const quoteRe = strings_1.escapeRegex;
|
|
204
|
+
function rdLoc(file, raw, from, needles) {
|
|
205
|
+
const found = findIn(raw, from, needles) ?? findIn(raw, undefined, [/\\usage/]);
|
|
206
|
+
return found === undefined ? [1, 1, 1, 1, file] : [found[0], found[1], found[0], found[1] + Math.max(found[2] - 1, 0), file];
|
|
207
|
+
}
|
|
208
|
+
/** the spellings an entry name may have in the Rd source: `print.foo` as `\method{print}{foo}` too */
|
|
209
|
+
function usageNeedles(name) {
|
|
210
|
+
const plain = name.replace(/<-$/, '');
|
|
211
|
+
const needles = [new RegExp(`${quoteRe(plain)}(?=\\s*\\()`)];
|
|
212
|
+
for (let i = plain.indexOf('.', 1); i >= 0; i = plain.indexOf('.', i + 1)) {
|
|
213
|
+
needles.push(new RegExp(`\\\\(?:S3)?method\\{${quoteRe(plain.slice(0, i))}\\}\\{${quoteRe(plain.slice(i + 1))}\\}`));
|
|
214
|
+
}
|
|
215
|
+
return needles;
|
|
216
|
+
}
|
|
217
|
+
const UsageStart = /\\usage\s*\{/;
|
|
218
|
+
const ArgumentsStart = /\\arguments\s*\{/;
|
|
219
|
+
/** the formals of the function a usage name stands for; `foo.bar<-` may also be the replacement function `foo<-.bar` */
|
|
220
|
+
function codeFunctionFor(name, fns) {
|
|
221
|
+
const candidates = [name];
|
|
222
|
+
if (name.endsWith('<-')) {
|
|
223
|
+
const plain = name.slice(0, -2);
|
|
224
|
+
for (let i = plain.indexOf('.', 1); i >= 0; i = plain.indexOf('.', i + 1)) {
|
|
225
|
+
candidates.push(`${plain.slice(0, i)}<-${plain.slice(i)}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (const c of candidates) {
|
|
229
|
+
const def = fns.get(c);
|
|
230
|
+
if (def !== undefined) {
|
|
231
|
+
return { name: c, def };
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
function signature(name, args) {
|
|
237
|
+
return `${name}(${args.join(', ')})`;
|
|
238
|
+
}
|
|
239
|
+
/** Port of the code/documentation consistency checks of `R CMD check`. */
|
|
240
|
+
exports.DOCUMENTATION_MISMATCH = {
|
|
241
|
+
createSearch: () => flowr_search_builder_1.Q.fromQuery({ type: 'dependencies', enabledCategories: [] }),
|
|
242
|
+
processSearchResult: async (_elements, config, data) => {
|
|
243
|
+
const ctx = data.inspectContext();
|
|
244
|
+
const pkg = (0, cmd_check_util_1.packageInfo)(ctx);
|
|
245
|
+
const normalize = await data.normalize();
|
|
246
|
+
const results = [];
|
|
247
|
+
/* only the package's own man/ counts, not that of packages vendored into it or shipped as test fixtures */
|
|
248
|
+
const description = (0, package_files_1.rootDescriptionFile)(ctx);
|
|
249
|
+
const manDir = description === undefined ? undefined : path_1.default.join(path_1.default.dirname(description.path()), 'man') + path_1.default.sep;
|
|
250
|
+
const docFiles = ctx.files.getFilesByRole(flowr_file_1.FileRole.Documentation)
|
|
251
|
+
.filter(f => manDir === undefined || path_1.default.normalize(f.path()).startsWith(manDir));
|
|
252
|
+
const macros = new Map();
|
|
253
|
+
for (const f of docFiles) {
|
|
254
|
+
if (f instanceof flowr_rd_file_1.FlowrRdMacroFile) {
|
|
255
|
+
for (const [n, m] of f.content()) {
|
|
256
|
+
macros.set(n, m);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const pages = docFiles.filter(f => f instanceof flowr_rd_file_1.FlowrRdFile).map(f => ({ file: f, path: f.path(), page: f.pageWith(macros) }));
|
|
261
|
+
const functions = new Map((0, cmd_check_util_1.topLevelDefinitions)(normalize, () => true).filter(d => pkg.isPackageCode(d.def.info.file)).map(d => [d.name, d.def]));
|
|
262
|
+
let consideredObjects = 0;
|
|
263
|
+
if (config.checkUndocumented && (pages.length > 0 || (pkg.namespace !== undefined && config.requireDocumentation))) {
|
|
264
|
+
const aliases = new Set(pages.flatMap(p => p.page.aliases));
|
|
265
|
+
const seen = new Set();
|
|
266
|
+
for (const file of normalize.ast.files) {
|
|
267
|
+
if (!pkg.isPackageCode(file.filePath)) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
for (const stmt of file.root.children) {
|
|
271
|
+
if (!r_binary_op_1.RBinaryOp.is(stmt) || !['<-', '=', '<<-'].includes(stmt.operator) || !r_symbol_1.RSymbol.is(stmt.lhs) && !r_string_1.RString.is(stmt.lhs)) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const name = r_symbol_1.RSymbol.is(stmt.lhs) ? identifier_1.Identifier.getName(stmt.lhs.content) : stmt.lhs.content.str;
|
|
275
|
+
const exported = pkg.namespace === undefined || (0, flowr_namespace_file_1.isExportedInInfo)(name, { ...pkg.namespace, exportS3Generics: new Map() }) !== false;
|
|
276
|
+
if (seen.has(name) || name.startsWith('.') || !exported) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
seen.add(name);
|
|
280
|
+
consideredObjects++;
|
|
281
|
+
const loc = range_1.SourceLocation.fromNode(stmt.lhs);
|
|
282
|
+
if (!aliases.has(name) && loc !== undefined) {
|
|
283
|
+
results.push({
|
|
284
|
+
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
285
|
+
involvedId: stmt.lhs.info.id,
|
|
286
|
+
loc,
|
|
287
|
+
kind: 'undocumented-object',
|
|
288
|
+
name,
|
|
289
|
+
message: `Undocumented code object: '${name}'`
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
for (const { file, path, page } of pages) {
|
|
296
|
+
const raw = file.rawText();
|
|
297
|
+
const rdName = path.split(/[\\/]/).pop() ?? path;
|
|
298
|
+
checkPage(page, rdName, path, raw, functions, config, results);
|
|
299
|
+
}
|
|
300
|
+
return { results, '.meta': { consideredObjects, consideredPages: pages.length } };
|
|
301
|
+
},
|
|
302
|
+
prettyPrint: {
|
|
303
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `${result.message} at ${range_1.SourceLocation.format(result.loc)}`,
|
|
304
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => `${result.message} at ${range_1.SourceLocation.format(result.loc)}`
|
|
305
|
+
},
|
|
306
|
+
info: {
|
|
307
|
+
name: 'Documentation Mismatch',
|
|
308
|
+
tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Documentation, linter_tags_1.LintingRuleTag.Bug],
|
|
309
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
310
|
+
description: 'Finds exported objects without documentation, functions whose formals differ from their `\\usage`, and arguments missing from or extra in `\\arguments`.',
|
|
311
|
+
defaultConfig: () => ({
|
|
312
|
+
checkUndocumented: true,
|
|
313
|
+
checkCodoc: true,
|
|
314
|
+
checkDefaults: true,
|
|
315
|
+
checkUsage: true,
|
|
316
|
+
checkInternalUsage: false,
|
|
317
|
+
requireDocumentation: true
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
function checkPage(page, rdName, path, raw, fns, config, out) {
|
|
322
|
+
if (page.usage.length === 0) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const calls = [];
|
|
326
|
+
let partial = false;
|
|
327
|
+
for (const entry of page.usage) {
|
|
328
|
+
const parsed = parseUsageEntry(entry);
|
|
329
|
+
if (parsed === undefined) {
|
|
330
|
+
partial = true;
|
|
331
|
+
}
|
|
332
|
+
else if (parsed !== 'ignored') {
|
|
333
|
+
calls.push(parsed);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const add = (kind, name, message, loc, fn) => {
|
|
337
|
+
out.push({ certainty: linter_format_1.LintingResultCertainty.Certain, involvedId: undefined, loc, kind, name, rdFile: rdName, function: fn, message });
|
|
338
|
+
};
|
|
339
|
+
const usageLoc = (call) => rdLoc(path, raw, UsageStart, usageNeedles(call.name));
|
|
340
|
+
if (config.checkCodoc && page.name !== 'defunct' && !page.name.endsWith('-defunct')) {
|
|
341
|
+
for (const call of calls) {
|
|
342
|
+
const code = codeFunctionFor(call.name, fns);
|
|
343
|
+
if (code === undefined) {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
const codeNames = (0, cmd_check_util_1.formalNames)(code.def);
|
|
347
|
+
const docNames = call.args.map(a => a.name);
|
|
348
|
+
if (codeNames.length !== docNames.length || codeNames.some((n, i) => n !== docNames[i])) {
|
|
349
|
+
add('argument-mismatch', call.name, `Codoc mismatches from Rd file '${rdName}': ${signature(call.name, docNames)} in the docs, but ${signature(code.name, codeNames)} in the code`, usageLoc(call), call.name);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (!config.checkDefaults) {
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
for (const [i, param] of code.def.parameters.entries()) {
|
|
356
|
+
const docDefault = call.args[i].default;
|
|
357
|
+
if (docDefault === undefined || docDefault === '') {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
const inCode = literalOfCode(param.defaultValue);
|
|
361
|
+
const inDocs = literalOfDocs(docDefault);
|
|
362
|
+
const bad = param.defaultValue === undefined ? true : inCode !== undefined && inDocs !== undefined && inCode !== inDocs;
|
|
363
|
+
if (bad) {
|
|
364
|
+
const codeText = param.defaultValue === undefined ? 'no default' : show(inCode);
|
|
365
|
+
add('default-mismatch', param.name.content, `Mismatches in argument default values for '${call.name}' in Rd file '${rdName}': argument '${param.name.content}' has ${codeText} in the code, but ${docDefault} in the docs`, usageLoc(call), call.name);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!config.checkUsage) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const aliases = new Set(page.aliases);
|
|
374
|
+
if (!page.aliases.every(a => a.endsWith('-deprecated'))) {
|
|
375
|
+
for (const call of calls) {
|
|
376
|
+
if (!aliases.has(call.name)) {
|
|
377
|
+
add('usage-without-alias', call.name, `Objects in \\usage without \\alias in Rd file '${rdName}': '${call.name}'`, usageLoc(call), call.name);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (partial) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const usageArgs = new Set(calls.flatMap(c => c.args.map(a => a.name)));
|
|
385
|
+
const reported = new Set();
|
|
386
|
+
const internal = page.keywords.includes('internal');
|
|
387
|
+
if (!internal || config.checkInternalUsage) {
|
|
388
|
+
for (const call of calls) {
|
|
389
|
+
for (const arg of call.args) {
|
|
390
|
+
if (page.arguments.has(arg.name) || reported.has(arg.name)) {
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
reported.add(arg.name);
|
|
394
|
+
add('undocumented-argument', arg.name, `Undocumented arguments in Rd file '${rdName}': '${arg.name}'`, usageLoc(call), call.name);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const usageText = page.usage.join('\n').replace(/\\l?dots/g, '...');
|
|
399
|
+
for (const arg of page.arguments.keys()) {
|
|
400
|
+
const simple = /^[\w.]+$/.test(arg);
|
|
401
|
+
if (usageArgs.has(arg) || simple && new RegExp(`(^|\\W)${quoteRe(arg)}($|\\W)`).test(usageText)) {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
add('documented-argument-not-in-usage', arg, `Documented arguments not in \\usage in Rd file '${rdName}': '${arg}'`, rdLoc(path, raw, ArgumentsStart, [new RegExp(`\\\\item\\s*\\{[^}]*${quoteRe(arg)}[^}]*\\}`)]));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
//# sourceMappingURL=documentation-mismatch.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LintingResultCertainty } from '../../linter-format';
|
|
2
|
+
import { SourceLocation } from '../../../util/range';
|
|
3
|
+
import type { CmdCheckResult } from './cmd-check-util';
|
|
4
|
+
import type { PackageFiles } from './package-files';
|
|
5
|
+
/** A finding of a check kind at a file (and line) of the package. */
|
|
6
|
+
export interface FileResult<K extends string> extends CmdCheckResult {
|
|
7
|
+
readonly kind: K;
|
|
8
|
+
readonly file: string;
|
|
9
|
+
}
|
|
10
|
+
/** Collects findings located at package files; findings of the kinds in `skip` are dropped. */
|
|
11
|
+
export declare function fileFindings<K extends string>(pf: PackageFiles, skip?: readonly K[]): {
|
|
12
|
+
results: FileResult<K>[];
|
|
13
|
+
add: (kind: K, file: string, message: string, line?: number, certainty?: LintingResultCertainty) => void;
|
|
14
|
+
};
|
|
15
|
+
/** The lines of a package file, empty if it cannot be read. */
|
|
16
|
+
export declare function linesOf(pf: PackageFiles, file: string): string[];
|
|
17
|
+
/** The 1-based number of the first line of `file` matching `pattern`, `undefined` if none does. */
|
|
18
|
+
export declare function firstLine(pf: PackageFiles, file: string, pattern: RegExp): number | undefined;
|
|
19
|
+
/** Pretty printing of a finding as its message and location. */
|
|
20
|
+
export declare const MessageAtLocation: {
|
|
21
|
+
query: (r: {
|
|
22
|
+
readonly message: string;
|
|
23
|
+
readonly loc: SourceLocation;
|
|
24
|
+
}) => string;
|
|
25
|
+
full: (r: {
|
|
26
|
+
readonly message: string;
|
|
27
|
+
readonly loc: SourceLocation;
|
|
28
|
+
}) => string;
|
|
29
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageAtLocation = void 0;
|
|
4
|
+
exports.fileFindings = fileFindings;
|
|
5
|
+
exports.linesOf = linesOf;
|
|
6
|
+
exports.firstLine = firstLine;
|
|
7
|
+
const linter_format_1 = require("../../linter-format");
|
|
8
|
+
const range_1 = require("../../../util/range");
|
|
9
|
+
/** Collects findings located at package files; findings of the kinds in `skip` are dropped. */
|
|
10
|
+
function fileFindings(pf, skip = []) {
|
|
11
|
+
const results = [];
|
|
12
|
+
const add = (kind, file, message, line, certainty = linter_format_1.LintingResultCertainty.Certain) => {
|
|
13
|
+
if (!skip.includes(kind)) {
|
|
14
|
+
results.push({ certainty, involvedId: undefined, loc: pf.locate(file, line), kind, file, message });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return { results, add };
|
|
18
|
+
}
|
|
19
|
+
/** The lines of a package file, empty if it cannot be read. */
|
|
20
|
+
function linesOf(pf, file) {
|
|
21
|
+
return (pf.read(file) ?? '').split(/\r?\n/);
|
|
22
|
+
}
|
|
23
|
+
/** The 1-based number of the first line of `file` matching `pattern`, `undefined` if none does. */
|
|
24
|
+
function firstLine(pf, file, pattern) {
|
|
25
|
+
const i = linesOf(pf, file).findIndex(l => pattern.test(l));
|
|
26
|
+
return i < 0 ? undefined : i + 1;
|
|
27
|
+
}
|
|
28
|
+
const atLocation = (r) => `${r.message} at ${range_1.SourceLocation.format(r.loc)}`;
|
|
29
|
+
/** Pretty printing of a finding as its message and location. */
|
|
30
|
+
exports.MessageAtLocation = {
|
|
31
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: atLocation,
|
|
32
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: atLocation
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=file-checks.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { LintingRuleCertainty } from '../../linter-format';
|
|
2
|
+
import type { MergeableRecord } from '../../../util/objects';
|
|
3
|
+
import { LintingRuleTag } from '../../linter-tags';
|
|
4
|
+
import { type CmdCheckResult } from './cmd-check-util';
|
|
5
|
+
/** what is wrong with a foreign function call */
|
|
6
|
+
export type ForeignFunctionCallIssue = 'missing-package' | 'empty-package' | 'base-package' | 'different-package' | 'undeclared-package';
|
|
7
|
+
export interface ForeignFunctionCallsResult extends CmdCheckResult {
|
|
8
|
+
readonly issue: ForeignFunctionCallIssue;
|
|
9
|
+
/** the foreign function interface called, e.g. `.Call` */
|
|
10
|
+
readonly call: string;
|
|
11
|
+
/** the routine the call names, if flowR can tell */
|
|
12
|
+
readonly routine?: string;
|
|
13
|
+
/** the `PACKAGE` the call names, for all issues but a missing one */
|
|
14
|
+
readonly package?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ForeignFunctionCallsConfig extends MergeableRecord {
|
|
17
|
+
/** also resolve the routine and `PACKAGE` through variables, which `R CMD check` cannot see (default `true`) */
|
|
18
|
+
readonly resolveValues: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ForeignFunctionCallsMetadata extends MergeableRecord {
|
|
21
|
+
/** foreign function calls inspected */
|
|
22
|
+
readonly consideredCalls: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Port of the `R CMD check` notes on foreign function calls (`checking foreign function calls`, from
|
|
26
|
+
* `tools:::checkFF`): a call of `.C`, `.Fortran`, `.Call` or `.External` naming its routine by a string
|
|
27
|
+
* without a `PACKAGE` argument in a package that loads no DLL with `useDynLib`, with an empty `PACKAGE`,
|
|
28
|
+
* or with a `PACKAGE` naming a base package, another package, or a package the DESCRIPTION does not declare.
|
|
29
|
+
* Unlike `R CMD check`, it recognizes the calls by what flowR knows about them (so a redefined `.Call` is ignored
|
|
30
|
+
* and `base::.Call` is not), resolves the routine and `PACKAGE` through variables, and accepts any DLL
|
|
31
|
+
* the NAMESPACE loads as `PACKAGE`. It does not check the registration of the routines, which needs the installed package.
|
|
32
|
+
*/
|
|
33
|
+
export declare const FOREIGN_FUNCTION_CALLS: {
|
|
34
|
+
readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", [], import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, 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>[]>>;
|
|
35
|
+
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: ForeignFunctionCallsConfig, data: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>) => Promise<{
|
|
36
|
+
results: ForeignFunctionCallsResult[];
|
|
37
|
+
'.meta': {
|
|
38
|
+
consideredCalls: number;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
readonly prettyPrint: {
|
|
42
|
+
query: (r: ForeignFunctionCallsResult) => string;
|
|
43
|
+
full: (r: ForeignFunctionCallsResult) => string;
|
|
44
|
+
};
|
|
45
|
+
readonly info: {
|
|
46
|
+
readonly name: "Foreign Function Calls";
|
|
47
|
+
readonly tags: readonly [LintingRuleTag.CmdCheck, LintingRuleTag.Bug, LintingRuleTag.Robustness];
|
|
48
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
49
|
+
readonly description: "Checks `.Call`, `.C`, `.External`, and `.Fortran` calls: a missing or empty `PACKAGE`, calls into base or other packages, and undeclared packages. Routine and package names are resolved through variables.";
|
|
50
|
+
readonly defaultConfig: () => {
|
|
51
|
+
resolveValues: true;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FOREIGN_FUNCTION_CALLS = void 0;
|
|
4
|
+
const linter_format_1 = require("../../linter-format");
|
|
5
|
+
const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
|
|
6
|
+
const linter_tags_1 = require("../../linter-tags");
|
|
7
|
+
const range_1 = require("../../../util/range");
|
|
8
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
9
|
+
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
10
|
+
const graph_1 = require("../../../dataflow/graph/graph");
|
|
11
|
+
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
12
|
+
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
13
|
+
const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
|
|
14
|
+
const resolve_helper_1 = require("../../../dataflow/environments/resolve-helper");
|
|
15
|
+
const node_value_1 = require("../../../dataflow/eval/resolve/node-value");
|
|
16
|
+
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
17
|
+
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
18
|
+
const flowr_file_1 = require("../../../project/context/flowr-file");
|
|
19
|
+
const cmd_check_util_1 = require("./cmd-check-util");
|
|
20
|
+
/** the formals of the foreign function interface, `PACKAGE` has to be named in full as it follows `...` */
|
|
21
|
+
const Formals = { '.NAME': 'name', '...': '...', 'PACKAGE': 'package' };
|
|
22
|
+
/** the DLLs the NAMESPACE loads with `useDynLib` */
|
|
23
|
+
function loadedDlls(ctx) {
|
|
24
|
+
const fmt = ctx.files.getFilesByRole(flowr_file_1.FileRole.Namespace)[0]?.content();
|
|
25
|
+
return new Set(Object.entries(fmt ?? {}).filter(([name, info]) => name !== 'current' && info.loadsWithSideEffects).map(([name]) => name));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Port of the `R CMD check` notes on foreign function calls (`checking foreign function calls`, from
|
|
29
|
+
* `tools:::checkFF`): a call of `.C`, `.Fortran`, `.Call` or `.External` naming its routine by a string
|
|
30
|
+
* without a `PACKAGE` argument in a package that loads no DLL with `useDynLib`, with an empty `PACKAGE`,
|
|
31
|
+
* or with a `PACKAGE` naming a base package, another package, or a package the DESCRIPTION does not declare.
|
|
32
|
+
* Unlike `R CMD check`, it recognizes the calls by what flowR knows about them (so a redefined `.Call` is ignored
|
|
33
|
+
* and `base::.Call` is not), resolves the routine and `PACKAGE` through variables, and accepts any DLL
|
|
34
|
+
* the NAMESPACE loads as `PACKAGE`. It does not check the registration of the routines, which needs the installed package.
|
|
35
|
+
*/
|
|
36
|
+
exports.FOREIGN_FUNCTION_CALLS = {
|
|
37
|
+
createSearch: () => flowr_search_builder_1.Q.fromQuery({ type: 'dependencies', enabledCategories: [] }),
|
|
38
|
+
processSearchResult: async (_elements, config, data) => {
|
|
39
|
+
const ctx = data.inspectContext();
|
|
40
|
+
const df = await data.dataflow();
|
|
41
|
+
const idMap = (await data.normalize()).idMap;
|
|
42
|
+
const pkg = (0, cmd_check_util_1.packageInfo)(ctx);
|
|
43
|
+
const dlls = loadedDlls(ctx);
|
|
44
|
+
const declared = new Set(cmd_check_util_1.DependencyFields.filter(f => f !== 'LinkingTo').flatMap(f => pkg.declared.get(f) ?? []));
|
|
45
|
+
const info = resolve_helper_1.Resolve.info(df.graph, ctx);
|
|
46
|
+
const text = (id) => {
|
|
47
|
+
const node = id === undefined ? undefined : idMap.get(id);
|
|
48
|
+
return node === undefined ? undefined : r_string_1.RString.is(node) ? node.content.str : config.resolveValues ? node_value_1.NodeValue.singleStringOf(node.info.id, info) : undefined;
|
|
49
|
+
};
|
|
50
|
+
const results = [];
|
|
51
|
+
let considered = 0;
|
|
52
|
+
const ffiNames = new Set(ctx.env.builtInIndex.with(built_in_props_1.CallProp.Ffi).map(n => identifier_1.Identifier.getName(n)));
|
|
53
|
+
for (const [id, vertex] of df.graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
54
|
+
if (!ffiNames.has(identifier_1.Identifier.getName(vertex.name))) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const props = (0, query_fn_props_1.callFnProps)(id, df);
|
|
58
|
+
const node = idMap.get(id);
|
|
59
|
+
if (!built_in_props_1.CallProps.hasAny(props, built_in_props_1.CallProp.Ffi) || !props?.sig?.some(([formal]) => formal === '.NAME') || node === undefined || !pkg.isPackageCode(node.info.file)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
considered++;
|
|
63
|
+
const bound = function_semantics_1.FunctionSemantics.call.match.toSpec(vertex.args, Formals);
|
|
64
|
+
/* a named argument is bound by the node naming it, the value lies below */
|
|
65
|
+
const values = new Map(vertex.args.filter(graph_1.FunctionArgument.isNamed).map(a => [a.nodeId, a.valueId]));
|
|
66
|
+
const valueOf = (formal) => {
|
|
67
|
+
const arg = bound.get(formal)?.[0];
|
|
68
|
+
return arg === undefined ? undefined : values.has(arg) ? values.get(arg) : arg;
|
|
69
|
+
};
|
|
70
|
+
const call = identifier_1.Identifier.getName(vertex.name);
|
|
71
|
+
const loc = range_1.SourceLocation.fromNode(node);
|
|
72
|
+
if (loc === undefined) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const routine = text(valueOf('name'));
|
|
76
|
+
const given = bound.get('package') !== undefined;
|
|
77
|
+
const target = text(valueOf('package'));
|
|
78
|
+
const report = (issue, message, named) => results.push({
|
|
79
|
+
...(0, cmd_check_util_1.at)(node),
|
|
80
|
+
issue,
|
|
81
|
+
call,
|
|
82
|
+
...(routine === undefined ? {} : { routine }),
|
|
83
|
+
...(named === undefined ? {} : { package: named }),
|
|
84
|
+
message: `${message}: ${call}(${routine === undefined ? '...' : JSON.stringify(routine)}, ...)`
|
|
85
|
+
});
|
|
86
|
+
if (!given) {
|
|
87
|
+
/* R only asks for the argument of a routine named by a string, and not when the NAMESPACE loads a DLL */
|
|
88
|
+
if (routine !== undefined && dlls.size === 0) {
|
|
89
|
+
report('missing-package', 'Foreign function call without \'PACKAGE\' argument');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (target === '') {
|
|
93
|
+
report('empty-package', 'Foreign function call with empty \'PACKAGE\' argument', '');
|
|
94
|
+
}
|
|
95
|
+
else if (target !== undefined && pkg.name !== undefined && target !== pkg.name && !dlls.has(target)) {
|
|
96
|
+
report((0, r_base_packages_1.isBaseRPackage)(target) ? 'base-package' : 'different-package', `Foreign function call to ${(0, r_base_packages_1.isBaseRPackage)(target) ? 'a base' : 'a different'} package`, target);
|
|
97
|
+
if (!(0, r_base_packages_1.isBaseRPackage)(target) && !declared.has(target)) {
|
|
98
|
+
report('undeclared-package', `Undeclared package ${JSON.stringify(target)} in foreign function call`, target);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { results, '.meta': { consideredCalls: considered } };
|
|
103
|
+
},
|
|
104
|
+
prettyPrint: (0, cmd_check_util_1.printer)(r => `${r.call}${r.routine === undefined ? '' : `(${JSON.stringify(r.routine)})`}: ${r.issue}`),
|
|
105
|
+
info: {
|
|
106
|
+
name: 'Foreign Function Calls',
|
|
107
|
+
tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Robustness],
|
|
108
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
109
|
+
description: 'Checks `.Call`, `.C`, `.External`, and `.Fortran` calls: a missing or empty `PACKAGE`, calls into base or other packages, and undeclared packages. Routine and package names are resolved through variables.',
|
|
110
|
+
defaultConfig: () => ({
|
|
111
|
+
resolveValues: true
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=foreign-function-calls.js.map
|