Skip to content

lint network functions

github-actions[bot] edited this page Sep 29, 2025 · 1 revision

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

Network Functions [overview]

smell security performance reproducibility

This rule is a best-effort rule.

Marks network functions that execute network operations, such as downloading files or making HTTP requests.
This linting rule is implemented in src/linter/rules/network-functions.ts.

Configuration

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

  • fns
    The list of function names that should be marked in the given context if their arguments match.
  • onlyTriggerWithArgument
    only trigger if the function's read argument is linked to a value that matches this pattern

Examples

read.csv("https://example.com/data.csv")
download.file("https://foo.bar")

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

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

Results (prettified and summarized):

Query: linter (3 ms)
   ╰ Network Functions (network-functions):
       ╰ certain:
           ╰ Function read.csv at 2.1-40
           ╰ Function download.file at 3.1-32
       ╰ Metadata: {"totalCalls":2,"totalFunctionDefinitions":2,"searchTimeMs":3,"processTimeMs":0}
All queries together required ≈3 ms (1ms accuracy, total 4 ms)

Show Detailed Results as Json

The analysis required 3.5 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": {
      "network-functions": {
        "results": [
          {
            "certainty": "certain",
            "function": "read.csv",
            "range": [
              2,
              1,
              2,
              40
            ]
          },
          {
            "certainty": "certain",
            "function": "download.file",
            "range": [
              3,
              1,
              3,
              32
            ]
          }
        ],
        ".meta": {
          "totalCalls": 2,
          "totalFunctionDefinitions": 2,
          "searchTimeMs": 3,
          "processTimeMs": 0
        }
      }
    },
    ".meta": {
      "timing": 3
    }
  },
  ".meta": {
    "timing": 3
  }
}

Additional Examples

These examples are synthesized from the test cases in: test/functionality/linter/lint-network-functions.test.ts

Test Case: network function nested

Testing the nested use the 'url' function in other function calls

Given the following input:

foo(url("http://example.com"))

And using the following configuration:

{ fns: ['url'] }

We expect the linter to report the following:

certainty: LintingResultCertainty.Certain, function: 'url', range: [1,5,1,29]

See here for the test-case implementation.

Test Case: `network funcion with multiple arguments: ${prefix}`

Given the following input:

`download.file("${prefix}foo.org/bar.csv", "local.csv")`

And using the following configuration:

{ fns: ['download.file'] }

We expect the linter to report the following:

certainty: LintingResultCertainty.Certain, function: 'download.file', range: [1,1,1,prefix.length+45]

See here for the test-case implementation.

Test Case: namespace call

Given the following input:

httr::GET("http://example.com")

And using the following configuration:

{ fns: ['GET'] }

We expect the linter to report the following:

certainty: LintingResultCertainty.Certain, function: 'httr::GET', range: [1,1,1,31]

See here for the test-case implementation.

Test Case: do not trigger without url prefix

Given the following input:

read.csv("www.example.com")

And using the following configuration:

{ fns: ['read.csv'] }

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: do not trigger with multiple arguments

Given the following input:

download.file("data/local.csv", "local.csv")

And using the following configuration:

{ fns: ['read.csv'] }

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: not in list test

Given the following input:

file("data/local.csv")

And using the following configuration:

{ fns: NETWORK_FUNCTIONS.info.defaultConfig.fns }

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: nor in list but prefix in string

Given the following input:

print("http://example.com")

And using the following configuration:

{ fns: NETWORK_FUNCTIONS.info.defaultConfig.fns }

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: Named argument

Given the following input:

read.csv(file = "http://example.com/data.csv")

And using the following configuration:

{ fns: ['read.csv'] }

We expect the linter to report the following:

certainty: LintingResultCertainty.Certain, function: 'read.csv', range: [1,1,1,46]

See here for the test-case implementation.

Test Case: Resolve value

Given the following input:

url <- "http://example.com/data.csv"; read.csv(url)

And using the following configuration:

{ fns: ['read.csv'] }

We expect the linter to report the following:

certainty: LintingResultCertainty.Certain, function: 'read.csv', range: [1,39,1,51]

See here for the test-case implementation.

Clone this wiki locally