CodeSOD: Waiting for File IO…
by Remy Porter from The Daily WTF on (#4Q34)
Trisha had the misfortune to inherit some old Cold Fusion code. One particular block needed to see if a file existed before it continued, and apparently the original developer really wanted to be patient and make sure the file was there, so they wrote this:
<cfif not fileExists(tPath)> <cfset CountR = 0> <cfloop index="ii" from="1" to="1000000"> <cfset CountR = CountR + 1> </cfloop> <cfif not fileExists(tPath)> <cfset CountR = 0> <cfloop index="ii" from="1" to="1000000"> <cfset CountR = CountR + 1> </cfloop> <cfif not fileExists(tPath)> <cfset CountR = 0> <cfloop index="ii" from="1" to="1000000"> <cfset CountR = CountR + 1> </cfloop> <cfif not fileExists(tPath)> <cfset CountR = 0> <cfloop index="ii" from="1" to="1000000"> <cfset CountR = CountR + 1> </cfloop> <cfif not fileExists(tPath)> <cfset CountR = 0> <cfloop index="ii" from="1" to="1000000"> <cfset CountR = CountR + 1> </cfloop> <cfelse> <cfset Good2Go = "Yes"> </cfif> <cfelse> <cfset Good2Go = "Yes"> </cfif> <cfelse> <cfset Good2Go = "Yes"> </cfif> <cfelse> <cfset Good2Go = "Yes"> </cfif><cfelse> <cfset Good2Go = "Yes"></cfif>[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!