CodeSOD: The Destination Dir

Date:

Share:

Darren is supporting a Delphi application in the current decade. Which is certainly a situation to be in. He writes:

I keep trying to get out of doing maintenance on legacy Delphi applications, but they keep pulling me back in.

The bit of code Darren sends us isn't the largest WTF, but it's a funny mistake, and it's a funny mistake that's been sitting in the codebase for decades at this point. And as we all know, jokes only get funnier with age.

FileName := DestDir + ExtractFileName(FileName);
if FileExists(DestDir + ExtractFileName(FileName)) then
begin
  ...
end;

This code is inside of a module that copies a file from a remote server to the local host. It starts by sanitizing the FileName, using ExtractFileName to strip off any path components, and replace them with DestDir, storing the result in the FileName variable.

And they liked doing that so much, they go ahead and do it again in the if statement, repeating the exact same process.

Darren writes:

As Homer Simpson said "Lather, rinse, and repeat. Always repeat."

[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

Source link

Subscribe to our magazine

━ more like this

The Bridge of Lies in Sibiu, Romania

This is the first forged-iron bridge in Romania, and one of the most important symbols of the city. Due to the fact that it...

Calvin Klein Short Puffer Jacket With Scarf Review

While each product featured is independently selected by our editors, we may include paid promotion. If you buy something through our links, we may...

My Entire Job Is Based on Testing 3D Printers and These Are the Ones I Recommend

Every build plate is supposed to heat up to a certain temperature, so we use the InfiRay thermal imaging camera...

Trump Lashes Out in Unhinged Thanksgiving Message & Hegseth in Hot Water Over Possible War Crimes | Jimmy Kimmel Live

Trump spent the Thanksgiving holiday at Mar-A-Lago where he issued a warm Thanksgiving message and lashed out...

Share a tip on taking part in an organised challenge in the UK or overseas | Travel

Forget the sun lounger, more of us than ever before are signing up for trips which involve completing a tough physical challenge, whether it’s...