Cover Image by fullvector on Freepik
Truth can only be found in one place: the code
The above quote is by Robert C. Martin from his popular book Clean Code. The one sentence says a lot about programming as the original source of truth is the code. In his book, he emphasizes writing better code by implementing clean code practices. Writing good code also deals with more than clean code. It can be in the form of having a good folder structure, knowing the codebase, removing unnecessary dependencies, and others.
There are also tools that can help you in implementing these practices. That’s why we are going to look into such tools for enhancing code quality.
So, let’s get started.
A search engine for your codebase; Ask Documatic a question and find relevant code and insights in seconds
The first step in writing better code is to know your codebase. When you write code in an organization or in a team, you are not going to write the whole codebase. Also, you might get appointed to an ongoing project. In such cases, knowing your code will help you in writing better code. To understand a code, you need to get your answer solved about the codebase. Documatic is one such tool that helps you in solving your question related to a codebase.
It is a codesearch engine for your codebase. You can ask questions as you will ask a maintainer about code. It will get your answer solved by providing a relevant code block from the codebase. The search engine also understands the code structure.
You can make search from your web application, VS Code using the extension and from Slack. You look here for the VS Code extension.
Clean Code using Code Spell Checker and Prettier
For clean coding, I have two tools on the list.
Code formatter using prettier
The readability of code is one of the important aspects of good code. We can use a code formatter for increasing the readability of code. One of the best code formatter extensions on VS Code marketplace is Prettier. It’s easy to set up and use as it doesn’t need a lot of setting up. You need to change your Default Formatter to Prettier from the User setting.
On every save, prettier will run for formatting the code. It has support for most of the popular languages. You can use plugins for other languages.
Code Spell Checker
Spelling checker for source code
A basic functionality but an important one. Code Spell Checker is a VS Code extension that will check your code for spelling errors in the name of a variable, function, or class. It will also check your comments for spelling errors. Removing spell errors will make your code more readable and a way towards clean code.
It has support for English(US and GB) but with an add-on, you can add support for more than 20 languages. This includes French, German, Italian, Spanish, Russian, and others.
Webpack Bundle Analyzer
Webpack plugin and CLI utility that represents bundle content as a convenient interactive zoomable treemap
Reducing file size is an important aspect of writing better code. Production-ready code is all about optimization. You can do that by removing unnecessary dependencies. The Wepback bundle analyzer will help you analyze the size of every dependency. They provide you with an interactive tree map visualization of your dependencies for analysis. You can interact with that by clicking and zooming.
Modern native git hooks made easy
Run test scripts before pushing code to a repository with Husky. This will help you by giving out any error in your code before pushing. You can run a different test to see the working of the code. Along with running tests, you can lint your commit messages and code. In this way, there will be less problematic code that is pushed to production.
It works using the git hooks features of Git. Git hooks let you run scripts before or after committing, pushing, and receiving. Install husky to your machine using the guide here.
Connect With Me
All the above tools are fantastic. Writing better code is not just the code, it's how you present, understand and read the code. With Documatic, you can understand the code. Using prettier and code spell checker, you can write readable code. ESLint and Husky will let you write less problematic code. Bundle Analyzer will help you in creating a lightweight application.
I hope the article has helped you in knowing some awesome tools to write better code. Thanks for reading the blog post.**
Top comments (4)
Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍
What's your recommendation for tools that assists in writing better code?
Just ESLint + Prettier combination works fine for me. And I also recommend these. 😀
Out of 6 tools mentioned, 2 of which, the ESLint and Prettier, I have integrated and been using on company projects. They help a lot.