Posts

Flotsam and Jetsam #111

  • My friends David Millington and Roman Yankovsky have teamed up to offer a Christmas time special.  You can buy both of their tools for the price of Fix Insight.  What are those tools?  Well, David’s tool is Navigator – a powerful, easy to use way to navigate your code.  Roman’s tool is Fix Insight – a static code analysis tool.  Right now, you can get both for the price of Fix Insight – that’s a $40 in savings.  I can vouch for both tools as being very useful and of high quality.  Don’t miss this good chance to get two excellent tools at a low price.  (While you are at David’s website, be sure to download the excellent and free Bookmarks plugin. And did you know that he has some open source items available as well?)
  • ‘Tis the season for Delphi updates.  Of course, Delphi 10 Seattle Update 1 is out.  It even includes a few new features.  It is available for all people on Update Subscription.  (For those of you complaining about this, I hate to say it, but you were given plenty of warning and opportunities to get on board.)  Dr. Bob reports on two hot fixes that are also available.
  • It looks like I’m going to be speaking in Denmark in April at DAPUG’s annual conference.  I have spoken twice before, and have always enjoyed my trips there, and the fine hospitality provided by Jens Fudge and his family.  I’m looking forward to speaking there again.  Not 100% sure what the topics will be yet, but I promise it will be interesting.
  • I had a great time at EKON 19 – you should attend next year no matter where you are in the world – and the thing I enjoyed the most was my three hour seminar on Dependency Injection.  I covered Dependency Injection in Coding in Delphi,  but things have changed in the mean time, and there have been additions to the Spring for Delphi framework that make things even more powerful and capable.  So much so, in fact, that I’ve decided to write a book entitled Dependency Injection in Delphi. It will very likely be shorter than my other two books, and I think to start I’ll sell it as an ebook only (MOBI, ePub, and PDF) on Leanpub.  It will, however, go into Dependency Injection much more in depth than my two chapters in Coding in Delphi.   In any event, you can follow this link and sign up for updates about  the book and let me know how much you think I should charge for it.  There’s absolutely no time table on this – as you saw above, I have a lot of preparation to do for DAPUG – but I will be working on it.  I’ll go with “it will be available later this year”.  Again, I’m humbled and grateful by all the people who have bought my books.  

Review: FixInsight

A confession:  I was given a free license to review FixInsight.

A summation:  I really like it.  It’s in a category tool that I think most Delphi developers don’t take advantage of. 

A statement:  It’s not as powerful as Delphi’s Code Audits, but it is more usable.  I presume that Roman Yankovsky will continue to improve it and eventually it will cover as many rules as Code Audits does.  Start using static analysis today, one way or another.

Full Comments:   FixInsight is a static code analysis tool.  A static tool is one that examines the code itself, apart from any runtime environment.  It uses a parser – in this case, a fork of Jacob Thurman’s Pascal Parser – to examine the code and apply a set of rules against the result.  Those rules can point to questionable constructs in your code that may be bugs or other problems.  You can use static analysis to enforce formatting rules,  find places where coding conventions have not been followed, and to enforce specific coding techniques.  The compiler will do a lot of this kind of thing for you, but there are certain things that the compiler won’t see that

FixInsight does all of this for you in the IDE.  Once installed, it provides a menu item that brings up the following dialog:

image

From here, you can select or unselect the Conventions or Warnings that you want to verify.  Some of the Conventions and Warnings can be configured as shown above where you can set the maximum number of variables that will be allowed in a given method on the right side of the window.

Conventions are things that “should” be done a certain way; they might be described as enforcing a certain coding “style”.  For instance, Convention C107 ensures that all private field variables in a class start with ‘F’, a long time Delphi convention. 

Warnings are coding constructs that “look suspicious”.  Things like a destructor without an inherited call, or the dreaded “Empty EXCEPT block” – that is, things that are likely just wrong code and that could cause problems in the execution of your code.    A warning basically says “Something doesn’t look right here and you should take a close look to make sure that all is well and correct”.

Running Fix Insight operates much like the compiler and produces Convention and Warning messages in – Surprise!  — the Message Pane:

image 

If you double click on one of the items, it take you to the spot in your code where the problem occurs.   Nice.

FixInsight also includes a command line tool for inclusion in a continuous integration process.  In fact, I’d recommend this be the main way you use it.  It can be used to fail a build that finds code in your repository that doesn’t conform to your definition of “clean” code. 

You can tell FixInsight to ignore chunks of your code via the _FIXINSIGHT_ compiler directive.

The documentation is quite nice, with each rule clearly explained, though I found that FixInsight’s descriptions are very easy to understand, and you shouldn’t have any trouble figuring out what it is trying to tell you. 

Here’s how I recommend you use FixInsight:

  1. Establish a set of Conventions and Warnings that you want to enforce.
  2. Use the IDE tooling to ensure that your code conforms to those rules and that you never check in code that violates any of your rules
  3. Run the command line tool as part of your continuous integration process, and break the build if any checked in code violates your rules

Do that, and it will go a long way towards keeping your codebase clean and tidy.

You can download a trial version of FixInsight here

I presume that Roman will add more Conventions and Warnings to future versions — there’s a lot of room here to do some very cool things.

Bottom Line:  FixInsight is a fine entry into the Delphi Third-party market.  Whether you decide to use it or Delphi’s own tool, you should be including static code analysis into daily routine and your continuous integration.