Linting your ColdFusion code

This post is more than 2 years old.

Earlier this week I discovered a new project on GitHub, CFLint. For my readers who may not be aware, linters are tools that inspect your code for bugs, best practices, and other issues. Numerous different types of linters exist, but as far as I know this is the first one for ColdFusion. It is still a bit rough (in my tests it would routinely have parsing issues on some of my files) but it is a good start and I think it could be a great tool for ColdFusion developers.

You can test this yourself on the project's releases page. They included scripts for both OS X and Windows. The core code is Java based if you want to peak under the hood. Like most linters, you can also disable rules you don't agree with. As I said, it isn't perfect, but I'd strongly urge folks to check it out and - even better - help improve it.

Want to test it out with ColdFusion Builder? I worked on an extension for it last night. You can right-click on a project, folder, or file and scan it using CFLint. As an example:

You can click on each line item to open the file right to the line reported by CFLint. Currently the biggest issue is that it doesn't provide feedback while it is working. If you test it on a large project, keep that in mind. You can download my extension here:

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Donnie posted on 7/31/2014 at 7:33 PM

Will the CFLint project work with Sublime Text 2?

Comment 2 by Donnie posted on 7/31/2014 at 7:34 PM

Ignore please. Reposting to subscribe.

Comment 3 by Raymond Camden posted on 7/31/2014 at 7:35 PM

Check out the CFLint project - they link to a Sublime version.

Comment 4 by Ryan Eberly posted on 8/1/2014 at 6:07 AM

Good article, Ray. We'll have to see what we can do about a progress bar.

Comment 5 by Dan Kraus posted on 8/1/2014 at 8:59 AM

Donnie, I happened to be looking at this today. Seems
Iike Sublime support is only available with SublimeLinter3 which is a Sublime 3 package.

I had thrown it at a smaller application. I got a lot of warnings back that had no description. Need to take a closer look but this is a great start and better than nothing at all. It's like varscoper taken to the next level.

Comment 6 by Donnie posted on 8/1/2014 at 8:33 PM

@Dan @Raymond Thanks. I've seen the Sublime 3 package, but 3 is still in beta. Is anyone using version 3 yet?

Comment 7 by Dan Kraus posted on 8/1/2014 at 8:43 PM

@Donnie I'm not. I don't think there's been an update to ST3 beta in close to a year. I think the maintainer dropped off.

I was going to give ST3 beta a shot really for purpose of integrating directly in with CFLint but the prospect of retooling all my configurations, packages, and everything else seemed a bit daunting. Also, some people on my team noted some issues with our project in ST3. I could see in the console it trying to constant read a non-open file that is particularly lengthy. ST2 has issues opening up. I think it screws with the formatter. But again, only when you actively try to open it. ST3 had things in the console log if it trying to constantly read it. Probably some sort of caching feature or something...

Comment 8 by Dave Jones posted on 8/5/2014 at 7:48 PM

Great extension, thanks Ray! When I first tried running this, I was getting an error in CF Builder: CFLint: Error occurred while parsing response from handler "/handlers/runlint.cfm". I discovered (through one of your previous blog posts) that this was because I had CF debugging enabled on the server I was running the extension against. I disabled debugging and the extension works great!

Hope this comment helps anyone else who might run across this issue.

Comment 9 by Raymond Camden posted on 8/5/2014 at 7:50 PM

Oops, I'll add code to disable debugging in the extension, that way you can leave it on.

Comment 10 by Raymond Camden posted on 8/5/2014 at 7:52 PM

The code has been updated.

Comment 11 by Derek posted on 8/7/2014 at 11:49 PM

I am trying this out, but it's not working correctly. I see a window pop up for a brief second after i call it, but that's it. No new tab shows up like in your image.

Comment 12 by Raymond Camden posted on 8/7/2014 at 11:50 PM

In CF Builder, ensure you have callbacks enabled and are using the full or trial edition of CFB, not express.

Comment 13 by Derek posted on 8/7/2014 at 11:56 PM

It is enabled, and it is the trial of CFB3

Comment 14 by Raymond Camden posted on 8/8/2014 at 12:08 AM

Best I can suggest is to check your CF logs. Extensions are just CFML and log the same.

Comment 15 by aaorn posted on 12/5/2014 at 4:09 PM

does it lint cfscript code?

Comment 16 (In reply to #15) by Raymond Camden posted on 12/5/2014 at 4:12 PM

I honestly don't remember. I'd check with the project owner.

Comment 17 by orcpac7 posted on 2/10/2015 at 8:06 PM

Thanks Ray, I discovered your blog entry after getting CFLint going... Saw it in a Sublime blog somewhere, never got it running there, but went ahead and tooled up to install it as a stand-alone and VERY happy, though it has a way to go.
Just as an aside, I've been using Chris Weller's "CodeChecker" for some time, a linter written in ColdFusion and extensible as well, but nowhere near as fast as CFLint.

Comment 18 (In reply to #17) by Raymond Camden posted on 2/10/2015 at 8:10 PM

I have to admit I had forgotten about this. :)

Comment 19 by Leslie Sherman posted on 5/18/2015 at 8:56 PM

Hi, I noted that the cflint extention for CFBuilder works for CF 10. Does it also work for CF 11? We are migrating from CF 9 to CF 11 and want to do some testing of how much code may be affected by the removed tags and tag parameters. A lint checker seemed like a nice way to do this.

Comment 20 (In reply to #19) by Raymond Camden posted on 5/18/2015 at 9:05 PM

I'd ask the project owner. I haven't used this since the blog post as I don't do much CF work anymore.