@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,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.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.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
|
|
@@ -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) {
|
|
@@ -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
|
}
|
|
@@ -31,7 +31,7 @@ export declare const functionFinderUtil: {
|
|
|
31
31
|
query: (result: FunctionsResult) => string;
|
|
32
32
|
full: (result: FunctionsResult) => string;
|
|
33
33
|
};
|
|
34
|
-
requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, analyzer: ReadonlyFlowrAnalysisProvider, requireValue: RegExp | string | undefined): Promise<Ternary>;
|
|
34
|
+
requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, analyzer: ReadonlyFlowrAnalysisProvider, requireValue: RegExp | string | undefined, identifier: Identifier | undefined): Promise<Ternary>;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Test if a function call has an argument with a specific value
|
|
@@ -14,7 +14,6 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
14
14
|
const dependencies_query_format_1 = require("../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
15
15
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
16
16
|
const logic_1 = require("../../util/logic");
|
|
17
|
-
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
18
17
|
/**
|
|
19
18
|
* This helper object collects utility functions used to create linting rules that search for specific functions.
|
|
20
19
|
*/
|
|
@@ -66,9 +65,8 @@ exports.functionFinderUtil = {
|
|
|
66
65
|
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Function \`${result.function}\` called at ${range_1.SourceLocation.format(result.loc)} is related to ${functionType}`
|
|
67
66
|
};
|
|
68
67
|
},
|
|
69
|
-
async requireArgumentValue(element, pool, analyzer, requireValue) {
|
|
68
|
+
async requireArgumentValue(element, pool, analyzer, requireValue, identifier) {
|
|
70
69
|
const dataflow = await analyzer.dataflow();
|
|
71
|
-
const identifier = df_helper_1.Dataflow.qualify(element.node.info.id, dataflow.graph, true) ?? (element.node.lexeme !== undefined ? identifier_1.Identifier.parse(element.node.lexeme) : undefined);
|
|
72
70
|
/* if we have no additional info, we assume they always access the network */
|
|
73
71
|
if (identifier === undefined || requireValue === undefined) {
|
|
74
72
|
return logic_1.Ternary.Always;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
1
2
|
import type { DataflowGraph } from '../../dataflow/graph/graph';
|
|
2
|
-
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { MergeableRecord } from '../../util/objects';
|
|
4
4
|
import { type LintingResult, type LintQuickFixReplacement, LintingRuleCertainty } from '../linter-format';
|
|
5
5
|
import { LintingRuleTag } from '../linter-tags';
|
|
@@ -6,14 +6,16 @@ exports.detectCasing = detectCasing;
|
|
|
6
6
|
exports.getMostUsedCasing = getMostUsedCasing;
|
|
7
7
|
exports.fixCasing = fixCasing;
|
|
8
8
|
exports.createNamingConventionQuickFixes = createNamingConventionQuickFixes;
|
|
9
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
10
|
+
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
9
11
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
10
|
-
const dfg_get_symbol_refs_1 = require("../../dataflow/origin/dfg-get-symbol-refs");
|
|
11
12
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
12
13
|
const assert_1 = require("../../util/assert");
|
|
13
14
|
const range_1 = require("../../util/range");
|
|
14
15
|
const linter_format_1 = require("../linter-format");
|
|
15
16
|
const linter_tags_1 = require("../linter-tags");
|
|
16
17
|
const unused_definition_1 = require("./unused-definition");
|
|
18
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
17
19
|
var CasingConvention;
|
|
18
20
|
(function (CasingConvention) {
|
|
19
21
|
CasingConvention["CamelCase"] = "camelCase";
|
|
@@ -122,22 +124,18 @@ function fixCasing(identifier, convention, ignorePrefix) {
|
|
|
122
124
|
(0, assert_1.assertUnreachable)(convention);
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
|
-
function unquoteName(lexeme) {
|
|
126
|
-
const quoted = /^(["'`])(.*)\1$/s.exec(lexeme);
|
|
127
|
-
return quoted ? { quote: quoted[1], name: quoted[2] } : { quote: '', name: lexeme };
|
|
128
|
-
}
|
|
129
127
|
/**
|
|
130
128
|
* Creates quick fixes for renaming all references to the given node to match the provided replacement.
|
|
131
129
|
*/
|
|
132
130
|
function createNamingConventionQuickFixes(graph, nodeId, replacement, conv) {
|
|
133
|
-
const refs =
|
|
131
|
+
const refs = df_helper_1.Dataflow.refsToSymbol(graph, nodeId);
|
|
134
132
|
const idMap = graph.idMap;
|
|
135
133
|
if (refs === undefined || idMap === undefined) {
|
|
136
134
|
return undefined;
|
|
137
135
|
}
|
|
138
136
|
/* the name as it is written, which is the only text a rename may overwrite */
|
|
139
|
-
const lexeme =
|
|
140
|
-
const original = lexeme === undefined ? undefined :
|
|
137
|
+
const lexeme = node_id_1.NodeId.recoverName(nodeId, idMap);
|
|
138
|
+
const original = lexeme === undefined ? undefined : r_string_1.RString.splitQuotes(lexeme).content;
|
|
141
139
|
if (original === undefined || original === replacement) {
|
|
142
140
|
/* a replacement equal to what is already there is no fix at all */
|
|
143
141
|
return undefined;
|
|
@@ -145,19 +143,20 @@ function createNamingConventionQuickFixes(graph, nodeId, replacement, conv) {
|
|
|
145
143
|
const result = [];
|
|
146
144
|
for (const ref of refs) {
|
|
147
145
|
const node = idMap.get(ref);
|
|
148
|
-
const written = node?.lexeme === undefined ? undefined :
|
|
149
|
-
if (node?.lexeme === undefined || written?.
|
|
146
|
+
const written = node?.lexeme === undefined ? undefined : r_string_1.RString.splitQuotes(node.lexeme);
|
|
147
|
+
if (node?.lexeme === undefined || written?.content !== original) {
|
|
150
148
|
/* a reference reached through something else, as `myfield(x) <- v` reaches `x` through the call it
|
|
151
149
|
names, sits at a place holding another name, and writing over it would rename that one instead */
|
|
152
150
|
continue;
|
|
153
151
|
}
|
|
152
|
+
const quote = written.quote ?? '';
|
|
154
153
|
const loc = range_1.SourceLocation.fromNode(node);
|
|
155
154
|
if (loc) {
|
|
156
155
|
// In case of a function call we only need to include the name, not the '()'
|
|
157
156
|
loc[3] = loc[1] + node.lexeme.length - 1;
|
|
158
157
|
result.push({
|
|
159
158
|
type: 'replace',
|
|
160
|
-
replacement: `${
|
|
159
|
+
replacement: `${quote}${replacement}${quote}`,
|
|
161
160
|
description: `Rename to match naming convention ${conv}`,
|
|
162
161
|
loc
|
|
163
162
|
});
|
|
@@ -173,7 +172,7 @@ exports.NAMING_CONVENTION = {
|
|
|
173
172
|
const called = (0, unused_definition_1.collectCalledNames)(dataflow.graph);
|
|
174
173
|
const symbols = elements.getElements()
|
|
175
174
|
.map(m => {
|
|
176
|
-
const name =
|
|
175
|
+
const name = r_string_1.RString.splitQuotes(m.node.lexeme).content;
|
|
177
176
|
return {
|
|
178
177
|
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
179
178
|
detectedCasing: detectCasing(name, config.ignorePrefix),
|
|
@@ -188,8 +187,8 @@ exports.NAMING_CONVENTION = {
|
|
|
188
187
|
const unambiguous = symbols.filter(s => detectPotentialCasings(s.name, config.ignorePrefix).length === 1);
|
|
189
188
|
const casing = config.caseing === 'auto' ? getMostUsedCasing(unambiguous) : config.caseing;
|
|
190
189
|
const taken = new Set(dataflow.graph.vertices(true).map(([id]) => {
|
|
191
|
-
const lexeme = dataflow.graph.idMap
|
|
192
|
-
return lexeme === undefined ? undefined :
|
|
190
|
+
const lexeme = node_id_1.NodeId.recoverName(id, dataflow.graph.idMap);
|
|
191
|
+
return lexeme === undefined ? undefined : r_string_1.RString.splitQuotes(lexeme).content;
|
|
193
192
|
}));
|
|
194
193
|
const results = casing === CasingConvention.Unknown ? [] : symbols
|
|
195
194
|
/* a name that already reads as the wanted convention is no violation, whatever else it could also be
|
|
@@ -31,9 +31,10 @@ export interface NetworkFunction extends MergeableRecord {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Every built-in that may reach the network, read back from the {@link DefaultBuiltinConfig}: the ones labeled
|
|
34
|
-
* {@link SemanticCallTag.Network} always do
|
|
35
|
-
*
|
|
36
|
-
* built-in `Network` or give it a resource
|
|
34
|
+
* {@link SemanticCallTag.Network} always do unless they may open a local {@link SemanticCallTag.File} instead,
|
|
35
|
+
* and any call naming an {@link ArgProp.Resource} does whenever that resource is a url rather than a path --
|
|
36
|
+
* which is what {@link UrlPattern} decides per call site. Label a built-in `Network` or give it a resource
|
|
37
|
+
* parameter and it shows up here; nothing is listed twice.
|
|
37
38
|
*/
|
|
38
39
|
export declare function networkFunctions(index: BuiltInIndex): NetworkFunction[];
|
|
39
40
|
export declare const NETWORK_FUNCTIONS: {
|