Definition
Static analysis is the automated examination of source code without executing it. Tools analyse the code text, data flow, control flow, and type information to identify defects, violations, and quality issues -- at compile time or in a dedicated analysis phase.
Static analysis finds defect classes that testing misses:
- Code paths that are never exercised by any test case
- Runtime errors that only occur under specific timing conditions
- Undefined behaviour in C (integer overflow, pointer arithmetic) that compilers may exploit
- Data flow defects (uninitialised variables, resource leaks) across function boundaries