Monday, November 27, 2006

Static Code Analysis for Javascript

I'm a big believer in static code analysis. It is one of many tools that can assist in developing quality software. And while it's no panacea, in my opinion it's a tool set that's underutilised. Today I took some Javascript code I wrote at work and ran it through a couple of static analysis tools.

http://www.jslint.com/ is an online tool which produces some very nice output. Just cut and paste your code into the window, press the button and it analyses your code. There is also a downloadable version.

http://www.javascriptlint.com/ doesn't have as nice an interface, but comes with a customizable batch script and configuration file. It would be better for production environments dealing with larger amounts of code.

Both tools highlighted a couple of coding mistakes I had made (specifically an operator which could have resulted in an implicit type conversion). Implicit type conversions are bad because while the program may continue to run, it means the programmer has likely lost track of which variable types he's using, which is always a bad situation.

2 Comments:

Blogger Unknown said...

I know this is a old post but check out http://www.jsure.org/ .

6:35 p.m.  
Blogger Shawn Abigail said...

Thanks for the link. I'm not programming in JavaScript anymore, but who knows what the future holds.

8:45 p.m.  

Post a Comment

<< Home