Understanding Fitness Score

Code quality is a complex, multi-dimensional aspect of software development. While code smells are commonly used to measure maintainability, or the lack thereof, the variety and granularity of smells can make interpretation challenging. Technical staff, such as developers, benefit from these detailed insights, but the technical nature of code smells may be difficult for non-technical stakeholders to understand.

To simplify this complexity and provide a clear view of a project’s code quality, DCode computes a fitness score. This score reflects the overall quality of the codebase, making it easier for both technical and non-technical team members to assess maintainability at a glance.

_images/code-fitness.png

Fitness Score Calculation

The fitness score depends on the ratio of smelly and non-smelly artifacts.

  1. Architecture smells:

    Count the number of unique smelly packages (As) and unique non-smelly packages (Ab).

  2. Design smells:

    Count the number of unique smelly classes (Ds) and unique non-smelly classes (Db). For Python projects, use modules instead of classes as the unit of analysis.

  3. Implementation smells:

    Count the number of unique smelly methods (Is) and unique non-smelly methods (Ib).

  4. Compute fitness score:

    The fitness score is computed as \(Fitness = \frac{1}{3} \left( \frac{A_b}{A_b + A_s} + \frac{D_b}{D_b + D_s} + \frac{I_b}{I_b + I_s} \right)\).

The fitness score ranges from 0 to 1. We round the result to two decimal points and associate it with the corresponding commit ID for tracking over time.