2010YOUY01 commented on issue #26257: URL: https://github.com/apache/datafusion/issues/26257#issuecomment-6205415191
> we can try to leverage https://github.com/mozilla/rust-code-analysis/ to define and enforce code complexities on the PR level TIL -- this tool is cool. Below is its major metrics > | Metric | How it's modeled | What it measures | > |---|---|---| > | **CC (Cyclomatic)** | `1 + decision points` (`if`, loops, match arms, `&&`, `\|\|`, `?` in Rust) | Number of independent control-flow paths | > | **Cognitive Complexity** | Control-flow structures + nesting penalties + boolean-expression complexity | How difficult the control flow is to understand | > | **Halstead** | Number and diversity of operators and operands | Syntactic complexity and estimated implementation effort | > | **MI (Maintainability Index)** | Composite of CC, Halstead, LOC, and comments | Overall maintainability estimate | > | **LOC** | Lines of code (physical/logical variants) | Code size | I see these metrics as useful additional references, though they may not fully capture the aspects of code complexity that matter most for maintainability. To me, the gold standard is how easily readers can understand and reason about the code or PR directly. It would be great if reviews place more emphasis on this. One key criterion is ease of local reasoning, which I believe is best achieved through good problem decomposition/modeling and deep modules, as described in Heuristic 1 in: - https://github.com/apache/datafusion/issues/26225 This doesn't always align with static analysis metrics such as Cyclomatic Complexity, Cognitive Complexity, or LoC. For example, a function or module can have a complex internal implementation, but if it exposes a simple interface and keeps that complexity encapsulated, it can still make the overall system easier to understand and maintain. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
