MCPcopy Create free account
hub / github.com/GitsSaikat/PyGen / evaluate_readability

Function evaluate_readability

pygen/translated_code_eval.py:49–53  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

47 return {"cyclomatic_complexity": cyclomatic_complexity, "line_count": line_count}
48
49def evaluate_readability(code):
50 comment_lines = sum(1 for line in code.splitlines() if line.strip().startswith("#") or line.strip().startswith("//"))
51 total_lines = len(code.splitlines())
52 comment_density = (comment_lines / total_lines) * 100 if total_lines else 0
53 return comment_density
54
55# Example code should be put in the variables
56python_code = """

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected