Skip to content

deprecated functions

github-actions[bot] edited this page Jun 23, 2025 · 1 revision

This document was generated from 'src/documentation/print-linter-wiki.ts' on 2025-06-23, 15:29:23 UTC presenting an overview of flowR's linter (v2.2.15, using R v4.5.0). Please do not edit this file/wiki page directly.

Deprecated Functions [overview]

smell deprecated reproducibility usability

Marks deprecated functions that should not be used anymore.
This linting rule is implemented in src/linter/rules/deprecated-functions.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The deprecated-functions rule accepts the following configuration options:

Examples

first <- data.frame(x = c(1, 2, 3), y = c(1, 2, 3))
second <- data.frame(x = c(1, 3, 2), y = c(1, 3, 2))
dplyr::all_equal(first, second)

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "deprecated-functions",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (0 ms)
   ╰ deprecated-functions:
       ╰ definitely:
           ╰ Function dplyr::all_equal at 4.1-31
       ╰ Metadata: {"totalRelevant":9,"totalNotDeprecated":8,"searchTimeMs":0,"processTimeMs":0}
All queries together required ≈0 ms (1ms accuracy, total 10 ms)

Show Detailed Results as Json

The analysis required 9.9 ms (including parsing and normalization and the query) within the generation environment.

In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.

{
  "linter": {
    "results": {
      "deprecated-functions": {
        "results": [
          {
            "certainty": "definitely",
            "function": "dplyr::all_equal",
            "range": [
              4,
              1,
              4,
              31
            ]
          }
        ],
        ".meta": {
          "totalRelevant": 9,
          "totalNotDeprecated": 8,
          "searchTimeMs": 0,
          "processTimeMs": 0
        }
      }
    },
    ".meta": {
      "timing": 0
    }
  },
  ".meta": {
    "timing": 0
  }
}

Additional Examples

These examples are synthesized from the test cases in: [lint-deprecated-functions.test.ts](https://github.com/flowr-analysis/flowr/tree/main//lint-deprecated-functions.test.ts)

Test Case: no function listed

Here, we expect no deprecated functions to be found, as neither cat nor print nor <- are listed as deprecated, we specifically clean the list of deprecated functions

Given the following input:

cat("hello")
print("hello")
x <- 1
cat(x)

And using the following configuration:

{ deprecatedFunctions: [] }

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: cat

Given that we declare cat as deprecated, we expect all uses to be marked!

Given the following input:

cat("hello")
print("hello")
x <- 1
cat(x)

And using the following configuration:

{ deprecatedFunctions: ['cat'] }

We expect the linter to report the following:

certainty: LintingCertainty.Definitely, function: 'cat', range: [1, 1, 1, 12] },
{ certainty: LintingCertainty.Definitely, function: 'cat', range: [4, 1, 4, 6] },

See here for the test-case implementation.

Test Case: custom cat

Overwriting the cat function with a user defined implementation (even though it is useless), should cause the linter to not mark calls to the custom cat function as deprecated

Given the following input:

cat("hello")
print("hello")
cat <- function(x) { }
x <- 1
cat(x)

And using the following configuration:

{ deprecatedFunctions: ['cat'] }

We expect the linter to report the following:

certainty: LintingCertainty.Definitely, function: 'cat', range: [1, 1, 1, 12]

See here for the test-case implementation.

Test Case: with defaults

Using the default linter configuration, a function such as all_equal should be marked as deprecated

Given the following input:

all_equal(foo)

We expect the linter to report the following:

certainty: LintingCertainty.Definitely, function: 'all_equal', range: [1, 1, 1, 14]

See here for the test-case implementation.

Test Case: with defaults nested

We should find deprecated functions even if they are nested in other function calls

Given the following input:

foo(all_equal(foo))

We expect the linter to report the following:

certainty: LintingCertainty.Definitely, function: 'all_equal', range: [1, 5, 1, 18]

See here for the test-case implementation.

Clone this wiki locally