Skip to content

analysis

Full name: tenets.models.analysis

analysis

Code analysis data models used by the analyzer system.

This module contains all data structures used by the code analysis subsystem, including file analysis results, project metrics, and dependency graphs.

Classes

ImportInfodataclass

Python
ImportInfo(module: str, alias: Optional[str] = None, line: int = 0, type: str = 'import', is_relative: bool = False, level: int = 0, from_module: Optional[str] = None, is_stdlib: bool = False, is_stl: bool = False, conditional: bool = False, is_project_header: bool = False, is_project_file: bool = False, has_include_guard: bool = False, uses_pragma_once: bool = False, import_clause: Optional[str] = None, original_name: Optional[str] = None, is_wildcard: bool = False, category: Optional[str] = None, package: Optional[str] = None, namespace: Optional[str] = None, import_type: Optional[str] = None, is_file_include: bool = False, is_dynamic: bool = False, reloads: bool = False, is_gem: bool = False, is_autoload: bool = False, lazy_load: bool = False, is_unity: bool = False, namespace_context: Optional[str] = None, is_project_reference: bool = False, is_external: bool = False, is_module_declaration: bool = False, is_glob: bool = False, is_dev_dependency: bool = False, is_dependency: bool = False, version: Optional[str] = None, loads_all_gems: bool = False, is_renamed: bool = False, is_given: bool = False, is_resource: bool = False, resource_type: Optional[str] = None, is_runtime_load: bool = False, is_inheritance: bool = False, parent_type: Optional[str] = None, associated_class: Optional[str] = None, is_editor_script: bool = False, is_package_declaration: bool = False, is_package: bool = False, is_dart_core: bool = False, is_deferred: bool = False, show_symbols: List[str] = list(), hide_symbols: List[str] = list(), is_part_file: bool = False, is_library_part: bool = False, is_library_declaration: bool = False, package_context: Optional[str] = None, is_android: bool = False, integrity: Optional[str] = None, crossorigin: Optional[str] = None, is_async: bool = False, is_defer: bool = False, is_module: bool = False, as_type: Optional[str] = None, media_query: Optional[str] = None, layer: Optional[str] = None, supports: Optional[str] = None, config: Optional[str] = None, visibility: Optional[str] = None, composes: Optional[str] = None, is_apple: bool = False, is_apple_framework: bool = False, is_testable: bool = False, is_exported: bool = False, import_kind: Optional[str] = None)

Information about an import statement in code.

Represents imports across different languages (import, require, include, use).

ATTRIBUTEDESCRIPTION
module

The imported module/package name

TYPE:str

alias

Any alias assigned to the import

TYPE:Optional[str]

line

Line number where import appears

TYPE:int

type

Type of import (import, from, require, include)

TYPE:str

is_relative

Whether this is a relative import

TYPE:bool

level

Relative import level (Python), 0 for absolute

TYPE:int

from_module

Module specified in a 'from X import ...' statement

TYPE:Optional[str]

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing all import information

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing all import information
    """
    return asdict(self)

ComplexityMetricsdataclass

Python
ComplexityMetrics(cyclomatic: int = 1, cognitive: int = 0, halstead_volume: float = 0.0, halstead_difficulty: float = 0.0, maintainability_index: float = 100.0, line_count: int = 0, function_count: int = 0, class_count: int = 0, max_depth: int = 0, comment_ratio: float = 0.0, code_lines: int = 0, comment_lines: int = 0, character_count: int = 0, key_count: int = 0, section_count: int = 0, tag_count: int = 0, header_count: int = 0, column_count: int = 0, row_count: int = 0, template_count: int = 0, template_specializations: int = 0, macro_count: int = 0, ifdef_count: int = 0, include_count: int = 0, new_count: int = 0, delete_count: int = 0, malloc_count: int = 0, free_count: int = 0, unique_ptr_count: int = 0, shared_ptr_count: int = 0, weak_ptr_count: int = 0, uses_raii: bool = False, memory_safety_score: float = 1.0, interface_count: int = 0, type_count: int = 0, enum_count: int = 0, record_count: int = 0, method_count: int = 0, try_blocks: int = 0, catch_blocks: int = 0, finally_blocks: int = 0, throws_declarations: int = 0, annotation_count: int = 0, extends_count: int = 0, implements_count: int = 0, lambda_count: int = 0, stream_operations: int = 0, unsafe_blocks: int = 0, unsafe_functions: int = 0, unsafe_traits: int = 0, unsafe_impl: int = 0, unsafe_score: int = 0, lifetime_annotations: int = 0, lifetime_bounds: int = 0, generic_types: int = 0, trait_bounds: int = 0, async_functions: int = 0, await_points: int = 0, result_types: int = 0, option_types: int = 0, unwrap_calls: int = 0, expect_calls: int = 0, question_marks: int = 0, macro_invocations: int = 0, derive_macros: int = 0, test_count: int = 0, bench_count: int = 0, assertion_count: int = 0, combine_operators: int = 0, task_count: int = 0, task_groups: int = 0, await_calls: int = 0, optional_types: int = 0, force_unwraps: int = 0, optional_chaining: int = 0, nil_coalescing: int = 0, guard_statements: int = 0, if_let_bindings: int = 0, guard_let_bindings: int = 0, published_wrappers: int = 0, combine_publishers: int = 0, combine_subscriptions: int = 0, trait_count: int = 0, object_count: int = 0, case_class_count: int = 0, match_expressions: int = 0, case_clauses: int = 0, pattern_guards: int = 0, higher_order_functions: int = 0, for_comprehensions: int = 0, partial_functions: int = 0, type_parameters: int = 0, variance_annotations: int = 0, type_aliases: int = 0, existential_types: int = 0, implicit_defs: int = 0, implicit_params: int = 0, implicit_conversions: int = 0, future_usage: int = 0, actor_usage: int = 0, async_await: int = 0, immutable_collections: int = 0, mutable_collections: int = 0, throw_statements: int = 0, option_usage: int = 0, either_usage: int = 0, try_usage: int = 0, signal_count: int = 0, export_count: int = 0, onready_count: int = 0, node_ref_count: int = 0, get_node_count: int = 0, connect_count: int = 0, emit_count: int = 0, lifecycle_count: int = 0, rpc_count: int = 0, typed_vars: int = 0, typed_funcs: int = 0, return_types: int = 0, has_csp: bool = False, has_integrity_checks: bool = False, has_https_links: int = 0, delegation_count: int = 0, lazy_properties: int = 0, observable_properties: int = 0, lateinit_count: int = 0)

Code complexity metrics for analysis.

Contains various complexity measurements used to assess code quality and maintainability.

ATTRIBUTEDESCRIPTION
cyclomatic

McCabe cyclomatic complexity

TYPE:int

cognitive

Cognitive complexity score

TYPE:int

halstead_volume

Halstead volume metric

TYPE:float

halstead_difficulty

Halstead difficulty metric

TYPE:float

maintainability_index

Maintainability index (0-100)

TYPE:float

line_count

Total number of lines

TYPE:int

function_count

Number of functions

TYPE:int

class_count

Number of classes

TYPE:int

max_depth

Maximum nesting depth

TYPE:int

comment_ratio

Ratio of comments to code

TYPE:float

code_lines

Number of actual code lines

TYPE:int

comment_lines

Number of comment lines

TYPE:int

character_count

Total number of characters

TYPE:int

key_count

Number of key/value pairs (for config files)

TYPE:int

section_count

Number of sections (for structured files)

TYPE:int

tag_count

Number of tags (for markup languages)

TYPE:int

header_count

Number of headers (for document files)

TYPE:int

column_count

Number of columns (for tabular data)

TYPE:int

row_count

Number of rows (for tabular data)

TYPE:int

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing all metrics

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing all metrics
    """
    return asdict(self)

FunctionInfodataclass

Python
FunctionInfo(name: str, line_start: int = 0, line_end: int = 0, parameters: List[str] = list(), complexity: int = 1, line: int = 0, end_line: int = 0, is_toplevel: bool = False, args: List[str] = list(), decorators: List[str] = list(), is_async: bool = False, docstring: Optional[str] = None, return_type: Optional[str] = None, is_constructor: bool = False, is_abstract: bool = False, is_static: bool = False, is_class: bool = False, is_property: bool = False, is_private: bool = False, is_generator: bool = False, is_exported: bool = False, is_arrow: bool = False, generics: Optional[str] = None, is_inline: bool = False, is_constexpr: bool = False, is_template: bool = False, is_extern: bool = False, is_unsafe: bool = False, is_const: bool = False, is_public: bool = False, visibility: Optional[str] = None, modifiers: List[str] = list(), type_parameters: Optional[str] = None, receiver_type: Optional[str] = None, is_extension: bool = False, is_suspend: bool = False, is_operator: bool = False, is_infix: bool = False, is_implicit: bool = False, is_curried: bool = False, is_lifecycle: bool = False, is_virtual: bool = False, access_level: Optional[str] = None, is_throwing: bool = False, where_clause: Optional[str] = None)

Information about a function or method.

Represents functions, methods, procedures across languages.

ATTRIBUTEDESCRIPTION
name

Function/method name

TYPE:str

line_start

Starting line number

TYPE:int

line_end

Ending line number

TYPE:int

parameters

List of parameter names

TYPE:List[str]

complexity

Cyclomatic complexity of the function

TYPE:int

line

Compatibility alias for line_start

TYPE:int

end_line

Compatibility alias for line_end

TYPE:int

is_toplevel

Whether function is top-level (for some analyzers)

TYPE:bool

args

Argument strings with type hints (analyzer compatibility)

TYPE:List[str]

decorators

Decorators applied to the function

TYPE:List[str]

is_async

Whether the function is async

TYPE:bool

docstring

Function docstring

TYPE:Optional[str]

return_type

Return type annotation

TYPE:Optional[str]

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing function information

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing function information
    """
    return asdict(self)

ClassInfodataclass

Python
ClassInfo(name: str, line_start: int = 0, line_end: int = 0, methods: List[FunctionInfo] = list(), base_classes: List[str] = list(), line: int = 0, decorators: List[str] = list(), docstring: Optional[str] = None, is_abstract: bool = False, metaclass: Optional[str] = None, attributes: List[Dict[str, Any]] = list(), end_line: int = 0, bases: List[str] = list(), fields: List[Dict[str, Any]] = list(), interfaces: List[str] = list(), visibility: Optional[str] = None, modifiers: List[str] = list(), generics: Optional[str] = None, inner_classes: List[str] = list(), struct_type: Optional[str] = None, is_public: bool = False, is_struct: bool = False, is_template: bool = False, is_exported: bool = False, properties: List[Dict[str, Any]] = list(), events: List[Dict[str, Any]] = list(), type_parameters: Optional[str] = None, constructor_params: List[Dict[str, Any]] = list(), mixins: List[str] = list(), included_modules: List[str] = list(), extended_modules: List[str] = list(), delegates: Dict[str, str] = dict(), companion_object: Optional[Dict[str, Any]] = dict(), nested_classes: List[Dict[str, Any]] = dict(), has_companion: bool = False, is_case_class: bool = False, is_data_class: bool = False, is_sealed: bool = False, is_enum: bool = False, is_inner: bool = False, is_value_class: bool = False, android_type: Optional[str] = None, traits_used: List[Dict[str, Any]] = list(), constants: List[Any] = list(), constructors: List[Dict[str, Any]] = list(), is_widget: bool = False, widget_type: Optional[str] = None, access_level: Optional[str] = None, is_open: bool = False, is_final: bool = False, superclass: Optional[str] = None, protocols: List[str] = list(), nested_types: List[Dict[str, Any]] = list(), ui_type: Optional[str] = None, is_inner_class: bool = False, is_singleton: bool = False, is_monobehaviour: bool = False, is_scriptable_object: bool = False, unity_methods: List[str] = list(), coroutines: List[str] = list())

Information about a class or similar construct.

Represents classes, structs, interfaces across languages.

ATTRIBUTEDESCRIPTION
name

Class/struct/interface name

TYPE:str

line_start

Starting line number

TYPE:int

line_end

Ending line number

TYPE:int

methods

List of methods in the class

TYPE:List[FunctionInfo]

base_classes

List of base/parent class names

TYPE:List[str]

line

Compatibility alias for line_start

TYPE:int

decorators

Decorator names applied to the class

TYPE:List[str]

docstring

Class docstring

TYPE:Optional[str]

is_abstract

Whether class is abstract

TYPE:bool

metaclass

Metaclass name

TYPE:Optional[str]

attributes

Collected class attributes

TYPE:List[Dict[str, Any]]

end_line

Compatibility alias for line_end

TYPE:int

bases

Compatibility alias accepted by some analyzers/tests

TYPE:List[str]

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing class information with serialized methods

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing class information with serialized methods
    """
    data = asdict(self)
    # Keep methods serialized
    data["methods"] = [m.to_dict() if hasattr(m, "to_dict") else m for m in self.methods]
    return data

CodeStructuredataclass

Python
CodeStructure(classes: List[ClassInfo] = list(), functions: List[FunctionInfo] = list(), imports: List[ImportInfo] = list(), file_type: str = 'text', sections: List[Dict[str, Any]] = list(), variables: List[Dict[str, Any]] = list(), constants: List[str] = list(), todos: List[Dict[str, Any]] = list(), block_count: int = 0, indent_levels: Dict[str, Any] = dict(), type_aliases: List[Dict[str, Any]] = list(), namespace: Optional[str] = None, is_unity_script: bool = False, language_variant: Optional[str] = None, namespaces: List[Dict[str, Any]] = list(), templates: List[Dict[str, Any]] = list(), macros: List[Dict[str, Any]] = list(), unions: List[Dict[str, Any]] = list(), structs: List[Dict[str, Any]] = list(), operator_overloads: int = 0, uses_stl: bool = False, smart_pointers: List[str] = list(), lambda_count: int = 0, interfaces: List[Dict[str, Any]] = list(), types: List[Dict[str, Any]] = list(), enums: List[Dict[str, Any]] = list(), modules: List[Dict[str, Any]] = list(), framework: Optional[str] = None, package: Optional[str] = None, records: List[Dict[str, Any]] = list(), annotations: List[str] = list(), anonymous_classes_count: int = 0, components: List[Dict[str, Any]] = list(), is_library: bool = False, is_binary: bool = False, aliases: List[Dict[str, Any]] = list(), is_test: bool = False, traits: List[Dict[str, Any]] = list(), impl_blocks: List[Dict[str, Any]] = list(), statics: List[Dict[str, Any]] = list(), derives: List[str] = list(), unsafe_blocks: int = 0, async_functions: int = 0, test_functions: int = 0, bench_functions: int = 0, crate_type: Optional[str] = None, await_points: int = 0, unsafe_functions: int = 0, objects: List[Dict[str, Any]] = list(), scala_version: Optional[int] = None, given_instances: int = 0, using_clauses: int = 0, extension_methods: int = 0, extension_functions: int = 0, match_expressions: int = 0, case_statements: int = 0, for_comprehensions: int = 0, yield_expressions: int = 0, implicit_defs: int = 0, implicit_params: int = 0, lambda_expressions: int = 0, partial_functions: int = 0, is_android: bool = False, suspend_functions: int = 0, coroutine_launches: int = 0, flow_usage: int = 0, nullable_types: int = 0, null_assertions: int = 0, safe_calls: int = 0, elvis_operators: int = 0, scope_functions: int = 0, is_tool_script: bool = False, class_name: Optional[str] = None, parent_class: Optional[str] = None, godot_version: Optional[int] = None, signals: List[Dict[str, Any]] = list(), export_vars: List[Dict[str, Any]] = list(), onready_vars: List[Dict[str, Any]] = list(), setget_properties: List[Dict[str, Any]] = list(), node_references: int = 0, get_node_calls: int = 0, connect_calls: int = 0, emit_signal_calls: int = 0, is_custom_resource: bool = False, is_flutter: bool = False, mixins: List[Dict[str, Any]] = list(), extensions: List[Dict[str, Any]] = list(), typedefs: List[Dict[str, Any]] = list(), has_main: bool = False, is_test_file: bool = False, is_ios: bool = False, is_swiftui: bool = False, is_uikit: bool = False, protocols: List[Dict[str, Any]] = list(), actors: List[Dict[str, Any]] = list(), task_count: int = 0, await_count: int = 0, optional_count: int = 0, force_unwrap_count: int = 0, optional_chaining_count: int = 0, nil_coalescing_count: int = 0, guard_count: int = 0, if_let_count: int = 0, guard_let_count: int = 0, actor_count: int = 0, property_wrappers: int = 0, result_builders: int = 0, combine_publishers: int = 0, combine_operators: int = 0, swiftui_views: int = 0, view_modifiers: int = 0, body_count: int = 0, form_count: int = 0, input_count: int = 0, alt_texts: int = 0)

Represents the structure of a code file.

Contains organized information about code elements found in a file.

ATTRIBUTEDESCRIPTION
classes

List of classes in the file

TYPE:List[ClassInfo]

functions

List of standalone functions

TYPE:List[FunctionInfo]

imports

List of import statements

TYPE:List[ImportInfo]

file_type

Type of the file (e.g., script, module, package)

TYPE:str

sections

List of sections or blocks in the code

TYPE:List[Dict[str, Any]]

variables

List of variables used

TYPE:List[Dict[str, Any]]

constants

List of constants

TYPE:List[str]

todos

List of TODO comments or annotations

TYPE:List[Dict[str, Any]]

block_count

Total number of code blocks

TYPE:int

indent_levels

Indentation levels used in the code

TYPE:Dict[str, Any]

type_aliases

List of type alias definitions (Python 3.10+)

TYPE:List[Dict[str, Any]]

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing all structural information

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing all structural information
    """
    base = {
        "classes": [c.to_dict() for c in self.classes],
        "functions": [f.to_dict() for f in self.functions],
        "imports": [i.to_dict() for i in self.imports],
    }
    # Include extended fields
    base.update(
        {
            "file_type": self.file_type,
            "sections": self.sections,
            "variables": self.variables,
            "constants": self.constants,
            "todos": self.todos,
            "block_count": self.block_count,
            "indent_levels": self.indent_levels,
            "type_aliases": self.type_aliases,
            # Extended
            "language_variant": self.language_variant,
            "namespaces": self.namespaces,
            "templates": self.templates,
            "macros": self.macros,
            "unions": self.unions,
            "operator_overloads": self.operator_overloads,
            "uses_stl": self.uses_stl,
            "smart_pointers": self.smart_pointers,
            "lambda_count": self.lambda_count,
            "interfaces": self.interfaces,
            "types": self.types,
            "enums": self.enums,
            "framework": self.framework,
            "package": self.package,
            "records": self.records,
            "annotations": self.annotations,
            "anonymous_classes_count": self.anonymous_classes_count,
            # JS/TS
            "components": self.components,
            # Rust
            "is_library": self.is_library,
            "is_binary": self.is_binary,
            "is_test": self.is_test,
            "traits": self.traits,
            "impl_blocks": self.impl_blocks,
            "modules": self.modules,
            "statics": self.statics,
            "derives": self.derives,
            "unsafe_blocks": self.unsafe_blocks,
            "async_functions": self.async_functions,
            "test_functions": self.test_functions,
            "bench_functions": self.bench_functions,
            "crate_type": self.crate_type,
            "await_points": self.await_points,
            "unsafe_functions": self.unsafe_functions,
            # Kotlin/Scala/General additions
            "objects": self.objects,
            "scala_version": self.scala_version,
            "given_instances": self.given_instances,
            "using_clauses": self.using_clauses,
            "extension_methods": self.extension_methods,
            "extension_functions": self.extension_functions,
            "match_expressions": self.match_expressions,
            "case_statements": self.case_statements,
            "for_comprehensions": self.for_comprehensions,
            "yield_expressions": self.yield_expressions,
            "implicit_defs": self.implicit_defs,
            "implicit_params": self.implicit_params,
            "lambda_expressions": self.lambda_expressions,
            "partial_functions": self.partial_functions,
            # Kotlin Android metrics
            "is_android": self.is_android,
            "suspend_functions": self.suspend_functions,
            "coroutine_launches": self.coroutine_launches,
            "flow_usage": self.flow_usage,
            "nullable_types": self.nullable_types,
            "null_assertions": self.null_assertions,
            "safe_calls": self.safe_calls,
            "elvis_operators": self.elvis_operators,
            "scope_functions": self.scope_functions,
            # GDScript-specific
            "is_tool_script": self.is_tool_script,
            "class_name": self.class_name,
            "parent_class": self.parent_class,
            "godot_version": self.godot_version,
            "signals": self.signals,
            "export_vars": self.export_vars,
            "onready_vars": self.onready_vars,
            "setget_properties": self.setget_properties,
            "node_references": self.node_references,
            "get_node_calls": self.get_node_calls,
            "connect_calls": self.connect_calls,
            "emit_signal_calls": self.emit_signal_calls,
            "is_custom_resource": self.is_custom_resource,
            # Dart analyzer additions
            "is_flutter": self.is_flutter,
            "mixins": self.mixins,
            "extensions": self.extensions,
            "typedefs": self.typedefs,
            "has_main": self.has_main,
            "is_test_file": self.is_test_file,
            # Swift structure additions
            "is_ios": self.is_ios,
            "is_swiftui": self.is_swiftui,
            "is_uikit": self.is_uikit,
            "structs": self.structs,
            "protocols": self.protocols,
            "actors": self.actors,
            "task_count": self.task_count,
            "await_count": self.await_count,
            "optional_count": self.optional_count,
            "force_unwrap_count": self.force_unwrap_count,
            "optional_chaining_count": self.optional_chaining_count,
            "nil_coalescing_count": self.nil_coalescing_count,
            "guard_count": self.guard_count,
            "if_let_count": self.if_let_count,
            "guard_let_count": self.guard_let_count,
            "actor_count": self.actor_count,
            "property_wrappers": self.property_wrappers,
            "result_builders": self.result_builders,
            "combine_publishers": self.combine_publishers,
            "combine_operators": self.combine_operators,
            "swiftui_views": self.swiftui_views,
            "view_modifiers": self.view_modifiers,
            "body_count": self.body_count,
            # HTML doc structure
            "form_count": self.form_count,
            "input_count": self.input_count,
            "alt_texts": self.alt_texts,
        }
    )
    return base

FileAnalysisdataclass

Python
FileAnalysis(path: str, content: str = '', size: int = 0, lines: int = 0, language: str = 'unknown', file_name: str = '', file_extension: str = '', last_modified: Optional[datetime] = None, hash: Optional[str] = None, imports: List[ImportInfo] = list(), exports: List[Dict[str, Any]] = list(), structure: Optional[CodeStructure] = None, complexity: Optional[ComplexityMetrics] = None, classes: List[ClassInfo] = list(), functions: List[FunctionInfo] = list(), keywords: List[str] = list(), git_info: Optional[Dict[str, Any]] = None, relevance_score: float = 0.0, quality_score: float = 0.0, error: Optional[str] = None)

Complete analysis results for a single file.

Contains all information extracted from analyzing a source code file, including structure, complexity, and metadata.

ATTRIBUTEDESCRIPTION
path

File path

TYPE:str

content

File content

TYPE:str

size

File size in bytes

TYPE:int

lines

Number of lines

TYPE:int

language

Programming language

TYPE:str

file_name

Name of the file

TYPE:str

file_extension

File extension

TYPE:str

last_modified

Last modification time

TYPE:Optional[datetime]

hash

Content hash

TYPE:Optional[str]

imports

List of imports

TYPE:List[ImportInfo]

exports

List of exports

TYPE:List[Dict[str, Any]]

structure

Code structure information

TYPE:Optional[CodeStructure]

complexity

Complexity metrics

TYPE:Optional[ComplexityMetrics]

classes

List of classes (convenience accessor)

TYPE:List[ClassInfo]

functions

List of functions (convenience accessor)

TYPE:List[FunctionInfo]

keywords

Extracted keywords

TYPE:List[str]

relevance_score

Relevance score for ranking

TYPE:float

quality_score

Code quality score

TYPE:float

error

Any error encountered during analysis

TYPE:Optional[str]

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing all file analysis data

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing all file analysis data
    """
    data = asdict(self)
    if self.last_modified:
        data["last_modified"] = self.last_modified.isoformat()
    if self.structure:
        data["structure"] = self.structure.to_dict()
    if self.complexity:
        data["complexity"] = self.complexity.to_dict()
    data["imports"] = [i.to_dict() for i in self.imports]
    data["classes"] = [c.to_dict() for c in self.classes]
    data["functions"] = [f.to_dict() for f in self.functions]
    return data
from_dictclassmethod
Python
from_dict(data: Dict[str, Any]) -> FileAnalysis

Create FileAnalysis from dictionary.

PARAMETERDESCRIPTION
data

Dictionary containing file analysis data

TYPE:Dict[str, Any]

RETURNSDESCRIPTION
FileAnalysis

FileAnalysis instance

Source code in tenets/models/analysis.py
Python
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "FileAnalysis":
    """Create FileAnalysis from dictionary.

    Args:
        data: Dictionary containing file analysis data

    Returns:
        FileAnalysis instance
    """
    # Handle datetime conversion
    if "last_modified" in data and isinstance(data["last_modified"], str):
        data["last_modified"] = datetime.fromisoformat(data["last_modified"])

    # Handle nested objects
    if "imports" in data:
        data["imports"] = [
            ImportInfo(**i) if isinstance(i, dict) else i for i in data["imports"]
        ]
    if "classes" in data:
        data["classes"] = [
            ClassInfo(**c) if isinstance(c, dict) else c for c in data["classes"]
        ]
    if "functions" in data:
        data["functions"] = [
            FunctionInfo(**f) if isinstance(f, dict) else f for f in data["functions"]
        ]
    if "structure" in data and isinstance(data["structure"], dict):
        # Reconstruct CodeStructure
        structure_data = data["structure"]
        if "classes" in structure_data:
            structure_data["classes"] = [
                ClassInfo(**c) if isinstance(c, dict) else c for c in structure_data["classes"]
            ]
        if "functions" in structure_data:
            structure_data["functions"] = [
                FunctionInfo(**f) if isinstance(f, dict) else f
                for f in structure_data["functions"]
            ]
        if "imports" in structure_data:
            structure_data["imports"] = [
                ImportInfo(**i) if isinstance(i, dict) else i for i in structure_data["imports"]
            ]
        data["structure"] = CodeStructure(**structure_data)
    if "complexity" in data and isinstance(data["complexity"], dict):
        data["complexity"] = ComplexityMetrics(**data["complexity"])

    return cls(**data)

DependencyGraphdataclass

Python
DependencyGraph(nodes: Dict[str, Any] = dict(), edges: List[tuple] = list(), cycles: List[List[str]] = list())

Represents project dependency graph.

Tracks dependencies between files and modules in the project.

ATTRIBUTEDESCRIPTION
nodes

Dictionary of node ID to node data

TYPE:Dict[str, Any]

edges

List of edges (from_id, to_id, edge_data)

TYPE:List[tuple]

cycles

List of detected dependency cycles

TYPE:List[List[str]]

Functions
add_node
Python
add_node(node_id: str, data: Any) -> None

Add a node to the dependency graph.

PARAMETERDESCRIPTION
node_id

Unique identifier for the node

TYPE:str

data

Node data (typically FileAnalysis)

TYPE:Any

Source code in tenets/models/analysis.py
Python
def add_node(self, node_id: str, data: Any) -> None:
    """Add a node to the dependency graph.

    Args:
        node_id: Unique identifier for the node
        data: Node data (typically FileAnalysis)
    """
    self.nodes[node_id] = data
add_edge
Python
add_edge(from_id: str, to_id: str, import_info: Optional[ImportInfo] = None) -> None

Add an edge representing a dependency.

PARAMETERDESCRIPTION
from_id

Source node ID

TYPE:str

to_id

Target node ID

TYPE:str

import_info

Optional import information

TYPE:Optional[ImportInfo]DEFAULT:None

Source code in tenets/models/analysis.py
Python
def add_edge(self, from_id: str, to_id: str, import_info: Optional[ImportInfo] = None) -> None:
    """Add an edge representing a dependency.

    Args:
        from_id: Source node ID
        to_id: Target node ID
        import_info: Optional import information
    """
    self.edges.append((from_id, to_id, import_info))
calculate_metrics
Python
calculate_metrics() -> None

Calculate graph metrics like centrality and cycles.

Updates internal metrics based on current graph structure.

Source code in tenets/models/analysis.py
Python
def calculate_metrics(self) -> None:
    """Calculate graph metrics like centrality and cycles.

    Updates internal metrics based on current graph structure.
    """
    # This would calculate various graph metrics
    # For now, just detect simple cycles
    pass
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing graph structure

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing graph structure
    """
    return {
        "nodes": list(self.nodes.keys()),
        "edges": [(e[0], e[1]) for e in self.edges],
        "cycles": self.cycles,
    }

ProjectAnalysisdataclass

Python
ProjectAnalysis(path: str, name: str, files: List[FileAnalysis] = list(), total_files: int = 0, analyzed_files: int = 0, failed_files: int = 0, total_lines: int = 0, total_code_lines: int = 0, total_comment_lines: int = 0, average_complexity: float = 0.0, total_functions: int = 0, total_classes: int = 0, languages: Dict[str, int] = dict(), language_distribution: Dict[str, float] = dict(), frameworks: List[str] = list(), project_type: str = 'unknown', dependency_graph: Optional[DependencyGraph] = None, summary: Dict[str, Any] = dict())

Analysis results for an entire project.

Aggregates file-level analysis into project-wide metrics and insights.

ATTRIBUTEDESCRIPTION
path

Project root path

TYPE:str

name

Project name

TYPE:str

files

List of analyzed files

TYPE:List[FileAnalysis]

total_files

Total number of files

TYPE:int

analyzed_files

Number of successfully analyzed files

TYPE:int

failed_files

Number of files that failed analysis

TYPE:int

total_lines

Total lines of code

TYPE:int

total_code_lines

Total non-blank, non-comment lines

TYPE:int

total_comment_lines

Total comment lines

TYPE:int

average_complexity

Average cyclomatic complexity

TYPE:float

total_functions

Total number of functions

TYPE:int

total_classes

Total number of classes

TYPE:int

languages

Language distribution (language -> file count)

TYPE:Dict[str, int]

language_distribution

Percentage distribution of languages

TYPE:Dict[str, float]

frameworks

Detected frameworks

TYPE:List[str]

project_type

Type of project (web, library, cli, etc.)

TYPE:str

dependency_graph

Project dependency graph

TYPE:Optional[DependencyGraph]

summary

Project summary dictionary

TYPE:Dict[str, Any]

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing all project analysis data

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing all project analysis data
    """
    data = asdict(self)
    data["files"] = [f.to_dict() for f in self.files]
    if self.dependency_graph:
        data["dependency_graph"] = self.dependency_graph.to_dict()
    return data

AnalysisReportdataclass

Python
AnalysisReport(timestamp: datetime = datetime.now(), format: str = 'json', content: str = '', statistics: Dict[str, Any] = dict(), output_path: Optional[str] = None)

Report generated from analysis results.

Formatted output of analysis results for different consumers.

ATTRIBUTEDESCRIPTION
timestamp

When report was generated

TYPE:datetime

format

Report format (json, html, markdown, csv)

TYPE:str

content

Report content

TYPE:str

statistics

Analysis statistics

TYPE:Dict[str, Any]

output_path

Where report was saved (if applicable)

TYPE:Optional[str]

Functions
to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict containing report information

Source code in tenets/models/analysis.py
Python
def to_dict(self) -> Dict[str, Any]:
    """Convert to dictionary representation.

    Returns:
        Dict containing report information
    """
    return {
        "timestamp": self.timestamp.isoformat(),
        "format": self.format,
        "statistics": self.statistics,
        "output_path": self.output_path,
    }