Expand description
Resources Command - Resource Lifecycle Analysis
Analyzes resource lifecycle to detect leaks, double-close, and use-after-close issues.
§Analysis Types
- R1: Resource detection - Identify resources requiring close
- R2: Close verification - All-paths leak detection
- R3: Double-close detection - Closing resources twice
- R4: Use-after-close - Using closed resources
- R6: Context manager suggestions - Suggest
withstatement - R7: Leak path enumeration - Detailed paths to leaks
- R9: Constraint generation - LLM-ready constraints
§TIGER Mitigations
- T04: MAX_PATHS=1000 with early termination for path enumeration
§Example
# Analyze a single file
tldr resources src/db.py
# Analyze specific function
tldr resources src/db.py query
# Check all issues
tldr resources src/db.py --check-all
# Show leak paths
tldr resources src/db.py --show-pathsStructs§
- Basic
Block - A basic block in the simplified control flow graph.
- Double
Close Detector - Double-close detector.
- Leak
Detector - Leak detector using CFG path analysis.
- Resource
Analysis Results - Aggregated resource analysis results for L2 consumption.
- Resource
Detector - Resource detector for finding must-close resources.
- Resources
Args - Analyze resource lifecycle to detect leaks, double-close, and use-after-close.
- Simple
Cfg - Simplified control flow graph for resource analysis.
- UseAfter
Close Detector - Use-after-close detector.
Constants§
- MAX_
PATHS - Maximum paths to enumerate before early termination (TIGER-04).
- RESOURCE_
CLOSERS - Legacy constant for backward compatibility with tests
- RESOURCE_
CREATORS - Legacy constant for backward compatibility with tests
Functions§
- analyze_
source_ for_ resource_ issues - Analyze source code for resource lifecycle issues.
- build_
cfg - Build a simplified CFG from a function AST.
- build_
cfg_ multilang - Build a simplified CFG from a function AST, using language-specific patterns.
- format_
resources_ text - Format resources report as human-readable text.
- generate_
constraints - Generate LLM-ready constraints from resource analysis.
- run
- Run the resources analysis command.
- suggest_
context_ manager - Suggest context manager usage for resources.
- suggest_
context_ manager_ multilang - Suggest cleanup patterns using language-appropriate idioms.