Static Code Analyzer for Obj-C

xcode.jpg

OK, I've been coding for a long time. I've used lots of development environments and the only one that I've found that really holds my interest is ProjectBuilder/Xcode on Mac OS X. From the first time I used it on NeXTSTEP 3.3, I knew it was something far beyond an editor with build tools. It was just so clearly built by developers, for developers. I'm still of that same opinion today.

This morning I read about an interesting tool that analyzes the Obj-C/C code and tells you where you might have issues with leaks, etc. Nothing that hasn't been covered a dozen times before in a dozen different tools, but this one is a little different. First, it's a syntax checker. Again, lint did this for decades, but this is different in that it knows about the idioms of Obj-C and the class structure that Mac OS X uses. That's huge.

Next, it's slick in it's reporting in that it's all web-based and generates all this very simply. I'm not a big fan of web apps, but for reporting, it just can't be beat. What they have done here is the very best of web reporting for coding issues, and I have to say it's remarkable.

I decided to put in one of my projects to see what it might find. Interestingly, it found a possible error in one of my classes in that I wasn't creating a - (void)dealloc method for the instance. Now, technically, the class involved is the main controller class, and it would not get deallocated except on shutdown, so there's no real problem there, but it's nice to keep things clean and try to do the right thing all the time. So I added the very simple method and re-ran the checker. Clean, save for a dead store issue that I'm not about to change as it's really just the last part of a method that doesn't return the error code. It's more of a coding style than an error, but I appreciate that it's telling me about this.

While I'm not doing a lot of Obj-C coding these days, it's tools like this that make me want to change jobs so that I did do a lot of Obj-C coding. The Mac is a wonderful platform, and its development tools are the best I've ever seen. With the addition of tools like this code analyzer, it's even better. Long live the Mac!