@eagleoutice/flowr 2.16.6 → 2.16.8
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 +21 -15
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
- package/abstract-interpretation/data-frame/resolve-args.js +2 -11
- package/cli/repl/commands/repl-cfg.js +5 -19
- package/cli/repl/commands/repl-code-command.d.ts +10 -0
- package/cli/repl/commands/repl-code-command.js +18 -0
- package/cli/repl/commands/repl-dataflow.js +34 -59
- package/cli/repl/commands/repl-normalize.js +24 -41
- package/cli/repl/commands/repl-query.js +10 -17
- package/config.js +3 -3
- package/control-flow/cfg-dead-code.js +15 -2
- package/control-flow/useless-loop.js +1 -2
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/dataflow/environments/ambient-state-name.d.ts +80 -0
- package/dataflow/environments/ambient-state-name.js +113 -0
- package/dataflow/environments/built-in-eval-name.d.ts +3 -1
- package/dataflow/environments/built-in-eval-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +27 -7
- package/dataflow/environments/built-in-props.js +59 -44
- package/dataflow/environments/built-in.d.ts +5 -2
- package/dataflow/environments/built-in.js +22 -5
- package/dataflow/environments/default-builtin-config.d.ts +538 -14
- package/dataflow/environments/default-builtin-config.js +189 -123
- package/dataflow/environments/environment.d.ts +7 -1
- package/dataflow/environments/environment.js +19 -1
- package/dataflow/environments/identifier.d.ts +12 -1
- package/dataflow/environments/reference-to-maybe.js +1 -6
- package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
- package/dataflow/eval/resolve/alias-tracking.js +66 -37
- package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
- package/dataflow/eval/resolve/resolve-argument.js +23 -11
- package/dataflow/eval/resolve/resolve.d.ts +5 -0
- package/dataflow/eval/resolve/resolve.js +25 -3
- package/dataflow/eval/values/r-value.d.ts +4 -2
- package/dataflow/eval/values/r-value.js +3 -1
- package/dataflow/eval/values/string/string-constants.d.ts +7 -1
- package/dataflow/eval/values/string/string-constants.js +38 -36
- package/dataflow/extractor.js +105 -2
- package/dataflow/fn/argument-roles.js +22 -8
- package/dataflow/fn/function-semantics.d.ts +3 -2
- package/dataflow/fn/strict-function.js +13 -2
- package/dataflow/graph/dataflowgraph-builder.d.ts +4 -4
- package/dataflow/graph/df-helper.d.ts +14 -1
- package/dataflow/graph/df-helper.js +37 -4
- package/dataflow/graph/graph.d.ts +6 -0
- package/dataflow/graph/graph.js +9 -10
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/hooks.d.ts +1 -1
- package/dataflow/info.d.ts +3 -3
- package/dataflow/internal/linker.d.ts +4 -1
- package/dataflow/internal/linker.js +12 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +21 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +43 -7
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
- package/dataflow/internal/process/functions/call/common.js +3 -4
- package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
- package/dataflow/internal/process/functions/call/deferred.js +17 -9
- package/dataflow/internal/process/functions/call/quoted.js +1 -1
- package/dataflow/processor.d.ts +1 -1
- package/documentation/doc-capabilities.js +3 -2
- package/documentation/doc-readme.js +1 -2
- package/documentation/doc-util/doc-dfg.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +3 -1
- package/documentation/doc-util/doc-query.js +4 -4
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-linter.js +16 -206
- package/documentation/wiki-linting-and-testing.js +31 -64
- package/documentation/wiki-query.js +41 -0
- package/index.d.ts +1 -0
- package/index.js +5 -1
- package/linter/linter-format.d.ts +6 -0
- package/linter/linter-format.js +10 -0
- package/linter/linter-rules.d.ts +155 -103
- package/linter/linter-rules.js +2 -0
- package/linter/linter-util.d.ts +23 -0
- package/linter/linter-util.js +58 -0
- package/linter/rules/absolute-path.d.ts +2 -2
- package/linter/rules/absolute-path.js +1 -4
- package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
- package/linter/rules/cmd-check/bogus-return.js +3 -7
- package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.js +3 -7
- package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
- package/linter/rules/cmd-check/cmd-check-util.js +14 -26
- package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
- package/linter/rules/cmd-check/compiled-code.js +3 -13
- package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
- package/linter/rules/cmd-check/dependency-declaration.js +6 -7
- package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
- package/linter/rules/cmd-check/file-checks.d.ts +19 -6
- package/linter/rules/cmd-check/file-checks.js +13 -5
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.js +3 -2
- package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
- package/linter/rules/cmd-check/namespace-tampering.js +9 -9
- package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.d.ts +11 -5
- package/linter/rules/cmd-check/package-data.js +5 -12
- package/linter/rules/cmd-check/package-files.js +4 -10
- package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
- package/linter/rules/cmd-check/package-hooks.js +10 -8
- package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
- package/linter/rules/cmd-check/package-metafiles.js +3 -12
- package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
- package/linter/rules/cmd-check/package-runtime.js +64 -20
- package/linter/rules/cmd-check/package-structure.d.ts +11 -5
- package/linter/rules/cmd-check/package-structure.js +4 -12
- package/linter/rules/cmd-check/rd-files.d.ts +8 -3
- package/linter/rules/cmd-check/rd-files.js +4 -14
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
- package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.js +5 -8
- package/linter/rules/dead-code.d.ts +5 -4
- package/linter/rules/dead-code.js +25 -14
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/deprecated-functions.js +16 -23
- package/linter/rules/file-path-validity.d.ts +2 -2
- package/linter/rules/file-path-validity.js +3 -6
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +7 -14
- package/linter/rules/namespace-access.d.ts +2 -2
- package/linter/rules/namespace-access.js +6 -9
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +1 -4
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/no-leaked-credentials.d.ts +2 -2
- package/linter/rules/no-leaked-credentials.js +1 -4
- package/linter/rules/overwritten-file.d.ts +38 -0
- package/linter/rules/overwritten-file.js +102 -0
- package/linter/rules/problematic-inputs.d.ts +16 -6
- package/linter/rules/problematic-inputs.js +78 -34
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +1 -4
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +6 -23
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -4
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +1 -4
- package/linter/rules/stop-with-call-arg.d.ts +2 -2
- package/linter/rules/stop-with-call-arg.js +4 -11
- package/linter/rules/syntactically-valid.d.ts +4 -2
- package/linter/rules/syntactically-valid.js +29 -10
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +1 -4
- package/linter/rules/undefined-symbol.d.ts +2 -2
- package/linter/rules/undefined-symbol.js +25 -22
- package/linter/rules/unescaped-arguments.d.ts +2 -2
- package/linter/rules/unescaped-arguments.js +1 -4
- package/linter/rules/unused-definition.d.ts +2 -2
- package/linter/rules/unused-definition.js +37 -25
- package/linter/rules/unused-import.d.ts +2 -2
- package/linter/rules/unused-import.js +9 -14
- package/linter/rules/useless-loop.d.ts +7 -6
- package/linter/rules/useless-loop.js +4 -8
- package/package.json +5 -3
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +15 -11
- package/project/context/flowr-analyzer-files-context.d.ts +3 -0
- package/project/context/flowr-analyzer-files-context.js +6 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
- package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
- package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
- package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
- package/project/plugins/file-plugins/files/r-session.js +58 -0
- package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
- package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/spec-query.d.ts +73 -0
- package/project/sigdb/spec-query.js +339 -0
- package/queries/base-query-format.d.ts +1 -1
- package/queries/base-query-format.js +2 -2
- package/queries/catalog/absint-query/absint-query-executor.js +3 -6
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
- package/queries/catalog/config-query/config-query-format.d.ts +0 -1
- package/queries/catalog/config-query/config-query-format.js +1 -2
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
- package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
- package/queries/catalog/dice-query/dice-query-executor.js +2 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
- package/queries/catalog/files-query/files-query-executor.js +2 -3
- package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
- package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
- package/queries/catalog/origin-query/origin-query-executor.js +3 -11
- package/queries/catalog/project-query/project-query-executor.js +23 -7
- package/queries/catalog/project-query/project-query-format.d.ts +5 -0
- package/queries/catalog/project-query/project-query-format.js +20 -2
- package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
- package/queries/catalog/search-query/search-query-executor.js +2 -3
- package/queries/catalog/signature-query/signature-query-executor.js +39 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-format.js +15 -1
- package/queries/catalog/signature-query/signature-query-render.js +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
- package/queries/query-function-property.d.ts +28 -0
- package/queries/query-function-property.js +48 -0
- package/queries/query-meta.d.ts +3 -0
- package/queries/query-meta.js +8 -0
- package/queries/query.d.ts +13 -18
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/type.js +3 -0
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
- package/reconstruct/reconstruct.js +35 -1
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/static/fingerprint.js +7 -3
- package/slicing/static/static-slicer.js +6 -0
- package/util/assert.js +2 -2
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +11 -0
- package/util/collections/defaultmap.d.ts +5 -1
- package/util/collections/defaultmap.js +6 -1
- package/util/files.js +26 -5
- package/util/flowr-version.d.ts +10 -0
- package/util/flowr-version.js +20 -0
- package/util/glob.js +6 -4
- package/util/r-regex.d.ts +6 -0
- package/util/r-regex.js +17 -0
- package/util/text/args.d.ts +5 -0
- package/util/text/args.js +28 -22
- package/util/text/name-rank.d.ts +2 -0
- package/util/text/name-rank.js +3 -1
- package/util/text/regex.d.ts +10 -0
- package/util/text/regex.js +29 -0
- package/util/version.d.ts +1 -6
- package/util/version.js +6 -14
- package/documentation/doc-util/doc-functions.d.ts +0 -24
- package/documentation/doc-util/doc-functions.js +0 -65
|
@@ -12,6 +12,7 @@ const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
|
|
|
12
12
|
const linter_tags_1 = require("../../linter-tags");
|
|
13
13
|
const range_1 = require("../../../util/range");
|
|
14
14
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
15
|
+
const linter_util_1 = require("../../linter-util");
|
|
15
16
|
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
16
17
|
const flowr_file_1 = require("../../../project/context/flowr-file");
|
|
17
18
|
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
@@ -21,14 +22,19 @@ const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/
|
|
|
21
22
|
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
22
23
|
const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
23
24
|
const cmd_check_util_1 = require("./cmd-check-util");
|
|
24
|
-
const
|
|
25
|
+
const file_checks_1 = require("./file-checks");
|
|
25
26
|
const package_code_1 = require("./package-code");
|
|
27
|
+
const r_regex_1 = require("../../../util/r-regex");
|
|
28
|
+
const string_constants_1 = require("../../../dataflow/eval/values/string/string-constants");
|
|
26
29
|
/** calls binding names in ways a scan of the assignments does not see, so an export may be defined after all */
|
|
27
30
|
const DynamicDefiners = new Set(['assign', 'delayedAssign', 'makeActiveBinding', 'eval', 'evalq', 'sys.source', 'list2env', 'source']);
|
|
31
|
+
/** calls whose definitions put names into the namespace no scan of the code sees, such as the `.__C__` metadata of a class */
|
|
32
|
+
const MetadataDefiners = new Set(['setClass', 'setClassUnion', 'setRefClass', 'setGeneric', 'setMethod', 'setValidity', 'setOldClass']);
|
|
28
33
|
/** the names the top level of the package code binds, including the generics `setGeneric` creates */
|
|
29
|
-
function definitionsOf(ast, pkg, data) {
|
|
34
|
+
function definitionsOf(ast, pkg, data, declaring) {
|
|
30
35
|
const names = new Set(data);
|
|
31
36
|
let dynamic = false;
|
|
37
|
+
let metadata = false;
|
|
32
38
|
const topLevelCalls = [];
|
|
33
39
|
const idMap = ast.idMap;
|
|
34
40
|
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
@@ -42,6 +48,7 @@ function definitionsOf(ast, pkg, data) {
|
|
|
42
48
|
topLevelCalls.push(fn);
|
|
43
49
|
}
|
|
44
50
|
const first = node.arguments[0] === r_function_call_1.EmptyArgument ? undefined : node.arguments[0]?.value;
|
|
51
|
+
metadata ||= MetadataDefiners.has(fn);
|
|
45
52
|
if ((fn === 'setGeneric' || fn === 'setRefClass' || fn === 'setClass') && r_string_1.RString.is(first)) {
|
|
46
53
|
names.add(first.content.str);
|
|
47
54
|
}
|
|
@@ -68,10 +75,43 @@ function definitionsOf(ast, pkg, data) {
|
|
|
68
75
|
names.add(target.content.str);
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
|
-
return { names, dynamic, opaque: topLevelCalls.some(fn => !names.has(fn) && (0, r_base_packages_1.baseRExportOwner)(fn) === undefined && !
|
|
78
|
+
return { names, dynamic, metadata, opaque: topLevelCalls.some(fn => !names.has(fn) && (0, r_base_packages_1.baseRExportOwner)(fn) === undefined && !declaring.has(fn) && fn !== 'assign') };
|
|
79
|
+
}
|
|
80
|
+
/** the names every namespace defines before the package code runs, which an export pattern can match as well */
|
|
81
|
+
const NamespaceInternals = ['.packageName', '.__NAMESPACE__.', '.__S3MethodsTable__.'];
|
|
82
|
+
/** whether a namespace exports anything: an export, a registered S3 method, or a pattern that `matches` a name */
|
|
83
|
+
function exportsAnything(ns, matches) {
|
|
84
|
+
return ns.exportedSymbols.length + ns.exportedFunctions.length + ns.exportedS4Methods.length + ns.exportedS4Classes.length + ns.exportS3Generics.size > 0
|
|
85
|
+
|| ns.exportedPatterns.some(matches)
|
|
86
|
+
|| [...ns.conditional?.values() ?? []].some(c => exportsAnything(c, matches));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Export patterns that match none of the names the package defines, and a NAMESPACE that exports nothing at all,
|
|
90
|
+
* which is fine only for a package that `shipsData`, as its data sets are what it offers.
|
|
91
|
+
* A pattern is only judged where the definitions are known (none `hidden` in binary files) and it reads the same in R and JavaScript.
|
|
92
|
+
*/
|
|
93
|
+
function exportChecks(ns, defs, config, hidden, shipsData, at, add) {
|
|
94
|
+
const certainty = defs.dynamic ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain;
|
|
95
|
+
const judged = !hidden && !defs.opaque && !defs.metadata;
|
|
96
|
+
const names = [...defs.names, ...NamespaceInternals];
|
|
97
|
+
/* a pattern that JavaScript reads differently from R, or that cannot be checked, is assumed to match */
|
|
98
|
+
const empty = new Set(judged ? ns.exportedPatterns.filter(pattern => {
|
|
99
|
+
const value = (0, string_constants_1.unescapeRString)(pattern);
|
|
100
|
+
const regex = value === undefined ? undefined : (0, r_regex_1.parseRRegexPatternExactly)(value);
|
|
101
|
+
return regex !== undefined && !names.some(n => regex.test(n));
|
|
102
|
+
}) : []);
|
|
103
|
+
for (const pattern of config.checkExports ? empty : []) {
|
|
104
|
+
add({ certainty, loc: at(pattern), kind: 'empty-export-pattern', message: `exportPattern("${pattern}") matches nothing the package defines, so it exports nothing` });
|
|
105
|
+
}
|
|
106
|
+
if (config.requireExports && !shipsData && !exportsAnything(ns, pattern => !empty.has(pattern))) {
|
|
107
|
+
add({
|
|
108
|
+
certainty: empty.size > 0 ? certainty : linter_format_1.LintingResultCertainty.Certain,
|
|
109
|
+
loc: at(''),
|
|
110
|
+
kind: 'no-exports',
|
|
111
|
+
message: 'the NAMESPACE exports nothing, so attaching the package gives access to none of its functions'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
72
114
|
}
|
|
73
|
-
/** calls at the top level of package code that define nothing beyond what the scan sees */
|
|
74
|
-
const TopLevelHarmless = new Set(['setGeneric', 'setClass', 'setRefClass', 'setMethod', 'setValidity', 'setClassUnion', 'assign', 'globalVariables']);
|
|
75
115
|
/** the line of the first NAMESPACE directive matching, to point a finding at it */
|
|
76
116
|
function lineMatching(text, pattern) {
|
|
77
117
|
const line = text?.split(/\r?\n/).findIndex(l => !l.trimStart().startsWith('#') && pattern.test(l));
|
|
@@ -105,7 +145,7 @@ function syntaxErrorRow(code, data) {
|
|
|
105
145
|
function writesIntoWorkingDirectory(file) {
|
|
106
146
|
return file !== '' && !path_1.default.isAbsolute(file) && !file.startsWith('~') && !/^[a-z]+:\/\//i.test(file) && file !== 'stdout' && file !== 'stderr';
|
|
107
147
|
}
|
|
108
|
-
function namespaceChecks(files, pkg, defs, data, add) {
|
|
148
|
+
function namespaceChecks(files, pkg, defs, data, config, shipsData, add) {
|
|
109
149
|
const ns = pkg.namespace;
|
|
110
150
|
const nsFile = data.inspectContext().files.getFilesByRole(flowr_file_1.FileRole.Namespace)[0];
|
|
111
151
|
if (ns === undefined || nsFile === undefined) {
|
|
@@ -113,6 +153,8 @@ function namespaceChecks(files, pkg, defs, data, add) {
|
|
|
113
153
|
}
|
|
114
154
|
const text = nsFile.rawText?.();
|
|
115
155
|
const relative = path_1.default.relative(files.root, nsFile.path()).split(path_1.default.sep).join('/');
|
|
156
|
+
/* the objects of `R/sysdata.rda` live in the namespace as well, under names only the binary file knows */
|
|
157
|
+
exportChecks(ns, defs, config, files.entries.some(e => e.relative === 'R/sysdata.rda'), shipsData, pattern => files.locate(relative, pattern === '' ? undefined : lineOf(text, pattern) ?? lineMatching(text, /^\s*exportPattern\s*\(/)), add);
|
|
116
158
|
if (defs.opaque) {
|
|
117
159
|
return;
|
|
118
160
|
}
|
|
@@ -120,7 +162,7 @@ function namespaceChecks(files, pkg, defs, data, add) {
|
|
|
120
162
|
/* a package may export what it imports (`importFrom(magrittr, "%>%")` and `export("%>%")`) */
|
|
121
163
|
const imported = new Set([...ns.importedPackages.values()].flatMap(v => v === 'all' ? [] : v));
|
|
122
164
|
const importsWhole = [...ns.importedPackages.values()].includes('all');
|
|
123
|
-
for (const name of [...ns.exportedSymbols, ...ns.exportedFunctions]) {
|
|
165
|
+
for (const name of config.checkExports ? [...ns.exportedSymbols, ...ns.exportedFunctions] : []) {
|
|
124
166
|
if (!defs.names.has(name) && !imported.has(name) && !importsWhole) {
|
|
125
167
|
add({ certainty, loc: files.locate(relative, lineOf(text, name)), kind: 'undefined-export', message: `undefined export: '${name}', installing the package fails` });
|
|
126
168
|
}
|
|
@@ -197,7 +239,7 @@ function testAndVignetteChecks(files, pkg, data, config, writers, add) {
|
|
|
197
239
|
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: at(node), kind: 'test-runner', message: `test_check("${strings[0]}") runs the tests of another package than '${pkg.name}'` });
|
|
198
240
|
}
|
|
199
241
|
else if (config.checkWrites && writers.has(fn)) {
|
|
200
|
-
const named = node.arguments.find(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined &&
|
|
242
|
+
const named = node.arguments.find(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && writers.get(fn)?.has(identifier_1.Identifier.getName(a.name.content)));
|
|
201
243
|
const second = node.arguments[1];
|
|
202
244
|
const file = named !== undefined && named !== r_function_call_1.EmptyArgument ? named.value : second !== undefined && second !== r_function_call_1.EmptyArgument ? second.value : undefined;
|
|
203
245
|
if (r_string_1.RString.is(file) && writesIntoWorkingDirectory(file.content.str)) {
|
|
@@ -228,22 +270,18 @@ function testAndVignetteChecks(files, pkg, data, config, writers, add) {
|
|
|
228
270
|
*/
|
|
229
271
|
exports.PACKAGE_RUNTIME = {
|
|
230
272
|
createSearch: () => flowr_search_builder_1.Q.from([]),
|
|
231
|
-
processSearchResult: async (
|
|
273
|
+
processSearchResult: (0, file_checks_1.onPackageFiles)({}, async (files, pkg, config, data) => {
|
|
232
274
|
const ctx = data.inspectContext();
|
|
233
|
-
const pkg = (0, cmd_check_util_1.packageInfo)(ctx);
|
|
234
|
-
const files = (0, package_files_1.packageFiles)(ctx, pkg.name);
|
|
235
275
|
const results = [];
|
|
236
|
-
if (files === undefined) {
|
|
237
|
-
return { results, '.meta': {} };
|
|
238
|
-
}
|
|
239
276
|
const add = (r) => results.push({ ...r, involvedId: undefined });
|
|
240
277
|
const ast = ctx.files.hasRequests() ? await data.normalize() : undefined;
|
|
241
278
|
const dataObjects = files.entries.filter(e => !e.isDirectory && e.relative.startsWith('data/')).map(e => path_1.default.posix.basename(e.relative).replace(/\..*$/, ''));
|
|
242
279
|
if (ast !== undefined) {
|
|
243
|
-
namespaceChecks(files, pkg, definitionsOf(ast, pkg, dataObjects), data, add);
|
|
280
|
+
namespaceChecks(files, pkg, definitionsOf(ast, pkg, dataObjects, (0, linter_util_1.namesWith)(ctx.env.builtInIndex, built_in_props_1.SemanticCallTag.Declares)), data, config, dataObjects.length > 0, add);
|
|
244
281
|
const ownName = pkg.name;
|
|
282
|
+
const attaching = (0, linter_util_1.namesWith)(ctx.env.builtInIndex, built_in_props_1.SemanticCallTag.AttachesPackage);
|
|
245
283
|
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
246
|
-
if (ownName !== undefined && pkg.isPackageCode(node.info.file) &&
|
|
284
|
+
if (ownName !== undefined && pkg.isPackageCode(node.info.file) && r_function_call_1.RFunctionCall.isNamed(node, attaching)) {
|
|
247
285
|
const arg = node.arguments[0] === r_function_call_1.EmptyArgument ? undefined : node.arguments[0]?.value;
|
|
248
286
|
const name = r_symbol_1.RSymbol.is(arg) ? identifier_1.Identifier.getName(arg.content) : r_string_1.RString.is(arg) ? arg.content.str : undefined;
|
|
249
287
|
const loc = range_1.SourceLocation.fromNode(node);
|
|
@@ -266,18 +304,24 @@ exports.PACKAGE_RUNTIME = {
|
|
|
266
304
|
if (installed !== undefined) {
|
|
267
305
|
add({ certainty: linter_format_1.LintingResultCertainty.Certain, loc: files.locate(installed), kind: 'not-source-package', message: `${installed} belongs to an installed package, R CMD check needs the package sources` });
|
|
268
306
|
}
|
|
269
|
-
const
|
|
307
|
+
const index = ctx.env.builtInIndex;
|
|
308
|
+
const writers = new Map((0, linter_util_1.namesWith)(index, built_in_props_1.SemanticCallTag.Writes).values().map(n => [n, new Set()]));
|
|
309
|
+
for (const p of index.params(built_in_props_1.ArgProp.Resource)) {
|
|
310
|
+
writers.get(identifier_1.Identifier.getName(p.call))?.add(p.name);
|
|
311
|
+
}
|
|
270
312
|
testAndVignetteChecks(files, pkg, data, config, writers, add);
|
|
271
313
|
return { results, '.meta': {} };
|
|
272
|
-
},
|
|
314
|
+
}),
|
|
273
315
|
prettyPrint: (0, cmd_check_util_1.printer)(r => r.kind),
|
|
274
316
|
info: {
|
|
275
317
|
name: 'Package Runtime',
|
|
276
318
|
tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Robustness],
|
|
277
319
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
278
|
-
description: 'Finds what makes installing, loading, or running the package fail without doing so: undefined exports, S3 methods without a function, bad NAMESPACE imports, a package attaching itself, tests that never run, test or vignette code that does not parse, missing vignette metadata, and files written into the working directory.',
|
|
320
|
+
description: 'Finds what makes installing, loading, or running the package fail without doing so: undefined exports, export patterns matching nothing, a NAMESPACE exporting nothing, S3 methods without a function, bad NAMESPACE imports, a package attaching itself, tests that never run, test or vignette code that does not parse, missing vignette metadata, and files written into the working directory.',
|
|
279
321
|
defaultConfig: () => ({
|
|
280
|
-
checkWrites: true
|
|
322
|
+
checkWrites: true,
|
|
323
|
+
checkExports: true,
|
|
324
|
+
requireExports: true
|
|
281
325
|
})
|
|
282
326
|
}
|
|
283
327
|
};
|
|
@@ -43,7 +43,13 @@ export interface PackageStructureMetadata extends MergeableRecord {
|
|
|
43
43
|
/** Port of the file and directory structure checks of `R CMD check` (portable names, hidden and top-level files, subdirectories, permissions, sizes, vignettes). */
|
|
44
44
|
export declare const PACKAGE_STRUCTURE: {
|
|
45
45
|
readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"from", [], import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../search/flowr-search").FlowrSearchElements<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
46
|
-
readonly processSearchResult: (_elements:
|
|
46
|
+
readonly processSearchResult: (_elements: unknown, config: PackageStructureConfig, data: import("../../..").ReadonlyFlowrAnalysisProvider) => PromiseLike<{
|
|
47
|
+
results: FileResult<PackageStructureKind>[];
|
|
48
|
+
'.meta': {
|
|
49
|
+
inspectedEntries: number;
|
|
50
|
+
onDisk: boolean;
|
|
51
|
+
};
|
|
52
|
+
}> | {
|
|
47
53
|
results: FileResult<PackageStructureKind>[];
|
|
48
54
|
'.meta': {
|
|
49
55
|
inspectedEntries: number;
|
|
@@ -51,14 +57,14 @@ export declare const PACKAGE_STRUCTURE: {
|
|
|
51
57
|
};
|
|
52
58
|
};
|
|
53
59
|
readonly prettyPrint: {
|
|
54
|
-
query: (r: {
|
|
60
|
+
readonly query: (r: {
|
|
55
61
|
readonly message: string;
|
|
56
62
|
readonly loc: import("../../..").SourceLocation;
|
|
57
|
-
}) => string;
|
|
58
|
-
full: (r: {
|
|
63
|
+
}, metadata: unknown) => string;
|
|
64
|
+
readonly full: (r: {
|
|
59
65
|
readonly message: string;
|
|
60
66
|
readonly loc: import("../../..").SourceLocation;
|
|
61
|
-
}) => string;
|
|
67
|
+
}, metadata: unknown) => string;
|
|
62
68
|
};
|
|
63
69
|
readonly info: {
|
|
64
70
|
readonly name: "Package Structure";
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PACKAGE_STRUCTURE = void 0;
|
|
7
|
+
const cmd_check_util_1 = require("./cmd-check-util");
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const linter_format_1 = require("../../linter-format");
|
|
@@ -12,15 +13,12 @@ const linter_tags_1 = require("../../linter-tags");
|
|
|
12
13
|
const flowr_file_1 = require("../../../project/context/flowr-file");
|
|
13
14
|
const flowr_rda_file_1 = require("../../../project/plugins/file-plugins/files/flowr-rda-file");
|
|
14
15
|
const strings_1 = require("../../../util/text/strings");
|
|
15
|
-
const cmd_check_util_1 = require("./cmd-check-util");
|
|
16
16
|
const os_1 = require("../../../util/os");
|
|
17
17
|
const file_checks_1 = require("./file-checks");
|
|
18
|
-
const package_files_1 = require("./package-files");
|
|
19
18
|
const PortableNameChars = /[^-A-Za-z0-9._!#$%&+,;=@^(){}'[\]]/;
|
|
20
19
|
const InvalidNameChars = /["*:<>?\\|]/;
|
|
21
20
|
const ReservedNames = /^(con|prn|aux|clock[$]|nul|lpt[1-9]|com[1-9])$/;
|
|
22
21
|
const CodeExtensions = new Set(['R', 'r', 'S', 's', 'q']);
|
|
23
|
-
const DataExtensions = /\.(R|r|RData|rdata|rda|tab|txt|TXT|csv|CSV)(\.(gz|bz2|xz))?$/;
|
|
24
22
|
const SweavePattern = /\.[RrSs](nw|tex)$/;
|
|
25
23
|
const VignettePattern = /\.([RrSs](nw|tex)|Rmd|rmd|qmd|Rmarkdown|rmarkdown)$/;
|
|
26
24
|
const ValidVignetteName = /^[A-Za-z][A-Za-z0-9._-]+$/;
|
|
@@ -150,7 +148,7 @@ function installedSize(env) {
|
|
|
150
148
|
/** the directories that must not be empty: the kind, the directory, whether it holds something, and the message */
|
|
151
149
|
const NonEmptyDirs = [
|
|
152
150
|
['empty-r-directory', 'R', env => codeFiles(env).length > 0 || env.kinds.has('R/sysdata.rda'), "Found directory 'R' with no source files."],
|
|
153
|
-
['empty-data-directory', 'data', env => env.children('data').some(e => !e.isDirectory &&
|
|
151
|
+
['empty-data-directory', 'data', env => env.children('data').some(e => !e.isDirectory && cmd_check_util_1.DataFile.test(e.relative)), "Subdirectory 'data' contains no data sets."],
|
|
154
152
|
['empty-demo-directory', 'demo', env => env.demos.length > 0, "Subdirectory 'demo' contains no demos."],
|
|
155
153
|
['empty-exec-directory', 'exec', env => env.children('exec').some(e => !base(e.relative).startsWith('.')), "Subdirectory 'exec' contains no files."],
|
|
156
154
|
['empty-inst-directory', 'inst', env => env.files.some(f => f.relative.startsWith('inst/')), "Subdirectory 'inst' contains no files."],
|
|
@@ -245,13 +243,7 @@ function buildFindings(env) {
|
|
|
245
243
|
/** Port of the file and directory structure checks of `R CMD check` (portable names, hidden and top-level files, subdirectories, permissions, sizes, vignettes). */
|
|
246
244
|
exports.PACKAGE_STRUCTURE = {
|
|
247
245
|
createSearch: () => flowr_search_builder_1.Q.from([]),
|
|
248
|
-
processSearchResult: (
|
|
249
|
-
const ctx = data.inspectContext();
|
|
250
|
-
const pkg = (0, cmd_check_util_1.packageInfo)(ctx);
|
|
251
|
-
const pf = (0, package_files_1.packageFiles)(ctx, pkg.name);
|
|
252
|
-
if (pf === undefined) {
|
|
253
|
-
return { results: [], '.meta': { inspectedEntries: 0, onDisk: false } };
|
|
254
|
-
}
|
|
246
|
+
processSearchResult: (0, file_checks_1.onPackageFiles)({ inspectedEntries: 0, onDisk: false }, (pf, pkg, config) => {
|
|
255
247
|
const found = (0, file_checks_1.fileFindings)(pf);
|
|
256
248
|
const entries = pf.entries;
|
|
257
249
|
const byParent = new Map();
|
|
@@ -293,7 +285,7 @@ exports.PACKAGE_STRUCTURE = {
|
|
|
293
285
|
}
|
|
294
286
|
buildFindings(env).forEach(([kind, message]) => found.add(kind, 'build/vignette.rds', message));
|
|
295
287
|
return { results: found.results, '.meta': { inspectedEntries: entries.length, onDisk: pf.onDisk } };
|
|
296
|
-
},
|
|
288
|
+
}),
|
|
297
289
|
prettyPrint: file_checks_1.MessageAtLocation,
|
|
298
290
|
info: {
|
|
299
291
|
name: 'Package Structure',
|
|
@@ -46,15 +46,20 @@ export interface RdFilesMetadata extends MergeableRecord {
|
|
|
46
46
|
/** Port of the Rd checks of `R CMD check`, run on the `man/*.Rd` sources. */
|
|
47
47
|
export declare const RD_FILES: {
|
|
48
48
|
readonly createSearch: () => import("../../../search/flowr-search-builder").FlowrSearchBuilder<"from", [], import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../search/flowr-search").FlowrSearchElements<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../search/flowr-search").FlowrSearchElement<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
49
|
-
readonly processSearchResult: (_elements:
|
|
49
|
+
readonly processSearchResult: (_elements: unknown, config: RdFilesConfig, data: ReadonlyFlowrAnalysisProvider) => PromiseLike<{
|
|
50
|
+
results: FileResult<RdFilesKind>[];
|
|
51
|
+
'.meta': {
|
|
52
|
+
checkedFiles: number;
|
|
53
|
+
};
|
|
54
|
+
}> | {
|
|
50
55
|
results: FileResult<RdFilesKind>[];
|
|
51
56
|
'.meta': {
|
|
52
57
|
checkedFiles: number;
|
|
53
58
|
};
|
|
54
59
|
};
|
|
55
60
|
readonly prettyPrint: {
|
|
56
|
-
readonly query: (
|
|
57
|
-
readonly full: (
|
|
61
|
+
readonly query: (r: RdFilesResult, metadata: unknown) => string;
|
|
62
|
+
readonly full: (r: RdFilesResult, metadata: unknown) => string;
|
|
58
63
|
};
|
|
59
64
|
readonly info: {
|
|
60
65
|
readonly name: "Rd Files";
|
|
@@ -15,7 +15,6 @@ const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
|
15
15
|
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
16
16
|
const flowr_rd_file_1 = require("../../../project/plugins/file-plugins/files/flowr-rd-file");
|
|
17
17
|
const cmd_check_util_1 = require("./cmd-check-util");
|
|
18
|
-
const package_files_1 = require("./package-files");
|
|
19
18
|
const package_code_1 = require("./package-code");
|
|
20
19
|
const file_checks_1 = require("./file-checks");
|
|
21
20
|
/** A map from each of the space-separated names of the keys to the value. */
|
|
@@ -575,13 +574,7 @@ function packageMacros(files, extra) {
|
|
|
575
574
|
/** Port of the Rd checks of `R CMD check`, run on the `man/*.Rd` sources. */
|
|
576
575
|
exports.RD_FILES = {
|
|
577
576
|
createSearch: () => flowr_search_builder_1.Q.from([]),
|
|
578
|
-
processSearchResult: (
|
|
579
|
-
const ctx = data.inspectContext();
|
|
580
|
-
const info = (0, cmd_check_util_1.packageInfo)(ctx);
|
|
581
|
-
const files = (0, package_files_1.packageFiles)(ctx, info.name);
|
|
582
|
-
if (files === undefined) {
|
|
583
|
-
return { results: [], '.meta': { checkedFiles: 0 } };
|
|
584
|
-
}
|
|
577
|
+
processSearchResult: (0, file_checks_1.onPackageFiles)({ checkedFiles: 0 }, (files, info, config, data) => {
|
|
585
578
|
const { results, add } = (0, file_checks_1.fileFindings)(files);
|
|
586
579
|
const description = info.description?.content();
|
|
587
580
|
const has = (field) => (description?.get(field)?.length ?? 0) > 0;
|
|
@@ -602,14 +595,11 @@ exports.RD_FILES = {
|
|
|
602
595
|
checkMetadata(pages, info.name, add);
|
|
603
596
|
}
|
|
604
597
|
if (config.crossReferences) {
|
|
605
|
-
checkCrossReferences(pages,
|
|
598
|
+
checkCrossReferences(pages, data.inspectContext(), info, config.uncertainLinks, add);
|
|
606
599
|
}
|
|
607
600
|
return { results, '.meta': { checkedFiles: pages.length } };
|
|
608
|
-
},
|
|
609
|
-
prettyPrint: {
|
|
610
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `${result.kind} in ${result.file} at ${range_1.SourceLocation.format(result.loc)}`,
|
|
611
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `${result.message} (at ${range_1.SourceLocation.format(result.loc)})`
|
|
612
|
-
},
|
|
601
|
+
}),
|
|
602
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `${result.kind} in ${result.file} at ${range_1.SourceLocation.format(result.loc)}`, result => `${result.message} (at ${range_1.SourceLocation.format(result.loc)})`),
|
|
613
603
|
info: {
|
|
614
604
|
name: 'Rd Files',
|
|
615
605
|
tags: [linter_tags_1.LintingRuleTag.CmdCheck, linter_tags_1.LintingRuleTag.Robustness],
|
|
@@ -54,8 +54,8 @@ export declare const S3_METHOD_CONSISTENCY: {
|
|
|
54
54
|
};
|
|
55
55
|
}>;
|
|
56
56
|
readonly prettyPrint: {
|
|
57
|
-
query: (r: S3MethodConsistencyResult) => string;
|
|
58
|
-
full: (r: S3MethodConsistencyResult) => string;
|
|
57
|
+
readonly query: (r: S3MethodConsistencyResult, metadata: unknown) => string;
|
|
58
|
+
readonly full: (r: S3MethodConsistencyResult, metadata: unknown) => string;
|
|
59
59
|
};
|
|
60
60
|
readonly info: {
|
|
61
61
|
readonly name: "S3 Method Consistency";
|
|
@@ -8,7 +8,7 @@ const linter_tags_1 = require("../../linter-tags");
|
|
|
8
8
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
9
9
|
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
10
10
|
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
11
|
-
const
|
|
11
|
+
const linter_util_1 = require("../../linter-util");
|
|
12
12
|
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
13
13
|
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
14
14
|
const r_unary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
@@ -64,14 +64,13 @@ function localGenerics(defs, ast, graph) {
|
|
|
64
64
|
const generics = new Map();
|
|
65
65
|
const seen = new Set();
|
|
66
66
|
for (const node of (0, cmd_check_util_1.projectNodes)(ast)) {
|
|
67
|
-
if (seen.has(node.info.id) || !r_function_call_1.RFunctionCall.
|
|
67
|
+
if (seen.has(node.info.id) || !r_function_call_1.RFunctionCall.is(node) || !(0, linter_util_1.callsBuiltIn)(graph, node.info.id, 'UseMethod')) {
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
70
70
|
seen.add(node.info.id);
|
|
71
|
-
const origins = df_helper_1.Dataflow.origin(graph, node.info.id);
|
|
72
71
|
const owner = model_1.RNode.strictlyEnclosingFunction(node.info.id, idMap);
|
|
73
72
|
const def = owner === undefined ? undefined : byId.get(owner);
|
|
74
|
-
if (def !== undefined
|
|
73
|
+
if (def !== undefined) {
|
|
75
74
|
generics.set(def.name, { formals: formalNames(def.def), local: true });
|
|
76
75
|
}
|
|
77
76
|
}
|
|
@@ -29,8 +29,8 @@ export declare const TRUE_FALSE_ABBREVIATION: {
|
|
|
29
29
|
};
|
|
30
30
|
}>;
|
|
31
31
|
readonly prettyPrint: {
|
|
32
|
-
query: (r: TrueFalseAbbreviationResult) => string;
|
|
33
|
-
full: (r: TrueFalseAbbreviationResult) => string;
|
|
32
|
+
readonly query: (r: TrueFalseAbbreviationResult, metadata: unknown) => string;
|
|
33
|
+
readonly full: (r: TrueFalseAbbreviationResult, metadata: unknown) => string;
|
|
34
34
|
};
|
|
35
35
|
readonly info: {
|
|
36
36
|
readonly name: "TRUE/FALSE Abbreviation";
|
|
@@ -32,8 +32,8 @@ export declare const DATA_FRAME_ACCESS_VALIDATION: {
|
|
|
32
32
|
'.meta': DataFrameAccessValidationMetadata;
|
|
33
33
|
}>;
|
|
34
34
|
readonly prettyPrint: {
|
|
35
|
-
readonly query: (
|
|
36
|
-
readonly full: (
|
|
35
|
+
readonly query: (r: DataFrameAccessValidationResult, metadata: unknown) => string;
|
|
36
|
+
readonly full: (r: DataFrameAccessValidationResult, metadata: unknown) => string;
|
|
37
37
|
};
|
|
38
38
|
readonly info: {
|
|
39
39
|
readonly name: "Dataframe Access Validation";
|
|
@@ -78,14 +78,11 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
|
|
|
78
78
|
}));
|
|
79
79
|
return { results, '.meta': metadata };
|
|
80
80
|
},
|
|
81
|
-
prettyPrint: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(typeof result.accessed === 'string' ? `"${result.accessed}"` : result.accessed) + ' does not exist ' +
|
|
87
|
-
(result.operand === undefined ? `at \`${result.access}\`` : `in \`${result.operand}\``) + ` at ${range_1.SourceLocation.format(result.loc)}`
|
|
88
|
-
},
|
|
81
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Access of ${result.type} ` +
|
|
82
|
+
(typeof result.accessed === 'string' ? `"${result.accessed}"` : result.accessed) + ' ' +
|
|
83
|
+
(result.operand === undefined ? `at \`${result.access}\`` : `of \`${result.operand}\``) + ` at ${range_1.SourceLocation.format(result.loc)}`, result => `Accessed ${result.type} ` +
|
|
84
|
+
(typeof result.accessed === 'string' ? `"${result.accessed}"` : result.accessed) + ' does not exist ' +
|
|
85
|
+
(result.operand === undefined ? `at \`${result.access}\`` : `in \`${result.operand}\``) + ` at ${range_1.SourceLocation.format(result.loc)}`),
|
|
89
86
|
info: {
|
|
90
87
|
name: 'Dataframe Access Validation',
|
|
91
88
|
tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
4
|
import { LintingRuleTag } from '../linter-tags';
|
|
4
5
|
import { type CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
|
|
5
6
|
export type DeadCodeResult = LintingResult;
|
|
@@ -11,13 +12,13 @@ export interface DeadCodeConfig extends MergeableRecord {
|
|
|
11
12
|
simplificationPasses?: readonly CfgSimplificationPassName[];
|
|
12
13
|
}
|
|
13
14
|
export declare const DEAD_CODE: {
|
|
14
|
-
readonly createSearch: (config: DeadCodeConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter"],
|
|
15
|
-
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<
|
|
15
|
+
readonly createSearch: (config: DeadCodeConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
|
|
16
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, _config: DeadCodeConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
16
17
|
results: LintingResult[];
|
|
17
18
|
}>;
|
|
18
19
|
readonly prettyPrint: {
|
|
19
|
-
readonly query: (
|
|
20
|
-
readonly full: (
|
|
20
|
+
readonly query: (r: LintingResult, metadata: unknown) => string;
|
|
21
|
+
readonly full: (r: LintingResult, metadata: unknown) => string;
|
|
21
22
|
};
|
|
22
23
|
readonly info: {
|
|
23
24
|
readonly name: "Dead Code";
|
|
@@ -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 model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
6
7
|
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
7
8
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
8
9
|
const linter_tags_1 = require("../linter-tags");
|
|
@@ -37,13 +38,17 @@ exports.DEAD_CODE = {
|
|
|
37
38
|
involvedId: element.node.info.id,
|
|
38
39
|
loc: range_1.SourceLocation.fromNode(element.node)
|
|
39
40
|
}))
|
|
40
|
-
.filter(element => (0, assert_1.isNotUndefined)(element.loc))).map(result =>
|
|
41
|
+
.filter(element => (0, assert_1.isNotUndefined)(element.loc))).map(result => {
|
|
42
|
+
const own = ownNode(result, idMap);
|
|
43
|
+
/* removing the unbraced branch of `if(c) x else b` leaves `if(c) else b`, which does not parse, so it becomes `{}` */
|
|
44
|
+
const fix = own === undefined ? undefined : isUnbracedBody(own, idMap)
|
|
45
|
+
? { type: 'replace', loc: result.loc, replacement: '{}', description: 'Replace the unreachable code with an empty block' }
|
|
46
|
+
: isStatement(own, idMap) ? { type: 'remove', loc: result.loc, description: 'Remove the unreachable code' } : undefined;
|
|
47
|
+
return fix === undefined ? result : { ...result, quickFix: [fix] };
|
|
48
|
+
})
|
|
41
49
|
};
|
|
42
50
|
},
|
|
43
|
-
prettyPrint: {
|
|
44
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Code at ${range_1.SourceLocation.format(result.loc)}`,
|
|
45
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Code at ${range_1.SourceLocation.format(result.loc)} can never be executed`,
|
|
46
|
-
},
|
|
51
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Code at ${range_1.SourceLocation.format(result.loc)}`, result => `Code at ${range_1.SourceLocation.format(result.loc)} can never be executed`),
|
|
47
52
|
info: {
|
|
48
53
|
name: 'Dead Code',
|
|
49
54
|
tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.QuickFix],
|
|
@@ -53,19 +58,25 @@ exports.DEAD_CODE = {
|
|
|
53
58
|
defaultConfig: () => ({})
|
|
54
59
|
}
|
|
55
60
|
};
|
|
56
|
-
/**
|
|
57
|
-
function
|
|
61
|
+
/** the expression whose location is exactly that of the result, `undefined` if there is none */
|
|
62
|
+
function ownNode(result, idMap) {
|
|
58
63
|
const ids = Array.isArray(result.involvedId) ? result.involvedId : [result.involvedId];
|
|
59
|
-
return ids.
|
|
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 */
|
|
64
|
+
return ids.map(id => id === undefined ? undefined : idMap.get(id)).find(node => {
|
|
63
65
|
const own = range_1.SourceLocation.fromNode(node);
|
|
64
|
-
return node?.info.role === "el-c" /* RoleInParent.ExpressionListChild */ &&
|
|
65
|
-
&& (
|
|
66
|
-
&& own !== undefined && range_1.SourceLocation.isSubsetOf(result.loc, own) && range_1.SourceLocation.isSubsetOf(own, result.loc);
|
|
66
|
+
return node?.info.role === "el-c" /* RoleInParent.ExpressionListChild */ && own !== undefined
|
|
67
|
+
&& range_1.SourceLocation.isSubsetOf(result.loc, own) && range_1.SourceLocation.isSubsetOf(own, result.loc);
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
/** whether the node is a statement in a block or at the top level, so removing it leaves valid code */
|
|
71
|
+
function isStatement(node, idMap) {
|
|
72
|
+
const parent = model_1.RNode.directParent(node, idMap);
|
|
73
|
+
return r_expression_list_1.RExpressionList.is(parent) && (parent.grouping !== undefined || parent.info.parent === undefined);
|
|
74
|
+
}
|
|
75
|
+
/** whether the node is the unbraced body of an `if` or a loop, like `x <- 1` in `if(c) x <- 1` */
|
|
76
|
+
function isUnbracedBody(node, idMap) {
|
|
77
|
+
const parent = model_1.RNode.directParent(node, idMap);
|
|
78
|
+
return r_expression_list_1.RExpressionList.isImplicit(parent) && parent.info.parent !== undefined && parent.children.length === 1;
|
|
79
|
+
}
|
|
69
80
|
function combineResults(results) {
|
|
70
81
|
for (let i = results.length - 1; i >= 0; i--) {
|
|
71
82
|
const result = results[i];
|
|
@@ -51,7 +51,7 @@ export interface DeprecatedFunctionsConfig extends MergeableRecord {
|
|
|
51
51
|
conditionally: Record<BrandedIdentifier, DeprecatedFunctionInformation>;
|
|
52
52
|
}
|
|
53
53
|
export declare const DEPRECATED_FUNCTIONS: {
|
|
54
|
-
readonly createSearch: (
|
|
54
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
|
|
55
55
|
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: DeprecatedFunctionsConfig, data: ReadonlyFlowrAnalysisProvider<KnownParser>) => Promise<{
|
|
56
56
|
results: DeprecatedFunctionRuleResult[];
|
|
57
57
|
'.meta': {
|
|
@@ -60,8 +60,8 @@ export declare const DEPRECATED_FUNCTIONS: {
|
|
|
60
60
|
};
|
|
61
61
|
}>;
|
|
62
62
|
readonly prettyPrint: {
|
|
63
|
-
readonly query: (
|
|
64
|
-
readonly full: (
|
|
63
|
+
readonly query: (r: DeprecatedFunctionRuleResult, metadata: unknown) => string;
|
|
64
|
+
readonly full: (r: DeprecatedFunctionRuleResult, metadata: unknown) => string;
|
|
65
65
|
};
|
|
66
66
|
readonly info: {
|
|
67
67
|
readonly name: "Deprecated Functions";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEPRECATED_FUNCTIONS = void 0;
|
|
4
|
+
const function_finder_util_1 = require("./function-finder-util");
|
|
4
5
|
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
5
6
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
6
7
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
@@ -13,9 +14,7 @@ const range_1 = require("../../util/range");
|
|
|
13
14
|
const linter_format_1 = require("../linter-format");
|
|
14
15
|
const linter_tags_1 = require("../linter-tags");
|
|
15
16
|
const r_version_1 = require("../../util/r-version");
|
|
16
|
-
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
17
17
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
18
|
-
const function_finder_util_1 = require("./function-finder-util");
|
|
19
18
|
const logic_1 = require("../../util/logic");
|
|
20
19
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
21
20
|
const dependencies_query_format_1 = require("../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
@@ -99,10 +98,7 @@ function conditionalyDeprecatedFromBuiltinConfig(definitions) {
|
|
|
99
98
|
exports.DEPRECATED_FUNCTIONS = {
|
|
100
99
|
// unlike functionFinderUtil.createSearch(config.fns), this does not pre-filter to the hardcoded list: the
|
|
101
100
|
// sigdb-driven pass below needs every resolved call, so the `fns` filtering happens in processSearchResult instead
|
|
102
|
-
createSearch: (
|
|
103
|
-
onlyBuiltin: true,
|
|
104
|
-
qualifyNames: true
|
|
105
|
-
}),
|
|
101
|
+
createSearch: () => function_finder_util_1.functionFinderUtil.createSearch(undefined),
|
|
106
102
|
processSearchResult: async (elements, config, data) => {
|
|
107
103
|
const always = indexAlways(config.always);
|
|
108
104
|
const conditionals = indexConditionals(config.conditionally);
|
|
@@ -182,24 +178,21 @@ exports.DEPRECATED_FUNCTIONS = {
|
|
|
182
178
|
'.meta': { builtin: results.length, sigdb: sigdbFlagged.length }
|
|
183
179
|
};
|
|
184
180
|
},
|
|
185
|
-
prettyPrint: {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const argStr = typeof result.arg === 'number' ? `at position \`${result.arg}\`` : result.arg;
|
|
191
|
-
str.push(`Argument \`${argStr}\` of`);
|
|
192
|
-
}
|
|
193
|
-
str.push(`Function \`${identifier_1.Identifier.toString(result.function)}\` is ${result.state ?? 'deprecated'}`);
|
|
194
|
-
if (result.sinceVersion) {
|
|
195
|
-
str.push(`since version ${result.sinceVersion.format()}`);
|
|
196
|
-
}
|
|
197
|
-
if (result.replacedBy) {
|
|
198
|
-
str.push(`and is replaced by \`${result.replacedBy}\``);
|
|
199
|
-
}
|
|
200
|
-
return str.join(' ');
|
|
181
|
+
prettyPrint: (0, linter_format_1.prettyPrint)((result) => `${result.type === 'deprecated-argument' ? `Argument \`${result.arg}\` of ` : ''}function \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)}`, (result) => {
|
|
182
|
+
const str = [];
|
|
183
|
+
if (result.type === 'deprecated-argument') {
|
|
184
|
+
const argStr = typeof result.arg === 'number' ? `at position \`${result.arg}\`` : result.arg;
|
|
185
|
+
str.push(`Argument \`${argStr}\` of`);
|
|
201
186
|
}
|
|
202
|
-
|
|
187
|
+
str.push(`Function \`${identifier_1.Identifier.toString(result.function)}\` is ${result.state ?? 'deprecated'}`);
|
|
188
|
+
if (result.sinceVersion) {
|
|
189
|
+
str.push(`since version ${result.sinceVersion.format()}`);
|
|
190
|
+
}
|
|
191
|
+
if (result.replacedBy) {
|
|
192
|
+
str.push(`and is replaced by \`${result.replacedBy}\``);
|
|
193
|
+
}
|
|
194
|
+
return str.join(' ');
|
|
195
|
+
}),
|
|
203
196
|
info: {
|
|
204
197
|
name: 'Deprecated Functions',
|
|
205
198
|
tags: [linter_tags_1.LintingRuleTag.Deprecated, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.QuickFix],
|