Expand description
TLDR-Core: Core analysis engine for code analysis
This crate provides the core analysis functionality for the TLDR tool, organized into analysis layers:
- Layer 1 (AST): tree, structure, extract, imports
- Layer 2 (Call Graph): calls, impact, dead, importers, arch
- Layer 3 (CFG): cfg, complexity
- Layer 4 (DFG): dfg
- Layer 5 (PDG): pdg, slice, thin_slice
- Layer 6 (SSA): ssa, reaching-defs (Session 10)
- Layer 7 (Alias): alias analysis (Session 11+)
- Layer 8 (Dataflow): available expressions, abstract interpretation (Session 13)
Plus search, context, quality, security, and diagnostics modules.
§Example
ⓘ
use tldr_core::{Language, TldrResult};
use tldr_core::fs::tree::get_file_tree;
use tldr_core::ast::{get_code_structure, extract_file, get_imports};
// Detect language from file extension
let lang = Language::from_extension(".py");
assert_eq!(lang, Some(Language::Python));
// Get file tree
let tree = get_file_tree(Path::new("src"), None, true, None)?;
// Extract code structure
let structure = get_code_structure(Path::new("src"), Language::Python, 0, None)?;Re-exports§
pub use error::TldrError;pub use ast::extract_file;pub use ast::get_code_structure;pub use ast::get_imports;pub use fs::get_file_tree;pub use analysis::architecture_analysis;pub use analysis::change_impact;pub use analysis::change_impact;pub use analysis::change_impact_extended;pub use analysis::collect_all_functions;pub use analysis::dead_code_analysis;pub use analysis::find_importers;pub use analysis::impact_analysis;pub use analysis::impact_analysis_with_ast_fallback;pub use analysis::ChangeImpactMetadata;pub use analysis::ChangeImpactReport;pub use analysis::DetectionMethod;pub use analysis::TestFunction;pub use callgraph::build_project_call_graph;pub use cfg::get_cfg_context;pub use metrics::calculate_complexity;pub use dfg::get_dfg_context;pub use pdg::get_pdg_context;pub use pdg::get_slice;pub use pdg::get_slice_rich;pub use pdg::RichSlice;pub use pdg::SliceEdge;pub use pdg::SliceNode;pub use search::enriched_search;pub use search::enriched_search_with_callgraph_cache;pub use search::enriched_search_with_index;pub use search::enriched_search_with_structure_cache;pub use search::hybrid_search;pub use search::read_callgraph_cache;pub use search::read_structure_cache;pub use search::search;pub use search::search_with_inner;pub use search::write_structure_cache;pub use search::Bm25Index;pub use search::Bm25Result;pub use search::CallGraphLookup;pub use search::EmbeddingClient;pub use search::EnrichedResult;pub use search::EnrichedSearchOptions;pub use search::EnrichedSearchReport;pub use search::HybridResult;pub use search::HybridSearchReport;pub use search::SearchMatch;pub use search::SearchMode;pub use search::StructureLookup;pub use search::Tokenizer;pub use validation::detect_or_parse_language;pub use validation::validate_file_path;pub use context::get_relevant_context;pub use context::FunctionContext;pub use context::RelevantContext;pub use quality::analyze_smells_aggregated;pub use quality::detect_smells;pub use quality::SmellFinding;pub use quality::SmellType;pub use quality::SmellsReport;pub use quality::ThresholdPreset;pub use quality::maintainability_index;pub use quality::FileMI;pub use quality::HalsteadMetrics;pub use quality::MISummary;pub use quality::MaintainabilityReport;pub use security::compute_taint;pub use security::compute_taint_with_tree;pub use security::TaintFlow;pub use security::TaintInfo;pub use security::TaintSink;pub use security::TaintSinkType;pub use security::TaintSource;pub use security::TaintSourceType;pub use security::scan_secrets;pub use security::SecretFinding;pub use security::SecretsReport;pub use security::Severity;pub use security::scan_vulnerabilities;pub use security::VulnFinding;pub use security::VulnReport;pub use security::VulnType;pub use patterns::detect_patterns;pub use patterns::detect_patterns_with_config;pub use patterns::PatternConfig;pub use patterns::PatternMiner;pub use inheritance::format::format_dot;pub use inheritance::format::format_text;pub use inheritance::extract_inheritance;pub use inheritance::InheritanceOptions;pub use diagnostics::Diagnostic;pub use diagnostics::DiagnosticsReport;pub use diagnostics::DiagnosticsSummary;pub use diagnostics::Severity as DiagnosticSeverity;pub use dataflow::compute_abstract_interp;pub use dataflow::compute_available_exprs;pub use dataflow::compute_available_exprs_with_source_and_lang;pub use dataflow::normalize_expression;pub use dataflow::AbstractInterpInfo;pub use dataflow::AbstractState;pub use dataflow::AbstractValue;pub use dataflow::AvailableExprsInfo;pub use dataflow::ConstantValue;pub use dataflow::Expression;pub use dataflow::Nullability;pub use types::*;
Modules§
- alias
- Alias Analysis Module
- analysis
- Analysis module - Impact, Dead Code, Importers, Architecture, Change Impact, Hubs, References, Clones, Similarity
- ast
- AST extraction and parsing for TLDR
- callgraph
- Call Graph Layer (L2) - Cross-file call graph construction
- cfg
- Control Flow Graph (CFG) module - Layer 3
- context
- Context module - LLM-ready context generation
- dataflow
- Dataflow Analysis Module
- dfg
- Data Flow Graph (DFG) module - Layer 4
- diagnostics
- Diagnostics module - Unified type checking and linting across languages
- encoding
- File encoding handling (Phase 10)
- error
- Error types for TLDR operations
- fix
- Diagnostic and auto-fix system for
tldr fix. - fs
- File system operations for TLDR
- git
- Git operations module
- inheritance
- Inheritance analysis module for class hierarchy extraction
- limits
- Memory and timeout limits for analysis operations (Phase 10)
- metrics
- Code metrics module - Layer 3
- patterns
- Pattern detection module for design pattern mining
- pdg
- Program Dependence Graph (PDG) module - Layer 5
- quality
- Code quality analysis module - Phase 8
- search
- Search functionality for TLDR
- security
- Security analysis module - Phase 8
- ssa
- Static Single Assignment (SSA) Form Module
- surface
- API surface extraction for libraries and packages.
- types
- Common types for TLDR operations
- validation
- Shared validation helpers for CLI and daemon handlers
- wrappers
- Wrappers module - Base infrastructure for GVN migration
Type Aliases§
- Tldr
Result - Result type alias for all TLDR operations