DEV Community

Cover image for 
One of the dark sides of open source software
Horacio Rivero
Horacio Rivero

Posted on • Edited on

One of the dark sides of open source software

This time I will tell you about a bookstore which is one of the most used in the world of web development called Terser.

The programmers of this library have created a new repository with an attractive logo and that has 90% of the old code, but why is the code of such poor quality?.

Note: I am not going to focus this time on talking about a security problems, only i focused on speak about code quality problems.

This library has a method that contains 208 lines of code with a cyclomatic complexity of 76. It is obviously a huge bloater smell, it has 46 if, 4 else, several nested if, variables that perform hoisting, 2 throw statements, mutates the values of some variables multiple times, including those of the input parameters, it returns two totally different values, all that within a try catch block, this library is undermined by this type of problem in all of his code.

This is just an example, much of the open source code that me, you and you great company use every day, is undermined by all kinds of code smells and design problems.

This library for those who do not know is the successor of UglifyJS, has 9,310,994 weekly downloads, I guess the developers, probably see these problems, but decided not to do Yak shaving, but well I think nobody wanted to refactor that for obvious reasons.

Those who want to see the specific method here i leave the link:

Terser smell code

Conclusión:

  • This is a library that is used in the development environments,
    the impact that this problem can cause, will only affect the processing times,
    but what would happen if it were a library that is used in productive environments, what impact would it have?.

  • If someone wants to collaborate or improve aspects of this library, they will find a code very difficult to understand, test and maintain.

  • Should be a law that every programmer must understand and know how create clean code o or understand about refactoring, and obviously the basic principles of software design.

  • Although it is ghost and unpaid work, it does not have to be of poor quality, remember that this represents what type of programmer you are.

Leave me your comment, and tell me, you use libraries without first reviewing the code, are you guided by his reputation, or maybe for the many stars they have on github?.

Maybe in my next articles write more in depth of other problems of the open source code.

Greetings to all!

Top comments (0)