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: https://github.com/cfjedimaster/CFLint-Extension.
Archived Comments
Will the CFLint project work with Sublime Text 2?
Ignore please. Reposting to subscribe.
Check out the CFLint project - they link to a Sublime version.
Good article, Ray. We'll have to see what we can do about a progress bar.
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.
@Dan @Raymond Thanks. I've seen the Sublime 3 package, but 3 is still in beta. Is anyone using version 3 yet?
@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...
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.
Oops, I'll add code to disable debugging in the extension, that way you can leave it on.
The code has been updated.
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.
In CF Builder, ensure you have callbacks enabled and are using the full or trial edition of CFB, not express.
It is enabled, and it is the trial of CFB3
Best I can suggest is to check your CF logs. Extensions are just CFML and log the same.
does it lint cfscript code?
I honestly don't remember. I'd check with the project owner.
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.
I have to admit I had forgotten about this. :)
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.
I'd ask the project owner. I haven't used this since the blog post as I don't do much CF work anymore.