Home » JavaScript » Static code analysis for free

About Juri Strumpflohner

Juri Strumpflohner
Juri Strumpflohner mainly operates in the web sector developing rich applications with HTML5 and JavaScript. Beside having a Java background and developing Android applications he currently works as a software architect in the e-government sector. When he’s not coding or blogging about his newest discoveries, he is practicing Yoseikan Budo where he owns a 2nd DAN.

Static code analysis for free

Although JavaScript might be the world’s most misunderstood language, it is now among the most popular and most used ones. Thus you should also treat it as such. Meaning, to properly structure your frontend, apply code linters, automated testing… The available tools make that even easier than you might think.

You can’t control what you can’t measure Tom DeMarco

A quote that remained me from my university studies. But it’s damn hard, isn’t it? You need to collect data, process and prepare it, in the best case visualize it in some way s.t. you can then analyze and draw conclusions from it.

Fortunately JavaScript has a huge community behind which releases new tooling on a daily basis. Plato gives you static JavaScript analysis and reporting for free. It is as simple as installing it from npm

$ npm install plato

and then executing it on your codebase.

$ node_modules/.bin/plato -r -d plato-report -t 'My report title' -x .json ./src

As a result you’ll get an amazing report with dozens of different visualizations of your data, generated directly into your specified output folder plato-report. Below is an example screenshot from the official Plato website of the result of running it on the jQuery codebase.

plato-jquery-1

Conclusion

Give it a try and see whether it makes sense for you. The job of a good developer is not only to implement the feature the customer requested, but to implement it in the best of his knowledge. As part of my daily job I have to care about the design of the application, about the “beauty of the codebase” as I like it to define.

Plato makes it extremely easy to generate a report, so the real challenge is to interpret the results, identify potential weaknesses and sanitize them accordingly.

So what I did is to create a Jenkins job which generates and publishes the reports on a webserver where all of our devs have access to. Takes you a couple of minutes but it’s extremely useful.

Reference: Static code analysis for free from our WCG partner Juri Strumpflohner at the Juri Strumpflohner’s TechBlog blog.
(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Web Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. Building web apps with Node.js
2. HTML5 Programming Cookbook
3. CSS Programming Cookbook
4. AngularJS Programming Cookbook
5. jQuery Programming Cookbook
6. Bootstrap Programming Cookbook
and many more ....
I agree to the Terms and Privacy Policy
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments