varScoper 1.0 release

Today I am releasing version 1.0 of a project that I've been working on for a few weeks. It's a cfc that can be used to parse cfm and cfc files and identify variables that haven't been locally scoped within cffunctions.

varScoper can do the following....

  • Find unscoped variables created with a cfset within a cffunction
  • Find unscoped variables created with cftags (cfloop, cfquery, etc)
  • Report line numbers and link directly to the line in the file
  • Output to screen or csv

Hopefully everyone else will find this as useful as I do. There's a link in my projects section to the project page, or you can follow this link.

varScoper 1.0

You might be surprised at the results you find. I've been careful to scope my vars within the last few years, but I found an alarming number of potential problems in some of the code I was writing a few years ago when I first started with CFCs. In any case, try downloading the sample code, run it against your codebase, and do some housecleaning.

Here's a screenshot

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Sweet little app! Works really well on our staging enviroment!

The only challange we ran into is that it does not work so well on a mac.. (or any UNIX system for that matter) I gets the /'s arround the wrong way :(
# Posted By Lucas Sherwood | 7/20/06 1:30 PM
Thanks for pointing that out. I'll try to take a look at it, unfortunately I don't have any *nix systems set up right now, so it may take a little while
# Posted By Mike Schierberl | 7/20/06 2:52 PM
This is a totally incredible tool! It found LOTS of non-var scoped variables in my apps. Even though this means I've been careless, I'm very happy to be able to track these now. Hopefully my Java Head overrun errors will be a thing of the past.

One caveat -- as far as I can tell, the code doesn't run out of the box on *nix systems, since you use '\' when recursing directories, instead of using the native os delimiter.
# Posted By Toby Reiter | 7/20/06 4:04 PM
Er, that should be Java Heap. Obviously, I was talking about where the problem is really happening (in my head)!
# Posted By Toby Reiter | 7/20/06 4:05 PM
This seems to be working fine on my OSX setup . . .
# Posted By Lola Lee Beno | 7/20/06 6:27 PM
sweet tool! wish i still did CF development.
# Posted By makrow | 7/21/06 11:51 AM
Does it work also with cfscrip... most my variable declaration is made with cfscript ;)

and could you make your lyla captcha all UPPCASE or lowercase - this would help.
# Posted By Daniel | 10/18/06 5:38 AM
Not only CFScript... but what about embedded javascript on page... does it know how to look through that and find just the CF variables?
# Posted By John Farrar | 10/18/06 8:52 AM
At this point, it does not check cfscript, although it should handle cf tags within embedded javascript. At some point I'm planning to add cfscript support (at least for var declarations), but I can't promise when that will be. Unfortunately I don't have much cfscript in my code, so there wasn't a need when I wrote it.
# Posted By Mike Schierberl | 10/18/06 9:31 AM
Just wanted to say thanks for this awesome tool. I've added it to my arsenal of debugging tools and use it regularly.
# Posted By Kerr | 6/20/07 12:00 PM
Simply A M A Z I N G !!!

One thing I found that is still missing is multi-line CFTAGs. e.g. Some of my code looks like below and CFScoper didn't point out the problem in var scope [i.e. retVar]:
----
<cfinvoke
webservice = "MyWebService"
method = "myMethod"
returnVariable = "retVar">
      
<cfinvokeargument name="nm" value="vl" />
</cfinvoke>
----
# Posted By Vivek Verma | 7/26/07 8:57 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. Contact Blog Owner