New C Code Scoring Tool Flags Risky Functions Using Nesting and Pointer Depth
A lightweight open-source tool called c-code-score assigns a single risk score to C functions based on three factors: nesting depth, pointer depth, and dereference chain length. The score is calculated by multiplying these three metrics, aiming to highlight functions most prone to memory bugs and null-pointer errors. When tested against real-world projects like libXt and libtiff, the score correlated with maintenance churn at rates of 0.52 and 0.38 respectively, outperforming both raw line count and cyclomatic complexity. The tool also works as a feedback loop for LLM-generated C code, allowing developers to iteratively prompt rewrites until scores improve. It is available via pip and requires no external dependencies or complex parsing infrastructure.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in