simonrenoult / code-complexity

Measure the churn/complexity ratio. Higher values mean hotspots where refactorings should happen.
MIT License
281 stars 28 forks source link

Measure cohesion score #42

Open simonrenoult opened 2 years ago

simonrenoult commented 2 years ago

Context

Cohesion is a core element of software quality. It defines the degree to which the elements of a module belong together (source). Measuring cohesion means measuring how strong relationships between modules are.

Problem

Cohesive piece of code should move and change together. On the contrary, when two unrelated pieces of code move together, it reveals a strong relationship between them, which reveals design weaknesses.

Idea

Since cohesive pieces of code move together, they are likely to be changed within the same commit. Cohesive pieces of code are located close to each other. If they are not, we can argue that cohesiveness weakens.

Furthermore, if a commit contains unrelated pieces of code, then we could argue that cohesiveness also weakens.