DEV Community

Cover image for Can Maintainability Be Measured? Trying It on NestJS
Bohdan Turyk
Bohdan Turyk

Posted on

Can Maintainability Be Measured? Trying It on NestJS

We talk a lot about maintainability, but it often stays a gut feeling. I got curious: what if I tried to put numbers on it, using well-known metrics like coupling, cohesion and complexity?

That curiosity turned into a library: nestjs-maintainability.

What it does

It reads your NestJS source code — no booting the app, no runtime instrumentation — resolves the @Module() metadata and the DI graph, and reports metrics per module:

  • Coupling — how entangled a module is with the rest of the app
  • Cohesion — whether a module's dependencies stay inside it
  • Complexity — how hard a typically hard function there is to read
  • Size — whether one module dominates the codebase
  • …and a few more

These get combined into a single 0–100 maintainability score with a letter grade.

Trying it is one command:

npx nestjs-maintainability analyze
Enter fullscreen mode Exit fullscreen mode

Please don't take it too seriously

This tool was born out of curiosity. The numbers may be inaccurate, so take them as a rough reference rather than a precise measurement. Treat it as something to play with and learn from, not as a verdict on your codebase.

Feel free to try it out on your project and share what you think — I'd love to hear your impressions.

👉 github.com/benedya/nestjs-maintainability

Top comments (0)