How it works
Static analysis runs in three steps:- Parse - Convert source files to TypeScript AST
- Walk - Traverse the AST tree visiting each node
- Detect - Apply rule visitors to find problematic patterns
Detection rules
Vibrant includes 15+ built-in rules organized by category:Security rules
These rules detect critical security vulnerabilities that could expose your application to attacks:- hardcoded-credentials - Detects API keys, passwords, tokens in source code
- no-sql-injection - Finds SQL injection vulnerabilities
- no-unsafe-inner-html - Catches XSS risks via
innerHTML
Example: hardcoded-credentials detection
Example: hardcoded-credentials detection
This rule checks variable names and property assignments for credential-related keywords:Detected pattern:Suggested fix:
Bug prevention rules
These rules catch common programming errors that cause runtime failures:- empty-catch-block - Empty catch blocks swallow errors silently
- unimplemented-error - Code throws “not implemented” errors
- empty-function-body - Functions with no implementation
- no-unreachable - Code after return/throw statements
- no-ex-assign - Reassigning exception variables
- use-isnan - Using
===to compare withNaN
Example: empty-catch-block detection
Example: empty-catch-block detection
Code quality rules
These rules enforce best practices and improve maintainability:- console-log-debugging - Debug console statements in production code
- no-explicit-any - Usage of TypeScript
anytype - no-await-in-loop - Sequential awaits instead of parallel execution
AI telltale rules
These rules detect patterns commonly found in AI-generated code:- ai-comment-emojis - Emojis in code comments
- ai-todo-comments - Excessive TODO/FIXME comments
- magic-numbers - Unnamed numeric constants
AI models often generate code with decorative emojis, many TODO comments, and magic numbers instead of named constants. These patterns suggest the code wasn’t reviewed by a human.
Performance
Static analysis is extremely fast because it doesn’t execute code or make network requests:- 100 files: ~200ms
- 500 files: ~800ms
- Zero API calls - Runs completely offline
Running static analysis
Static analysis runs by default when you use thevibrant command:
Static analysis is the default mode. No flags required.
Ignoring false positives
You can suppress false positives using inline comments:vibrant.config.js:
Advantages of static analysis
- Deterministic - Same input always produces same output
- Offline - Works without internet connection
- Zero cost - No API fees
- Instant feedback - Results in milliseconds
- CI/CD friendly - Perfect for automated pipelines
Limitations
Static analysis can only detect syntactic patterns. It cannot:- Understand business logic context
- Detect complex architectural issues
- Recognize domain-specific anti-patterns
- Understand intent behind code decisions
--ai flag.
Next steps
AI analysis
Learn about AI-powered deep code analysis
Auto-fix
Automatically fix detected issues