How to determine which files ColdFusion uses?

I am starting work on an existing ColdFusion application without version control, and that looks like unused cfm files (test.cfm, test2.cfm, etc.). I would like to get an idea of ​​which files are actually part of the application, so I can get it in git or subversion in a managed state.

How would you do that? Regular expression and some methods for finding and matching cfinclude and cfcomponent tags? Is there any existing tool that does this?

+4
source share
6 answers

Ben Nadel has a way to examine the direct stack trace from a working template. It seems to me that you can easily transfer this to your application and register the results in a database. After you have done this, you have a good idea of ​​what is used and what is not.

I think the easiest way is to enable debugging (the standard disclaimer here is about the development server, etc.). The standard ColdFusion debugger provides you with a complete list of all files used at runtime on a single page. ColdFire will do the same in a convenient Firebug extension (click "ColdFusion", then "Exec Times").

It should be noted that the built-in debugger even shows you the files included in CFC calls, as well as the files included in these calls. It is all inclusive .

Ben Nadel on a stack trace

Ray Camden ColdFire

Example CF debugging from a live page:
alt text http://i43.tinypic.com/ofvh37.jpg

+10
source

Paste it into git first! . Then, if you mess up, you can easily fold back.
(If you are concerned about having a β€œclean” repository, when you are done and fully tested, you have the option to simply delete one .git folder and create a new one.)

Then, as Tomalak suggests, use cflog for each file. Infact I would say that perhaps even logging twice, above and below each script, could potentially help you determine how the application works.

+4
source

Regular expression is not recommended. Since ColdFusion is quite flexible in how files can be included or specified, it will not be possible to determine the final list of dependencies only from the source code.

You can insert <cflog> into each file and create a log from a running application. Examine the log after the application has been active for some time, and all functions were available at least once.

+3
source

Do not document every file, just copy the page name into OnRequest inside application.cfc - the target page is an argument.

Of course, then the problem becomes code coverage and the ability to fully use the application.

 <cffunction name="onRequest" returnType="void"> <cfargument name="targetPage" type="String" required=true/> <cflog file="Usedpage" text="#Arguments.targetPage#"> <cfinclude template="#Arguments.targetPage#"> ... </cffunction> 
+1
source

cfinclude will not tell you if url should download the file directly. I saw a system in which some files are not included through index.cfm, even if the environment expects this. I have this in my own work, where index.cfm loads most of the code, but reset.cfm bypasses the infrastructure to reset configurations and session data.

0
source

Download a trial version of Dreamweaver and define the ColdFusion site. DW can create a sitemap and tell you which files are not included, linked, cfmoduled, etc. I don't know if he can identify unused CFCs, but CFMs should be lightweight. Please note that I have not used DW for many years, but had this functionality around CF 4/5.

0
source

All Articles