Skip to content

varScoper 1.0 release

by Mike on July 20, 2006

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



From → ColdFusion, varscoper

11 Comments
  1. 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 :(

  2. 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

  3. 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.

  4. Er, that should be Java Heap. Obviously, I was talking about where the problem is really happening (in my head)!

  5. Lola Lee Beno permalink

    This seems to be working fine on my OSX setup . . .

  6. makrow permalink

    sweet tool! wish i still did CF development.

  7. 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.

  8. John Farrar permalink

    Not only CFScript… but what about embedded javascript on page… does it know how to look through that and find just the CF variables?

  9. 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.

  10. Kerr permalink

    Just wanted to say thanks for this awesome tool. I’ve added it to my arsenal of debugging tools and use it regularly.

  11. Vivek Verma permalink

    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>
    —-

Comments are closed.