Repository navigation
[Linting Rule] Global Environment Modification
Generated from 'wiki-linter.ts' on 2026-10-25, 09:29:25 UTC (v2.16.6), do not edit directly.
Global Environment Modification [overview]
This rule ports the following steps of R CMD check (see the conformance table for the legend):
| # | Step | Coverage | Note |
|---|---|---|---|
| 37 | R code for possible problems (book) | 🟩⭐ | ⭐ also quick fixes, deprecated arguments, environments resolved through variables, hooks followed into callees |
This rule is a best-effort rule.
Finds code that changes the global environment: assign() or data() into it, attach(), <<- without a binding in an enclosing function, and <<- to a package variable, whose binding is locked at run time.
This linting rule is implemented in src/linter/rules/cmd-check/global-environment-modification.ts.
Linting rules can be configured by passing a configuration object to the linter query as shown in the example below.
The global-environment-modification rule accepts the following configuration options:
-
allowedGlobals
variables that may be assigned in the global environment (default.Random.seed, asR CMD checkallows)
R CMD check #37 -
checkSuperAssignments
report<<-assignments that reach the global environment or a locked namespace binding (defaulttrue)
R CMD check #37
cache <- function(v) assign("cached", v, envir = globalenv())
count <- function() counter <<- counter + 1The linting query can be used to run this rule on the above example:
[ { "type": "linter", "rules": [ { "name": "global-environment-modification", "config": {} } ] } ]Results (prettified and summarized):
Query: linter (3 ms)
╰ Global Environment Modification (global-environment-modification):
╰ certain:
╰ assign of cached at 1.22-61
╰ global-superassignment of counter at 2.21-43
More examples are the test cases in test/functionality/linter/cmd-check/lint-global-environment-modification.test.ts.
Currently maintained by Florian Sihler and Oliver Gerstl at Ulm University
Email | GitHub | Penguins | Portfolio
- 🧑💻 Developer Onboarding
- 💻 Setup
- 👓 Overview
- 🪟 Interfacing with flowR
- 🌋 Core
- 🧹 Testing & Linting (Benchmark Page)
⁉️ FAQ- ℹ️ Extra Information