Docs Menu

Linting & Static Analysis

Ion brings Rust-like memory safety analysis to C++ without compromising speed.

Running a Check

To analyze the current project, simply run:

bash
ion check

Flags supported by the linter include:

  • --fix: Automatically apply suggestions where the linter is confident.
  • --watch: Rerun the linter automatically when files change.
  • --list-rules: Display all active rules.
  • --rule <id>: Only run a specific rule check.

Output Formats

Ion can output diagnostic data in machine-readable formats for CI pipelines or editor integration.

bash
ion check --format json
ion check --format sarif > out.sarif

Engines

Ion uses two engines for linting: a fast AST-based tree-sitter pass for stylistic rules, and a deeper libclang pass for type-aware memory flow analysis if libclang is available on your system.

Rule Catalogue

Rule IDAuto-fixDescription
memory/leakDetects allocated heap memory not freed on all paths
memory/use-after-freeDetects use of pointer after free() or delete
memory/double-freeDetects freeing the same pointer twice
modern/nullptrReplace NULL/0 with nullptr
modern/c-castReplace C-style cast with static_cast where safe
memory/smart-getDetects raw-pointer use via .get() on smart pointer
memory/raw-from-smartDetects passing unique_ptr::get() to owning functions
memory/move-after-useDetects use of moved-from object
memory/shared-cycle-hintHints at potential shared_ptr reference cycles