Static vs Dynamic Analysis
| Aspect | Static Analysis | Dynamic Analysis (Tests) |
|---|---|---|
| When it runs | Before/without execution | During execution |
| What it sees | All code paths | Only executed paths |
| Speed | Fast (no runtime) | Slower (needs execution) |
| Coverage | Complete source | Depends on test coverage |
| False positives | Possible | Rare |
| False negatives | Possible | Depends on tests |
Why Static Analysis Matters
1. Finds Bugs Tests Miss
Tests only cover the paths you think to test. Static analysis examines every path:2. Catches Issues Earlier
The earlier you find a bug, the cheaper it is to fix: Static analysis catches issues at the code stage—before review, testing, or deployment.3. Scales to Large Codebases
Manual code review doesn’t scale:| Codebase Size | Manual Review | Static Analysis |
|---|---|---|
| 1K lines | 1 hour | 1 second |
| 100K lines | 100 hours | 10 seconds |
| 1M lines | Impossible | 1 minute |
4. Enforces Consistency
Static analysis applies rules uniformly. It doesn’t:- Get tired on Friday afternoon
- Forget to check that one file
- Apply standards inconsistently
Types of Static Analysis
Syntactic Analysis (Linting)
Checks code style and structure without understanding meaning:Semantic Analysis
Understands meaning and relationships:Data Flow Analysis
Tracks how values move through code:Taint Analysis
Traces untrusted data to dangerous operations:How Skylos Fits In
Skylos combines multiple analysis types:| Analysis Type | What Skylos Finds |
|---|---|
| Syntactic | Unused imports |
| Semantic | Dead functions, classes, variables |
| Data Flow | Complexity, nesting depth |
| Taint | SQL injection, command injection, SSRF, XSS |
Limitations of Static Analysis
Static analysis is powerful but not perfect:Can’t Understand Runtime Values
Can’t Prove Correctness
Static analysis finds potential issues. It can’t prove your code is correct—only that it doesn’t have known problems.May Have False Positives
Static Analysis in Your Workflow
The best time to run static analysis: Pre-commit: Fast feedback, catch issues immediately CI Pipeline: Enforce standards, block bad PRsKey Concepts Glossary
| Term | Definition |
|---|---|
| AST | Abstract Syntax Tree—structured representation of code |
| Taint | Untrusted data that could be dangerous |
| Source | Where tainted data enters (user input, files) |
| Sink | Dangerous operation (SQL, shell, eval) |
| False positive | Reported issue that isn’t actually a problem |
| False negative | Real issue that wasn’t detected |
| Cyclomatic complexity | Count of independent paths through code |
