@eagleoutice/flowr 2.16.2 → 2.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/abstract-interpretation/data-frame/arguments.js +4 -3
- package/abstract-interpretation/data-frame/dataframe-semantics.js +1 -2
- package/abstract-interpretation/data-frame/semantics.d.ts +2 -2
- package/abstract-interpretation/data-frame/semantics.js +2 -6
- package/benchmark/slicer.js +1 -3
- package/benchmark/summarizer/first-phase/input.js +1 -12
- package/benchmark/summarizer/second-phase/process.d.ts +7 -0
- package/benchmark/summarizer/second-phase/process.js +15 -12
- package/cli/repl/commands/repl-cfg.js +18 -49
- package/cli/repl/commands/repl-clipboard.d.ts +2 -0
- package/cli/repl/commands/repl-clipboard.js +5 -0
- package/cli/repl/commands/repl-commands.js +2 -2
- package/cli/repl/commands/repl-dataflow.js +21 -55
- package/cli/repl/commands/repl-normalize.js +15 -28
- package/cli/repl/commands/repl-parse.js +2 -2
- package/cli/repl/commands/repl-query.js +10 -10
- package/cli/repl/commands/repl-signature.js +4 -4
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +8 -30
- package/cli/repl/server/messages/message-analysis.js +1 -1
- package/config.d.ts +6 -0
- package/config.js +7 -4
- package/control-flow/cfg-dead-code.js +5 -14
- package/control-flow/cfg-to-basic-blocks.js +1 -6
- package/control-flow/control-flow-graph.d.ts +2 -16
- package/control-flow/control-flow-graph.js +8 -66
- package/control-flow/diff-cfg.js +10 -23
- package/control-flow/semantic-cfg-guided-visitor.js +5 -11
- package/control-flow/simple-visitor.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +138 -138
- package/data/r-base-packages.generated.js +0 -1
- package/data/r-base-primitives.generated.js +0 -1
- package/data/r-s3-generics.generated.d.ts +5 -0
- package/data/r-s3-generics.generated.js +103 -0
- package/dataflow/cluster.js +2 -1
- package/dataflow/environments/append.d.ts +1 -0
- package/dataflow/environments/built-in-props.d.ts +10 -0
- package/dataflow/environments/built-in-props.js +25 -1
- package/dataflow/environments/built-in.js +15 -9
- package/dataflow/environments/clone.d.ts +1 -0
- package/dataflow/environments/clone.js +1 -0
- package/dataflow/environments/default-builtin-config.d.ts +188 -14
- package/dataflow/environments/default-builtin-config.js +125 -65
- package/dataflow/environments/define.d.ts +1 -0
- package/dataflow/environments/define.js +1 -0
- package/dataflow/environments/environment.d.ts +27 -0
- package/dataflow/environments/environment.js +37 -16
- package/dataflow/environments/frame-memory.d.ts +9 -1
- package/dataflow/environments/frame-memory.js +12 -1
- package/dataflow/environments/identifier.d.ts +0 -2
- package/dataflow/environments/identifier.js +5 -7
- package/dataflow/environments/overwrite.js +1 -0
- package/dataflow/environments/query-fn-props.js +4 -4
- package/dataflow/environments/scoping.d.ts +3 -0
- package/dataflow/environments/scoping.js +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +3 -3
- package/dataflow/eval/resolve/resolve-argument.d.ts +7 -3
- package/dataflow/eval/resolve/resolve-argument.js +16 -11
- package/dataflow/eval/resolve/resolve-numbers.js +5 -2
- package/dataflow/eval/resolve/resolve-strings.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -2
- package/dataflow/eval/resolve/resolve.js +3 -8
- package/dataflow/eval/values/intervals/interval-constants.js +1 -6
- package/dataflow/eval/values/r-value.js +1 -6
- package/dataflow/extractor.js +17 -17
- package/dataflow/fn/argument-roles.js +15 -15
- package/dataflow/fn/class-declaration.js +7 -7
- package/dataflow/fn/frame-reflection.d.ts +1 -23
- package/dataflow/fn/frame-reflection.js +8 -95
- package/dataflow/fn/function-props.d.ts +0 -3
- package/dataflow/fn/function-props.js +9 -11
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/fn/strict-function.js +15 -14
- package/dataflow/graph/call-graph.d.ts +8 -0
- package/dataflow/graph/call-graph.js +40 -25
- package/dataflow/graph/dataflowgraph-builder.d.ts +0 -60
- package/dataflow/graph/dataflowgraph-builder.js +15 -135
- package/dataflow/graph/df-helper.d.ts +56 -4
- package/dataflow/graph/df-helper.js +116 -1
- package/dataflow/graph/diff-dataflow-graph.js +13 -15
- package/dataflow/graph/graph-helper.d.ts +20 -0
- package/dataflow/graph/graph-helper.js +18 -0
- package/dataflow/graph/graph.js +3 -8
- package/dataflow/graph/match-args.d.ts +1 -1
- package/dataflow/graph/match-args.js +3 -3
- package/dataflow/internal/linker.d.ts +4 -10
- package/dataflow/internal/linker.js +21 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +39 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +6 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +27 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +33 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +7 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +5 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +36 -38
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +6 -7
- package/dataflow/internal/process/functions/call/deferred.js +8 -8
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +11 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +11 -7
- package/dataflow/internal/process/functions/call/named-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/nse.js +4 -4
- package/dataflow/internal/process/functions/call/quoted.js +16 -14
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
- package/dataflow/internal/process/functions/process-parameter.js +2 -2
- package/dataflow/internal/process/process-named-call.js +1 -1
- package/dataflow/origin/dfg-get-origin.js +2 -2
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -0
- package/dataflow/origin/dfg-get-symbol-refs.js +3 -8
- package/documentation/data/faq/wiki-faq-store.js +2 -2
- package/documentation/doc-capabilities.js +2 -1
- package/documentation/doc-util/doc-functions.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +1 -1
- package/documentation/doc-util/doc-query.js +3 -1
- package/documentation/doc-util/doc-repl.js +4 -4
- package/documentation/doc-util/doc-timings.js +3 -2
- package/documentation/doc-util/doc-types.js +2 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-cfg.js +2 -1
- package/documentation/wiki-create-linting-rules.js +2 -2
- package/documentation/wiki-dataflow-graph.js +6 -6
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.d.ts +14 -0
- package/documentation/wiki-linter.js +353 -88
- package/documentation/wiki-mk/doc-maker.js +1 -2
- package/documentation/wiki-query.js +25 -0
- package/documentation/wiki-search.js +2 -1
- package/documentation/wiki-signature-database.js +0 -2
- package/linter/linter-executor.js +4 -0
- package/linter/linter-rules.d.ts +552 -35
- package/linter/linter-rules.js +39 -1
- package/linter/linter-tags.d.ts +6 -0
- package/linter/linter-tags.js +6 -0
- package/linter/rules/absolute-path.d.ts +1 -1
- package/linter/rules/absolute-path.js +9 -6
- package/linter/rules/cmd-check/bogus-return.d.ts +29 -0
- package/linter/rules/cmd-check/bogus-return.js +63 -0
- package/linter/rules/cmd-check/call-arguments.d.ts +63 -0
- package/linter/rules/cmd-check/call-arguments.js +216 -0
- package/linter/rules/cmd-check/class-string-comparison.d.ts +48 -0
- package/linter/rules/cmd-check/class-string-comparison.js +135 -0
- package/linter/rules/cmd-check/cmd-check-util.d.ts +67 -0
- package/linter/rules/cmd-check/cmd-check-util.js +169 -0
- package/linter/rules/cmd-check/compiled-code.d.ts +86 -0
- package/linter/rules/cmd-check/compiled-code.js +350 -0
- package/linter/rules/cmd-check/conformance.d.ts +51 -0
- package/linter/rules/cmd-check/conformance.js +166 -0
- package/linter/rules/cmd-check/dependency-declaration.d.ts +95 -0
- package/linter/rules/cmd-check/dependency-declaration.js +299 -0
- package/linter/rules/cmd-check/description-metadata.d.ts +63 -0
- package/linter/rules/cmd-check/description-metadata.js +393 -0
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +60 -0
- package/linter/rules/cmd-check/documentation-mismatch.js +407 -0
- package/linter/rules/cmd-check/file-checks.d.ts +29 -0
- package/linter/rules/cmd-check/file-checks.js +34 -0
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +54 -0
- package/linter/rules/cmd-check/foreign-function-calls.js +115 -0
- package/linter/rules/cmd-check/global-environment-modification.d.ts +61 -0
- package/linter/rules/cmd-check/global-environment-modification.js +237 -0
- package/linter/rules/cmd-check/namespace-tampering.d.ts +52 -0
- package/linter/rules/cmd-check/namespace-tampering.js +162 -0
- package/linter/rules/cmd-check/non-ascii-code.d.ts +51 -0
- package/linter/rules/cmd-check/non-ascii-code.js +112 -0
- package/linter/rules/cmd-check/package-code.d.ts +30 -0
- package/linter/rules/cmd-check/package-code.js +141 -0
- package/linter/rules/cmd-check/package-data.d.ts +51 -0
- package/linter/rules/cmd-check/package-data.js +181 -0
- package/linter/rules/cmd-check/package-files.d.ts +41 -0
- package/linter/rules/cmd-check/package-files.js +157 -0
- package/linter/rules/cmd-check/package-hooks.d.ts +57 -0
- package/linter/rules/cmd-check/package-hooks.js +173 -0
- package/linter/rules/cmd-check/package-metafiles.d.ts +49 -0
- package/linter/rules/cmd-check/package-metafiles.js +292 -0
- package/linter/rules/cmd-check/package-runtime.d.ts +67 -0
- package/linter/rules/cmd-check/package-runtime.js +284 -0
- package/linter/rules/cmd-check/package-structure.d.ts +85 -0
- package/linter/rules/cmd-check/package-structure.js +320 -0
- package/linter/rules/cmd-check/rd-files.d.ts +83 -0
- package/linter/rules/cmd-check/rd-files.js +621 -0
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +72 -0
- package/linter/rules/cmd-check/s-three-method-consistency.js +206 -0
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +45 -0
- package/linter/rules/cmd-check/true-false-abbreviation.js +121 -0
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.js +1 -1
- package/linter/rules/dead-code.d.ts +4 -4
- package/linter/rules/dead-code.js +19 -4
- package/linter/rules/deprecated-functions.d.ts +1 -1
- package/linter/rules/deprecated-functions.js +5 -5
- package/linter/rules/file-path-validity.d.ts +6 -2
- package/linter/rules/file-path-validity.js +7 -3
- package/linter/rules/namespace-access.d.ts +3 -3
- package/linter/rules/namespace-access.js +12 -3
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +14 -15
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/network-functions.js +1 -1
- package/linter/rules/no-leaked-credentials.d.ts +1 -1
- package/linter/rules/no-leaked-credentials.js +5 -5
- package/linter/rules/problematic-inputs.d.ts +2 -2
- package/linter/rules/problematic-inputs.js +4 -3
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +2 -2
- package/linter/rules/seeded-randomness.d.ts +2 -2
- package/linter/rules/seeded-randomness.js +7 -7
- package/linter/rules/software-has-license.d.ts +3 -3
- package/linter/rules/software-has-license.js +3 -3
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +2 -2
- package/linter/rules/stop-with-call-arg.d.ts +3 -3
- package/linter/rules/stop-with-call-arg.js +21 -4
- package/linter/rules/syntactically-valid.d.ts +1 -1
- package/linter/rules/syntactically-valid.js +1 -1
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +5 -5
- package/linter/rules/undefined-symbol-util.js +16 -32
- package/linter/rules/undefined-symbol.d.ts +3 -1
- package/linter/rules/undefined-symbol.js +34 -4
- package/linter/rules/unescaped-arguments.d.ts +1 -1
- package/linter/rules/unescaped-arguments.js +11 -10
- package/linter/rules/unused-definition.d.ts +1 -1
- package/linter/rules/unused-definition.js +14 -20
- package/linter/rules/unused-import.d.ts +1 -1
- package/linter/rules/unused-import.js +1 -1
- package/linter/rules/useless-loop.d.ts +1 -1
- package/linter/rules/useless-loop.js +1 -1
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.js +1 -1
- package/project/context/flowr-analyzer-context.js +1 -1
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -2
- package/project/context/flowr-analyzer-environment-context.js +2 -1
- package/project/context/flowr-analyzer-files-context.d.ts +6 -0
- package/project/context/flowr-analyzer-files-context.js +15 -11
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +0 -2
- package/project/context/flowr-analyzer-incremental-analysis-context.js +0 -4
- package/project/context/flowr-file.d.ts +4 -0
- package/project/context/flowr-file.js +4 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +11 -14
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +3 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +25 -15
- package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +44 -0
- package/project/plugins/file-plugins/files/flowr-rd-file.js +130 -61
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -16
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -0
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +0 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +3 -7
- package/project/sigdb/build.js +16 -30
- package/project/sigdb/dict.d.ts +4 -6
- package/project/sigdb/dict.js +125 -31
- package/project/sigdb/reader.js +2 -18
- package/project/sigdb/sigdb-download.js +14 -23
- package/queries/base-query-format.d.ts +2 -0
- package/queries/base-query-format.js +10 -2
- package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
- package/queries/catalog/absint-query/absint-query-format.js +5 -7
- package/queries/catalog/call-context-query/call-context-query-executor.js +24 -32
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -3
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -4
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -4
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -3
- package/queries/catalog/config-query/config-query-format.js +3 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -3
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -3
- package/queries/catalog/dependencies-query/data-flow.d.ts +45 -0
- package/queries/catalog/dependencies-query/data-flow.js +179 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +18 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +108 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +17 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +14 -11
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.js +13 -13
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +3 -3
- package/queries/catalog/dependencies-query/function-info/source-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.js +8 -8
- package/queries/catalog/dependencies-query/function-info/transform-functions.d.ts +8 -0
- package/queries/catalog/dependencies-query/function-info/transform-functions.js +17 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.js +4 -0
- package/queries/catalog/dependencies-query/implicit-echo.d.ts +5 -3
- package/queries/catalog/dependencies-query/implicit-echo.js +36 -35
- package/queries/catalog/dependencies-query/link-devices.d.ts +3 -2
- package/queries/catalog/dependencies-query/link-devices.js +9 -6
- package/queries/catalog/dependencies-query/plot-description.d.ts +10 -0
- package/queries/catalog/dependencies-query/plot-description.js +119 -0
- package/queries/catalog/dependencies-query/plot-objects.d.ts +13 -0
- package/queries/catalog/dependencies-query/plot-objects.js +61 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -2
- package/queries/catalog/dice-query/dice-query-format.js +3 -40
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +2 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +2 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -3
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.js +28 -29
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +4 -7
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +1 -1
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/catalog/linter-query/linter-query-executor.js +10 -3
- package/queries/catalog/linter-query/linter-query-format.d.ts +4 -1
- package/queries/catalog/linter-query/linter-query-format.js +32 -21
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -3
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.js +4 -5
- package/queries/catalog/project-query/project-query-format.js +2 -2
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -4
- package/queries/catalog/search-query/search-query-format.js +1 -3
- package/queries/catalog/signature-query/signature-query-executor.js +3 -3
- package/queries/catalog/signature-query/signature-query-format.js +2 -2
- package/queries/catalog/slice-query-options.d.ts +16 -0
- package/queries/catalog/slice-query-options.js +28 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -42
- package/queries/query-print.d.ts +4 -0
- package/queries/query-print.js +17 -1
- package/queries/query.d.ts +3 -3
- package/queries/query.js +3 -4
- package/r-bridge/lang-4.x/ast/model/model.d.ts +27 -3
- package/r-bridge/lang-4.x/ast/model/model.js +28 -1
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +20 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +25 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +18 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +15 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +17 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +20 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/operators.js +0 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/fold.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -3
- package/r-bridge/lang-4.x/ast/parser/json/format.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -20
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -9
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +7 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -10
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +30 -82
- package/r-bridge/retriever.d.ts +0 -4
- package/r-bridge/retriever.js +0 -13
- package/r-bridge/roxygen2/documentation-provider.js +3 -7
- package/r-bridge/shell.js +3 -8
- package/reconstruct/auto-select/magic-comments.js +8 -7
- package/reconstruct/inline/source-inline-map.d.ts +3 -0
- package/reconstruct/inline/source-inline-map.js +8 -7
- package/reconstruct/reconstruct.d.ts +1 -1
- package/reconstruct/reconstruct.js +33 -109
- package/search/flowr-search-printer.js +4 -15
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/filters/all-variables.js +1 -2
- package/slicing/static/fingerprint.js +11 -2
- package/slicing/static/slice-call.d.ts +2 -8
- package/slicing/static/slice-call.js +8 -18
- package/slicing/static/static-slicer.js +81 -6
- package/util/collections/arrays.js +1 -1
- package/util/collections/set.js +1 -1
- package/util/diff-graph.d.ts +4 -0
- package/util/diff-graph.js +12 -0
- package/util/files.js +2 -6
- package/util/json.js +1 -15
- package/util/mermaid/cfg.js +10 -17
- package/util/mermaid/dfg.js +6 -8
- package/util/objects.d.ts +1 -1
- package/util/quads.js +4 -13
- package/util/r-author.js +5 -5
- package/util/range.d.ts +9 -0
- package/util/range.js +11 -0
- package/util/schema.js +3 -3
- package/util/simple-df/dfg-view.js +2 -1
- package/util/text/ansi.js +1 -2
- package/util/text/playground-link.js +2 -1
- package/util/text/r-highlight.js +2 -1
- package/util/text/strings.d.ts +2 -0
- package/util/text/strings.js +5 -0
- package/util/text/time.js +1 -2
- package/util/version.js +4 -3
- package/dataflow/fn/recursive-function.d.ts +0 -6
- package/dataflow/fn/recursive-function.js +0 -32
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +0 -16
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +0 -27
|
@@ -3,12 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WikiLinter = void 0;
|
|
6
|
+
exports.WikiLinter = exports.LintingRuleExamples = void 0;
|
|
7
|
+
const r_string_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
7
8
|
const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
|
|
8
9
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
10
|
+
const conformance_1 = require("../linter/rules/cmd-check/conformance");
|
|
9
11
|
const linter_rules_1 = require("../linter/linter-rules");
|
|
10
12
|
const doc_code_1 = require("./doc-util/doc-code");
|
|
11
13
|
const doc_query_1 = require("./doc-util/doc-query");
|
|
14
|
+
const retriever_1 = require("../r-bridge/retriever");
|
|
12
15
|
const doc_types_1 = require("./doc-util/doc-types");
|
|
13
16
|
const path_1 = __importDefault(require("path"));
|
|
14
17
|
const assert_1 = require("../util/assert");
|
|
@@ -24,15 +27,25 @@ const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
|
24
27
|
const flowr_analyzer_context_1 = require("../project/context/flowr-analyzer-context");
|
|
25
28
|
const config_1 = require("../config");
|
|
26
29
|
const documentedContext = new flowr_analyzer_context_1.FlowrAnalyzerContext(config_1.FlowrConfig.default());
|
|
27
|
-
|
|
30
|
+
/** one color per role of a tag: the kind of issue, R CMD check, quick fixes, the status of a rule, and every other aspect */
|
|
31
|
+
const TagColors = {
|
|
28
32
|
[linter_tags_1.LintingRuleTag.Bug]: 'red',
|
|
29
|
-
[linter_tags_1.LintingRuleTag.Security]: 'orange',
|
|
30
33
|
[linter_tags_1.LintingRuleTag.Smell]: 'yellow',
|
|
31
|
-
[linter_tags_1.LintingRuleTag.
|
|
34
|
+
[linter_tags_1.LintingRuleTag.Style]: 'blue',
|
|
35
|
+
[linter_tags_1.LintingRuleTag.CmdCheck]: 'blueviolet',
|
|
36
|
+
[linter_tags_1.LintingRuleTag.QuickFix]: 'brightgreen',
|
|
37
|
+
[linter_tags_1.LintingRuleTag.Experimental]: 'lightgrey'
|
|
32
38
|
};
|
|
33
|
-
|
|
39
|
+
const AspectColor = 'teal';
|
|
40
|
+
const ConformancePageName = 'R CMD check Conformance';
|
|
41
|
+
const ConformancePage = `${doc_files_1.FlowrWikiBaseRef}/${ConformancePageName.replaceAll(' ', '-')}`;
|
|
42
|
+
/** text as a part of a shields.io badge url */
|
|
43
|
+
const shield = (text) => encodeURIComponent(text.replaceAll('-', '--').replaceAll('_', '__'));
|
|
44
|
+
function makeTagBadge(name, info, message, href = `${doc_files_1.FlowrWikiBaseRef}/Linter#${name}`) {
|
|
34
45
|
const doc = (0, doc_types_1.getDocumentationForType)('LintingRuleTag::' + name, info, '', { fuzzy: true }).replaceAll('\n', ' ');
|
|
35
|
-
|
|
46
|
+
const color = TagColors[name] ?? AspectColor;
|
|
47
|
+
const badge = message === undefined ? `${shield(name)}-${color}` : `${shield(name)}-${shield(message)}-${color}`;
|
|
48
|
+
return (0, html_hover_over_1.textWithTooltip)(`<a href='${href}'> </a>`, doc);
|
|
36
49
|
}
|
|
37
50
|
function getPageNameForLintingRule(name) {
|
|
38
51
|
// convert file-path-validity to 'Linting Rule: File Path Validity'
|
|
@@ -209,12 +222,12 @@ These examples are synthesized from the test cases in: ${(0, doc_files_1.linkFlo
|
|
|
209
222
|
continue;
|
|
210
223
|
}
|
|
211
224
|
// drop any quotes around the test name
|
|
212
|
-
const testNameClean =
|
|
225
|
+
const testNameClean = r_string_1.RString.unquote(testName);
|
|
213
226
|
result += `\n${(0, doc_structure_1.section)('Test Case: ' + testNameClean, 4)}
|
|
214
227
|
|
|
215
228
|
${report.comments ? report.comments.map(c => `> ${c}`).join('\n') + '\n' : ''}
|
|
216
229
|
Given the following input:
|
|
217
|
-
${(0, doc_code_1.codeBlock)('r', args[2].getText(report.source)
|
|
230
|
+
${(0, doc_code_1.codeBlock)('r', r_string_1.RString.unquote(args[2].getText(report.source)).replace(/\\n/g, '\n'))}
|
|
218
231
|
${args.length >= 7 ? `\nAnd using the following [configuration](#configuration): ${(0, doc_code_1.codeBlock)('ts', prettyPrintExpectedOutput(args[6].getText(report.source)))}` : ''}
|
|
219
232
|
|
|
220
233
|
We expect the linter to report the following:
|
|
@@ -227,90 +240,259 @@ See [here](${(0, doc_types_1.getTypePathLink)({ filePath: report.source.fileName
|
|
|
227
240
|
}
|
|
228
241
|
return result;
|
|
229
242
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
const ExampleDescription = 'Package: pkg\nVersion: 1.0\nTitle: A Package\nLicense: MIT\n';
|
|
244
|
+
const ExampleRoot = '/pkg';
|
|
245
|
+
/** what the wiki shows for each linting rule: its configuration and implementation types, its tests, and an example with findings */
|
|
246
|
+
exports.LintingRuleExamples = {
|
|
247
|
+
'deprecated-functions': {
|
|
248
|
+
configType: 'DeprecatedFunctionsConfig', ruleType: 'DEPRECATED_FUNCTIONS', testfile: 'lint-deprecated-functions',
|
|
249
|
+
example: `
|
|
233
250
|
first <- data.frame(x = c(1, 2, 3), y = c(1, 2, 3))
|
|
234
251
|
second <- data.frame(x = c(1, 3, 2), y = c(1, 3, 2))
|
|
235
252
|
dplyr::all_equal(first, second)
|
|
236
|
-
|
|
237
|
-
|
|
253
|
+
|
|
254
|
+
library(ggplot2)
|
|
255
|
+
theme(panel.grid = element_line(size = 1))
|
|
256
|
+
`
|
|
257
|
+
},
|
|
258
|
+
'network-functions': {
|
|
259
|
+
configType: 'NetworkFunctionsConfig', ruleType: 'NETWORK_FUNCTIONS', testfile: 'lint-network-functions',
|
|
260
|
+
example: `
|
|
238
261
|
read.csv("https://example.com/data.csv")
|
|
239
262
|
download.file("https://foo.bar")
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
263
|
+
`
|
|
264
|
+
},
|
|
265
|
+
'file-path-validity': {
|
|
266
|
+
configType: 'FilePathValidityConfig', ruleType: 'FILE_PATH_VALIDITY', testfile: 'lint-file-path-validity',
|
|
267
|
+
example: { code: 'survey <- read.csv("data/Survey.csv")', files: { 'R/survey.csv': 'id,value\n1,2\n' } }
|
|
268
|
+
},
|
|
269
|
+
'absolute-file-paths': {
|
|
270
|
+
configType: 'AbsoluteFilePathConfig', ruleType: 'ABSOLUTE_PATH', testfile: 'lint-absolute-path',
|
|
271
|
+
example: 'read.csv("/home/me/project/data/survey.csv")',
|
|
272
|
+
config: { useAsWd: '/home/me/project' }
|
|
273
|
+
},
|
|
274
|
+
'unused-definitions': {
|
|
275
|
+
configType: 'UnusedDefinitionConfig', ruleType: 'UNUSED_DEFINITION', testfile: 'lint-unused-definition',
|
|
276
|
+
example: `
|
|
248
277
|
x <- 42
|
|
249
278
|
y <- 3
|
|
250
279
|
print(x)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
280
|
+
`
|
|
281
|
+
},
|
|
282
|
+
'seeded-randomness': {
|
|
283
|
+
configType: 'SeededRandomnessConfig', ruleType: 'SEEDED_RANDOMNESS', testfile: 'lint-seeded-randomness',
|
|
284
|
+
example: 'runif(1)'
|
|
285
|
+
},
|
|
286
|
+
'naming-convention': {
|
|
287
|
+
configType: 'NamingConventionConfig', ruleType: 'NAMING_CONVENTION', testfile: 'lint-naming-convention',
|
|
288
|
+
example: `
|
|
289
|
+
testVar <- 5
|
|
290
|
+
testVarTwo <- 5
|
|
291
|
+
other_var <- 5
|
|
292
|
+
`
|
|
293
|
+
},
|
|
294
|
+
'dataframe-access-validation': {
|
|
295
|
+
configType: 'DataFrameAccessValidationConfig', ruleType: 'DATA_FRAME_ACCESS_VALIDATION', testfile: 'lint-dataframe-access-validation',
|
|
296
|
+
example: `
|
|
258
297
|
df <- data.frame(id = 1:5, name = 6:10)
|
|
259
298
|
df[6, "value"]
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
299
|
+
`
|
|
300
|
+
},
|
|
301
|
+
'dead-code': {
|
|
302
|
+
configType: 'DeadCodeConfig', ruleType: 'DEAD_CODE', testfile: 'lint-dead-code',
|
|
303
|
+
example: `
|
|
304
|
+
f <- function(x) {
|
|
305
|
+
return(x)
|
|
306
|
+
print("never reached")
|
|
307
|
+
}
|
|
308
|
+
if(TRUE) 1 else 2
|
|
309
|
+
`
|
|
310
|
+
},
|
|
311
|
+
'useless-loop': {
|
|
312
|
+
configType: 'UselessLoopConfig', ruleType: 'USELESS_LOOP', testfile: 'lint-useless-loop',
|
|
313
|
+
example: 'for(i in c(1)) { print(i) }'
|
|
314
|
+
},
|
|
315
|
+
'stop-call': {
|
|
316
|
+
configType: 'StopWithCallConfig', ruleType: 'STOP_WITH_CALL_ARG', testfile: 'lint-stop-call',
|
|
317
|
+
example: 'f <- function(x) stop(x)'
|
|
318
|
+
},
|
|
319
|
+
'roxygen-arguments': {
|
|
320
|
+
configType: 'RoxygenArgsConfig', ruleType: 'ROXYGEN_ARGS', testfile: 'lint-roxygen-arguments',
|
|
321
|
+
example: '#\' A function with two parameters, but only only one documented\n#\' @param a A variable\nf = function(a, b){return a;}'
|
|
322
|
+
},
|
|
323
|
+
'problematic-inputs': {
|
|
324
|
+
configType: 'ProblematicInputsConfig', ruleType: 'PROBLEMATIC_INPUTS', testfile: 'lint-problematic-inputs',
|
|
325
|
+
example: `
|
|
266
326
|
function(x) {
|
|
267
327
|
eval(x)
|
|
268
328
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
329
|
+
`
|
|
330
|
+
},
|
|
331
|
+
'software-has-license': {
|
|
332
|
+
configType: 'SoftwareHasLicenseConfig', ruleType: 'SOFTWARE_HAS_LICENSE', testfile: 'lint-software-has-license',
|
|
333
|
+
example: 'cat("a project without a license")'
|
|
334
|
+
},
|
|
335
|
+
'software-has-tests': {
|
|
336
|
+
configType: 'SoftwareHasTestsConfig', ruleType: 'SOFTWARE_HAS_TESTS', testfile: 'lint-software-has-tests',
|
|
337
|
+
example: 'cat("hello")'
|
|
338
|
+
},
|
|
339
|
+
'no-leaked-credentials': {
|
|
340
|
+
configType: 'NoLeakedCredentialsConfig', ruleType: 'NO_LEAKED_CREDENTIALS', testfile: 'lint-no-leaked-credentials',
|
|
341
|
+
example: 'password <- "s3cr3t"'
|
|
342
|
+
},
|
|
343
|
+
'undefined-symbol': {
|
|
344
|
+
configType: 'UndefinedSymbolConfig', ruleType: 'UNDEFINED_SYMBOL', testfile: 'lint-undefined-symbol',
|
|
345
|
+
example: 'undefined_helper(42)'
|
|
346
|
+
},
|
|
347
|
+
'syntactically-valid': {
|
|
348
|
+
configType: 'SyntacticallyValidConfig', ruleType: 'SYNTACTICALLY_VALID', testfile: 'lint-syntactically-valid',
|
|
349
|
+
example: 'x <- c(1, 2'
|
|
350
|
+
},
|
|
351
|
+
'unclosed-connection': {
|
|
352
|
+
configType: 'UnclosedConnectionConfig', ruleType: 'UNCLOSED_CONNECTION', testfile: 'lint-unclosed-connection',
|
|
353
|
+
example: 'con <- file("data.csv")\nreadLines(con)'
|
|
354
|
+
},
|
|
355
|
+
'unused-import': {
|
|
356
|
+
configType: 'UnusedImportConfig', ruleType: 'UNUSED_IMPORT', testfile: 'lint-unused-import',
|
|
357
|
+
example: 'library(stats)\nprint("no stats function is used")'
|
|
358
|
+
},
|
|
359
|
+
'unescaped-arguments': {
|
|
360
|
+
configType: 'UnescapedArgumentsConfig', ruleType: 'UNESCAPED_ARGUMENTS', testfile: 'lint-unescaped-arguments',
|
|
361
|
+
example: 'function(dir) {\n\tsystem(paste0("ls ", dir))\n}'
|
|
362
|
+
},
|
|
363
|
+
'namespace-access': {
|
|
364
|
+
configType: 'NamespaceAccessConfig', ruleType: 'NAMESPACE_ACCESS', testfile: 'lint-namespace-access',
|
|
365
|
+
example: 'dplyr:::filter(df, x > 1)'
|
|
366
|
+
},
|
|
367
|
+
'description-metadata': {
|
|
368
|
+
configType: 'DescriptionMetadataConfig', ruleType: 'DESCRIPTION_METADATA', testfile: 'cmd-check/lint-description-metadata',
|
|
369
|
+
example: { code: 'x <- 1', files: { DESCRIPTION: 'Package: pkg\nVersion: 1.0\nTitle: A Package\nLicense: GPL-3 + file LICENSE\n' } }
|
|
370
|
+
},
|
|
371
|
+
'documentation-mismatch': {
|
|
372
|
+
configType: 'DocumentationMismatchConfig', ruleType: 'DOCUMENTATION_MISMATCH', testfile: 'cmd-check/lint-documentation-mismatch',
|
|
373
|
+
example: { code: 'f <- function(x, y) x + y', files: { DESCRIPTION: ExampleDescription, 'NAMESPACE': 'export(f)\n', 'man/f.Rd': '\\name{f}\n\\alias{f}\n\\title{Add}\n\\usage{f(x)}\n\\arguments{\\item{x}{a number}}\n' } }
|
|
374
|
+
},
|
|
375
|
+
'non-ascii-code': {
|
|
376
|
+
configType: 'NonAsciiCodeConfig', ruleType: 'NON_ASCII_CODE', testfile: 'cmd-check/lint-non-ascii-code',
|
|
377
|
+
example: 'escaped <- function() message("Gr\\u00fc\\u00dfe")\nliteral <- function() message("Gr\u00fc\u00dfe")'
|
|
378
|
+
},
|
|
379
|
+
'class-string-comparison': {
|
|
380
|
+
configType: 'ClassStringComparisonConfig', ruleType: 'CLASS_STRING_COMPARISON', testfile: 'cmd-check/lint-class-string-comparison',
|
|
381
|
+
example: 'f <- function(x) if(class(x) == "data.frame") nrow(x) else length(x)'
|
|
382
|
+
},
|
|
383
|
+
'true-false-abbreviation': {
|
|
384
|
+
configType: 'TrueFalseAbbreviationConfig', ruleType: 'TRUE_FALSE_ABBREVIATION', testfile: 'cmd-check/lint-true-false-abbreviation',
|
|
385
|
+
example: 'f <- function(x) mean(x, na.rm = T)'
|
|
386
|
+
},
|
|
387
|
+
'bogus-return': {
|
|
388
|
+
configType: 'BogusReturnConfig', ruleType: 'BOGUS_RETURN', testfile: 'cmd-check/lint-bogus-return',
|
|
389
|
+
example: 'f <- function(x) {\n\tif(is.null(x)) return\n\tx + 1\n}'
|
|
390
|
+
},
|
|
391
|
+
'package-hooks': {
|
|
392
|
+
configType: 'PackageHooksConfig', ruleType: 'PACKAGE_HOOKS', testfile: 'cmd-check/lint-package-hooks',
|
|
393
|
+
example: '.onLoad <- function(libname, pkgname) {\n\tlibrary(stats)\n\tcat("Loading")\n}\n.onAttach <- function(libname, pkgname) message("Welcome!")'
|
|
394
|
+
},
|
|
395
|
+
'global-environment-modification': {
|
|
396
|
+
configType: 'GlobalEnvironmentModificationConfig', ruleType: 'GLOBAL_ENVIRONMENT_MODIFICATION', testfile: 'cmd-check/lint-global-environment-modification',
|
|
397
|
+
example: 'cache <- function(v) assign("cached", v, envir = globalenv())\ncount <- function() counter <<- counter + 1'
|
|
398
|
+
},
|
|
399
|
+
'namespace-tampering': {
|
|
400
|
+
configType: 'NamespaceTamperingConfig', ruleType: 'NAMESPACE_TAMPERING', testfile: 'cmd-check/lint-namespace-tampering',
|
|
401
|
+
example: 'patch <- function() assignInNamespace("mean", function(x, ...) 42, "base")'
|
|
402
|
+
},
|
|
403
|
+
's3-method-consistency': {
|
|
404
|
+
configType: 'S3MethodConsistencyConfig', ruleType: 'S3_METHOD_CONSISTENCY', testfile: 'cmd-check/lint-s-three-method-consistency',
|
|
405
|
+
example: 'print.myclass <- function(obj) cat("myclass")\n`size<-` <- function(x, v) { attr(x, "size") <- v; x }'
|
|
406
|
+
},
|
|
407
|
+
'foreign-function-calls': {
|
|
408
|
+
configType: 'ForeignFunctionCallsConfig', ruleType: 'FOREIGN_FUNCTION_CALLS', testfile: 'cmd-check/lint-foreign-function-calls',
|
|
409
|
+
example: 'f <- function(x) .Call("C_mean", x)'
|
|
410
|
+
},
|
|
411
|
+
'dependency-declaration': {
|
|
412
|
+
configType: 'DependencyDeclarationConfig', ruleType: 'DEPENDENCY_DECLARATION', testfile: 'cmd-check/lint-dependency-declaration',
|
|
413
|
+
example: { code: 'f <- function(df) {\n\tlibrary(dplyr)\n\ttidyr::drop_na(df)\n}', files: { DESCRIPTION: ExampleDescription } }
|
|
414
|
+
},
|
|
415
|
+
'call-arguments': {
|
|
416
|
+
configType: 'CallArgumentsConfig', ruleType: 'CALL_ARGUMENTS', testfile: 'cmd-check/lint-call-arguments',
|
|
417
|
+
example: 'scale_by <- function(x, factor) x * factor\nf <- function(x) scale_by(x, fact = 2, center = TRUE)'
|
|
418
|
+
},
|
|
419
|
+
'package-structure': {
|
|
420
|
+
configType: 'PackageStructureConfig', ruleType: 'PACKAGE_STRUCTURE', testfile: 'cmd-check/lint-package-structure',
|
|
421
|
+
example: { code: 'f <- function() 1', files: { DESCRIPTION: ExampleDescription, 'R/a:b.R': 'g <- function() 2\n' } }
|
|
422
|
+
},
|
|
423
|
+
'compiled-code': {
|
|
424
|
+
configType: 'CompiledCodeConfig', ruleType: 'COMPILED_CODE', testfile: 'cmd-check/lint-compiled-code',
|
|
425
|
+
example: { code: 'f <- function(x) .Call("C_f", x)', files: { DESCRIPTION: ExampleDescription, 'NAMESPACE': 'useDynLib(pkg)\nexport(f)\n', 'src/Makevars': 'PKG_CXXFLAGS = -O3 -Wall -fPIC\n' } }
|
|
426
|
+
},
|
|
427
|
+
'package-metafiles': {
|
|
428
|
+
configType: 'PackageMetafilesConfig', ruleType: 'PACKAGE_METAFILES', testfile: 'cmd-check/lint-package-metafiles',
|
|
429
|
+
example: { code: 'f <- function() 1', files: { DESCRIPTION: ExampleDescription, 'demo/a.R': 'f()\n', 'demo/b.R': 'f() + 1\n', 'demo/00Index': 'a A first demo\n' } }
|
|
430
|
+
},
|
|
431
|
+
'rd-files': {
|
|
432
|
+
configType: 'RdFilesConfig', ruleType: 'RD_FILES', testfile: 'cmd-check/lint-rd-files',
|
|
433
|
+
example: { code: 'f <- function(x) x', files: { DESCRIPTION: ExampleDescription, 'man/f.Rd': '\\name{f}\n\\alias{f}\n\\title{F}\n\\description{D}\n\\details{\n a \\foo{x}}\n' } }
|
|
434
|
+
},
|
|
435
|
+
'package-data': {
|
|
436
|
+
configType: 'PackageDataConfig', ruleType: 'PACKAGE_DATA', testfile: 'cmd-check/lint-package-data',
|
|
437
|
+
example: { code: 'f <- function() 1', files: { DESCRIPTION: ExampleDescription, 'data/notes.md': 'what the data means\n' } }
|
|
438
|
+
},
|
|
439
|
+
'package-runtime': {
|
|
440
|
+
configType: 'PackageRuntimeConfig', ruleType: 'PACKAGE_RUNTIME', testfile: 'cmd-check/lint-package-runtime',
|
|
441
|
+
example: { code: 'f <- function() 1', files: { DESCRIPTION: ExampleDescription, 'NAMESPACE': 'export(f)\nexport(g)\n' } }
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
/** the kinds of issue a rule finds, each rule carries at most one */
|
|
445
|
+
const RuleKinds = [
|
|
446
|
+
[linter_tags_1.LintingRuleTag.Bug, 'Bugs'],
|
|
447
|
+
[linter_tags_1.LintingRuleTag.Smell, 'Smells'],
|
|
448
|
+
[linter_tags_1.LintingRuleTag.Style, 'Style']
|
|
449
|
+
];
|
|
450
|
+
/** the tags of a rule as the wiki shows them: its kind, R CMD check, quick fixes, then the aspects by name */
|
|
451
|
+
function sortedTags(tags) {
|
|
452
|
+
const rank = (t) => RuleKinds.some(([k]) => k === t) ? 0 : t === linter_tags_1.LintingRuleTag.CmdCheck ? 1 : t === linter_tags_1.LintingRuleTag.QuickFix ? 2 : 3;
|
|
453
|
+
return tags.toSorted((a, b) => rank(a) - rank(b) || a.localeCompare(b));
|
|
454
|
+
}
|
|
455
|
+
/** one table per kind of rule, the rules without a kind check the files of a package */
|
|
456
|
+
function rulesOverview(info) {
|
|
457
|
+
const names = Object.keys(linter_rules_1.LintingRules).toSorted((a, b) => linter_rules_1.LintingRules[a].info.name.localeCompare(linter_rules_1.LintingRules[b].info.name));
|
|
458
|
+
const kindOf = (name) => RuleKinds.find(([k]) => linter_rules_1.LintingRules[name].info.tags.includes(k))?.[0];
|
|
459
|
+
const row = (name) => {
|
|
460
|
+
const rule = linter_rules_1.LintingRules[name].info;
|
|
461
|
+
const finds = rule.description.split(/\.\s+(?=[A-Z`])/)[0].replace(/^Finds /, '').replace(/\.$/, '');
|
|
462
|
+
const badges = sortedTags(rule.tags).filter(t => !RuleKinds.some(([k]) => k === t)).map(t => makeTagBadge(t, info));
|
|
463
|
+
/* the steps are text, a badge naming them grows with them and squeezes the others */
|
|
464
|
+
const step = (n) => `[${n}](${ConformancePage}#cmd-check-${n})`;
|
|
465
|
+
const steps = cmdCheckRuns(name).map(r => r.from === r.to ? step(r.from) : `${step(r.from)}–${step(r.to)}`).join(', ');
|
|
466
|
+
return `| [${rule.name}](${doc_files_1.FlowrWikiBaseRef}/${encodeURIComponent(getPageNameForLintingRule(name))}) | ${finds.replaceAll('|', '\\|')}${steps === '' ? '' : `<br><sub>R CMD check ${steps}</sub>`} | ${badges.join(' ')} |`;
|
|
467
|
+
};
|
|
468
|
+
const groups = [...RuleKinds.map(([kind, title]) => [title, names.filter(n => kindOf(n) === kind)]), ['Package Files', names.filter(n => kindOf(n) === undefined)]];
|
|
469
|
+
const anchor = (title) => `rules-${title.toLowerCase().replaceAll(' ', '-')}`;
|
|
470
|
+
const toc = groups.map(([title, rules]) => `[${title}](#${anchor(title)}) (${rules.length})`).join(', ');
|
|
471
|
+
return `${toc}\n\n` + groups
|
|
472
|
+
.map(([title, rules]) => `${(0, doc_structure_1.section)(title, 3, anchor(title))}
|
|
473
|
+
|
|
474
|
+
| Rule | Finds | Tags |
|
|
475
|
+
| :-- | :-- | :-- |
|
|
476
|
+
${rules.map(row).join('\n')}`).join('\n\n');
|
|
477
|
+
}
|
|
478
|
+
function registerRules(knownParser, tagTypes) {
|
|
479
|
+
const ruleExplanations = new Map();
|
|
480
|
+
for (const [name, { configType, ruleType, testfile, example, config }] of Object.entries(exports.LintingRuleExamples)) {
|
|
481
|
+
rule(knownParser, name, configType, ruleType, testfile, example, config, tagTypes);
|
|
482
|
+
}
|
|
483
|
+
function rule(parser, name, configType, ruleType, testfile, example, config, types) {
|
|
280
484
|
const rule = linter_rules_1.LintingRules[name];
|
|
281
|
-
const tags = rule.info.tags.
|
|
282
|
-
// sort but specials first
|
|
283
|
-
if (a === b) {
|
|
284
|
-
return 0;
|
|
285
|
-
}
|
|
286
|
-
if (SpecialTagColors[a] && SpecialTagColors[b]) {
|
|
287
|
-
return SpecialTagColors[b].localeCompare(SpecialTagColors[a]);
|
|
288
|
-
}
|
|
289
|
-
else if (SpecialTagColors[a]) {
|
|
290
|
-
return -1;
|
|
291
|
-
}
|
|
292
|
-
else if (SpecialTagColors[b]) {
|
|
293
|
-
return 1;
|
|
294
|
-
}
|
|
295
|
-
return a.localeCompare(b);
|
|
296
|
-
}).map(t => makeTagBadge(t, types)).join(' ');
|
|
485
|
+
const tags = sortedTags(rule.info.tags).map(t => t === linter_tags_1.LintingRuleTag.CmdCheck ? cmdCheckBadge(name, types) : makeTagBadge(t, types)).join(' ');
|
|
297
486
|
const certaintyDoc = (0, doc_types_1.getDocumentationForType)(`LintingRuleCertainty::${rule.info.certainty}`, types, '', { fuzzy: true }).replaceAll('\n', ' ');
|
|
298
487
|
const certaintyText = `\`${(0, html_hover_over_1.textWithTooltip)(rule.info.certainty, certaintyDoc)}\``;
|
|
299
|
-
|
|
300
|
-
ruleExplanations.set(name, () => Promise.resolve(`
|
|
301
|
-
**[${rule.info.name}](${doc_files_1.FlowrWikiBaseRef}/${encodeURIComponent(getPageNameForLintingRule(name))}):** ${rule.info.description} [see ${(0, doc_types_1.shortLinkFile)(ruleType, types)}]\\
|
|
302
|
-
${tags}
|
|
303
|
-
|
|
304
|
-
`.trim()));
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
ruleExplanations.set(name, async () => `
|
|
488
|
+
ruleExplanations.set(name, async () => `
|
|
308
489
|
|
|
309
490
|
${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'linter' })}
|
|
310
491
|
${(0, doc_structure_1.section)(rule.info.name + ` <sup>[<a href="${doc_files_1.FlowrWikiBaseRef}/Linter">overview</a>]</sup>`, 2, name)}
|
|
311
492
|
|
|
312
493
|
${tags}
|
|
313
494
|
|
|
495
|
+
${cmdCheckStepsOf(name)}
|
|
314
496
|
|
|
315
497
|
This rule is a ${certaintyText} rule.
|
|
316
498
|
|
|
@@ -323,23 +505,86 @@ _This linting rule is implemented in ${(0, doc_types_1.shortLinkFile)(ruleType,
|
|
|
323
505
|
Linting rules can be configured by passing a configuration object to the linter query as shown in the example below.
|
|
324
506
|
The \`${name}\` rule accepts the following configuration options:
|
|
325
507
|
|
|
326
|
-
${Object.keys(linter_rules_1.LintingRules[name].info.defaultConfig(documentedContext)).sort().map(key => `- ${(0, doc_types_1.shortLink)(`${configType}:::${key}`, types)}\\\n${(0, doc_types_1.getDocumentationForType)(`${configType}::${key}`, types)}`).join('\n')}
|
|
508
|
+
${Object.keys(linter_rules_1.LintingRules[name].info.defaultConfig(documentedContext)).sort().map(key => `- ${(0, doc_types_1.shortLink)(`${configType}:::${key}`, types)}\\\n${(0, doc_types_1.getDocumentationForType)(`${configType}::${key}`, types)}${cmdCheckStepsOfOption(name, key)}`).join('\n')}
|
|
327
509
|
|
|
328
510
|
### Examples
|
|
329
511
|
|
|
330
|
-
${(0, doc_code_1.codeBlock)('r', example)}
|
|
512
|
+
${typeof example === 'string' ? (0, doc_code_1.codeBlock)('r', example) : `A project with the code \`R/code.R\`:\n\n${(0, doc_code_1.codeBlock)('r', example.code)}\n\nand the files\n\n${Object.entries(example.files).map(([file, content]) => `\`${file}\`:\n\n${(0, doc_code_1.codeBlock)(file.endsWith('.R') ? 'r' : 'text', content.trimEnd())}`).join('\n\n')}`}
|
|
331
513
|
|
|
332
514
|
The linting query can be used to run this rule on the above example:
|
|
333
515
|
|
|
334
|
-
${await (
|
|
516
|
+
${await exampleQuery(parser, name, example, config)}
|
|
335
517
|
|
|
336
|
-
${buildSamplesFromLinterTestCases(parser, `${testfile}.test.ts`)}
|
|
518
|
+
${rule.info.tags.includes(linter_tags_1.LintingRuleTag.CmdCheck) ? `More examples are the test cases in ${(0, doc_files_1.linkFlowRSourceFile)(`test/functionality/linter/${testfile}.test.ts`)}.` : buildSamplesFromLinterTestCases(parser, `${testfile}.test.ts`)}
|
|
337
519
|
|
|
338
520
|
`.trim());
|
|
339
|
-
}
|
|
340
521
|
}
|
|
341
522
|
return ruleExplanations;
|
|
342
523
|
}
|
|
524
|
+
/** runs the linter query on a rule's wiki example, refusing an example that shows no finding or an error */
|
|
525
|
+
async function exampleQuery(parser, name, example, config = {}) {
|
|
526
|
+
const queries = [{ type: 'linter', rules: [{ name, config: config }] }];
|
|
527
|
+
const shown = typeof example === 'string' ? await (0, doc_query_1.showQuery)(parser, example, queries, { collapseQuery: true })
|
|
528
|
+
: await (0, doc_query_1.showQuery)(parser, `${retriever_1.fileProtocol}${ExampleRoot}/R/code.R`, queries, {
|
|
529
|
+
collapseQuery: true,
|
|
530
|
+
files: [['R/code.R', example.code], ...Object.entries(example.files)].map(([file, content]) => ({ name: `${ExampleRoot}/${file}`, content }))
|
|
531
|
+
});
|
|
532
|
+
if (shown.includes('_no findings_') || shown.includes('Error during execution of rule') || shown.includes('rules failed to execute')) {
|
|
533
|
+
throw new Error(`the wiki example of ${name} must show a finding: ${shown}`);
|
|
534
|
+
}
|
|
535
|
+
return shown;
|
|
536
|
+
}
|
|
537
|
+
const ConformanceSymbol = {
|
|
538
|
+
[conformance_1.ConformanceLevel.Full]: '🟩',
|
|
539
|
+
[conformance_1.ConformanceLevel.Static]: '🔷',
|
|
540
|
+
[conformance_1.ConformanceLevel.Partial]: '🔶'
|
|
541
|
+
};
|
|
542
|
+
/** the R CMD check steps a rule covers, consecutive steps joined into one run */
|
|
543
|
+
function cmdCheckRuns(name) {
|
|
544
|
+
const runs = [];
|
|
545
|
+
for (const e of (0, conformance_1.numberedConformance)().filter(e => e.rules.includes(name))) {
|
|
546
|
+
const last = runs.at(-1);
|
|
547
|
+
if (last !== undefined && last.to + 1 === e.number) {
|
|
548
|
+
last.to = e.number;
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
runs.push({ from: e.number, to: e.number });
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return runs;
|
|
555
|
+
}
|
|
556
|
+
/** the cmd-check badge, naming the R CMD check steps the rule covers */
|
|
557
|
+
function cmdCheckBadge(name, info) {
|
|
558
|
+
const steps = cmdCheckRuns(name).map(r => r.from === r.to ? `${r.from}` : `${r.from}–${r.to}`).join(', ');
|
|
559
|
+
return steps === '' ? makeTagBadge(linter_tags_1.LintingRuleTag.CmdCheck, info) : makeTagBadge(linter_tags_1.LintingRuleTag.CmdCheck, info, steps, `${ConformancePage}`);
|
|
560
|
+
}
|
|
561
|
+
const MoreThanCmdCheck = '⭐';
|
|
562
|
+
/** how much of a step flowR covers, starred when it reports more */
|
|
563
|
+
function cmdCheckCoverage(e) {
|
|
564
|
+
return `${ConformanceSymbol[e.level]}${e.adds === undefined ? '' : MoreThanCmdCheck}`;
|
|
565
|
+
}
|
|
566
|
+
/** what flowR adds to a step and what it leaves out */
|
|
567
|
+
function cmdCheckNote(e) {
|
|
568
|
+
return [e.adds === undefined ? undefined : `${MoreThanCmdCheck} also ${e.adds}`, e.note].filter(n => n !== undefined).join('<br>').replaceAll('|', '\\|');
|
|
569
|
+
}
|
|
570
|
+
/** an R CMD check step, linked to its code in R's `check.R` and its section in R Packages */
|
|
571
|
+
function cmdCheckStep(e) {
|
|
572
|
+
return `[${e.check.replaceAll('|', '\\|')}](${conformance_1.CmdCheckSource}#L${e.line}) ([book](${conformance_1.RPackagesCmdCheck}#${e.book}))`;
|
|
573
|
+
}
|
|
574
|
+
/** links to the R CMD check steps that `option` of rule `name` tunes */
|
|
575
|
+
function cmdCheckStepsOfOption(name, option) {
|
|
576
|
+
const steps = (0, conformance_1.numberedConformance)().filter(e => e.options?.includes(`${name}.${option}`));
|
|
577
|
+
return steps.length === 0 ? '' : `\\\n_R CMD check ${steps.map(e => `[#${e.number}](${ConformancePage}#cmd-check-${e.number} "checking ${e.check.replaceAll('"', '\'')}")`).join(', ')}_`;
|
|
578
|
+
}
|
|
579
|
+
/** the R CMD check steps a rule covers, each linked to the code of R that performs it */
|
|
580
|
+
function cmdCheckStepsOf(name) {
|
|
581
|
+
const steps = (0, conformance_1.numberedConformance)().filter(e => e.rules.includes(name));
|
|
582
|
+
return steps.length === 0 ? '' : `This rule ports the following steps of \`R CMD check\` (see the [conformance table](${ConformancePage}) for the legend):
|
|
583
|
+
|
|
584
|
+
| # | Step | Coverage | Note |
|
|
585
|
+
|---|------|:--------:|------|
|
|
586
|
+
${steps.map(e => `| [${e.number}](${ConformancePage}#cmd-check-${e.number}) | ${cmdCheckStep(e)} | ${cmdCheckCoverage(e)} | ${cmdCheckNote(e)} |`).join('\n')}`;
|
|
587
|
+
}
|
|
343
588
|
function getAllLintingRulesWithTag(tag) {
|
|
344
589
|
return Object.entries(linter_rules_1.LintingRules).filter(([_, rule]) => rule.info.tags.includes(tag)).map(([name]) => name);
|
|
345
590
|
}
|
|
@@ -350,7 +595,6 @@ function linkToRule(name) {
|
|
|
350
595
|
return `[${name}](${doc_files_1.FlowrWikiBaseRef}/${encodeURIComponent(getPageNameForLintingRule(name).replaceAll(' ', '-'))})`;
|
|
351
596
|
}
|
|
352
597
|
async function getTextMainPage(knownParser, tagTypes, ctx) {
|
|
353
|
-
const rules = registerRules(knownParser, tagTypes.info);
|
|
354
598
|
return `
|
|
355
599
|
This page describes the flowR linter, which is a tool that utilizes flowR's dataflow analysis to find common issues in R scripts. The linter can currently be used through the linter ${ctx.linkPage('wiki/Query API', 'query')}.
|
|
356
600
|
Some rules also draw on the ${ctx.linkPage('wiki/Signature Database', 'signature database')}.
|
|
@@ -377,17 +621,10 @@ ${(0, doc_structure_1.block)({
|
|
|
377
621
|
content: `If you want to add a new linting rule, see ${ctx.linkPage('wiki/Create Linting Rules')}.`
|
|
378
622
|
})}
|
|
379
623
|
|
|
380
|
-
The following linting rules are available
|
|
624
|
+
The following linting rules are available, grouped by the kind of issue they find.
|
|
625
|
+
Badges link to the [tags](#tags), steps of \`R CMD check\` to the [conformance page](${ConformancePage}).
|
|
381
626
|
|
|
382
|
-
${
|
|
383
|
-
let result = '';
|
|
384
|
-
for (const k of Object.keys(linter_rules_1.LintingRules).sort()) {
|
|
385
|
-
const rule = rules.get(k);
|
|
386
|
-
(0, assert_1.guard)(rule !== undefined, `Linting rule ${k} is not documented!`);
|
|
387
|
-
result += '\n\n' + await rule();
|
|
388
|
-
}
|
|
389
|
-
return result;
|
|
390
|
-
})()}
|
|
627
|
+
${rulesOverview(tagTypes.info)}
|
|
391
628
|
|
|
392
629
|
${(0, doc_structure_1.section)('Quick Fixes', 2, 'quick-fixes')}
|
|
393
630
|
|
|
@@ -429,10 +666,37 @@ ${(0, doc_structure_1.section)('Result Certainty', 3, 'result-certainty')}
|
|
|
429
666
|
| ---------------- | :---------- |
|
|
430
667
|
${Object.entries(linter_format_1.LintingResultCertainty).map(([name, certainty]) => `| <a id="${certainty}"></a> \`${certainty}\` | ${(0, doc_types_1.getDocumentationForType)('LintingResultCertainty::' + name, tagTypes.info).replaceAll('\n', ' ')} |`).join('\n')}
|
|
431
668
|
|
|
669
|
+
${(0, doc_structure_1.section)('R CMD check', 2, 'r-cmd-check')}
|
|
670
|
+
|
|
671
|
+
Rules tagged ${makeTagBadge(linter_tags_1.LintingRuleTag.CmdCheck, tagTypes.info)} port \`R CMD check\`, they run by default only for packages (config option \`linter.disabledTags\`).
|
|
672
|
+
The [R CMD check conformance](${ConformancePage}) page lists every step of \`R CMD check\`, the rules covering it, and how far they go.
|
|
673
|
+
|
|
432
674
|
`.trim();
|
|
433
675
|
}
|
|
676
|
+
/** the page listing every step of R CMD check and the rules covering it */
|
|
677
|
+
function getConformancePage(tagTypes) {
|
|
678
|
+
return `${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'linter' })}
|
|
679
|
+
|
|
680
|
+
Rules tagged ${makeTagBadge(linter_tags_1.LintingRuleTag.CmdCheck, tagTypes.info)} port \`R CMD check\` (R 4.6.1, see [Writing R Extensions](${conformance_1.WritingRExtensionsCmdCheck}) and [R Packages](${conformance_1.RPackagesCmdCheck})).
|
|
681
|
+
They run by default only for packages (config option \`linter.disabledTags\`), see the [linter](${doc_files_1.FlowrWikiBaseRef}/Linter) for all rules.
|
|
682
|
+
Below are all steps of \`R CMD check\`, numbered by us (R itself prints them as \`* checking ...\`), each linked to its code in [R's \`check.R\`](${conformance_1.CmdCheckSource}) and its section in R Packages.
|
|
683
|
+
|
|
684
|
+
| | Coverage |
|
|
685
|
+
| :-: | :-- |
|
|
686
|
+
| ${ConformanceSymbol.full} | everything the step reports |
|
|
687
|
+
| ${ConformanceSymbol.static} | what can be decided without building, installing, or running the package |
|
|
688
|
+
| ${ConformanceSymbol.partial} | part of what the step reports |
|
|
689
|
+
| ${MoreThanCmdCheck} | flowR reports more than the step, the note says what |
|
|
690
|
+
|
|
691
|
+
${conformance_1.CmdCheckConformance.map(({ area }) => `${(0, doc_structure_1.section)(area, 3)}
|
|
692
|
+
|
|
693
|
+
| # | Step (\`checking ...\`) | | Rules | Note |
|
|
694
|
+
| --: | :-- | :-: | :-- | :-- |
|
|
695
|
+
${(0, conformance_1.numberedConformance)().filter(e => e.area === area).map(e => `| <a id="cmd-check-${e.number}"></a>${e.number} | ${cmdCheckStep(e)} | ${cmdCheckCoverage(e)} | ${e.rules.map(r => linkToRule(r)).join(', ')} | ${cmdCheckNote(e)} |`).join('\n')}`).join('\n\n')}
|
|
696
|
+
`;
|
|
697
|
+
}
|
|
434
698
|
async function getRulesPages(knownParser, tagTypes) {
|
|
435
|
-
const rules = registerRules(knownParser, tagTypes.info
|
|
699
|
+
const rules = registerRules(knownParser, tagTypes.info);
|
|
436
700
|
const result = {};
|
|
437
701
|
for (const [name, rule] of rules) {
|
|
438
702
|
const filepath = path_1.default.join('wiki', `${getPageNameForLintingRule(name)}.md`);
|
|
@@ -448,7 +712,8 @@ async function getTexts(parser, ctx) {
|
|
|
448
712
|
});
|
|
449
713
|
return {
|
|
450
714
|
'main': await getTextMainPage(parser, tagTypes, ctx),
|
|
451
|
-
...await getRulesPages(parser, tagTypes)
|
|
715
|
+
...await getRulesPages(parser, tagTypes),
|
|
716
|
+
[path_1.default.join('wiki', `${ConformancePageName}.md`)]: getConformancePage(tagTypes)
|
|
452
717
|
};
|
|
453
718
|
}
|
|
454
719
|
/**
|
|
@@ -33,8 +33,7 @@ const UrlEncodedHomePath = /(?:[a-z]%3A)?(%2F|%5C)(?:home|users)\1(?:[\w.%-]+\1)
|
|
|
33
33
|
const DefaultReplacementPatterns = [
|
|
34
34
|
// mute signature database load time variance in wiki table (before the `ms` rule, which would eat half of it)
|
|
35
35
|
[/≈\s*<?[\d.]+\s*[µm]s/g, ''],
|
|
36
|
-
|
|
37
|
-
[/\d+(\.\d+)?( |\s*)?ms/g, ''],
|
|
36
|
+
[/\d+(\.\d+)?(\u2009|\s*)?ms/g, ''],
|
|
38
37
|
[/tmp[%A-Za-z0-9-]+/g, ''],
|
|
39
38
|
[/"?(timing|searchTimeMs|processTimeMs|id|tsId)"?:\s*\d+(\.\d)?,?/g, ''],
|
|
40
39
|
[/"format":"compact"[^\n\r]*/giu, ''],
|
|
@@ -546,6 +546,13 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({ inputSources: {
|
|
|
546
546
|
shortDescription: 'Returns all direct dependencies (in- and outputs) of a given R script',
|
|
547
547
|
buildExplanation: async (shell, ctx) => {
|
|
548
548
|
const exampleCode = 'library(x)';
|
|
549
|
+
const transformCode = `
|
|
550
|
+
library(dplyr)
|
|
551
|
+
library(ggplot2)
|
|
552
|
+
small <- measurements |> filter(x > 1) |> select(x, y)
|
|
553
|
+
p <- ggplot(small, aes(x, y)) + geom_point() + ggtitle("Small")
|
|
554
|
+
ggsave("small.png", plot = p)
|
|
555
|
+
`;
|
|
549
556
|
const longerCode = `
|
|
550
557
|
source("sample.R")
|
|
551
558
|
foo <- loadNamespace("bar")
|
|
@@ -592,6 +599,24 @@ ${await (0, doc_query_1.showQuery)(shell, 'sd(c(1, 2, 3))', [{ type: 'dependenci
|
|
|
592
599
|
convention and \`R_DEFAULT_PACKAGES\` (or \`options(defaultPackages=)\`) can drop any of them, whereas \`base\` is always
|
|
593
600
|
there and cannot be detached -- so it is never something the script could have asked for, and never something to
|
|
594
601
|
suggest a \`library\` call for.
|
|
602
|
+
|
|
603
|
+
Beyond libraries, files and outputs, the query knows the \`visualize\` category (plots) and the \`transform\` category
|
|
604
|
+
(\`Data Transformations\`): the calls that reshape, filter, join or aggregate data, like \`dplyr::filter\`, \`tidyr::pivot_longer\`,
|
|
605
|
+
\`merge\`, \`aggregate\` or \`data.table::setDT\`. The category is read from the built-in configuration: every built-in labeled
|
|
606
|
+
\`SemanticCallTag.Transforms\` belongs to it. Every such built-in names its package, so \`filter\` is only a transformation when it
|
|
607
|
+
resolves to \`dplyr\` and never for the time-series \`stats::filter\`.
|
|
608
|
+
|
|
609
|
+
The \`read\`, \`write\`, \`visualize\`, and \`transform\` entries additionally state how data flows through the call,
|
|
610
|
+
resolved with the ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graph')} instead of the syntax:
|
|
611
|
+
* \`inputVariables\` (for \`write\`, \`visualize\`, and \`transform\`) are the variables the result is computed from, through every call
|
|
612
|
+
in between. What an argument's role in the signature excludes (a file, a flag, a callee) is no input, nor is what a call quotes or
|
|
613
|
+
looks up in a data mask: \`df\` for \`df |> filter(x > 1)\`, both \`a\` and \`b\` for \`left_join(a, b)\`. An addon to a plot draws its data.
|
|
614
|
+
* \`assignedTo\` (for \`read\`, \`visualize\`, and \`transform\`) is the variable the result is stored in, following every call that hands
|
|
615
|
+
it on (a pipe into a call, parentheses, a \`+\` adding to a plot) up to \`<-\`, \`=\` or \`->\`: \`small\` for \`small <- filter(df, x > 1)\`, and
|
|
616
|
+
nothing for \`f(filter(df, x > 1))\`.
|
|
617
|
+
* Every plot additionally carries its \`title\` (from \`ggtitle\`, \`labs(title = )\` or \`main =\`) and the file it is written to as \`savedTo\`
|
|
618
|
+
(by \`ggsave\`, which names its \`plot\` or saves \`last_plot()\`, or by the graphics device open when it is drawn).
|
|
619
|
+
${await (0, doc_query_1.showQuery)(shell, transformCode, [{ type: 'dependencies', enabledCategories: ['transform', 'visualize'] }], { showCode: true, collapseQuery: true, collapseResult: false, ctx })}
|
|
595
620
|
`;
|
|
596
621
|
}
|
|
597
622
|
});
|
|
@@ -7,6 +7,7 @@ const vertex_1 = require("../dataflow/graph/vertex");
|
|
|
7
7
|
const flowr_search_executor_1 = require("../search/flowr-search-executor");
|
|
8
8
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
9
9
|
const flowr_search_1 = require("../search/flowr-search");
|
|
10
|
+
const strings_1 = require("../util/text/strings");
|
|
10
11
|
/**
|
|
11
12
|
* https://github.com/flowr-analysis/flowr/wiki/Search-API
|
|
12
13
|
*/
|
|
@@ -50,7 +51,7 @@ also allow you to pass in a regex to only match files that fit your specified pa
|
|
|
50
51
|
|
|
51
52
|
We offer the following generators:
|
|
52
53
|
|
|
53
|
-
${Object.keys(flowr_search_builder_1.Q).filter(n => n !== 'name').sort(
|
|
54
|
+
${Object.keys(flowr_search_builder_1.Q).filter(n => n !== 'name').sort(strings_1.compareByCodeUnit).map(key => `- ${ctx.linkO(flowr_search_builder_1.FlowrSearchGenerator, key)}\\\n${ctx.docO(flowr_search_builder_1.FlowrSearchGenerator, key)}`).join('\n')}
|
|
54
55
|
|
|
55
56
|
Likewise, we have a palette of _transformers_ and _modifiers_:
|
|
56
57
|
|
|
@@ -10,8 +10,6 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
11
11
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
12
12
|
const reader_1 = require("../project/sigdb/reader");
|
|
13
|
-
// FnProp is a const enum referenced only via `typeof` (for linkE's member typing); a type-only import would break `typeof`
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
15
13
|
const schema_1 = require("../project/sigdb/schema");
|
|
16
14
|
const manifest_1 = require("../project/sigdb/manifest");
|
|
17
15
|
const codec_1 = require("../project/sigdb/codec");
|