import json

with open("semantics/semantic_map.json") as f:
    data = json.load(f)

for m in data.get("modules", []):
    if m.get("name") == "backend.src.core.task_manager.persistence":
        def print_issues(node, depth=0):
            issues = node.get("compliance", {}).get("issues", [])
            if issues:
                print("  "*depth, f"{node.get('type')} {node.get('name')} (line {node.get('start_line')}):")
                for i in issues:
                    print("  "*(depth+1), "-", i.get("message"))
            for c in node.get("children", []):
                print_issues(c, depth+1)
            for k in ["functions", "classes", "components"]:
                for c in node.get(k, []):
                    print_issues(c, depth+1)
        print_issues(m)

