Strictness Levels
Infr supports three strictness levels that control how aggressively it checks your code. This lets you start permissive and increase strictness as your codebase matures.
Levels
| Level | Bare <- behavior | Nullable access without null check | Notes |
|---|---|---|---|
relaxed (default) | Treated as mutable, no warnings | No diagnostic | Maximum compatibility with existing R |
moderate | Treated as mutable, warns "consider const or let" | Warning | Nudges toward explicit intent |
strict | Error: must use const or let | Error | Full explicitness required |
Configuration
Set the strictness level in infr.toml:
infr.toml
[check]
strictness = "moderate"
Examples
Bare <- assignment
x <- 10
- relaxed: No diagnostic
- moderate:
Warning [infr]: Consider using const or let for explicit intent - strict:
Error [infr]: Must use const or let (strict mode)
Nullable access
const val: numeric? <- maybe_get()
val + 1
- relaxed: No diagnostic
- moderate:
Warning [infr]: val is numeric? (nullable). Consider checking for NULL first. - strict:
Error [infr]: Cannot pass numeric? to + which expects numeric. Check for NULL first.
Recommended progression
- Start with
relaxed— check your existing R code without changes - Move to
moderate— get warnings that guide you toward const/let and null checks - Adopt
strict— enforce full explicitness in mature codebases