The Code Health score goes from 10 (healthy code that is relatively easy to understand and evolve) down to 1, which indicates code with severe quality issues. Examples of Code Health issues include – but are not limited to – the following
-
Brain Method: A single function/method that centers too much behavior and becomes a local hotspot.
-
Nested Complexity: This is typically revealed as if-statements inside other if-statements and/or loops, and is a construct that significantly increases the risk for defects.
-
Bumpy Road: A bumpy road is a function that fails to encapsulate its responsibilities, leading to code containing multiple logical chunks of logic. Just like a bumpy road will slow down your driving, a bumpy road in code presents an obstacle to comprehension. There’s also an increased risk of feature entanglement. The remedy is often to extract and encapsulate the chunks of logically dispersed behaviors in their own functions.
-
Developer Congestion: Code becomes a coordination bottleneck when multiple developers need to work on it in parallel (see Parallel Development and Code Fragmentation).
-
Knowledge Loss due to former contributors: If the developer behind a hotspot with low code health leaves the organization, the maintenance risk increases significantly.
-
DRY (Don’t Repeat Yourself) Violations: CodeScene detects duplicated logic that is actually changed together in predictable patterns.
-
Primitive Obsession: Code that uses a high degree of built-in, primitives such as integers, strings, and floats, often lacks a domain language that encapsulates the validation and semantics of function arguments.
The Code Health trends can be automatically supervised in your CI/CD pipeline and/or Pull Requests, so check out how to enable that integration: Integrate CodeScene with Pull Requests.
For more details check: CODE HEALTH – HOW EASY IS YOUR CODE TO MAINTAIN AND EVOLVE?