@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
|
@@ -30,7 +30,7 @@ export interface SeededRandomnessMeta extends MergeableRecord {
|
|
|
30
30
|
callsWithOtherBranchProducers: number;
|
|
31
31
|
}
|
|
32
32
|
export declare const SEEDED_RANDOMNESS: {
|
|
33
|
-
readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"
|
|
33
|
+
readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], 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>[]>>>;
|
|
34
34
|
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: SeededRandomnessConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
35
35
|
results: {
|
|
36
36
|
involvedId: NodeId;
|
|
@@ -57,7 +57,7 @@ export declare const SEEDED_RANDOMNESS: {
|
|
|
57
57
|
readonly description: "Finds randomness-based function calls not preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like `set.seed`.";
|
|
58
58
|
};
|
|
59
59
|
readonly prettyPrint: {
|
|
60
|
-
readonly query: (
|
|
61
|
-
readonly full: (
|
|
60
|
+
readonly query: (r: SeededRandomnessResult, metadata: unknown) => string;
|
|
61
|
+
readonly full: (r: SeededRandomnessResult, metadata: unknown) => string;
|
|
62
62
|
};
|
|
63
63
|
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SEEDED_RANDOMNESS = void 0;
|
|
4
4
|
const linter_format_1 = require("../linter-format");
|
|
5
|
+
const r_value_1 = require("../../dataflow/eval/values/r-value");
|
|
6
|
+
const function_finder_util_1 = require("./function-finder-util");
|
|
5
7
|
const range_1 = require("../../util/range");
|
|
6
|
-
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
7
8
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
8
9
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
9
|
-
const flowr_search_filters_1 = require("../../search/flowr-search-filters");
|
|
10
10
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
11
11
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
12
|
const linter_tags_1 = require("../linter-tags");
|
|
@@ -14,7 +14,6 @@ const node_value_1 = require("../../dataflow/eval/resolve/node-value");
|
|
|
14
14
|
const config_1 = require("../../config");
|
|
15
15
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
16
16
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
17
|
-
const r_value_1 = require("../../dataflow/eval/values/r-value");
|
|
18
17
|
const info_1 = require("../../dataflow/info");
|
|
19
18
|
const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
|
|
20
19
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
@@ -26,18 +25,7 @@ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
|
26
25
|
const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
|
|
27
26
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
28
27
|
exports.SEEDED_RANDOMNESS = {
|
|
29
|
-
createSearch: config =>
|
|
30
|
-
.with(search_enrichers_1.Enrichment.CallTargets, {
|
|
31
|
-
onlyBuiltin: true,
|
|
32
|
-
qualifyNames: false // we don't use qualified names for this rule yet
|
|
33
|
-
})
|
|
34
|
-
.filter({
|
|
35
|
-
name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
|
|
36
|
-
args: {
|
|
37
|
-
enrichment: search_enrichers_1.Enrichment.CallTargets,
|
|
38
|
-
test: { targets: identifier_1.Identifier.regex(...config.randomnessConsumers) }
|
|
39
|
-
}
|
|
40
|
-
}),
|
|
28
|
+
createSearch: config => function_finder_util_1.functionFinderUtil.createSearch(config.randomnessConsumers, false),
|
|
41
29
|
processSearchResult: async (elements, config, data) => {
|
|
42
30
|
const { graph } = await data.dataflow();
|
|
43
31
|
const ctx = data.inspectContext();
|
|
@@ -174,9 +162,7 @@ exports.SEEDED_RANDOMNESS = {
|
|
|
174
162
|
],
|
|
175
163
|
randomnessConsumers: [
|
|
176
164
|
...ctx.env.deriveFromIndex(randomnessConsumers),
|
|
177
|
-
'
|
|
178
|
-
'rxor', 'rmvnorm', 'randomForest',
|
|
179
|
-
'permuted', 'permute', 'shuffle', 'shuffleSet', 'data_shuffle', 'sample_frac', 'sample_n',
|
|
165
|
+
'generateSeedVectors', 'rxor', 'permuted', 'data_shuffle',
|
|
180
166
|
],
|
|
181
167
|
}),
|
|
182
168
|
tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility],
|
|
@@ -185,10 +171,7 @@ exports.SEEDED_RANDOMNESS = {
|
|
|
185
171
|
name: 'Seeded Randomness',
|
|
186
172
|
description: 'Finds randomness-based function calls not preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like `set.seed`.'
|
|
187
173
|
},
|
|
188
|
-
prettyPrint: {
|
|
189
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: (result, _meta) => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
190
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: (result, _meta) => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)} is called without a preceding random seed function like \`set.seed\``
|
|
191
|
-
}
|
|
174
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)}`, result => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)} is called without a preceding random seed function like \`set.seed\``)
|
|
192
175
|
};
|
|
193
176
|
function getDefaultAssignments(definitions) {
|
|
194
177
|
return definitions.filter((b) => b.type === 'function' && (b.processor === built_in_proc_name_1.BuiltInProcName.Assignment || b.processor === built_in_proc_name_1.BuiltInProcName.AssignmentLike));
|
|
@@ -212,7 +195,7 @@ function isConstantArgument(graph, call, argIndex, ctx) {
|
|
|
212
195
|
return values?.elements.every(v => v.type === 'number' ||
|
|
213
196
|
v.type === 'logical' ||
|
|
214
197
|
v.type === 'string' ||
|
|
215
|
-
|
|
198
|
+
r_value_1.RValue.numberOf(v) !== undefined)
|
|
216
199
|
?? false;
|
|
217
200
|
}
|
|
218
201
|
//# sourceMappingURL=seeded-randomness.js.map
|
|
@@ -16,8 +16,8 @@ export declare const SOFTWARE_HAS_LICENSE: {
|
|
|
16
16
|
'.meta': {};
|
|
17
17
|
};
|
|
18
18
|
readonly prettyPrint: {
|
|
19
|
-
readonly query: (
|
|
20
|
-
readonly full: (
|
|
19
|
+
readonly query: (r: SoftwareHasLicenseResult, metadata: unknown) => string;
|
|
20
|
+
readonly full: (r: SoftwareHasLicenseResult, metadata: unknown) => string;
|
|
21
21
|
};
|
|
22
22
|
readonly info: {
|
|
23
23
|
readonly name: "Software Has License";
|
|
@@ -29,10 +29,7 @@ exports.SOFTWARE_HAS_LICENSE = {
|
|
|
29
29
|
}];
|
|
30
30
|
return { results, '.meta': {} };
|
|
31
31
|
},
|
|
32
|
-
prettyPrint:
|
|
33
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => result.message,
|
|
34
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => result.message
|
|
35
|
-
},
|
|
32
|
+
prettyPrint: (0, linter_format_1.prettyPrint)((result) => result.message),
|
|
36
33
|
info: {
|
|
37
34
|
name: 'Software Has License',
|
|
38
35
|
description: 'Finds software projects without a license (a LICENSE file or the License field of the DESCRIPTION).',
|
|
@@ -23,8 +23,8 @@ export declare const SOFTWARE_HAS_TESTS: {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
readonly prettyPrint: {
|
|
26
|
-
readonly query: (
|
|
27
|
-
readonly full: (
|
|
26
|
+
readonly query: (r: SoftwareHasTestsResult, metadata: unknown) => string;
|
|
27
|
+
readonly full: (r: SoftwareHasTestsResult, metadata: unknown) => string;
|
|
28
28
|
};
|
|
29
29
|
readonly info: {
|
|
30
30
|
readonly name: "Software Has Tests";
|
|
@@ -31,10 +31,7 @@ exports.SOFTWARE_HAS_TESTS = {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
},
|
|
34
|
-
prettyPrint:
|
|
35
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => result.message,
|
|
36
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => result.message
|
|
37
|
-
},
|
|
34
|
+
prettyPrint: (0, linter_format_1.prettyPrint)((result) => result.message),
|
|
38
35
|
info: {
|
|
39
36
|
name: 'Software Has Tests',
|
|
40
37
|
description: 'Finds software projects without tests (test files in a test directory or test function calls in R code).',
|
|
@@ -16,8 +16,8 @@ export declare const STOP_WITH_CALL_ARG: {
|
|
|
16
16
|
'.meta': StopWithCallMetadata;
|
|
17
17
|
}>;
|
|
18
18
|
readonly prettyPrint: {
|
|
19
|
-
readonly query: (
|
|
20
|
-
readonly full: (
|
|
19
|
+
readonly query: (r: LintingResult, metadata: unknown) => string;
|
|
20
|
+
readonly full: (r: LintingResult, metadata: unknown) => string;
|
|
21
21
|
};
|
|
22
22
|
readonly info: {
|
|
23
23
|
readonly name: "Stop Without Call";
|
|
@@ -11,16 +11,16 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
11
11
|
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
12
12
|
const general_1 = require("../../dataflow/eval/values/general");
|
|
13
13
|
const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
|
|
14
|
-
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
15
14
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
16
15
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
17
16
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
18
17
|
const r_logical_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-logical");
|
|
19
18
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
19
|
+
const linter_util_1 = require("../linter-util");
|
|
20
20
|
const ConditionConstructors = new Set(['simpleCondition', 'simpleError', 'simpleWarning', 'simpleMessage', 'errorCondition', 'warningCondition']);
|
|
21
21
|
/** whether the call builds a condition object, for which `stop` ignores `call.`: a constructor, or a class naming `condition` */
|
|
22
22
|
function isConditionObject(signaled, graph, data) {
|
|
23
|
-
if (
|
|
23
|
+
if ((0, linter_util_1.callsBuiltIn)(graph, signaled.info.id, ConditionConstructors)) {
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
const vertex = graph.getVertex(signaled.info.id);
|
|
@@ -55,16 +55,12 @@ exports.STOP_WITH_CALL_ARG = {
|
|
|
55
55
|
const idMap = dataflow.graph.idMap;
|
|
56
56
|
const fCall = dataflow.graph.getVertex(element.node.info.id);
|
|
57
57
|
/* a call that hands over `stop` itself, like `do.call(stop, args)`, states its arguments elsewhere */
|
|
58
|
-
if (!r_function_call_1.RFunctionCall.is(element.node) ||
|
|
58
|
+
if (!r_function_call_1.RFunctionCall.is(element.node) || !(0, linter_util_1.callsBuiltIn)(dataflow.graph, element.node.info.id, 'stop')) {
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
if (idMap !== undefined && model_1.RNode.findEnclosing(element.node.info.id, idMap, r_function_definition_1.RFunctionDefinition.is) === undefined) {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
|
-
// only built-in functions
|
|
65
|
-
if (df_helper_1.Dataflow.origin(dataflow.graph, element.node.info.id)?.some(e => e.type !== 3 /* OriginType.BuiltInFunctionOrigin */)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
64
|
// filter out function calls with argument "call." set to false
|
|
69
65
|
const stopParamMap = { '...': '...', 'call.': 'call.', 'domain': 'domain' };
|
|
70
66
|
const mapping = function_semantics_1.FunctionSemantics.call.match.toSpec(fCall.args, stopParamMap);
|
|
@@ -91,10 +87,7 @@ exports.STOP_WITH_CALL_ARG = {
|
|
|
91
87
|
'.meta': meta
|
|
92
88
|
};
|
|
93
89
|
},
|
|
94
|
-
prettyPrint: {
|
|
95
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `\`stop()\` without \`call. = FALSE\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
96
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `\`stop()\` at ${range_1.SourceLocation.format(result.loc)} is called without \`call. = FALSE\`, so the error message names the call it was raised in, which is usually not intended. Pass \`call. = FALSE\` to leave it out.`,
|
|
97
|
-
},
|
|
90
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `\`stop()\` without \`call. = FALSE\` at ${range_1.SourceLocation.format(result.loc)}`, result => `\`stop()\` at ${range_1.SourceLocation.format(result.loc)} is called without \`call. = FALSE\`, so the error message names the call it was raised in, which is usually not intended. Pass \`call. = FALSE\` to leave it out.`),
|
|
98
91
|
info: {
|
|
99
92
|
name: 'Stop Without Call',
|
|
100
93
|
tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.QuickFix],
|
|
@@ -25,6 +25,8 @@ export interface RegionScan {
|
|
|
25
25
|
readonly closers: readonly string[];
|
|
26
26
|
/** Offset of every `%` outside a string or comment; an odd count means an unclosed `%...%` operator. */
|
|
27
27
|
readonly percentAt: readonly number[];
|
|
28
|
+
/** Offset where the only missing `)` belongs: the end of a `for`/`while`/`if`/`function` head, right before its `{` body. */
|
|
29
|
+
readonly headAt?: number;
|
|
28
30
|
}
|
|
29
31
|
/** A `missing` (parser-inserted, zero-width) or `error` (un-parseable) tree-sitter node. */
|
|
30
32
|
export interface SyntaxErrorFinding {
|
|
@@ -52,8 +54,8 @@ export declare const SYNTACTICALLY_VALID: {
|
|
|
52
54
|
".meta": SyntacticallyValidMetadata;
|
|
53
55
|
}>;
|
|
54
56
|
readonly prettyPrint: {
|
|
55
|
-
readonly query: (
|
|
56
|
-
readonly full: (
|
|
57
|
+
readonly query: (r: SyntacticallyValidResult, metadata: unknown) => string;
|
|
58
|
+
readonly full: (r: SyntacticallyValidResult, metadata: unknown) => string;
|
|
57
59
|
};
|
|
58
60
|
readonly info: {
|
|
59
61
|
readonly name: "Syntactically Valid";
|
|
@@ -5,6 +5,8 @@ const linter_format_1 = require("../linter-format");
|
|
|
5
5
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
6
6
|
const range_1 = require("../../util/range");
|
|
7
7
|
const linter_tags_1 = require("../linter-tags");
|
|
8
|
+
/** what precedes the `(` of a control structure's head */
|
|
9
|
+
const ControlHead = /\b(?:for|while|if|function)\s*$/;
|
|
8
10
|
const DelimiterInsert = new Map([[')', ')'], ['}', '}'], [']', ']'], [']]', ']]'], ['"', '"'], ['\'', '\''], ['`', '`'], [',', ','], [';', ';']]);
|
|
9
11
|
const KeywordInsert = new Map([['in', ' in '], ['else', ' else ']]);
|
|
10
12
|
const OperatorToken = /^([-+*/^:~!<>=&|@$]+|<-|<<-|->|->>|\|>|%[^%]*%)$/;
|
|
@@ -22,6 +24,8 @@ const isDanglingOperator = (n) => !!n && !n.isNamed && OperatorToken.test(n.type
|
|
|
22
24
|
/** Read an error region: what it leaves open, and where its operators sit. */
|
|
23
25
|
function scanRegion(text) {
|
|
24
26
|
const stack = [];
|
|
27
|
+
/* for each open `(` that heads a control structure, where the `{` that follows it starts the body (once there is one) */
|
|
28
|
+
const heads = [];
|
|
25
29
|
const percentAt = [];
|
|
26
30
|
let quote;
|
|
27
31
|
for (let i = 0; i < text.length; i++) {
|
|
@@ -47,26 +51,36 @@ function scanRegion(text) {
|
|
|
47
51
|
}
|
|
48
52
|
else if (c === '(') {
|
|
49
53
|
stack.push(')');
|
|
54
|
+
heads.push(ControlHead.test(text.slice(Math.max(0, i - 24), i)) ? {} : undefined);
|
|
50
55
|
}
|
|
51
56
|
else if (c === '[') {
|
|
52
57
|
stack.push(text[i + 1] === '[' ? (i++, ']]') : ']');
|
|
58
|
+
heads.push(undefined);
|
|
53
59
|
}
|
|
54
60
|
else if (c === '{') {
|
|
61
|
+
const head = heads[heads.length - 1];
|
|
62
|
+
if (head !== undefined && stack[stack.length - 1] === ')' && head.bodyAt === undefined) {
|
|
63
|
+
head.bodyAt = text.slice(0, i).trimEnd().length;
|
|
64
|
+
}
|
|
55
65
|
stack.push('}');
|
|
66
|
+
heads.push(undefined);
|
|
56
67
|
}
|
|
57
68
|
else if ((c === ')' || c === '}') && stack[stack.length - 1] === c) {
|
|
58
69
|
stack.pop();
|
|
70
|
+
heads.pop();
|
|
59
71
|
}
|
|
60
72
|
else if (c === ']') {
|
|
61
73
|
if (stack[stack.length - 1] === ']') {
|
|
62
74
|
stack.pop();
|
|
75
|
+
heads.pop();
|
|
63
76
|
}
|
|
64
77
|
else if (stack[stack.length - 1] === ']]') {
|
|
65
78
|
stack[stack.length - 1] = ']';
|
|
66
79
|
}
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
|
-
|
|
82
|
+
/* the one `)` that is missing belongs where the head ends, not after everything that came with the body */
|
|
83
|
+
return { closers: stack.reverse(), percentAt, headAt: stack.length === 1 && stack[0] === ')' ? heads[0]?.bodyAt : undefined };
|
|
70
84
|
}
|
|
71
85
|
/** Fuzzy-complete the `%...` operator at `at` to the nearest known one (else just close it). */
|
|
72
86
|
function operatorCompletion(node, at) {
|
|
@@ -76,7 +90,9 @@ function operatorCompletion(node, at) {
|
|
|
76
90
|
const column = node.startPosition.column + at;
|
|
77
91
|
return { range: [node.startPosition.row + 1, column + 1, node.startPosition.row + 1, column + fragment.length], full };
|
|
78
92
|
}
|
|
79
|
-
|
|
93
|
+
/** the grammar reports a missing string quote as `string_close`, which stands for whatever quote opened the string */
|
|
94
|
+
const missingToken = (node) => node.type === 'string_close' ? node.parent?.firstChild?.text ?? node.type : node.type;
|
|
95
|
+
const isMissingExpression = (f) => f.kind === 'missing' && !DelimiterInsert.has(missingToken(f.node)) && !KeywordInsert.has(missingToken(f.node));
|
|
80
96
|
/** The built-in auto-fix patterns; append a {@link SyntaxErrorFixPattern} to add repairs. */
|
|
81
97
|
exports.SyntaxErrorFixPatterns = [
|
|
82
98
|
// first, because it judges the whole line: `[1] 1 2 3` errors on both `[` and `]`, and repairing those as
|
|
@@ -97,12 +113,12 @@ exports.SyntaxErrorFixPatterns = [
|
|
|
97
113
|
name: 'insert-missing-token',
|
|
98
114
|
description: 'Insert a delimiter, quote, or keyword the parser expected but did not find.',
|
|
99
115
|
direction: 'add',
|
|
100
|
-
appliesTo: f => f.kind === 'missing' && (DelimiterInsert.has(f.node
|
|
116
|
+
appliesTo: f => f.kind === 'missing' && (DelimiterInsert.has(missingToken(f.node)) || KeywordInsert.has(missingToken(f.node))),
|
|
101
117
|
quickFix: (f, file) => ({
|
|
102
118
|
type: 'replace',
|
|
103
119
|
loc: range_1.SourceLocation.from(point(f.node.startPosition), file),
|
|
104
|
-
description: `Insert missing \`${f.node
|
|
105
|
-
replacement: DelimiterInsert.get(f.node
|
|
120
|
+
description: `Insert missing \`${missingToken(f.node)}\``,
|
|
121
|
+
replacement: DelimiterInsert.get(missingToken(f.node)) ?? KeywordInsert.get(missingToken(f.node))
|
|
106
122
|
})
|
|
107
123
|
},
|
|
108
124
|
{
|
|
@@ -126,6 +142,12 @@ exports.SyntaxErrorFixPatterns = [
|
|
|
126
142
|
appliesTo: f => f.kind === 'error' && f.scan.closers.length > 0,
|
|
127
143
|
quickFix: (f, file) => {
|
|
128
144
|
const closers = f.scan.closers.join('');
|
|
145
|
+
if (f.scan.headAt !== undefined) {
|
|
146
|
+
/* the offset is in the region's text, which starts where the node does */
|
|
147
|
+
const before = f.node.text.slice(0, f.scan.headAt).split('\n');
|
|
148
|
+
const column = before.length === 1 ? f.node.startPosition.column + f.scan.headAt : before[before.length - 1].length;
|
|
149
|
+
return { type: 'replace', loc: range_1.SourceLocation.from(point({ row: f.node.startPosition.row + before.length - 1, column }), file), description: 'Add missing closing `)` after the head', replacement: ')' };
|
|
150
|
+
}
|
|
129
151
|
return { type: 'replace', loc: range_1.SourceLocation.from(point(f.node.endPosition), file), description: `Add missing closing \`${closers}\``, replacement: closers };
|
|
130
152
|
}
|
|
131
153
|
},
|
|
@@ -205,7 +227,7 @@ function collectFindings(node, lines, out = []) {
|
|
|
205
227
|
}
|
|
206
228
|
function describe(finding) {
|
|
207
229
|
if (finding.kind === 'missing') {
|
|
208
|
-
return `Missing \`${finding.node
|
|
230
|
+
return `Missing \`${missingToken(finding.node)}\``;
|
|
209
231
|
}
|
|
210
232
|
const text = finding.node.text.replace(/\s+/g, ' ').trim();
|
|
211
233
|
return `Unexpected \`${text.length > 30 ? text.slice(0, 27) + '...' : text}\``;
|
|
@@ -253,10 +275,7 @@ exports.SYNTACTICALLY_VALID = {
|
|
|
253
275
|
}
|
|
254
276
|
return { results, '.meta': { parser, errors: results.length, fixable: results.filter(r => r.quickFix !== undefined).length } };
|
|
255
277
|
},
|
|
256
|
-
prettyPrint: {
|
|
257
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => `${result.message} at ${range_1.SourceLocation.format(result.loc)}`,
|
|
258
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Syntax error (${result.kind}): ${result.message} at ${range_1.SourceLocation.format(result.loc)}`
|
|
259
|
-
},
|
|
278
|
+
prettyPrint: (0, linter_format_1.prettyPrint)((result) => `${result.message} at ${range_1.SourceLocation.format(result.loc)}`, (result) => `Syntax error (${result.kind}): ${result.message} at ${range_1.SourceLocation.format(result.loc)}`),
|
|
260
279
|
info: {
|
|
261
280
|
name: 'Syntactically Valid',
|
|
262
281
|
description: 'Finds syntax errors with the configured (error-tolerant) parser. Offers extensible quick fixes to repair them.',
|
|
@@ -28,8 +28,8 @@ export declare const UNCLOSED_CONNECTION: {
|
|
|
28
28
|
};
|
|
29
29
|
}>;
|
|
30
30
|
readonly prettyPrint: {
|
|
31
|
-
readonly query: (
|
|
32
|
-
readonly full: (
|
|
31
|
+
readonly query: (r: LintingResult, metadata: unknown) => string;
|
|
32
|
+
readonly full: (r: LintingResult, metadata: unknown) => string;
|
|
33
33
|
};
|
|
34
34
|
readonly info: {
|
|
35
35
|
readonly name: "Unclosed Connection";
|
|
@@ -198,10 +198,7 @@ exports.UNCLOSED_CONNECTION = {
|
|
|
198
198
|
}
|
|
199
199
|
return { results, '.meta': { totalOpened: opens.size, totalClosed: closes.length } };
|
|
200
200
|
},
|
|
201
|
-
prettyPrint: {
|
|
202
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Unclosed connection at ${range_1.SourceLocation.format(result.loc)}`,
|
|
203
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `The connection opened at ${range_1.SourceLocation.format(result.loc)} is not closed on every path that opens it`
|
|
204
|
-
},
|
|
201
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Unclosed connection at ${range_1.SourceLocation.format(result.loc)}`, result => `The connection opened at ${range_1.SourceLocation.format(result.loc)} is not closed on every path that opens it`),
|
|
205
202
|
info: {
|
|
206
203
|
name: 'Unclosed Connection',
|
|
207
204
|
tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.QuickFix],
|
|
@@ -63,8 +63,8 @@ export declare const UNDEFINED_SYMBOL: {
|
|
|
63
63
|
'.meta': UndefinedSymbolMetadata;
|
|
64
64
|
}>;
|
|
65
65
|
readonly prettyPrint: {
|
|
66
|
-
readonly query: (
|
|
67
|
-
readonly full: (
|
|
66
|
+
readonly query: (r: UndefinedSymbolResult, metadata: unknown) => string;
|
|
67
|
+
readonly full: (r: UndefinedSymbolResult, metadata: unknown) => string;
|
|
68
68
|
};
|
|
69
69
|
readonly info: {
|
|
70
70
|
readonly name: "Undefined Symbol";
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UNDEFINED_SYMBOL = void 0;
|
|
4
|
+
const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
|
|
4
5
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
5
6
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
6
7
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
8
|
+
const linter_util_1 = require("../linter-util");
|
|
9
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
7
10
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
8
11
|
const flowr_search_filters_1 = require("../../search/flowr-search-filters");
|
|
9
12
|
const assert_1 = require("../../util/assert");
|
|
@@ -26,8 +29,9 @@ const DispatchVariables = ['.Generic', '.Method', '.Class'];
|
|
|
26
29
|
*/
|
|
27
30
|
function declaredGlobalVariables(graph, ctx) {
|
|
28
31
|
const names = new Set(DispatchVariables);
|
|
29
|
-
for (const [, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
30
|
-
const
|
|
32
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
33
|
+
const callee = (0, linter_util_1.builtInOf)(graph, id);
|
|
34
|
+
const [name, ns] = callee === undefined ? [] : identifier_1.Identifier.toArray(callee);
|
|
31
35
|
if (name !== 'globalVariables' || (ns !== undefined && ns !== 'utils')) {
|
|
32
36
|
continue;
|
|
33
37
|
}
|
|
@@ -48,9 +52,8 @@ const NameBindingFunctions = new Set(['assign', 'delayedAssign']);
|
|
|
48
52
|
*/
|
|
49
53
|
function assignedNames(graph, ctx) {
|
|
50
54
|
const names = new Set();
|
|
51
|
-
for (const [, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
52
|
-
|
|
53
|
-
if (!NameBindingFunctions.has(name) || (ns !== undefined && ns !== 'base')) {
|
|
55
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
56
|
+
if (!(0, linter_util_1.callsBuiltIn)(graph, id, NameBindingFunctions)) {
|
|
54
57
|
continue;
|
|
55
58
|
}
|
|
56
59
|
const values = (0, resolve_argument_1.getArgumentStringValue)(ctx.config.solver.variables, graph, vertex, 0, 'x', true, ctx);
|
|
@@ -62,8 +65,10 @@ function assignedNames(graph, ctx) {
|
|
|
62
65
|
}
|
|
63
66
|
return names;
|
|
64
67
|
}
|
|
65
|
-
/** calls that load a package; an unresolved one means we cannot enumerate all exports in scope */
|
|
66
|
-
|
|
68
|
+
/** calls that load or attach a package (what flowR states, plus `pacman::p_load`); an unresolved one means we cannot enumerate all exports in scope */
|
|
69
|
+
function libraryLoadFunctions(index) {
|
|
70
|
+
return new Set([...(0, linter_util_1.namesWith)(index, built_in_props_1.SemanticCallTag.LoadsPackage), ...(0, linter_util_1.namesWith)(index, built_in_props_1.SemanticCallTag.AttachesPackage), 'p_load']);
|
|
71
|
+
}
|
|
67
72
|
/** test frameworks whose namespace a test file runs under implicitly (e.g. `tests/testthat/test-*.R` sees testthat's exports without a `library()`) */
|
|
68
73
|
const ImplicitTestFrameworks = ['testthat', 'tinytest', 'RUnit'];
|
|
69
74
|
/** whether name is an export of a default-attached base package (needs no library()) */
|
|
@@ -108,8 +113,9 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
108
113
|
const isImplicitTestExport = (name, file) => file !== undefined && testFiles.has(file) && testExports.has(name);
|
|
109
114
|
/* a library() we could not resolve could export any bare name, so such names are suppressed rather than guessed */
|
|
110
115
|
const unknownIds = new Set([...graph.unknownSideEffects].map(e => graph_1.UnknownSideEffect.id(e)));
|
|
116
|
+
const libraryLoads = libraryLoadFunctions(ctx.env.builtInIndex);
|
|
111
117
|
const unresolvedLibraryInScope = unknownIds.size > 0 && [...graph.verticesOfType(vertex_1.VertexType.FunctionCall)]
|
|
112
|
-
.some(([id, v]) => unknownIds.has(id) &&
|
|
118
|
+
.some(([id, v]) => unknownIds.has(id) && libraryLoads.has(identifier_1.Identifier.getName(v.name)));
|
|
113
119
|
// names a package declares global (`utils::globalVariables`) are no undefined symbols to R CMD check either
|
|
114
120
|
const declaredGlobals = declaredGlobalVariables(graph, ctx);
|
|
115
121
|
const boundByAssign = assignedNames(graph, ctx);
|
|
@@ -196,7 +202,7 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
196
202
|
const symbolOf = (node) => {
|
|
197
203
|
const vtx = graph.getVertex(node.info.id);
|
|
198
204
|
if (vertex_1.DfgVertex.isFunctionCall(vtx)) {
|
|
199
|
-
return vtx.
|
|
205
|
+
return !vertex_1.DfgVertex.hasOrigin(vtx, built_in_proc_name_1.BuiltInProcName.Unnamed) && config.checkFunctions ? ['function', vtx.name] : undefined;
|
|
200
206
|
}
|
|
201
207
|
const plainSymbol = r_symbol_1.RSymbol.is(node) && node.lexeme !== '...' && node.lexeme !== undefined;
|
|
202
208
|
return vertex_1.DfgVertex.isUse(vtx) && config.checkVariables && plainSymbol ? ['variable', node.content] : undefined;
|
|
@@ -215,20 +221,17 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
215
221
|
}).filter(assert_1.isNotUndefined);
|
|
216
222
|
return { results, '.meta': meta };
|
|
217
223
|
},
|
|
218
|
-
prettyPrint: {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const hint = result.availableInPackages.length === 1 ? `with \`library(${result.availableInPackages[0]})\`` : 'from one of them';
|
|
225
|
-
return `\`${result.name}\` at ${where} is used but not defined. It is exported by ${pkgs}, so it may only need loading, for example ${hint}.`;
|
|
226
|
-
}
|
|
227
|
-
return result.kind === 'function'
|
|
228
|
-
? `\`${result.name}\` at ${where} is called but is neither defined locally, a base R builtin, nor exported by a loaded package`
|
|
229
|
-
: `\`${result.name}\` at ${where} is used as a variable but is never defined in scope`;
|
|
224
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Undefined ${result.kind} \`${result.name}\` at ${range_1.SourceLocation.format(result.loc)}`, result => {
|
|
225
|
+
const where = range_1.SourceLocation.format(result.loc);
|
|
226
|
+
if (result.availableInPackages && result.availableInPackages.length > 0) {
|
|
227
|
+
const pkgs = result.availableInPackages.map(p => `\`${p}\``).join(', ');
|
|
228
|
+
const hint = result.availableInPackages.length === 1 ? `with \`library(${result.availableInPackages[0]})\`` : 'from one of them';
|
|
229
|
+
return `\`${result.name}\` at ${where} is used but not defined. It is exported by ${pkgs}, so it may only need loading, for example ${hint}.`;
|
|
230
230
|
}
|
|
231
|
-
|
|
231
|
+
return result.kind === 'function'
|
|
232
|
+
? `\`${result.name}\` at ${where} is called but is neither defined locally, a base R builtin, nor exported by a loaded package`
|
|
233
|
+
: `\`${result.name}\` at ${where} is used as a variable but is never defined in scope`;
|
|
234
|
+
}),
|
|
232
235
|
info: {
|
|
233
236
|
name: 'Undefined Symbol',
|
|
234
237
|
certainty: linter_format_1.LintingRuleCertainty.OverApproximative,
|
|
@@ -108,8 +108,8 @@ export declare const UNESCAPED_ARGUMENTS: {
|
|
|
108
108
|
};
|
|
109
109
|
}>;
|
|
110
110
|
readonly prettyPrint: {
|
|
111
|
-
readonly query: (
|
|
112
|
-
readonly full: (
|
|
111
|
+
readonly query: (r: UnescapedArgumentsResult, metadata: unknown) => string;
|
|
112
|
+
readonly full: (r: UnescapedArgumentsResult, metadata: unknown) => string;
|
|
113
113
|
};
|
|
114
114
|
readonly info: {
|
|
115
115
|
readonly name: "Unescaped Arguments";
|
|
@@ -321,10 +321,7 @@ exports.UNESCAPED_ARGUMENTS = {
|
|
|
321
321
|
'.meta': { totalCriticalArguments: targets.length, totalEscapedArguments: escaped }
|
|
322
322
|
};
|
|
323
323
|
},
|
|
324
|
-
prettyPrint: {
|
|
325
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Unescaped ${result.category} argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
326
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `The argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)} reaches a ${result.category} call unescaped (input: ${result.input.join(', ')})`
|
|
327
|
-
},
|
|
324
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Unescaped ${result.category} argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)}`, result => `The argument of \`${identifier_1.Identifier.toString(result.function)}\` at ${range_1.SourceLocation.format(result.loc)} reaches a ${result.category} call unescaped (input: ${result.input.join(', ')})`),
|
|
328
325
|
info: {
|
|
329
326
|
name: 'Unescaped Arguments',
|
|
330
327
|
tags: [linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Shiny, linter_tags_1.LintingRuleTag.QuickFix],
|
|
@@ -33,8 +33,8 @@ export declare const UNUSED_DEFINITION: {
|
|
|
33
33
|
".meta": UnusedDefinitionMetadata;
|
|
34
34
|
}>;
|
|
35
35
|
readonly prettyPrint: {
|
|
36
|
-
readonly query: (
|
|
37
|
-
readonly full: (
|
|
36
|
+
readonly query: (r: UnusedDefinitionResult, metadata: unknown) => string;
|
|
37
|
+
readonly full: (r: UnusedDefinitionResult, metadata: unknown) => string;
|
|
38
38
|
};
|
|
39
39
|
readonly info: {
|
|
40
40
|
readonly name: "Unused Definitions";
|