buried treasure

from Jargon File (4.4.4, 14 Aug 2003)
buried treasure
 n.

   A surprising piece of code found in some program. While usually not
   wrong, it tends to vary from {crufty} to {bletcherous}, and has lain
   undiscovered only because it was functionally correct, however
   horrible it is. Used sarcastically, because what is found is anything
   but treasure. Buried treasure almost always needs to be dug up and
   removed. "I just found that the scheduler sorts its queue using
   {bubble sort}! Buried treasure!"
    
from The Free On-line Dictionary of Computing (8 July 2008)
buried treasure

   A surprising piece of code found in some program.  While
   usually not wrong, it tends to vary from {crufty} to
   bletcherous, and has lain undiscovered only because it was
   functionally correct, however horrible it is.  Used
   sarcastically, because what is found is anything *but*
   treasure.  Buried treasure almost always needs to be dug up
   and removed.  "I just found that the scheduler sorts its queue
   using {bubble sort}!  Buried treasure!"

   [{Jargon File}]
    

[email protected]