Friday, April 08, 2011

Filtering JustCode Errors and Warnings

JustCode is an awesome Visual Studio productivity tool, built on an incredible code analysis engine that works across C#, VB, XAML, JavaScript, HTML, and ASP.NET. This goes well beyond Visual Studio's ability to only analyze VB and C#, and opens the door to some cool features, like navigation and code analysis in JavaScript files.

But what do you do when you have files, or "categories" of files, that you'd prefer JustCode ignore?

There are cases where perfectly valid runtime code- usually code not written by you- generates distracting JustCode errors and warnings. A good example is minified JavaScript files. While technically valid JavaScript, the shorthand notation can sometimes cause JustCode to report extra warnings. Fortunately, there's an easy filtering solution!

How to Add JustCode Filters

JustCode supports filters that essentially "hide" errors and warnings for specific files. A filter works by matching any part of a file's full path (case insensitive). By default, JustCode ships with these filters enabled:


These four filters, separated by semicolons, will hide any errors or warnings generated by files with ".designer.cs/vb" or "\Reference.cs\vb." Designer and Reference files usually contain auto-generated code in Visual Studio, which is why we want to ignore them.

To edit filter settings, use the Visual Studio JustCode menu to navigation to Options > Code Analysis > General where you'll find two textboxes: Exclude file filters and Exclude project filters.


Ignoring Minified JavaScript

Let's add a filter to ignore minified JavaScript to JustCode. By default, I have a web project with JustCode and several minified JS files (such as jquery.min.js and modernizr.min.js). With default settings, JustCode reports no errors, but does report 102 warnings, mostly consisting of issues related to my minified script.


To eliminate all minified script errors and warnings, I'm going to add a filter to tell JustCode to hide these issues for any file that has .min.js in the path.

I navigate to JustCode > Options > Code Analysis > General and add ";.min.js" to the existing filters in the Exclude file filters textbox, producing:


Once I save my new settings, JustCode updates the error and warning reporting UI (the only part of JustCode that runs in the Visual Studio process, I might add- that's how JustCode avoids creating VS lag). We now find that my project has only 2 errors, which I rightly should consider addressing.


Filtering Limits

Today, JustCode's filtering only supports matching the strings you provide in file and project paths. There is no support for wild cards or other more advanced pattern matching techniques (like RegEx). That said, the product team has received feedback from enough customers to add more power to JustCode's filtering abilities, that you'll very likely seem more advanced options for filtering in the future. Until then, you should find that even this basic filtering enables you to cover 90% of the common cases where you why JustCode to hide errors and warnings.

So, setup those filters and make sure the errors and warnings JustCode is reporting are the ones that truly need your attention!

Not using JustCode yet? Give it a try for free. If you don't like it, tell me why: