@eagleoutice/flowr 2.16.1 → 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 +15 -2
- package/dataflow/environments/built-in-props.js +31 -4
- 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 +385 -25
- package/dataflow/environments/default-builtin-config.js +186 -106
- 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 +1 -2
- package/dataflow/environments/identifier.js +5 -7
- package/dataflow/environments/overwrite.js +1 -0
- package/dataflow/environments/query-fn-props.d.ts +3 -0
- package/dataflow/environments/query-fn-props.js +7 -0
- package/dataflow/environments/resolve-by-name.js +11 -4
- 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 +21 -12
- 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 +15 -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 +14 -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 +64 -11
- 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 +526 -4
- 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/function-finder-util.d.ts +1 -1
- package/linter/rules/function-finder-util.js +1 -3
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +13 -14
- package/linter/rules/network-functions.d.ts +4 -3
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +8 -3
- package/linter/rules/no-leaked-credentials.js +134 -36
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +21 -14
- 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.d.ts +13 -2
- package/linter/rules/unescaped-arguments.js +104 -15
- 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 +26 -33
- 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-source-functions.d.ts +6 -4
- package/queries/catalog/input-sources-query/input-source-functions.js +11 -6
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -3
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +11 -5
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +12 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +237 -40
- 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-enrichers.js +5 -3
- 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,292 @@
|
|
|
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.PACKAGE_METAFILES = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
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 r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
|
+
const match_args_1 = require("../../../dataflow/graph/match-args");
|
|
14
|
+
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
15
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
16
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
17
|
+
const cmd_check_util_1 = require("./cmd-check-util");
|
|
18
|
+
const file_checks_1 = require("./file-checks");
|
|
19
|
+
const package_files_1 = require("./package-files");
|
|
20
|
+
/** the `BibTeX` entry types `R CMD check` knows, with their required fields (alternatives joined by `|`) */
|
|
21
|
+
const BibTeXRequiredFields = new Map(Object.entries({
|
|
22
|
+
article: ['author', 'title', 'journal', 'year'],
|
|
23
|
+
book: ['author|editor', 'title', 'publisher', 'year'],
|
|
24
|
+
booklet: ['title'],
|
|
25
|
+
inbook: ['author|editor', 'title', 'chapter', 'publisher', 'year'],
|
|
26
|
+
incollection: ['author', 'title', 'booktitle', 'publisher', 'year'],
|
|
27
|
+
inproceedings: ['author', 'title', 'booktitle', 'year'],
|
|
28
|
+
manual: ['title'],
|
|
29
|
+
mastersthesis: ['author', 'title', 'school', 'year'],
|
|
30
|
+
misc: [],
|
|
31
|
+
phdthesis: ['author', 'title', 'school', 'year'],
|
|
32
|
+
proceedings: ['title', 'year'],
|
|
33
|
+
techreport: ['author', 'title', 'institution', 'year'],
|
|
34
|
+
unpublished: ['author', 'title', 'note']
|
|
35
|
+
}));
|
|
36
|
+
/** the formal arguments `R CMD check` reads the entries of `citEntry()` and `bibentry()` by, the fields follow them */
|
|
37
|
+
const CitEntryFormals = ['entry', 'textVersion', 'header', 'footer'];
|
|
38
|
+
const BibEntryFormals = ['bibtype', 'textVersion', 'header', 'footer', 'other'];
|
|
39
|
+
/** the citation functions with a newer replacement, the replacement's name */
|
|
40
|
+
const SupersededCitation = new Map([
|
|
41
|
+
['citEntry', 'bibentry'],
|
|
42
|
+
['citHeader', 'bibentry'],
|
|
43
|
+
['citFooter', 'bibentry'],
|
|
44
|
+
['personList', 'person'],
|
|
45
|
+
['as.personList', 'person']
|
|
46
|
+
]);
|
|
47
|
+
/** the documents whose relative links are checked */
|
|
48
|
+
const LinkedDocument = /^(README|NEWS)\.md$|^vignettes\/.*\.(Rmd|md)$/;
|
|
49
|
+
/** a markdown link `](target)` or an HTML `href`/`src` attribute, the target in the first or second group */
|
|
50
|
+
const LinkTarget = /\]\(\s*<?([^)\s>]*)>?(?:\s+"[^"]*")?\s*\)|\b(?:href|src)\s*=\s*"([^"]*)"/g;
|
|
51
|
+
/** the entries of an index file, as `R`'s `tools:::read.00Index` reads them: paragraphs of `item<spaces>description` lines */
|
|
52
|
+
function readIndex(text) {
|
|
53
|
+
const entries = [];
|
|
54
|
+
/* `readLines` drops the final newline, which `strsplit` would otherwise turn into an empty item */
|
|
55
|
+
const body = text.endsWith('\n') ? text.slice(0, -1) : text;
|
|
56
|
+
for (const chunk of body.split(/\n[ \t\n]*\n/)) {
|
|
57
|
+
if (!/( {3}|\t)/.test(chunk)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
for (const line of chunk.replace(/\n[ \t]+/g, '\t').split('\n')) {
|
|
61
|
+
const [item, ...rest] = line.split(/[ \t]/);
|
|
62
|
+
entries.push({ item, description: rest.filter(t => t !== '').join(' ') });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return entries;
|
|
66
|
+
}
|
|
67
|
+
/** the line (1-based) of the first line of `text` that starts with `item`, `1` if none does */
|
|
68
|
+
function lineOf(text, item) {
|
|
69
|
+
const i = text.split('\n').findIndex(l => l.trim().split(/[ \t]/)[0] === item);
|
|
70
|
+
return i < 0 ? 1 : i + 1;
|
|
71
|
+
}
|
|
72
|
+
/** whether the package contains the folder `dir` (or any file below it) */
|
|
73
|
+
function hasDir(files, dir) {
|
|
74
|
+
return files.entries.some(e => e.relative === dir || e.relative.startsWith(`${dir}/`));
|
|
75
|
+
}
|
|
76
|
+
/** the `.R` and `.r` files directly in `demo/` whose name starts with a letter, as `R CMD check` takes them as demos */
|
|
77
|
+
function demoTopics(files) {
|
|
78
|
+
return files.entries
|
|
79
|
+
.filter(e => !e.isDirectory && /^demo\/[A-Za-z][^/]*\.[Rr]$/.test(e.relative))
|
|
80
|
+
.map(e => ({ topic: e.relative.slice('demo/'.length, -2), file: e.relative }));
|
|
81
|
+
}
|
|
82
|
+
/** `R CMD check` only counts an argument as a field if it has a value that is neither `NULL` nor blank */
|
|
83
|
+
function isEmptyValue(value) {
|
|
84
|
+
return value === undefined || model_1.RNode.lexeme(value) === 'NULL' || r_string_1.RString.is(value) && value.content.str.trim() === '';
|
|
85
|
+
}
|
|
86
|
+
/** the names of the named, non-empty arguments of a call (lower-cased, as `R CMD check` compares them) */
|
|
87
|
+
function fieldNames(args) {
|
|
88
|
+
return args.flatMap(a => a === r_function_call_1.EmptyArgument || a.name === undefined || isEmptyValue(a.value) ? [] : [identifier_1.Identifier.getName(a.name.content).toLowerCase()]);
|
|
89
|
+
}
|
|
90
|
+
/** the entries of `demo/00Index`, the index and the demos must agree on */
|
|
91
|
+
function checkIndices(files, report) {
|
|
92
|
+
let read = 0;
|
|
93
|
+
const index = files.read('INDEX');
|
|
94
|
+
if (index !== undefined) {
|
|
95
|
+
read++;
|
|
96
|
+
if (index === '') {
|
|
97
|
+
report('empty-index', 'INDEX', 1, 'Empty file \'INDEX\'.');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!hasDir(files, 'demo')) {
|
|
101
|
+
return read;
|
|
102
|
+
}
|
|
103
|
+
read++;
|
|
104
|
+
const demoIndex = files.read('demo/00Index');
|
|
105
|
+
if (demoIndex === undefined || demoIndex === '') {
|
|
106
|
+
report('empty-demo-index', 'demo/00Index', 1, 'Empty or missing file \'demo/00Index\'.');
|
|
107
|
+
return read;
|
|
108
|
+
}
|
|
109
|
+
const entries = readIndex(demoIndex);
|
|
110
|
+
const topics = demoTopics(files);
|
|
111
|
+
const described = new Map();
|
|
112
|
+
for (const { item, description } of entries) {
|
|
113
|
+
if (!described.has(item)) {
|
|
114
|
+
described.set(item, description);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (const { topic, file } of topics) {
|
|
118
|
+
if ((described.get(topic) ?? '').trim() === '') {
|
|
119
|
+
report('undocumented-demo', file, 1, `Demos with missing or empty index information: '${topic}' (in '${file}')`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const known = new Set(topics.map(t => t.topic));
|
|
123
|
+
for (const { item } of entries) {
|
|
124
|
+
if (!known.has(item)) {
|
|
125
|
+
report('missing-demo', 'demo/00Index', lineOf(demoIndex, item), `Demo index entry without corresponding demo: '${item}'`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return read;
|
|
129
|
+
}
|
|
130
|
+
/** the CITATION files `R CMD check` finds outside of `inst/` (where `inst/CITATION` is the standard place) */
|
|
131
|
+
function checkCitationLocations(files, report) {
|
|
132
|
+
for (const e of files.entries) {
|
|
133
|
+
if (e.isDirectory || e.relative === 'inst/CITATION' || !/^CITATION(\.[A-Za-z0-9]+)?$/.test(path_1.default.posix.basename(e.relative))) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
report('citation-location', e.relative, 1, `Found the CITATION file in a non-standard place: '${e.relative}', most likely 'inst/CITATION' should be used instead`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** the first node of a syntax tree the parser could not make sense of */
|
|
140
|
+
function firstError(node) {
|
|
141
|
+
if (node.isError || node.isMissing) {
|
|
142
|
+
return node;
|
|
143
|
+
}
|
|
144
|
+
for (const child of node.children) {
|
|
145
|
+
const found = firstError(child);
|
|
146
|
+
if (found !== undefined) {
|
|
147
|
+
return found;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
/** Checks `inst/CITATION` (`tools:::.check_citation`) and returns the number of files read (0 or 1). */
|
|
153
|
+
function checkCitationFile(files, data, config, report) {
|
|
154
|
+
const rel = 'inst/CITATION';
|
|
155
|
+
const text = files.read(rel);
|
|
156
|
+
if (text === undefined) {
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
const tree = data.parseStandalone(text);
|
|
160
|
+
const error = tree.rootNode.hasError ? firstError(tree.rootNode) : undefined;
|
|
161
|
+
if (error !== undefined) {
|
|
162
|
+
if (config.citation) {
|
|
163
|
+
report('citation-syntax', rel, error.startPosition.row + 1, `Invalid citation information in '${rel}': unexpected code at line ${error.startPosition.row + 1}`);
|
|
164
|
+
}
|
|
165
|
+
return 1;
|
|
166
|
+
}
|
|
167
|
+
const ast = data.normalizeStandalone(text);
|
|
168
|
+
if (config.superseded) {
|
|
169
|
+
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
170
|
+
if (!r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const name = identifier_1.Identifier.getName(node.functionName.content);
|
|
174
|
+
const replacement = SupersededCitation.get(name);
|
|
175
|
+
if (replacement !== undefined) {
|
|
176
|
+
report('citation-superseded', rel, range_1.SourceLocation.fromNode(node)?.[0] ?? 1, `${name}() is superseded by ${replacement}(), use that instead`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (config.citation) {
|
|
181
|
+
let entry = 0;
|
|
182
|
+
for (const expr of ast.ast.files.flatMap(f => f.root.children)) {
|
|
183
|
+
if (!r_function_call_1.RFunctionCall.isNamed(expr)) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const fn = identifier_1.Identifier.getName(expr.functionName.content);
|
|
187
|
+
if (fn !== 'citEntry' && fn !== 'bibentry') {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
entry++;
|
|
191
|
+
const line = range_1.SourceLocation.fromNode(expr)?.[0] ?? 1;
|
|
192
|
+
const bibentry = fn === 'bibentry';
|
|
193
|
+
const bound = match_args_1.MatchArgs.toNames(expr.arguments, bibentry ? BibEntryFormals : CitEntryFormals);
|
|
194
|
+
const typeValue = bound.get(bibentry ? 'bibtype' : 'entry')?.value;
|
|
195
|
+
const type = typeValue !== undefined && r_string_1.RString.is(typeValue) ? typeValue.content.str : undefined;
|
|
196
|
+
const required = type === undefined ? undefined : BibTeXRequiredFields.get(type.toLowerCase());
|
|
197
|
+
if (required === undefined) {
|
|
198
|
+
const shown = type ?? (typeValue === undefined ? '' : model_1.RNode.lexeme(typeValue) ?? '');
|
|
199
|
+
report('citation-entry-type', rel, line, `entry ${entry}: invalid type '${shown}'`);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const boundArgs = new Set(bound.values());
|
|
203
|
+
const others = expr.arguments.filter((a) => a !== r_function_call_1.EmptyArgument && !boundArgs.has(a));
|
|
204
|
+
const fields = fieldNames(others);
|
|
205
|
+
const other = bound.get('other')?.value;
|
|
206
|
+
if (bibentry && other !== undefined && r_function_call_1.RFunctionCall.isNamed(other) && identifier_1.Identifier.getName(other.functionName.content) === 'list') {
|
|
207
|
+
fields.push(...fieldNames(other.arguments));
|
|
208
|
+
}
|
|
209
|
+
const missing = required.filter(alternatives => !alternatives.split('|').some(f => fields.includes(f)));
|
|
210
|
+
if (missing.length > 0) {
|
|
211
|
+
report('citation-missing-field', rel, line, `entry ${entry} (${type}): missing required field(s) ${missing.map(m => `'${m}'`).join(', ')}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return 1;
|
|
216
|
+
}
|
|
217
|
+
/** the target of a link in `from` as a path of the package, `undefined` for links that leave the package alone (URLs, anchors, absolute paths) */
|
|
218
|
+
function localTarget(from, target) {
|
|
219
|
+
if (/^([A-Za-z][A-Za-z0-9+.-]*:|\/)/.test(target)) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
const local = target.split(/[#?]/)[0];
|
|
223
|
+
if (local === '') {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
const resolved = path_1.default.posix.normalize(path_1.default.posix.join(path_1.default.posix.dirname(from), local));
|
|
227
|
+
return resolved === '.' ? undefined : resolved;
|
|
228
|
+
}
|
|
229
|
+
/** the relative links of the README, NEWS and vignettes that name no file of the package */
|
|
230
|
+
function checkRelativeLinks(files, report) {
|
|
231
|
+
const known = new Set(files.entries.map(e => e.relative));
|
|
232
|
+
let read = 0;
|
|
233
|
+
for (const doc of files.entries.filter(e => !e.isDirectory && LinkedDocument.test(e.relative))) {
|
|
234
|
+
const text = files.read(doc.relative);
|
|
235
|
+
if (text === undefined) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
read++;
|
|
239
|
+
for (const m of text.matchAll(LinkTarget)) {
|
|
240
|
+
const target = m[1] ?? m[2];
|
|
241
|
+
const resolved = localTarget(doc.relative, target);
|
|
242
|
+
if (resolved !== undefined && !known.has(resolved)) {
|
|
243
|
+
report('relative-link', doc.relative, text.slice(0, m.index).split('\n').length, `Found the (possibly) invalid relative link '${target}' in '${doc.relative}', no such file in the package`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return read;
|
|
248
|
+
}
|
|
249
|
+
/** Port of the `R CMD check` notes on `INDEX`, `demo/00Index`, `inst/CITATION`, CITATION locations, and relative links of README, NEWS and vignettes. */
|
|
250
|
+
exports.PACKAGE_METAFILES = {
|
|
251
|
+
createSearch: () => flowr_search_builder_1.Q.from([]),
|
|
252
|
+
processSearchResult: (_elements, config, data) => {
|
|
253
|
+
const ctx = data.inspectContext();
|
|
254
|
+
const files = (0, package_files_1.packageFiles)(ctx, (0, cmd_check_util_1.packageInfo)(ctx).name);
|
|
255
|
+
if (files === undefined) {
|
|
256
|
+
return { results: [], '.meta': { checkedFiles: 0 } };
|
|
257
|
+
}
|
|
258
|
+
const { results, add } = (0, file_checks_1.fileFindings)(files);
|
|
259
|
+
const report = (kind, file, line, message) => add(kind, file, message, line);
|
|
260
|
+
let checked = 0;
|
|
261
|
+
if (config.index) {
|
|
262
|
+
checked += checkIndices(files, report);
|
|
263
|
+
}
|
|
264
|
+
if (config.citation) {
|
|
265
|
+
checkCitationLocations(files, report);
|
|
266
|
+
}
|
|
267
|
+
if (config.citation || config.superseded) {
|
|
268
|
+
checked += checkCitationFile(files, data, config, report);
|
|
269
|
+
}
|
|
270
|
+
if (config.relativeLinks) {
|
|
271
|
+
checked += checkRelativeLinks(files, report);
|
|
272
|
+
}
|
|
273
|
+
return { results, '.meta': { checkedFiles: checked } };
|
|
274
|
+
},
|
|
275
|
+
prettyPrint: {
|
|
276
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `${result.kind} in ${result.file} at ${range_1.SourceLocation.format(result.loc)}`,
|
|
277
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => `${result.message} (at ${range_1.SourceLocation.format(result.loc)})`
|
|
278
|
+
},
|
|
279
|
+
info: {
|
|
280
|
+
name: 'Package Metafiles',
|
|
281
|
+
tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Robustness],
|
|
282
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
283
|
+
description: 'Checks the demo index, `INDEX`, `inst/CITATION`, and relative links in README, NEWS, and vignettes.',
|
|
284
|
+
defaultConfig: () => ({
|
|
285
|
+
index: true,
|
|
286
|
+
citation: true,
|
|
287
|
+
superseded: true,
|
|
288
|
+
relativeLinks: true
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
//# sourceMappingURL=package-metafiles.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { LintingRuleCertainty } from '../../linter-format';
|
|
2
|
+
import type { MergeableRecord } from '../../../util/objects';
|
|
3
|
+
import { LintingRuleTag } from '../../linter-tags';
|
|
4
|
+
import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
+
import type { ReadonlyFlowrAnalysisProvider } from '../../../project/flowr-analyzer';
|
|
6
|
+
import { type CmdCheckResult } from './cmd-check-util';
|
|
7
|
+
export type PackageRuntimeKind =
|
|
8
|
+
/** `export(x)` of something the package does not define, which fails the installation ("undefined exports") */
|
|
9
|
+
'undefined-export'
|
|
10
|
+
/** `S3method(gen, cls)` without a function `gen.cls`, which fails loading the namespace */
|
|
11
|
+
| 'missing-s3-method'
|
|
12
|
+
/** a NAMESPACE import from a package not in Imports or Depends ("Namespace dependency missing from DESCRIPTION Imports/Depends entries") */
|
|
13
|
+
| 'undeclared-namespace-import'
|
|
14
|
+
/** `importFrom(pkg, f)` of a name `pkg` does not export, which fails loading the namespace */
|
|
15
|
+
| 'unexported-import'
|
|
16
|
+
/** `library(pkg)` of the package itself in its own code, which fails when it is not on the library search path */
|
|
17
|
+
| 'self-attach'
|
|
18
|
+
/** test code `R CMD check` never runs, or that runs the tests of another package */
|
|
19
|
+
| 'test-runner'
|
|
20
|
+
/** test or vignette code that does not parse, so running it fails */
|
|
21
|
+
| 'syntax'
|
|
22
|
+
/** a vignette without the metadata R needs to find and build it */
|
|
23
|
+
| 'vignette-metadata'
|
|
24
|
+
/** test or vignette code writing a file into the working directory, which `R CMD check` notes as left behind */
|
|
25
|
+
| 'check-directory-write'
|
|
26
|
+
/** a `tests/*.Rout.save` without the test it is the expected output of */
|
|
27
|
+
| 'orphan-reference-output'
|
|
28
|
+
/** Rust code without the SystemRequirements CRAN asks for */
|
|
29
|
+
| 'rust-requirements'
|
|
30
|
+
/** a package without a NAMESPACE file, which no package may be since R 3.0.0 */
|
|
31
|
+
| 'missing-namespace'
|
|
32
|
+
/** a DESCRIPTION `Type` other than `Package` */
|
|
33
|
+
| 'extension-type'
|
|
34
|
+
/** an installed package (or a build left inside the sources) handed to the check instead of a source package */
|
|
35
|
+
| 'not-source-package';
|
|
36
|
+
export interface PackageRuntimeResult extends CmdCheckResult {
|
|
37
|
+
readonly kind: PackageRuntimeKind;
|
|
38
|
+
}
|
|
39
|
+
export interface PackageRuntimeConfig extends MergeableRecord {
|
|
40
|
+
/** report writes of tests and vignettes into the working directory (default `true`) */
|
|
41
|
+
readonly checkWrites: boolean;
|
|
42
|
+
}
|
|
43
|
+
export type PackageRuntimeMetadata = MergeableRecord;
|
|
44
|
+
/**
|
|
45
|
+
* The static part of the `R CMD check` steps that build, install, load, or run the package: what makes installing
|
|
46
|
+
* or loading the namespace fail, what keeps tests and vignettes from running, and what they leave behind.
|
|
47
|
+
*/
|
|
48
|
+
export declare const PACKAGE_RUNTIME: {
|
|
49
|
+
readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"from", [], ParentInformation, import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
|
|
50
|
+
readonly processSearchResult: (_elements: import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: PackageRuntimeConfig, data: ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>) => Promise<{
|
|
51
|
+
results: PackageRuntimeResult[];
|
|
52
|
+
'.meta': {};
|
|
53
|
+
}>;
|
|
54
|
+
readonly prettyPrint: {
|
|
55
|
+
query: (r: PackageRuntimeResult) => string;
|
|
56
|
+
full: (r: PackageRuntimeResult) => string;
|
|
57
|
+
};
|
|
58
|
+
readonly info: {
|
|
59
|
+
readonly name: "Package Runtime";
|
|
60
|
+
readonly tags: readonly [LintingRuleTag.CmdCheck, LintingRuleTag.Bug, LintingRuleTag.Robustness];
|
|
61
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
62
|
+
readonly description: "Finds what makes installing, loading, or running the package fail without doing so: undefined exports, S3 methods without a function, bad NAMESPACE imports, a package attaching itself, tests that never run, test or vignette code that does not parse, missing vignette metadata, and files written into the working directory.";
|
|
63
|
+
readonly defaultConfig: () => {
|
|
64
|
+
checkWrites: true;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,284 @@
|
|
|
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.PACKAGE_RUNTIME = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const strings_1 = require("../../../util/text/strings");
|
|
9
|
+
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
10
|
+
const linter_format_1 = require("../../linter-format");
|
|
11
|
+
const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
|
|
12
|
+
const linter_tags_1 = require("../../linter-tags");
|
|
13
|
+
const range_1 = require("../../../util/range");
|
|
14
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
15
|
+
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
16
|
+
const flowr_file_1 = require("../../../project/context/flowr-file");
|
|
17
|
+
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
18
|
+
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
19
|
+
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
20
|
+
const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
21
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
22
|
+
const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
23
|
+
const cmd_check_util_1 = require("./cmd-check-util");
|
|
24
|
+
const package_files_1 = require("./package-files");
|
|
25
|
+
const package_code_1 = require("./package-code");
|
|
26
|
+
/** calls binding names in ways a scan of the assignments does not see, so an export may be defined after all */
|
|
27
|
+
const DynamicDefiners = new Set(['assign', 'delayedAssign', 'makeActiveBinding', 'eval', 'evalq', 'sys.source', 'list2env', 'source']);
|
|
28
|
+
/** the names the top level of the package code binds, including the generics `setGeneric` creates */
|
|
29
|
+
function definitionsOf(ast, pkg, data) {
|
|
30
|
+
const names = new Set(data);
|
|
31
|
+
let dynamic = false;
|
|
32
|
+
const topLevelCalls = [];
|
|
33
|
+
const idMap = ast.idMap;
|
|
34
|
+
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
35
|
+
if (!pkg.isPackageCode(node.info.file)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
39
|
+
const fn = identifier_1.Identifier.getName(node.functionName.content);
|
|
40
|
+
const parentNode = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
41
|
+
if (r_expression_list_1.RExpressionList.is(parentNode) && parentNode.info.parent === undefined) {
|
|
42
|
+
topLevelCalls.push(fn);
|
|
43
|
+
}
|
|
44
|
+
const first = node.arguments[0] === r_function_call_1.EmptyArgument ? undefined : node.arguments[0]?.value;
|
|
45
|
+
if ((fn === 'setGeneric' || fn === 'setRefClass' || fn === 'setClass') && r_string_1.RString.is(first)) {
|
|
46
|
+
names.add(first.content.str);
|
|
47
|
+
}
|
|
48
|
+
else if (fn === 'assign' && r_string_1.RString.is(first)) {
|
|
49
|
+
names.add(first.content.str);
|
|
50
|
+
}
|
|
51
|
+
else if (DynamicDefiners.has(fn)) {
|
|
52
|
+
dynamic = true;
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!r_binary_op_1.RBinaryOp.is(node) || !['<-', '=', '->', '<<-'].includes(node.operator)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const parent = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
60
|
+
if (parent !== undefined && !(r_expression_list_1.RExpressionList.is(parent) && parent.info.parent === undefined)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const target = node.operator === '->' ? node.rhs : node.lhs;
|
|
64
|
+
if (r_symbol_1.RSymbol.is(target)) {
|
|
65
|
+
names.add(identifier_1.Identifier.getName(target.content));
|
|
66
|
+
}
|
|
67
|
+
else if (r_string_1.RString.is(target)) {
|
|
68
|
+
names.add(target.content.str);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { names, dynamic, opaque: topLevelCalls.some(fn => !names.has(fn) && (0, r_base_packages_1.baseRExportOwner)(fn) === undefined && !TopLevelHarmless.has(fn)) };
|
|
72
|
+
}
|
|
73
|
+
/** calls at the top level of package code that define nothing beyond what the scan sees */
|
|
74
|
+
const TopLevelHarmless = new Set(['setGeneric', 'setClass', 'setRefClass', 'setMethod', 'setValidity', 'setClassUnion', 'assign', 'globalVariables']);
|
|
75
|
+
/** the line of the first NAMESPACE directive matching, to point a finding at it */
|
|
76
|
+
function lineMatching(text, pattern) {
|
|
77
|
+
const line = text?.split(/\r?\n/).findIndex(l => !l.trimStart().startsWith('#') && pattern.test(l));
|
|
78
|
+
return line === undefined || line < 0 ? undefined : line + 1;
|
|
79
|
+
}
|
|
80
|
+
/** the line of the first NAMESPACE directive mentioning `name` */
|
|
81
|
+
function lineOf(text, name) {
|
|
82
|
+
return lineMatching(text, new RegExp(`(^|[(,\\s"'\`])${(0, strings_1.escapeRegex)(name)}([)\\s,"'\`]|$)`));
|
|
83
|
+
}
|
|
84
|
+
/** the first row with a syntax error, `undefined` if the code parses */
|
|
85
|
+
function syntaxErrorRow(code, data) {
|
|
86
|
+
try {
|
|
87
|
+
const tree = data.parseStandalone(code);
|
|
88
|
+
if (!tree.rootNode.hasError) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
const stack = [tree.rootNode];
|
|
92
|
+
for (let node = stack.pop(); node !== undefined; node = stack.pop()) {
|
|
93
|
+
if (node.isError || node.isMissing) {
|
|
94
|
+
return node.startPosition.row;
|
|
95
|
+
}
|
|
96
|
+
stack.push(...node.children.toReversed());
|
|
97
|
+
}
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** whether a literal path stays out of the working directory: the temporary directory or an absolute path elsewhere is fine for this */
|
|
105
|
+
function writesIntoWorkingDirectory(file) {
|
|
106
|
+
return file !== '' && !path_1.default.isAbsolute(file) && !file.startsWith('~') && !/^[a-z]+:\/\//i.test(file) && file !== 'stdout' && file !== 'stderr';
|
|
107
|
+
}
|
|
108
|
+
function namespaceChecks(files, pkg, defs, data, add) {
|
|
109
|
+
const ns = pkg.namespace;
|
|
110
|
+
const nsFile = data.inspectContext().files.getFilesByRole(flowr_file_1.FileRole.Namespace)[0];
|
|
111
|
+
if (ns === undefined || nsFile === undefined) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const text = nsFile.rawText?.();
|
|
115
|
+
const relative = path_1.default.relative(files.root, nsFile.path()).split(path_1.default.sep).join('/');
|
|
116
|
+
if (defs.opaque) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const certainty = defs.dynamic ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain;
|
|
120
|
+
/* a package may export what it imports (`importFrom(magrittr, "%>%")` and `export("%>%")`) */
|
|
121
|
+
const imported = new Set([...ns.importedPackages.values()].flatMap(v => v === 'all' ? [] : v));
|
|
122
|
+
const importsWhole = [...ns.importedPackages.values()].includes('all');
|
|
123
|
+
for (const name of [...ns.exportedSymbols, ...ns.exportedFunctions]) {
|
|
124
|
+
if (!defs.names.has(name) && !imported.has(name) && !importsWhole) {
|
|
125
|
+
add({ certainty, loc: files.locate(relative, lineOf(text, name)), kind: 'undefined-export', message: `undefined export: '${name}', installing the package fails` });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (const [generic, classes] of ns.exportS3Generics) {
|
|
129
|
+
for (const cls of classes) {
|
|
130
|
+
const fun = ns.s3MethodFunctions?.get(`${generic}.${cls}`) ?? `${generic}.${cls}`;
|
|
131
|
+
if (!defs.names.has(fun)) {
|
|
132
|
+
add({ certainty, loc: files.locate(relative, lineMatching(text, new RegExp(`S3method\\(\\s*["'\`]?${(0, strings_1.escapeRegex)(generic)}["'\`]?\\s*,\\s*["'\`]?${(0, strings_1.escapeRegex)(cls)}\\b`))), kind: 'missing-s3-method', message: `S3method(${generic}, ${cls}) registers '${fun}', which the package does not define, so loading its namespace fails` });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const declared = new Set([...pkg.declared.get('Imports') ?? [], ...pkg.declared.get('Depends') ?? []]);
|
|
137
|
+
const sources = data.inspectContext().deps.signatureSources();
|
|
138
|
+
for (const [imported, names] of ns.importedPackages) {
|
|
139
|
+
if (imported === pkg.name) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (!declared.has(imported) && !(0, cmd_check_util_1.isStandardPackage)(imported)) {
|
|
143
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(relative, lineOf(text, imported)), kind: 'undeclared-namespace-import', message: `Namespace dependency missing from DESCRIPTION Imports/Depends entries: '${imported}'` });
|
|
144
|
+
}
|
|
145
|
+
const known = sources.find(s => s.has(imported))?.lookup(imported);
|
|
146
|
+
if (names === 'all' || known === undefined) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
for (const name of names) {
|
|
150
|
+
if (!known.exported.includes(name)) {
|
|
151
|
+
add({
|
|
152
|
+
certainty: known.internal.includes(name) ? linter_format_1.LintingResultCertainty.Certain : linter_format_1.LintingResultCertainty.Uncertain,
|
|
153
|
+
loc: files.locate(relative, lineOf(text, name)),
|
|
154
|
+
kind: 'unexported-import',
|
|
155
|
+
message: `'${name}' is not exported by 'namespace:${imported}', so loading the namespace fails`
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function testAndVignetteChecks(files, pkg, data, config, writers, add) {
|
|
162
|
+
const entries = files.entries.filter(e => !e.isDirectory).map(e => e.relative);
|
|
163
|
+
const testFiles = entries.filter(f => /^tests\/[^/]+\.[rR]$/.test(f));
|
|
164
|
+
const testthatFiles = entries.filter(f => /^tests\/testthat\/test[^/]*\.[rR]$/.test(f));
|
|
165
|
+
if (testthatFiles.length > 0 && testFiles.length === 0) {
|
|
166
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(testthatFiles[0]), kind: 'test-runner', message: 'tests/testthat/ has tests, but no tests/*.R runs them (e.g. tests/testthat.R calling test_check()), so R CMD check never does' });
|
|
167
|
+
}
|
|
168
|
+
for (const save of entries.filter(f => /^tests\/[^/]+\.Rout\.save$/.test(f))) {
|
|
169
|
+
if (!entries.includes(save.replace(/\.Rout\.save$/, '.R')) && !entries.includes(save.replace(/\.Rout\.save$/, '.r'))) {
|
|
170
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(save), kind: 'orphan-reference-output', message: `${save} is the expected output of a test that does not exist` });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const code of (0, package_code_1.packageCode)(files)) {
|
|
174
|
+
if (code.origin === 'examples') {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const row = syntaxErrorRow(code.code, data);
|
|
178
|
+
if (row !== undefined) {
|
|
179
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(code.file, row + code.lineOffset), kind: 'syntax', message: `the ${code.origin === 'tests' ? 'test' : 'vignette'} code in ${code.file} does not parse, so running it fails` });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
let ast;
|
|
183
|
+
try {
|
|
184
|
+
ast = data.normalizeStandalone(code.code);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
r_project_1.RProject.visitAst(ast.ast, node => {
|
|
190
|
+
if (!r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
const fn = identifier_1.Identifier.getName(node.functionName.content);
|
|
194
|
+
const at = (n) => files.locate(code.file, (range_1.SourceLocation.getRange(range_1.SourceLocation.fromNode(n) ?? range_1.SourceLocation.invalid())[0]) + code.lineOffset - 1);
|
|
195
|
+
const strings = node.arguments.flatMap(a => a !== r_function_call_1.EmptyArgument && r_string_1.RString.is(a.value) ? [a.value.content.str] : []);
|
|
196
|
+
if (fn === 'test_check' && strings.length > 0 && pkg.name !== undefined && strings[0] !== pkg.name) {
|
|
197
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: at(node), kind: 'test-runner', message: `test_check("${strings[0]}") runs the tests of another package than '${pkg.name}'` });
|
|
198
|
+
}
|
|
199
|
+
else if (config.checkWrites && writers.has(fn)) {
|
|
200
|
+
const named = node.arguments.find(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && ['file', 'con', 'path', 'filename', 'description'].includes(identifier_1.Identifier.getName(a.name.content)));
|
|
201
|
+
const second = node.arguments[1];
|
|
202
|
+
const file = named !== undefined && named !== r_function_call_1.EmptyArgument ? named.value : second !== undefined && second !== r_function_call_1.EmptyArgument ? second.value : undefined;
|
|
203
|
+
if (r_string_1.RString.is(file) && writesIntoWorkingDirectory(file.content.str)) {
|
|
204
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Uncertain, loc: at(node), kind: 'check-directory-write', message: `${fn}() writes '${file.content.str}' into the working directory, which R CMD check notes as left behind; write to tempdir() instead` });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
});
|
|
209
|
+
if (code.origin === 'vignettes' && !/\.R$/i.test(code.file)) {
|
|
210
|
+
const text = files.read(code.file) ?? '';
|
|
211
|
+
if (!/\\VignetteIndexEntry\{/.test(text)) {
|
|
212
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(code.file), kind: 'vignette-metadata', message: `${code.file} has no %\\VignetteIndexEntry{}, so R does not list it` });
|
|
213
|
+
}
|
|
214
|
+
if (!/\.Rnw$/i.test(code.file) && !/\\VignetteEngine\{/.test(text)) {
|
|
215
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(code.file), kind: 'vignette-metadata', message: `${code.file} has no %\\VignetteEngine{}, so R does not build it (only Sweave is the default)` });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const rust = entries.find(f => /^src\/(rust\/)?Cargo\.toml$/.test(f));
|
|
220
|
+
const requirements = (pkg.description?.content().get('SystemRequirements') ?? []).join(' ');
|
|
221
|
+
if (rust !== undefined && !/cargo/i.test(requirements)) {
|
|
222
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate('DESCRIPTION'), kind: 'rust-requirements', message: `the package compiles Rust (${rust}) but SystemRequirements names no Cargo/rustc` });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The static part of the `R CMD check` steps that build, install, load, or run the package: what makes installing
|
|
227
|
+
* or loading the namespace fail, what keeps tests and vignettes from running, and what they leave behind.
|
|
228
|
+
*/
|
|
229
|
+
exports.PACKAGE_RUNTIME = {
|
|
230
|
+
createSearch: () => flowr_search_builder_1.Q.from([]),
|
|
231
|
+
processSearchResult: async (_elements, config, data) => {
|
|
232
|
+
const ctx = data.inspectContext();
|
|
233
|
+
const pkg = (0, cmd_check_util_1.packageInfo)(ctx);
|
|
234
|
+
const files = (0, package_files_1.packageFiles)(ctx, pkg.name);
|
|
235
|
+
const results = [];
|
|
236
|
+
if (files === undefined) {
|
|
237
|
+
return { results, '.meta': {} };
|
|
238
|
+
}
|
|
239
|
+
const add = (r) => results.push({ ...r, involvedId: undefined });
|
|
240
|
+
const ast = ctx.files.hasRequests() ? await data.normalize() : undefined;
|
|
241
|
+
const dataObjects = files.entries.filter(e => !e.isDirectory && e.relative.startsWith('data/')).map(e => path_1.default.posix.basename(e.relative).replace(/\..*$/, ''));
|
|
242
|
+
if (ast !== undefined) {
|
|
243
|
+
namespaceChecks(files, pkg, definitionsOf(ast, pkg, dataObjects), data, add);
|
|
244
|
+
const ownName = pkg.name;
|
|
245
|
+
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
246
|
+
if (ownName !== undefined && pkg.isPackageCode(node.info.file) && (r_function_call_1.RFunctionCall.isNamed(node, 'library') || r_function_call_1.RFunctionCall.isNamed(node, 'require'))) {
|
|
247
|
+
const arg = node.arguments[0] === r_function_call_1.EmptyArgument ? undefined : node.arguments[0]?.value;
|
|
248
|
+
const name = r_symbol_1.RSymbol.is(arg) ? identifier_1.Identifier.getName(arg.content) : r_string_1.RString.is(arg) ? arg.content.str : undefined;
|
|
249
|
+
const loc = range_1.SourceLocation.fromNode(node);
|
|
250
|
+
if (name === ownName && loc !== undefined) {
|
|
251
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc, kind: 'self-attach', message: `the package attaches itself with ${identifier_1.Identifier.getName(node.functionName.content)}(${ownName}), which fails when it is loaded without being on the library search path` });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const relativeFiles = new Set(files.entries.map(e => e.relative));
|
|
257
|
+
/* only a listing of the whole folder can tell that a file is missing */
|
|
258
|
+
if (files.onDisk && !relativeFiles.has('NAMESPACE')) {
|
|
259
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate('DESCRIPTION'), kind: 'missing-namespace', message: 'the package has no NAMESPACE file, which all packages need as from R 3.0.0' });
|
|
260
|
+
}
|
|
261
|
+
const type = pkg.description?.content().get('Type')?.[0]?.trim();
|
|
262
|
+
if (type !== undefined && type !== 'Package') {
|
|
263
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate('DESCRIPTION'), kind: 'extension-type', message: `the DESCRIPTION states Type: ${type}, but only packages (Type: Package) can be checked` });
|
|
264
|
+
}
|
|
265
|
+
const installed = ['Meta/package.rds', `R/${pkg.name ?? ''}.rdb`, 'R/all.rda'].find(f => relativeFiles.has(f));
|
|
266
|
+
if (installed !== undefined) {
|
|
267
|
+
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(installed), kind: 'not-source-package', message: `${installed} belongs to an installed package, R CMD check needs the package sources` });
|
|
268
|
+
}
|
|
269
|
+
const writers = new Set(ctx.env.builtInIndex.with(built_in_props_1.SemanticCallTag.Writes).map(n => identifier_1.Identifier.getName(n)));
|
|
270
|
+
testAndVignetteChecks(files, pkg, data, config, writers, add);
|
|
271
|
+
return { results, '.meta': {} };
|
|
272
|
+
},
|
|
273
|
+
prettyPrint: (0, cmd_check_util_1.printer)(r => r.kind),
|
|
274
|
+
info: {
|
|
275
|
+
name: 'Package Runtime',
|
|
276
|
+
tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Robustness],
|
|
277
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
278
|
+
description: 'Finds what makes installing, loading, or running the package fail without doing so: undefined exports, S3 methods without a function, bad NAMESPACE imports, a package attaching itself, tests that never run, test or vignette code that does not parse, missing vignette metadata, and files written into the working directory.',
|
|
279
|
+
defaultConfig: () => ({
|
|
280
|
+
checkWrites: true
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
//# sourceMappingURL=package-runtime.js.map
|