Tokei is a free code analysis tool to generate code statistics for programming projects. Here it takes single or multiple directories from you and generates detailed statistics that you can analyze. It analyzes the code files in the directory and generates statistics about the line of codes, blanks, comments, etc., ordered by programming languages. Not only this but you can even export the statistics that t generates in a file. It can export the code statistics in JSON, YAML, and TMOL format. You just have to run a single command to generate stats and it works on all platforms.
If you want to generate code statistics of projects you are working on then the tool I have mentioned here will help you. Just install it on whatever platform you are on and then you are just done. There is just one command that you have to use in order to do all the hard work. In the end, you just analyze the table with statistics that it produces and then do whatever you want. It supports almost all the programming languages and this is an open-source tool as well. If you want then you can find its repository on GitHub and even contribute to it.
See Lines of Code, Comments, Language Statistics of Programming Projects
Using this simple command-line tool is very simple. You just start by installing on your PC and it can be installed in different ways based on what operating system you are using. If you work with Python and have Anaconda distribution installed then you can install it through that. You can run the ‘conda’ command like this and wait for it to install.
conda install -c conda-forge tokei
Now, Anaconda has installed it properly, you are all ready to install it. The basic command to analyze a single directory or multiple directories is below. You just type “tokei” and then specify directory names afterward. You can see the screenshot below to understand how it works.
By default, it generates a table with all the stats on the command line. But you can append a simple switch in the above command and then produce output in JSON, YAML, and TOML format. You can even pipe the CLI output to a file and then you can simply do whatever you want with it. See the screenshot below.
tokei ./work --output json > stats.data
In this way, you can use this simple and powerful tool to analyze the code of any programming project. The output it generates is very nice and you can use it on your persona and work projects. There is a simple command there that does the job and you can have the output in any format you want.
Code analysis is kind of necessary for some projects and if you are about to do it then I will suggest you use Tokei. IT is simple and very easy to use. And what I liked best about it is that you can use to analyze multiple projects in one go. So, if you are looking for a code analysis tool then use the one mentioned here.