-
Notifications
You must be signed in to change notification settings - Fork 7
deprecated functions
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]
Marks deprecated functions that should not be used anymore.
This linting rule is implemented in src/linter/rules/deprecated-functions.ts.
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:
-
deprecatedFunctions
The list of function names that should be marked as deprecated.
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
}
}
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)
Here, we expect no deprecated functions to be found, as neither
cat
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.
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.
Overwriting the
cat
function with a user defined implementation (even though it is useless), should cause the linter to not mark calls to the customcat
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.
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.
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.
Currently maintained by Florian Sihler at Ulm University
Email | GitHub | Penguins | Portfolio