Source code for haive.core.utils.debugkit.analysis
"""Advanced code analysis utilities for type checking and complexity analysis.This package provides comprehensive code analysis capabilities including:- Static type analysis with multiple type checkers- Multi-dimensional complexity analysis- Code quality scoring and recommendations- Integration with popular Python analysis toolsThe analysis modules work together to provide detailed insights into codequality, maintainability, and potential issues."""fromtypingimportTYPE_CHECKING,OptionalifTYPE_CHECKING:from.complexityimportComplexityAnalyzer,ComplexityMetrics,ComplexityReportfrom.staticimportAnalysisResult,StaticAnalysisOrchestratorfrom.typesimportFunctionTypeAnalysis,TypeAnalyzer,TypeInfo# Analysis modules with lazy loading_type_analyzer:Optional["TypeAnalyzer"]=None_complexity_analyzer:Optional["ComplexityAnalyzer"]=None_static_orchestrator:Optional["StaticAnalysisOrchestrator"]=None
[docs]defget_type_analyzer()->"TypeAnalyzer":"""Get or create the type analyzer instance. Returns: TypeAnalyzer: The type analyzer instance """global_type_analyzerif_type_analyzerisNone:fromhaive.core.utils.debugkit.configimportconfigfrom.typesimportTypeAnalyzer_type_analyzer=TypeAnalyzer(use_mypy=config.is_tool_enabled("mypy"),cache_enabled=True,strict_mode=(config.strict_thresholdsifhasattr(config,"strict_thresholds")elseFalse),)return_type_analyzer
[docs]defget_complexity_analyzer()->"ComplexityAnalyzer":"""Get or create the complexity analyzer instance. Returns: ComplexityAnalyzer: The complexity analyzer instance """global_complexity_analyzerif_complexity_analyzerisNone:from.complexityimportComplexityAnalyzer_complexity_analyzer=ComplexityAnalyzer()return_complexity_analyzer
[docs]defget_static_orchestrator()->"StaticAnalysisOrchestrator":"""Get or create the static analysis orchestrator instance. Returns: StaticAnalysisOrchestrator: The static analysis orchestrator """global_static_orchestratorif_static_orchestratorisNone:from.staticimportStaticAnalysisOrchestrator_static_orchestrator=StaticAnalysisOrchestrator()return_static_orchestrator