@eagleoutice/flowr 2.16.2 → 2.16.4
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 +15 -15
- 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 +4 -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 +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 +3 -8
- 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-query.d.ts +1 -1
- package/documentation/doc-util/doc-query.js +3 -1
- package/documentation/doc-util/doc-repl.js +4 -4
- package/documentation/doc-util/doc-timings.js +3 -2
- 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 +2 -2
- package/documentation/wiki-dataflow-graph.js +6 -6
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.d.ts +14 -0
- package/documentation/wiki-linter.js +353 -88
- 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 +552 -35
- 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.d.ts +1 -1
- package/linter/rules/absolute-path.js +9 -6
- 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 +216 -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 +51 -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 +60 -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 +51 -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 +173 -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 +83 -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/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.js +1 -1
- package/linter/rules/dead-code.d.ts +4 -4
- package/linter/rules/dead-code.js +19 -4
- package/linter/rules/deprecated-functions.d.ts +1 -1
- package/linter/rules/deprecated-functions.js +5 -5
- package/linter/rules/file-path-validity.d.ts +6 -2
- package/linter/rules/file-path-validity.js +7 -3
- package/linter/rules/namespace-access.d.ts +3 -3
- package/linter/rules/namespace-access.js +12 -3
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +14 -15
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/network-functions.js +1 -1
- package/linter/rules/no-leaked-credentials.d.ts +1 -1
- package/linter/rules/no-leaked-credentials.js +5 -5
- package/linter/rules/problematic-inputs.d.ts +2 -2
- package/linter/rules/problematic-inputs.js +4 -3
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +2 -2
- package/linter/rules/seeded-randomness.d.ts +2 -2
- package/linter/rules/seeded-randomness.js +7 -7
- package/linter/rules/software-has-license.d.ts +3 -3
- package/linter/rules/software-has-license.js +3 -3
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +2 -2
- package/linter/rules/stop-with-call-arg.d.ts +3 -3
- package/linter/rules/stop-with-call-arg.js +21 -4
- package/linter/rules/syntactically-valid.d.ts +1 -1
- package/linter/rules/syntactically-valid.js +1 -1
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +5 -5
- package/linter/rules/undefined-symbol-util.js +16 -32
- package/linter/rules/undefined-symbol.d.ts +3 -1
- package/linter/rules/undefined-symbol.js +34 -4
- package/linter/rules/unescaped-arguments.d.ts +1 -1
- package/linter/rules/unescaped-arguments.js +11 -10
- package/linter/rules/unused-definition.d.ts +1 -1
- package/linter/rules/unused-definition.js +14 -20
- package/linter/rules/unused-import.d.ts +1 -1
- package/linter/rules/unused-import.js +1 -1
- package/linter/rules/useless-loop.d.ts +1 -1
- package/linter/rules/useless-loop.js +1 -1
- 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 +2 -2
- package/project/context/flowr-analyzer-environment-context.js +2 -1
- package/project/context/flowr-analyzer-files-context.d.ts +6 -0
- package/project/context/flowr-analyzer-files-context.js +15 -11
- 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/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
- 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 +45 -0
- package/queries/catalog/dependencies-query/data-flow.js +179 -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 +36 -35
- 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,72 @@
|
|
|
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 CmdCheckResult } from './cmd-check-util';
|
|
6
|
+
/** what is wrong with the function */
|
|
7
|
+
export type S3MethodIssue =
|
|
8
|
+
/** the method does not take the arguments of its generic */
|
|
9
|
+
'argument-mismatch'
|
|
10
|
+
/** an exported method of an exported generic that is no registered S3 method */
|
|
11
|
+
| 'unregistered-method'
|
|
12
|
+
/** a replacement function without `value` as its last argument */
|
|
13
|
+
| 'replacement-value';
|
|
14
|
+
export interface S3MethodConsistencyResult extends CmdCheckResult {
|
|
15
|
+
readonly kind: S3MethodIssue;
|
|
16
|
+
/** the offending function, e.g. `print.foo` or `foo<-` */
|
|
17
|
+
readonly function: string;
|
|
18
|
+
/** the generic the function is a method of, absent for a replacement function that is no method */
|
|
19
|
+
readonly generic?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface S3MethodConsistencyConfig extends MergeableRecord {
|
|
22
|
+
/** check that methods take the arguments of their generic (default `true`) */
|
|
23
|
+
readonly checkMethods: boolean;
|
|
24
|
+
/** also check functions named like a method but not registered in the `NAMESPACE`, which `R CMD check` only does on request (default `true`) */
|
|
25
|
+
readonly checkApparentMethods: boolean;
|
|
26
|
+
/** report apparent methods of an exported generic that the `NAMESPACE` does not register (default `true`) */
|
|
27
|
+
readonly checkUnregistered: boolean;
|
|
28
|
+
/** check that replacement functions end in `value` (default `true`) */
|
|
29
|
+
readonly checkReplacementValues: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface S3MethodConsistencyMetadata extends MergeableRecord {
|
|
32
|
+
/** the methods compared with their generic */
|
|
33
|
+
readonly consideredMethods: number;
|
|
34
|
+
/** the replacement functions inspected */
|
|
35
|
+
readonly consideredReplacements: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Port of the `R CMD check` checks `checking S3 generic/method consistency` (`tools::checkS3methods`) and
|
|
39
|
+
* `checking replacement functions` (`tools::checkReplaceFuns`).
|
|
40
|
+
* A method must take all the arguments of its generic in the same order (and `...` if the generic does); a replacement
|
|
41
|
+
* function must end in `value`. The methods are the `S3method()` registrations of the `NAMESPACE` (certain) and the
|
|
42
|
+
* functions named `generic.class` for a generic (uncertain, `R CMD check` merely lists these on request). The generics are
|
|
43
|
+
* the package's own functions calling `UseMethod`, the group generics, and the functions flowR knows as generic
|
|
44
|
+
* with their formals; a function flowR knows as an ordinary function (`t.test`) is no method of `t`.
|
|
45
|
+
* Additionally, apparent methods that are exported but not registered are reported.
|
|
46
|
+
*/
|
|
47
|
+
export declare const S3_METHOD_CONSISTENCY: {
|
|
48
|
+
readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", [], ParentInformation, import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
|
|
49
|
+
readonly processSearchResult: (_elements: import("../../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: S3MethodConsistencyConfig, data: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>) => Promise<{
|
|
50
|
+
results: S3MethodConsistencyResult[];
|
|
51
|
+
'.meta': {
|
|
52
|
+
consideredMethods: number;
|
|
53
|
+
consideredReplacements: number;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
readonly prettyPrint: {
|
|
57
|
+
query: (r: S3MethodConsistencyResult) => string;
|
|
58
|
+
full: (r: S3MethodConsistencyResult) => string;
|
|
59
|
+
};
|
|
60
|
+
readonly info: {
|
|
61
|
+
readonly name: "S3 Method Consistency";
|
|
62
|
+
readonly tags: readonly [LintingRuleTag.CmdCheck, LintingRuleTag.Bug, LintingRuleTag.Robustness];
|
|
63
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
64
|
+
readonly description: "Finds S3 methods whose formals do not match their generic, methods not registered in the NAMESPACE, and replacement functions whose last formal is not `value`.";
|
|
65
|
+
readonly defaultConfig: () => {
|
|
66
|
+
checkMethods: true;
|
|
67
|
+
checkApparentMethods: true;
|
|
68
|
+
checkUnregistered: true;
|
|
69
|
+
checkReplacementValues: true;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S3_METHOD_CONSISTENCY = void 0;
|
|
4
|
+
const r_s3_generics_generated_1 = require("../../../data/r-s3-generics.generated");
|
|
5
|
+
const linter_format_1 = require("../../linter-format");
|
|
6
|
+
const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
|
|
7
|
+
const linter_tags_1 = require("../../linter-tags");
|
|
8
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
9
|
+
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
10
|
+
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
11
|
+
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
12
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
13
|
+
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
14
|
+
const r_unary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
15
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
16
|
+
const group_generics_1 = require("../../../dataflow/environments/group-generics");
|
|
17
|
+
const flowr_namespace_file_1 = require("../../../project/plugins/file-plugins/files/flowr-namespace-file");
|
|
18
|
+
const cmd_check_util_1 = require("./cmd-check-util");
|
|
19
|
+
/** the formals of a definition, without the backticks of non-syntactic names */
|
|
20
|
+
function formalNames(def) {
|
|
21
|
+
return (0, cmd_check_util_1.formalNames)(def).map(n => n.replace(/^`(.*)`$/, '$1'));
|
|
22
|
+
}
|
|
23
|
+
/** the subsetting generics dispatch internally on an argument list that varies by method, so a method may take any */
|
|
24
|
+
const SubsetGenerics = new Set(['[', '[[', '$']);
|
|
25
|
+
/** the operators for which a method with as many arguments as the generic is fine whatever their names */
|
|
26
|
+
const OperatorGenerics = new Set(['+', '-', '*', '/', '^', '%%', '%/%', '&', '|', '!', '==', '!=', '<', '<=', '>=', '>']);
|
|
27
|
+
/** whether a method with the formals `mArgs` is consistent with the generic `gName` of formals `gArgs` (`tools::checkS3methods`) */
|
|
28
|
+
function consistent(gName, gArgs, mName, mArgs) {
|
|
29
|
+
if (gName === 'round' && mArgs[0] === 'x') {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
/* the second argument of `plot` is not one the methods have to take */
|
|
33
|
+
const generic = gName === 'plot' ? gArgs.filter((_, i) => i !== 1) : gArgs;
|
|
34
|
+
let g = generic;
|
|
35
|
+
let m = mArgs;
|
|
36
|
+
if (mName.endsWith('.formula')) {
|
|
37
|
+
g = g[0] !== '...' ? g.slice(1) : g;
|
|
38
|
+
m = m[0] !== '...' ? m.slice(1) : m;
|
|
39
|
+
}
|
|
40
|
+
const gDots = g.indexOf('...');
|
|
41
|
+
const mDots = m.indexOf('...');
|
|
42
|
+
/* only the arguments before the dots are matched by position */
|
|
43
|
+
const positional = Math.min(gDots < 0 ? g.length : gDots, mDots < 0 ? Infinity : mDots);
|
|
44
|
+
let positionalOk = true;
|
|
45
|
+
for (let i = 0; i < positional; i++) {
|
|
46
|
+
positionalOk &&= g[i] === m[i];
|
|
47
|
+
}
|
|
48
|
+
const takesAll = g.every(a => m.includes(a)) || mDots >= 0;
|
|
49
|
+
const onlyKnown = m.every(a => a === '...' || g.includes(a)) || generic.includes('...');
|
|
50
|
+
return (positionalOk && takesAll && onlyKnown) || (OperatorGenerics.has(gName) && generic.length === mArgs.length);
|
|
51
|
+
}
|
|
52
|
+
function formatFormals(name, formals) {
|
|
53
|
+
return `${name}:\n function(${formals.join(', ')})`;
|
|
54
|
+
}
|
|
55
|
+
/** the node naming the function a definition is bound to, the definition itself when it is anonymous */
|
|
56
|
+
function nameNodeOf(def, idMap) {
|
|
57
|
+
const parent = def.info.parent === undefined ? undefined : idMap.get(def.info.parent);
|
|
58
|
+
return parent !== undefined && r_binary_op_1.RBinaryOp.is(parent) && parent.rhs === def ? parent.lhs : def;
|
|
59
|
+
}
|
|
60
|
+
/** the package functions that call `UseMethod` on their own account, i.e. the generics the package defines */
|
|
61
|
+
function localGenerics(defs, ast, graph) {
|
|
62
|
+
const idMap = ast.idMap;
|
|
63
|
+
const byId = new Map(defs.map(d => [d.def.info.id, d]));
|
|
64
|
+
const generics = new Map();
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
67
|
+
if (seen.has(node.info.id) || !r_function_call_1.RFunctionCall.isNamed(node) || identifier_1.Identifier.getName(node.functionName.content) !== 'UseMethod') {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
seen.add(node.info.id);
|
|
71
|
+
const origins = df_helper_1.Dataflow.origin(graph, node.info.id);
|
|
72
|
+
const owner = model_1.RNode.strictlyEnclosingFunction(node.info.id, idMap);
|
|
73
|
+
const def = owner === undefined ? undefined : byId.get(owner);
|
|
74
|
+
if (def !== undefined && (origins === undefined || origins.every(o => o.type === 3 /* OriginType.BuiltInFunctionOrigin */))) {
|
|
75
|
+
generics.set(def.name, { formals: formalNames(def.def), local: true });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return generics;
|
|
79
|
+
}
|
|
80
|
+
/** the functions and operators the package code calls, by name */
|
|
81
|
+
function calledNames(ast) {
|
|
82
|
+
const called = new Set();
|
|
83
|
+
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
84
|
+
if (r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
85
|
+
called.add(identifier_1.Identifier.getName(node.functionName.content));
|
|
86
|
+
}
|
|
87
|
+
else if (r_binary_op_1.RBinaryOp.is(node) || r_unary_op_1.RUnaryOp.is(node)) {
|
|
88
|
+
called.add(node.operator);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return called;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Port of the `R CMD check` checks `checking S3 generic/method consistency` (`tools::checkS3methods`) and
|
|
95
|
+
* `checking replacement functions` (`tools::checkReplaceFuns`).
|
|
96
|
+
* A method must take all the arguments of its generic in the same order (and `...` if the generic does); a replacement
|
|
97
|
+
* function must end in `value`. The methods are the `S3method()` registrations of the `NAMESPACE` (certain) and the
|
|
98
|
+
* functions named `generic.class` for a generic (uncertain, `R CMD check` merely lists these on request). The generics are
|
|
99
|
+
* the package's own functions calling `UseMethod`, the group generics, and the functions flowR knows as generic
|
|
100
|
+
* with their formals; a function flowR knows as an ordinary function (`t.test`) is no method of `t`.
|
|
101
|
+
* Additionally, apparent methods that are exported but not registered are reported.
|
|
102
|
+
*/
|
|
103
|
+
exports.S3_METHOD_CONSISTENCY = {
|
|
104
|
+
createSearch: () => flowr_search_builder_1.Q.fromQuery({ type: 'dependencies', enabledCategories: [] }),
|
|
105
|
+
processSearchResult: async (_elements, config, data) => {
|
|
106
|
+
const ctx = data.inspectContext();
|
|
107
|
+
const { graph } = await data.dataflow();
|
|
108
|
+
const ast = await data.normalize();
|
|
109
|
+
const idMap = ast.idMap;
|
|
110
|
+
const pkg = (0, cmd_check_util_1.packageInfo)(ctx);
|
|
111
|
+
const ns = pkg.namespace;
|
|
112
|
+
const notMethods = new Set(r_s3_generics_generated_1.RS3Generics.nonS3Methods[pkg.name ?? ''] ?? []);
|
|
113
|
+
const defs = (0, cmd_check_util_1.topLevelDefinitions)(ast, () => true).filter(d => pkg.isPackageCode(d.def.info.file));
|
|
114
|
+
const defined = new Set(defs.map(d => d.name));
|
|
115
|
+
const local = localGenerics(defs, ast, graph);
|
|
116
|
+
const generics = new Map(local);
|
|
117
|
+
/* a function of the package named like a generic of base hides it, unless it is a generic itself */
|
|
118
|
+
const genericNames = new Set(ctx.env.deriveFromIndex(index => index.with(built_in_props_1.CallProp.Generic).map(g => identifier_1.Identifier.getName(g))));
|
|
119
|
+
for (const name of genericNames) {
|
|
120
|
+
const formals = r_s3_generics_generated_1.RS3Generics.genericFormals[name] ?? (0, query_fn_props_1.fnInfo)(identifier_1.Identifier.make(name), ctx)?.entry?.signature?.map(p => p.name) ?? [];
|
|
121
|
+
if (!generics.has(name) && !defined.has(name) && !SubsetGenerics.has(name) && formals.length > 0) {
|
|
122
|
+
generics.set(name, { formals, local: false });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const [name, formals] of Object.entries(r_s3_generics_generated_1.RS3Generics.groupGenericFormals)) {
|
|
126
|
+
if (!local.has(name) && !defined.has(name)) {
|
|
127
|
+
generics.set(name, { formals, local: false });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const called = calledNames(ast);
|
|
131
|
+
/* like `R CMD check`, an unregistered method of a generic from base R only matters if the package calls the generic */
|
|
132
|
+
const dispatched = (generic) => called.has(generic) || ((0, group_generics_1.s3GroupGenericMembers)(generic)?.some(m => called.has(m)) ?? false);
|
|
133
|
+
const byLength = [...generics.keys()].sort((a, b) => b.length - a.length);
|
|
134
|
+
const results = [];
|
|
135
|
+
let methods = 0;
|
|
136
|
+
let replacements = 0;
|
|
137
|
+
const report = (def, kind, name, generic, certain, message) => {
|
|
138
|
+
results.push({
|
|
139
|
+
...(0, cmd_check_util_1.at)(nameNodeOf(def, idMap), certain),
|
|
140
|
+
kind,
|
|
141
|
+
function: name,
|
|
142
|
+
...(generic === undefined ? {} : { generic }),
|
|
143
|
+
message
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const registered = (generic, name) => ns?.exportS3Generics.get(generic)?.includes(name.slice(generic.length + 1)) ?? false;
|
|
147
|
+
/* a function flowR knows as ordinary function of a package (`t.test`) is no method of the generic it starts with */
|
|
148
|
+
const ordinary = (name) => {
|
|
149
|
+
const known = (0, query_fn_props_1.fnInfo)(identifier_1.Identifier.make(name), ctx);
|
|
150
|
+
return known !== undefined && known.entry?.props.includes('s3-method') !== true;
|
|
151
|
+
};
|
|
152
|
+
const replacementCheck = (def, name, generic, certain) => {
|
|
153
|
+
replacements++;
|
|
154
|
+
const formals = formalNames(def);
|
|
155
|
+
if (formals.length > 0 && formals[formals.length - 1] !== 'value') {
|
|
156
|
+
report(def, 'replacement-value', name, generic, certain, `Replacement function ${name} should have 'value' as its last argument`);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
for (const { name, def } of defs) {
|
|
160
|
+
/* the longest generic wins: `t.test.default` is a method of `t.test`, not of `t` */
|
|
161
|
+
const generic = notMethods.has(name) ? undefined : byLength.find(g => name.length > g.length + 1 && name.startsWith(g + '.'));
|
|
162
|
+
const info = generic === undefined ? undefined : generics.get(generic);
|
|
163
|
+
const isRegistered = generic !== undefined && registered(generic, name);
|
|
164
|
+
if (generic !== undefined && info !== undefined && (isRegistered || info.local || !ordinary(name))) {
|
|
165
|
+
if (config.checkMethods && (isRegistered || (config.checkApparentMethods && (info.local || dispatched(generic))))) {
|
|
166
|
+
methods++;
|
|
167
|
+
const formals = formalNames(def);
|
|
168
|
+
if (!consistent(generic, info.formals, name, formals)) {
|
|
169
|
+
report(def, 'argument-mismatch', name, generic, isRegistered, `S3 generic/method inconsistency:\n${formatFormals(generic, info.formals)}\n${formatFormals(name, formals)}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (config.checkUnregistered && ns !== undefined && !isRegistered && (0, flowr_namespace_file_1.isExportedInInfo)(info.local ? generic : name, ns) === true) {
|
|
173
|
+
report(def, 'unregistered-method', name, generic, false, `Apparent S3 method ${name} for ${info.local ? 'exported generic' : 'generic'} ${generic} is not registered in the NAMESPACE`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!config.checkReplacementValues) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (name.endsWith('<-') && !(name.startsWith('%') && name.endsWith('%'))) {
|
|
180
|
+
replacementCheck(def, name, undefined, true);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
/* a method of a replacement generic (`[<-.cls`) is a replacement function as well, even though its name does not end in `<-` */
|
|
184
|
+
const split = name.indexOf('<-.');
|
|
185
|
+
const replacementGeneric = split > 0 ? name.slice(0, split + 2) : undefined;
|
|
186
|
+
if (replacementGeneric !== undefined && (registered(replacementGeneric, name) || local.has(replacementGeneric) || genericNames.has(replacementGeneric.slice(0, -2)))) {
|
|
187
|
+
replacementCheck(def, name, replacementGeneric, registered(replacementGeneric, name));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { results, '.meta': { consideredMethods: methods, consideredReplacements: replacements } };
|
|
191
|
+
},
|
|
192
|
+
prettyPrint: (0, cmd_check_util_1.printer)(r => `${r.function}: ${r.kind}`),
|
|
193
|
+
info: {
|
|
194
|
+
name: 'S3 Method Consistency',
|
|
195
|
+
tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Robustness],
|
|
196
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
197
|
+
description: 'Finds S3 methods whose formals do not match their generic, methods not registered in the NAMESPACE, and replacement functions whose last formal is not `value`.',
|
|
198
|
+
defaultConfig: () => ({
|
|
199
|
+
checkMethods: true,
|
|
200
|
+
checkApparentMethods: true,
|
|
201
|
+
checkUnregistered: true,
|
|
202
|
+
checkReplacementValues: true
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=s-three-method-consistency.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
export interface TrueFalseAbbreviationResult extends CmdCheckResult {
|
|
6
|
+
/** the abbreviation used */
|
|
7
|
+
readonly name: 'T' | 'F';
|
|
8
|
+
/** a read of the abbreviation, or a definition masking it */
|
|
9
|
+
readonly kind: 'use' | 'redefinition';
|
|
10
|
+
}
|
|
11
|
+
export interface TrueFalseAbbreviationConfig extends MergeableRecord {
|
|
12
|
+
/** report definitions of `T` or `F`, which change what every later abbreviation means (default `true`) */
|
|
13
|
+
readonly reportRedefinitions: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface TrueFalseAbbreviationMetadata extends MergeableRecord {
|
|
16
|
+
/** uses of `T`/`F` that resolve to a definition of the analyzed code and are hence left alone */
|
|
17
|
+
readonly locallyDefined: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Port of the `R CMD check` note "found T/F in" (`checking R code for possible problems`, `tools::checkTnF`).
|
|
21
|
+
* `T` and `F` are ordinary variables that merely default to `TRUE` and `FALSE`, so any code (or user) may rebind them.
|
|
22
|
+
*/
|
|
23
|
+
export declare const TRUE_FALSE_ABBREVIATION: {
|
|
24
|
+
readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../../search/flowr-search").FlowrSearchElements<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../../search/flowr-search").FlowrSearchElement<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
25
|
+
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: TrueFalseAbbreviationConfig, data: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>) => Promise<{
|
|
26
|
+
results: TrueFalseAbbreviationResult[];
|
|
27
|
+
'.meta': {
|
|
28
|
+
locallyDefined: number;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
31
|
+
readonly prettyPrint: {
|
|
32
|
+
query: (r: TrueFalseAbbreviationResult) => string;
|
|
33
|
+
full: (r: TrueFalseAbbreviationResult) => string;
|
|
34
|
+
};
|
|
35
|
+
readonly info: {
|
|
36
|
+
readonly name: "TRUE/FALSE Abbreviation";
|
|
37
|
+
readonly tags: readonly [LintingRuleTag.Smell, LintingRuleTag.CmdCheck, LintingRuleTag.Robustness, LintingRuleTag.Readability, LintingRuleTag.QuickFix];
|
|
38
|
+
readonly certainty: LintingRuleCertainty.Exact;
|
|
39
|
+
readonly activeByDefault: false;
|
|
40
|
+
readonly description: "Finds `T` and `F` used for `TRUE` and `FALSE`, and top-level definitions of `T` or `F`. Off by default, as R only checks this for packages without a NAMESPACE.";
|
|
41
|
+
readonly defaultConfig: () => {
|
|
42
|
+
reportRedefinitions: true;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRUE_FALSE_ABBREVIATION = void 0;
|
|
4
|
+
const linter_format_1 = require("../../linter-format");
|
|
5
|
+
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
6
|
+
const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
7
|
+
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
8
|
+
const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
|
|
9
|
+
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
10
|
+
const linter_tags_1 = require("../../linter-tags");
|
|
11
|
+
const range_1 = require("../../../util/range");
|
|
12
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
13
|
+
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
14
|
+
const edge_1 = require("../../../dataflow/graph/edge");
|
|
15
|
+
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
16
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
17
|
+
const r_parameter_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
|
|
18
|
+
const r_function_definition_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
19
|
+
const cmd_check_util_1 = require("./cmd-check-util");
|
|
20
|
+
const Abbreviations = { T: 'TRUE', F: 'FALSE' };
|
|
21
|
+
/**
|
|
22
|
+
* Whether a read of `id` may reach the built-in constant and whether it may reach a definition of the code. As the
|
|
23
|
+
* functions of a package only run once all of its top-level code has, a function reading an unconditional top-level
|
|
24
|
+
* definition never sees the built-in.
|
|
25
|
+
*/
|
|
26
|
+
function reachedDefinitions(graph, id, idMap) {
|
|
27
|
+
let builtIn = false;
|
|
28
|
+
let local = false;
|
|
29
|
+
let shadowed = false;
|
|
30
|
+
const inFunction = model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is) !== undefined;
|
|
31
|
+
for (const [target, edge] of graph.edgesFrom(id)) {
|
|
32
|
+
if (edge_1.DfEdge.doesNotIncludeType(edge, edge_1.EdgeType.Reads)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (node_id_1.NodeId.isBuiltIn(target)) {
|
|
36
|
+
builtIn = true;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
local = true;
|
|
40
|
+
shadowed ||= inFunction && isUnconditionalTopLevel(target, idMap);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { builtIn: builtIn && !shadowed, local };
|
|
44
|
+
}
|
|
45
|
+
/** whether the node is evaluated by the top level of its file whenever the file is, i.e. not within a function or a branch */
|
|
46
|
+
function isUnconditionalTopLevel(id, idMap) {
|
|
47
|
+
for (let cur = idMap.get(id); cur?.info.parent !== undefined; cur = idMap.get(cur.info.parent)) {
|
|
48
|
+
const parent = idMap.get(cur.info.parent);
|
|
49
|
+
if (parent !== undefined && !r_expression_list_1.RExpressionList.is(parent) && !(r_binary_op_1.RBinaryOp.is(parent) && parent.lhs === cur)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Port of the `R CMD check` note "found T/F in" (`checking R code for possible problems`, `tools::checkTnF`).
|
|
57
|
+
* `T` and `F` are ordinary variables that merely default to `TRUE` and `FALSE`, so any code (or user) may rebind them.
|
|
58
|
+
*/
|
|
59
|
+
exports.TRUE_FALSE_ABBREVIATION = {
|
|
60
|
+
createSearch: () => flowr_search_builder_1.Q.all().filter(type_1.RType.Symbol),
|
|
61
|
+
processSearchResult: async (elements, config, data) => {
|
|
62
|
+
const { graph } = await data.dataflow();
|
|
63
|
+
const idMap = (await data.normalize()).idMap;
|
|
64
|
+
const pkg = (0, cmd_check_util_1.packageInfo)(data.inspectContext());
|
|
65
|
+
const results = [];
|
|
66
|
+
let locallyDefined = 0;
|
|
67
|
+
for (const { node } of elements.getElements()) {
|
|
68
|
+
if (!r_symbol_1.RSymbol.is(node)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const name = identifier_1.Identifier.getName(node.content);
|
|
72
|
+
const replacement = Abbreviations[name];
|
|
73
|
+
const loc = range_1.SourceLocation.fromNode(node);
|
|
74
|
+
if (replacement === undefined || identifier_1.Identifier.getNamespace(node.content) !== undefined || loc === undefined || !pkg.isPackageCode(node.info.file)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const vertex = graph.getVertex(node.info.id);
|
|
78
|
+
if (vertex_1.DfgVertex.isVariableDefinition(vertex)) {
|
|
79
|
+
/* a local `T` (a parameter, a variable of a function) only shadows within that function */
|
|
80
|
+
if (config.reportRedefinitions && model_1.RNode.strictlyEnclosingFunction(node.info.id, idMap) === undefined && !r_parameter_1.RParameter.is(idMap.get(node.info.parent ?? ''))) {
|
|
81
|
+
results.push({
|
|
82
|
+
...(0, cmd_check_util_1.at)(node),
|
|
83
|
+
name: name,
|
|
84
|
+
kind: 'redefinition',
|
|
85
|
+
message: `${name} is redefined, which changes the meaning of every ${name} used as an abbreviation of ${replacement}`
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (!vertex_1.DfgVertex.isUse(vertex)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const { builtIn, local } = reachedDefinitions(graph, node.info.id, idMap);
|
|
94
|
+
if (local && !builtIn) {
|
|
95
|
+
locallyDefined++;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
results.push({
|
|
99
|
+
...(0, cmd_check_util_1.at)(node, !local),
|
|
100
|
+
name: name,
|
|
101
|
+
kind: 'use',
|
|
102
|
+
message: `${name} is used as an abbreviation of ${replacement}`,
|
|
103
|
+
quickFix: [{ type: 'replace', description: `Replace \`${name}\` with \`${replacement}\``, replacement, loc }]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return { results, '.meta': { locallyDefined } };
|
|
107
|
+
},
|
|
108
|
+
prettyPrint: (0, cmd_check_util_1.printer)(r => `${r.kind === 'use' ? 'Use' : 'Redefinition'} of \`${r.name}\``),
|
|
109
|
+
info: {
|
|
110
|
+
name: 'TRUE/FALSE Abbreviation',
|
|
111
|
+
tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Readability, linter_tags_1.LintingRuleTag.QuickFix],
|
|
112
|
+
certainty: linter_format_1.LintingRuleCertainty.Exact,
|
|
113
|
+
/* R CMD check only runs `checkTnF` for a package without a NAMESPACE, which no current package is */
|
|
114
|
+
activeByDefault: false,
|
|
115
|
+
description: 'Finds `T` and `F` used for `TRUE` and `FALSE`, and top-level definitions of `T` or `F`. Off by default, as R only checks this for packages without a NAMESPACE.',
|
|
116
|
+
defaultConfig: () => ({
|
|
117
|
+
reportRedefinitions: true
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=true-false-abbreviation.js.map
|
|
@@ -39,7 +39,7 @@ export declare const DATA_FRAME_ACCESS_VALIDATION: {
|
|
|
39
39
|
readonly name: "Dataframe Access Validation";
|
|
40
40
|
readonly tags: readonly [LintingRuleTag.Bug, LintingRuleTag.Usability, LintingRuleTag.Reproducibility];
|
|
41
41
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
42
|
-
readonly description: "
|
|
42
|
+
readonly description: "Finds accesses to columns and rows a data frame does not have.";
|
|
43
43
|
readonly defaultConfig: () => {
|
|
44
44
|
readLoadedData: false;
|
|
45
45
|
};
|
|
@@ -91,7 +91,7 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
|
|
|
91
91
|
tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility],
|
|
92
92
|
// this rule is unable to detect all cases of dataframe access, but sufficiently ensures returned results are valid
|
|
93
93
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
94
|
-
description: '
|
|
94
|
+
description: 'Finds accesses to columns and rows a data frame does not have.',
|
|
95
95
|
defaultConfig: () => ({ readLoadedData: false })
|
|
96
96
|
}
|
|
97
97
|
};
|
|
@@ -12,18 +12,18 @@ export interface DeadCodeConfig extends MergeableRecord {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const DEAD_CODE: {
|
|
14
14
|
readonly createSearch: (config: DeadCodeConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
15
|
-
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: DeadCodeConfig,
|
|
15
|
+
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: DeadCodeConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
16
16
|
results: LintingResult[];
|
|
17
|
-
}
|
|
17
|
+
}>;
|
|
18
18
|
readonly prettyPrint: {
|
|
19
19
|
readonly query: (result: LintingResult) => string;
|
|
20
20
|
readonly full: (result: LintingResult) => string;
|
|
21
21
|
};
|
|
22
22
|
readonly info: {
|
|
23
23
|
readonly name: "Dead Code";
|
|
24
|
-
readonly tags: readonly [LintingRuleTag.Smell, LintingRuleTag.Usability, LintingRuleTag.Reproducibility];
|
|
24
|
+
readonly tags: readonly [LintingRuleTag.Smell, LintingRuleTag.Usability, LintingRuleTag.Reproducibility, LintingRuleTag.QuickFix];
|
|
25
25
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
26
|
-
readonly description: "
|
|
26
|
+
readonly description: "Finds code that is never reached during execution.";
|
|
27
27
|
readonly defaultConfig: () => {};
|
|
28
28
|
};
|
|
29
29
|
};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DEAD_CODE = void 0;
|
|
4
4
|
const linter_format_1 = require("../linter-format");
|
|
5
5
|
const range_1 = require("../../util/range");
|
|
6
|
+
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
6
7
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
7
8
|
const linter_tags_1 = require("../linter-tags");
|
|
8
9
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
@@ -27,7 +28,8 @@ exports.DEAD_CODE = {
|
|
|
27
28
|
roleInParent: "el-g" /* RoleInParent.ExpressionListGrouping */
|
|
28
29
|
}
|
|
29
30
|
}))),
|
|
30
|
-
processSearchResult: (elements, _config,
|
|
31
|
+
processSearchResult: async (elements, _config, data) => {
|
|
32
|
+
const { idMap } = await data.normalize();
|
|
31
33
|
return {
|
|
32
34
|
results: combineResults(elements.getElements()
|
|
33
35
|
.map(element => ({
|
|
@@ -35,7 +37,7 @@ exports.DEAD_CODE = {
|
|
|
35
37
|
involvedId: element.node.info.id,
|
|
36
38
|
loc: range_1.SourceLocation.fromNode(element.node)
|
|
37
39
|
}))
|
|
38
|
-
.filter(element => (0, assert_1.isNotUndefined)(element.loc)))
|
|
40
|
+
.filter(element => (0, assert_1.isNotUndefined)(element.loc))).map(result => isStatement(result, idMap) ? { ...result, quickFix: [{ type: 'remove', loc: result.loc, description: 'Remove the unreachable code' }] } : result)
|
|
39
41
|
};
|
|
40
42
|
},
|
|
41
43
|
prettyPrint: {
|
|
@@ -44,13 +46,26 @@ exports.DEAD_CODE = {
|
|
|
44
46
|
},
|
|
45
47
|
info: {
|
|
46
48
|
name: 'Dead Code',
|
|
47
|
-
tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility],
|
|
49
|
+
tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.QuickFix],
|
|
48
50
|
// our limited dead code analysis causes complex cases of dead code not to be included in the linting result, but deadness is properly investigated for returned results
|
|
49
51
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
50
|
-
description: '
|
|
52
|
+
description: 'Finds code that is never reached during execution.',
|
|
51
53
|
defaultConfig: () => ({})
|
|
52
54
|
}
|
|
53
55
|
};
|
|
56
|
+
/** whether the result is a whole statement of a block or the file, which can go without breaking the code around it */
|
|
57
|
+
function isStatement(result, idMap) {
|
|
58
|
+
const ids = Array.isArray(result.involvedId) ? result.involvedId : [result.involvedId];
|
|
59
|
+
return ids.some(id => {
|
|
60
|
+
const node = id === undefined ? undefined : idMap.get(id);
|
|
61
|
+
const parent = node?.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
62
|
+
/* the branch of an `if` without braces is a list of its own, which is no block */
|
|
63
|
+
const own = range_1.SourceLocation.fromNode(node);
|
|
64
|
+
return node?.info.role === "el-c" /* RoleInParent.ExpressionListChild */ && r_expression_list_1.RExpressionList.is(parent)
|
|
65
|
+
&& (parent.grouping !== undefined || parent.info.parent === undefined)
|
|
66
|
+
&& own !== undefined && range_1.SourceLocation.isSubsetOf(result.loc, own) && range_1.SourceLocation.isSubsetOf(own, result.loc);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
54
69
|
function combineResults(results) {
|
|
55
70
|
for (let i = results.length - 1; i >= 0; i--) {
|
|
56
71
|
const result = results[i];
|
|
@@ -67,7 +67,7 @@ export declare const DEPRECATED_FUNCTIONS: {
|
|
|
67
67
|
readonly name: "Deprecated Functions";
|
|
68
68
|
readonly tags: readonly [LintingRuleTag.Deprecated, LintingRuleTag.Smell, LintingRuleTag.Usability, LintingRuleTag.Reproducibility, LintingRuleTag.QuickFix];
|
|
69
69
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
70
|
-
readonly description: "
|
|
70
|
+
readonly description: "Finds deprecated functions and deprecated arguments of still-current functions, offering the replacement as a quick fix where one is known. A call to a bare name whose package the code never attaches is reported as uncertain, as any function of that name would answer to it.";
|
|
71
71
|
readonly defaultConfig: (ctx: import("../../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext) => {
|
|
72
72
|
always: Identifier[];
|
|
73
73
|
conditionally: Record<BrandedIdentifier, DeprecatedFunctionInformation>;
|
|
@@ -62,7 +62,7 @@ function indexAlways(always) {
|
|
|
62
62
|
return index;
|
|
63
63
|
}
|
|
64
64
|
/** The packages the code attaches; `undefined` when one of them cannot be named, so nothing is ruled out. */
|
|
65
|
-
async function
|
|
65
|
+
async function librariesAttachedBy(analyzer) {
|
|
66
66
|
const attached = new Set();
|
|
67
67
|
for (const lib of (await analyzer.query([{ type: 'dependencies', enabledCategories: ['library'] }]))['dependencies'].library) {
|
|
68
68
|
if (lib.value === undefined || lib.value === dependencies_query_format_1.Unknown) {
|
|
@@ -126,7 +126,7 @@ exports.DEPRECATED_FUNCTIONS = {
|
|
|
126
126
|
owners: always.get(identifier_1.Identifier.getName(candidate.target))
|
|
127
127
|
})).filter(m => m.conditional !== undefined || m.owners !== undefined);
|
|
128
128
|
/* only asked once something matched, so a clean file queries nothing */
|
|
129
|
-
const attached = matched.length === 0 ? undefined : await
|
|
129
|
+
const attached = matched.length === 0 ? undefined : await librariesAttachedBy(data);
|
|
130
130
|
const packageVersions = await inferPackageVersions(data, matched.map(m => m.conditional));
|
|
131
131
|
const results = matched.map(({ candidate, conditional, owners }) => {
|
|
132
132
|
if (conditional !== undefined) {
|
|
@@ -206,7 +206,7 @@ exports.DEPRECATED_FUNCTIONS = {
|
|
|
206
206
|
// the hardcoded `always` and `conditionally` list ensures every reported hit is real, but the list is pre-crawled and hence
|
|
207
207
|
// incomplete; the signature-database pass above adds recall for whichever packages are resolved
|
|
208
208
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
209
|
-
description: '
|
|
209
|
+
description: 'Finds deprecated functions and deprecated arguments of still-current functions, offering the replacement as a quick fix where one is known. A call to a bare name whose package the code never attaches is reported as uncertain, as any function of that name would answer to it.',
|
|
210
210
|
defaultConfig: ctx => ({
|
|
211
211
|
always: ctx.env.deriveFromDefinitions(alwayDeprecatedFromBuiltinConfig),
|
|
212
212
|
conditionally: ctx.env.deriveFromDefinitions(conditionalyDeprecatedFromBuiltinConfig)
|
|
@@ -283,7 +283,7 @@ function renameFix(node, replacedBy, what) {
|
|
|
283
283
|
return [{ type: 'replace', description: `Replace ${what} with \`${replacedBy}\``, replacement: replacedBy, loc }];
|
|
284
284
|
}
|
|
285
285
|
/** The name to rename, `undefined` for `pkg::fn` as the replacement states no package to put back. */
|
|
286
|
-
function
|
|
286
|
+
function renamableCallee(node) {
|
|
287
287
|
return r_function_call_1.RFunctionCall.isNamed(node) && identifier_1.Identifier.getNamespace(node.functionName.content) === undefined
|
|
288
288
|
? node.functionName : undefined;
|
|
289
289
|
}
|
|
@@ -347,7 +347,7 @@ function deprecateFunctionConditionally(candidate, dataflow, idMap, analyzer, en
|
|
|
347
347
|
state: info.state,
|
|
348
348
|
replacedBy: info.replacedBy,
|
|
349
349
|
sinceVersion: fnSinceVersion,
|
|
350
|
-
quickFix: renameFix(
|
|
350
|
+
quickFix: renameFix(renamableCallee(candidate.node), info.replacedBy, 'the call')
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
353
|
}
|
|
@@ -2,8 +2,10 @@ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
3
|
import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
|
|
4
4
|
import { LintingRuleTag } from '../linter-tags';
|
|
5
|
-
import
|
|
5
|
+
import { RString } from '../../r-bridge/lang-4.x/ast/model/nodes/r-string';
|
|
6
|
+
import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
6
7
|
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
8
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
9
|
export interface FilePathValidityResult extends LintingResult {
|
|
8
10
|
filePath: string;
|
|
9
11
|
}
|
|
@@ -43,7 +45,7 @@ export declare const FILE_PATH_VALIDITY: {
|
|
|
43
45
|
}>;
|
|
44
46
|
readonly info: {
|
|
45
47
|
readonly name: "File Path Validity";
|
|
46
|
-
readonly description: "
|
|
48
|
+
readonly description: "Finds file paths used in read and write operations that are invalid or do not point to existing files.";
|
|
47
49
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
48
50
|
readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility, LintingRuleTag.Bug, LintingRuleTag.QuickFix];
|
|
49
51
|
readonly defaultConfig: () => {
|
|
@@ -58,3 +60,5 @@ export declare const FILE_PATH_VALIDITY: {
|
|
|
58
60
|
readonly full: (result: FilePathValidityResult) => string;
|
|
59
61
|
};
|
|
60
62
|
};
|
|
63
|
+
/** the string-literal path argument of a call whose resolved value is `value`, for anchoring a quick fix */
|
|
64
|
+
export declare function pathArgStringNode(idMap: AstIdMap, callId: NodeId, value: string): RString | undefined;
|