ColdFusion Snippet Stumper

I ran across this bit of CF code in a project that I'm working on upgrading, and I was so completely confused by the it that I thought I might throw it up here to see what people think of it.

...

<cfloop query="GetTimesheetData">
    <cfset additionalNumber = additionalNumber />
    
    <cfloop from="#startDate#" to="#endDate#" index="i">        
        <cfset temp_list="hours_#projectCode#_#taskCode#_#positionCode#_#i#" />
        <cfset temp_projectCode = ListGetAt(temp_list,2,"_") />
        <cfset temp_taskCode = ListGetAt(temp_list,3,"_") />
        <cfset temp_positionCode = ListGetAt(temp_list,4,"_") />
        <cfset temp_WorkDate = ListGetAt(temp_list,5,"_") />
        
        <cfif temp_WorkDate eq i>
            <cfif temp_projectCode eq projectCode>
                <cfif temp_taskCode eq taskCode>
                    <cfif temp_positionCode eq positionCode>
                        <!--- Do stuff with the data --->
                        ...
                        
                    </cfif>
                </cfif>    
            </cfif>
        </cfif>
    </cfloop>
</cfloop>

...

I personally cannot think of anything that the code inside the <cfloop> actually accomplishes. Am I missing something?

 

Comments

Rick O's Gravatar It seems like a particularly kludgy way of making sure the project and task codes don't have underscores in them ...
Jon Hartmann's Gravatar @Rick Yeah I guess it would let you check that... From its original context though, I wouldn't think that that was the intended effect though, since those values shouldn't include underscores anyway. That said, I have no idea what the code is supposed to do, so you've got the winning idea so far.
Greg Stevens's Gravatar All the if statements here are going always evaluate to true. Seems quite silly. I can see where Rick's underscore theory comes in but I don't think that is happening there. Just seems like this is completely useless. Guessing at some point of time maybe it did something but got changed probably to match the user's expected behaviour.

The statement like <cfif temp_positionCode eq positionCode> is always true because temp_positionCode is always going to be equal to positionCode since that is what it is set to with <cfset temp_positionCode = ListGetAt(temp_list,4,"_") />.

To confirm all statements are always true you could output something like #temp_WorkDate eq i# and #temp_projectCode eq projectCode# for each row, for each condition.
Jon Hartmann's Gravatar @Greg Yeah, thats what I'd decided was going on as well, but I figured I'd throw it up here just to see if I was missing something... that's such a large chunk of code to be doing _nothing_ that I kept thinking "it has to do something!"
Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me.

Post a job. Find one. authenticjobs.com

Interested in becoming a sponsor? Contact me.