Skip to content

Architecture & Heuristics

Krzysztofci edited this page Jun 26, 2026 · 2 revisions

How logic-cov Works (Under the Hood)

The tool analyzes source code statically without executing it, leveraging Python's built-in ast (Abstract Syntax Tree) module. This ensures that the analysis process is completely safe, lightweight, and fast.

🧠 Function Classification Algorithm

Every function within the target project is mapped by the Analyzer(ast.NodeVisitor) class and receives score points (weights) across two categories: GUI and LOGIC.

  1. Function Names:
    • Keywords like build, show, ui, widget award score points to GUI (provided that the file imports known windowing/UI libraries).
    • Keywords like calc, parse, load, process automatically increment the LOGIC counter.
  2. Internal Method Calls:
    • Methods such as .pack(), .grid(), .bind() or UI component instantiations (e.g., Button, Frame) serve as strong GUI indicators.
    • System-level calls and file operations (open, json, subprocess, os, re) push the weight towards LOGIC.

📊 Mathematical Triage Rules

The final classification of a function is determined by the ratio of its accumulated scores:

  • UNKNOWN: Total weight equals 0 (e.g., abstract methods, empty interfaces).
  • GUI / LOGIC: One type dominates the other by a factor of at least $1.5\times$ (or the opposing weight is exactly 0).
  • MIXED: The function exhibits characteristics of both types, but neither managed to establish a $1.5\times$ lead. This signals a heavy coupling between view and logic (tight coupling) — a clear invitation for architectural refactoring.

Clone this wiki locally