Linter - flowr-analysis/flowr GitHub Wiki
This document was generated from 'src/documentation/print-linter-wiki.ts' on 2025-06-02, 21:03:49 UTC presenting an overview of flowR's linter (v2.2.14, using R v4.4.3). Please do not edit this file/wiki page directly.
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 query.
The following linting rules are available:
This rule detects the usage of deprecated functions in code based on a predefined list of known deprecated functions.
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 (2 ms)
╰ deprecated-functions:
╰ Metadata: {"totalRelevant":9,"totalNotDeprecated":9,"searchTimeMs":0,"processTimeMs":1}
All queries together required ≈2 ms (1ms accuracy, total 25 ms)
Show Detailed Results as Json
The analysis required 25.4 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": [],
".meta": {
"totalRelevant": 9,
"totalNotDeprecated": 9,
"searchTimeMs": 0,
"processTimeMs": 1
}
}
},
".meta": {
"timing": 2
}
},
".meta": {
"timing": 2
}
}
This rule finds places in the code where files are being read from. In such places, it checks whether the file path is valid and whether the file exists on disk.
Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The file-path-validity
rule accepts the following configuration options:
-
additionalReadFunctions
The set of functions that should additionally be considered as reading a file path. Entries in this array use theFunctionInfo
format from the dependencies query. -
additionalWriteFunctions
The set of functions that should additionally be considered as writing to a file path. Entries in this array use theFunctionInfo
format from the dependencies query. -
includeUnknown
Whether unknown file paths should be included as linting results.
my_data <- read.csv("C:/Users/me/Documents/My R Scripts/Reproducible.csv")
The linting query can be used to run this rule on the above example:
[ { "type": "linter", "rules": [ { "name": "file-path-validity", "config": {} } ] } ]
Results (prettified and summarized):
Query: linter (9 ms)
╰ file-path-validity:
╰ definitely:
╰ Path C:/Users/me/Documents/My R Scripts/Reproducible.csv
at 2.12-74
╰ Metadata: {"totalReads":1,"totalUnknown":0,"totalWritesBeforeAlways":0,"totalValid":0,"searchTimeMs":8,"processTimeMs":1}
All queries together required ≈9 ms (1ms accuracy, total 14 ms)
Show Detailed Results as Json
The analysis required 13.7 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": {
"file-path-validity": {
"results": [
{
"range": [
2,
12,
2,
74
],
"filePath": "C:/Users/me/Documents/My R Scripts/Reproducible.csv",
"certainty": "definitely"
}
],
".meta": {
"totalReads": 1,
"totalUnknown": 0,
"totalWritesBeforeAlways": 0,
"totalValid": 0,
"searchTimeMs": 8,
"processTimeMs": 1
}
}
},
".meta": {
"timing": 9
}
},
".meta": {
"timing": 9
}
}