Skip to content
github-actions[bot] edited this page Jul 14, 2025 · 1 revision

This document was generated from 'src/documentation/print-linter-wiki.ts' on 2025-07-14, 16:41:23 UTC presenting an overview of flowR's linter (v2.2.16, using R v4.5.0). 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. For example:

$ docker run -it --rm eagleoutice/flowr # or npm run flowr 
flowR repl using flowR v2.2.16, R v4.5.0 (r-shell engine)
R> :query @linter "read.csv(\"/root/x.txt\")"
Output
Query: [;1mlinter[0m (2 ms)
   ╰ **Deprecated Functions** (deprecated-functions):
       ╰ _Metadata_: <code>{"totalDeprecatedCalls":0,"totalDeprecatedFunctionDefinitions":0,"searchTimeMs":0,"processTimeMs":0}</code>
   ╰ **File Path Validity** (file-path-validity):
       ╰ definitely:
           ╰ Path `/root/x.txt` at 1.1-23
       ╰ _Metadata_: <code>{"totalReads":1,"totalUnknown":0,"totalWritesBeforeAlways":0,"totalValid":0,"searchTimeMs":1,"processTimeMs":0}</code>
   ╰ **Seeded Randomness** (seeded-randomness):
       ╰ _Metadata_: <code>{"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":0,"processTimeMs":0}</code>
   ╰ **Absolute Paths** (absolute-file-paths):
       ╰ definitely:
           ╰ Path `/root/x.txt` at 1.1-23
       ╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":1,"processTimeMs":0}</code>
   ╰ **Unused Definitions** (unused-definitions):
       ╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":0,"processTimeMs":0}</code>
   ╰ **Naming Convention** (naming-convention):
       ╰ _Metadata_: <code>{"numMatches":0,"numBreak":0,"searchTimeMs":0,"processTimeMs":0}</code>
[;3mAll queries together required ≈2 ms (1ms accuracy, total 7 ms)[0m[0m

The linter will analyze the code and return any issues found. Formatted more nicely, this returns:

[ { "type": "linter" } ]

Results (prettified and summarized):

Query: linter (9 ms)
   ╰ Deprecated Functions (deprecated-functions):
       ╰ Metadata: {"totalDeprecatedCalls":0,"totalDeprecatedFunctionDefinitions":0,"searchTimeMs":2,"processTimeMs":0}
   ╰ File Path Validity (file-path-validity):
       ╰ definitely:
           ╰ Path /root/x.txt at 1.1-23
       ╰ Metadata: {"totalReads":1,"totalUnknown":0,"totalWritesBeforeAlways":0,"totalValid":0,"searchTimeMs":4,"processTimeMs":0}
   ╰ Seeded Randomness (seeded-randomness):
       ╰ Metadata: {"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":1,"processTimeMs":0}
   ╰ Absolute Paths (absolute-file-paths):
       ╰ definitely:
           ╰ Path /root/x.txt at 1.1-23
       ╰ Metadata: {"totalConsidered":1,"totalUnknown":0,"searchTimeMs":1,"processTimeMs":1}
   ╰ Unused Definitions (unused-definitions):
       ╰ Metadata: {"totalConsidered":0,"searchTimeMs":0,"processTimeMs":0}
   ╰ Naming Convention (naming-convention):
       ╰ Metadata: {"numMatches":0,"numBreak":0,"searchTimeMs":0,"processTimeMs":0}
All queries together required ≈9 ms (1ms accuracy, total 19 ms)

Show Detailed Results as Json

The analysis required 19.1 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": {
          "totalDeprecatedCalls": 0,
          "totalDeprecatedFunctionDefinitions": 0,
          "searchTimeMs": 2,
          "processTimeMs": 0
        }
      },
      "file-path-validity": {
        "results": [
          {
            "range": [
              1,
              1,
              1,
              23
            ],
            "filePath": "/root/x.txt",
            "certainty": "definitely"
          }
        ],
        ".meta": {
          "totalReads": 1,
          "totalUnknown": 0,
          "totalWritesBeforeAlways": 0,
          "totalValid": 0,
          "searchTimeMs": 4,
          "processTimeMs": 0
        }
      },
      "seeded-randomness": {
        "results": [],
        ".meta": {
          "consumerCalls": 0,
          "callsWithFunctionProducers": 0,
          "callsWithAssignmentProducers": 0,
          "callsWithNonConstantProducers": 0,
          "searchTimeMs": 1,
          "processTimeMs": 0
        }
      },
      "absolute-file-paths": {
        "results": [
          {
            "certainty": "definitely",
            "filePath": "/root/x.txt",
            "range": [
              1,
              1,
              1,
              23
            ]
          }
        ],
        ".meta": {
          "totalConsidered": 1,
          "totalUnknown": 0,
          "searchTimeMs": 1,
          "processTimeMs": 1
        }
      },
      "unused-definitions": {
        "results": [],
        ".meta": {
          "totalConsidered": 0,
          "searchTimeMs": 0,
          "processTimeMs": 0
        }
      },
      "naming-convention": {
        "results": [],
        ".meta": {
          "numMatches": 0,
          "numBreak": 0,
          "searchTimeMs": 0,
          "processTimeMs": 0
        }
      }
    },
    ".meta": {
      "timing": 9
    }
  },
  ".meta": {
    "timing": 9
  }
}

Linting Rules

The following linting rules are available:

Absolute Paths: Checks whether file paths are absolute. [see src/linter/rules/absolute-path.ts]
smell quickfix reproducibility robustness

Deprecated Functions: Marks deprecated functions that should not be used anymore. [see src/linter/rules/deprecated-functions.ts]
smell deprecated reproducibility usability

File Path Validity: Checks whether file paths used in read and write operations are valid and point to existing files. [see src/linter/rules/file-path-validity.ts]
bug reproducibility robustness

Naming Convention: Checks wether the symbols conform to a certain naming convention [see src/linter/rules/naming-convention.ts]
quickfix style

Seeded Randomness: Checks whether randomness-based function calls are 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. [see src/linter/rules/seeded-randomness.ts]
reproducibility robustness

Unused Definitions: Checks for unused definitions. [see src/linter/rules/unused-definition.ts]
smell quickfix readability

Tags

We use tags to categorize linting rules. The following tags are available:

Tag/Badge   Description
bug This rule is used to detect bugs in the code. Everything that affects the semantics of the code, such as incorrect function calls, wrong arguments, etc. is to be considered a bug. Otherwise, it may be a smell or a style issue. (rule: file-path-validity)
deprecated This signals the use of deprecated functions or features. (rule: deprecated-functions)
documentation This rule is used to detect issues that are related to the documentation of the code. For example, missing or misleading comments. (rules: none)
experimental This marks rules which are currently considered experimental, not that they detect experimental code. (rules: none)
performance This rule is used to detect issues that are related to the performance of the code. For example, inefficient algorithms, unnecessary computations, or unoptimized data structures. (rules: none)
robustness This rule is used to detect issues that are related to the portability of the code. For example, platform-specific code, or code that relies on specific R versions or packages. (rules: file-path-validity, seeded-randomness, and absolute-file-paths)
rver3 The rule is specific to R version 3.x. (rules: none)
rver4 The rule is specific to R version 4.x. (rules: none)
readability This rule is used to detect issues that are related to the readability of the code. For example, complex expressions, long lines, or inconsistent formatting. (rule: unused-definitions)
reproducibility This rule is used to detect issues that are related to the reproducibility of the code. For example, missing or incorrect random seeds, or missing data. (rules: deprecated-functions, file-path-validity, seeded-randomness, and absolute-file-paths)
security This rule is used to detect security-critical. For example, missing input validation. (rules: none)
shiny This rule is used to detect issues that are related to the shiny framework. (rules: none)
smell This rule is used to detect issues that do not directly affect the semantics of the code, but are still considered bad practice. (rules: deprecated-functions, absolute-file-paths, and unused-definitions)
style This rule is used to detect issues that are related to the style of the code. For example, inconsistent naming conventions, or missing or incorrect formatting. (rule: naming-convention)
usability This rule is used to detect issues that are related to the (re-)usability of the code. For example, missing or incorrect error handling, or missing or incorrect user interface elements. (rule: deprecated-functions)
quickfix This rule may provide quickfixes to automatically fix the issues it detects. (rules: absolute-file-paths, unused-definitions, and naming-convention)
Clone this wiki locally