# Static Analysis

> Checking code for mistakes just by reading it. It is never run.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** Static Code Analysis, Static Checking, SAST

## Think of it like

Think of it like a spell checker. It reads your writing and marks mistakes before anyone sees them.

## Definition

Static analysis is checking code for problems without running it. A tool reads the code and looks for mistakes and risky habits. Linters like ESLint do this. So do type checkers, like the one in TypeScript. Some tools look for safety holes, like passwords left in code. It finds many bugs in seconds, before any test runs.

## Example

Jack saves a file, and the type checker flags line 2 at once. He has put the text ten into a variable meant for numbers.

## Example code

```console
$ npx tsc --noEmit price.ts
price.ts(2,1): error TS2322: Type 'string' is not assignable to type 'number'.
```

The checker read the file, never ran it, and found the bug.

## Why it matters

It is the cheapest check there is. It runs on every save and finds whole kinds of bug for free.

## Common mistake

Turning off every warning that gets in the way. Fix them, or switch off just that rule, with a reason written down.

## Three principles

- **Reads, never runs.** Checks the source.
- **Linters and type checkers.** The common kinds.
- **Before any test.** Seconds, on every save.

## Related terms

- [Linter](https://learn.benibix.com/term/development/linter)
- [Type System](https://learn.benibix.com/term/development/type-system)
- [Code Smell](https://learn.benibix.com/term/development/code-smell)
- [Software Testing](https://learn.benibix.com/term/development/software-testing)
- [Data Flow Analysis](https://learn.benibix.com/term/development/data-flow-analysis)
- [Code Intelligence](https://learn.benibix.com/term/development/code-intelligence)

---

Source: https://learn.benibix.com/term/development/static-analysis
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
