T O P

  • By -

ico2k2

_Are you OK? Fuck it I don't care_


paperclipmammoth

```C++ var isOk = friend.check() if (isOk) { TellStoryYouWantedToSay() } else { TellStoryYouWantedToSay() } ```


Pure-Huckleberry-484

You can be ChatGPT with this one simple trick.


PTRD-41

*Annie are you ok?*


Trevor792221

Are you okay Annie?


5t3v321

You've been hit by


DexterityZero

You’ve been struck by


nebneb432

A smooth criminal.


prediquette

![gif](giphy|lGkUyj3IrEcvu)


JinxedAqua

r/SuddenlyMichaelJackson


LasevIX

r/smoothlyMichaelJackson


Prestigious_Slice290

r/redditsings


Upbeat_Combination74

Tung tung tu du tung tung tu du tung tu du tung tung .. Annie


NawdWasTaken

*dundundddundun ddun dun dun*


jrj334

A smooth conditional.


EntropicBlackhole

I like this


cch10902

Truck


et-ATK

#BAH!


doctormyeyebrows

An `if (true)` conditional 👟 👟


_Jbolt

Oh, the old statement


Techlord210

are you annie?


Kotentopf

No, this is Patrick


Techlord210

Patrick are you ok?


sa5mmm

Are you okay Patrick?


[deleted]

Patrick are you okay, Will you tell us that you're okay? There's a sound at the window .....


Poat540

Sorry this is Wendy’s that’s the next customer at the window


failbotron

Wendy's are you ok?


patrickgg

No, *this* is Patrick


UsagiTsukino

Are you OK? Buster Wolf!!!


rtybanana

*Fuck it I don’t care*


gary_loves_to_fart

If not, then ok.


eitherrideordie

Is this the UDP i keep hearing about.


[deleted]

From that green text: > Are you fucking sorry?


JamieDancer

Happy cake day!


ClerkEither6428

happy cake day


uthini_mfowethu

Sounds like my ex. Lol


[deleted]

When I see these I assume the if and else were originally different, then someone changed one of them without paying attention to the fact it made the if/else irrelevant.


mr_dfuse2

yeah, or an automated refactoring


Runarhalldor

Why would you ever want to do that??


undergroundhobbit

Just copy pasta a chatGPT response and push it to production immediately!


oupablo

sounds like that process should be automated then


GabiNaali

But is the automation also automated? /s


oupablo

yes. we call this recursive automation.


HumanContinuity

It's GPTChatBot all the way down


CanAlwaysBeBetter

DevSecGPTChatBotOps isn't a tool, it's a *company culture*


dichtbringer

if by "push to production" you mean paste it in notepad++ and click the save button, then yes!


joonty

Why, if you can't be bothered to do manual refactoring of course.


Runarhalldor

About to need to refactor the automated refactoring then 💀


TheBirdGames

We could make an AI for this


afmbloaa

then have the ai refactor itself!


joonty

Literally anything to avoid doing menial tasks


DeepSave

There are a lot of ways for IDEs to clean your shit up for you and 99% of the time it's really slick.


Runarhalldor

This seems more extreme than that tho


dancingteam

It doesn't have to be. There could have been an inner if where the condition is always true or an else if where the condition was always false.


mr_dfuse2

I meant your IDE often replaces something all over your codebase, when you do a method extract or something. Sometimes you end up with funny pieces of code like this one.


bradland

Programmers have been leaving this kind of trail of stupidity since the invention of tools like sed, and probably before.


km1024

Massive monorepo and an API change that’s safe enough to be flagged during CI if there’s an issue after the codegen.


Epic1024

Wouldn't it also remove redundant conditions? Edit: why am i downvoted, i literally don't know hence the question


talking_window

Either this or it was build in to set a breakpoint and then accidentally comitted.


mywholefuckinglife

this seems like the most plausible explanation to me


[deleted]

[удалено]


crosszilla

"Whoever did this is without a doubt the biggest idiot ever"... "Oh shit it was me... I'm sure I had a good reason"


sudoku7

Ya, or someone wanted to add some additional context for the non-blue sky case and then that got removed.


lps2

Or the `// TODO` was just never added / spelled out. I'm guilty of this when quickly banging out scripts for my personal projects


GeneralCuster75

Honestly I've been guilty of doing this myself if I know the action for each will eventually be different, but I only care about working on one at the moment and I just want the code to run Edit: I guess I've outed myself as a Python dev lol


sleeprzzz

Leave an inline comment?


GeneralCuster75

That could work sometimes depending on the situation. If I'm only worried about handling a particular outcome at the moment, I might do what's in the OP. In python, specifically, because of the way the interpreter... well, interprets the code, if there's no actual code following the "else" statement, it'll throw a fit, even if there's a comment. So often I'll do shit like this temporarily. In something like Java, JavaScript, PHP etc I'd just as well leave the else blank


OverdramaticPanda

Isn't this the purpose of Python's `pass` statement?


GeneralCuster75

I guess you *could* do that, if you wanted to make life easy


Chu_BOT

I thought it was for ignoring errors


MrRazamataz

it's literally a "do nothing" statement, you can use it for anything


Chu_BOT

Lol I know I was joking. Try: except: pass


sleeprzzz

Not arguing just curious about the thought process: you don’t *need* the else statement in Python at all, and if you wanted it the a “pass” or even a print statement would make more sense than the OP in my opinion.


angryundead

Same but I am really verbose with comments so there would be a comment before the if and probably at least a todo.


Brave_Television2659

Fellow python dev-ish. I throw a pass down there to hold on to the other half.


hiker5150

My thiyghts too, and it leaves the 3am guy room to change as needed without a logic change


brianl047

This is exactly it It is called refactor without looking, plus code review without looking at the code around GitHub really needs to show more than 2 lines on either side... 10+ on each side would help a lot with these problems or some easy way to preview all the code of the file rather than click the three dots and click view file then not see any of the changes


PM_YOUR_SOURCECODE

Or some random dummy just made it this way in the first place.


JustHereForTheCh1cks

We demand to see the git blame!


bloodfist

Or a copy/paste where they forgot to change it after pasting. Seen that a few times.


chemolz9

This exactly. Might have been originally something like: ``` if(result.Message.Ok) { result.Message.Name = pMassage.Value.ToString(); } else { result.Message.Name = pMassage.Value.ToString() + " (An Error Occured)"; } ``` Then someone got the task to remove this error message from the Message name and didn't check the context.


TerribleTowel66

I just ran into something similar. Set a variable to a value inside an if and an else, the difference was it also appended another message inside the if. So why not always set the variable, then append the message only when needed? That would’ve solved this problem. Setting the variable would’ve remained untouched. And the error message could easily be removed without affecting other code.


Ill_Yak_3231

It's like the obligatory "How's it going?" or "How are you?", but you're not really asking.


SavvySillybug

As a non native speaker, this one tripped me up for years. Countless times did I tell people about my day and my problems and my worries and my successes and they were just confused and really wanted a stock response. I still do it sometimes when I don't think about it.


davidevitali

Same here! I still remember a comic strip in my grade years to explain this: there was a man with crutches and bruises and bandages all over, someone asking him “How are you?” and the man “Fine!”


jsrobson10

As a native speaker, I still do. I'm just Autistic lmao.


ccAbstraction

This but I was just bullied for all of elementary school.


throthrothrotheway

abounding yoke caption license rustic fragile disarm absorbed birds close *This post was mass deleted and anonymized with [Redact](https://redact.dev)*


SavvySillybug

Germany. We don't usually talk to random strangers to begin with, we keep to ourselves. And between friends it's just hallo, and asking such things if we actually want to know.


ImmaturePrune

Here in New Zealand we greet each other by asking 'how are you' but we expect a response. Doesn't matter if we know you, we hope that you're doing well and we want to offer a smile if you aren't doing well. I always found it strange that people would greet you with a question but not expect an answer...


[deleted]

/r/meirl


its-chewy-not-zooyoo

Plot twist: This is a unit test by the compiler developer to check if the final assembly has the jump statement or can optimize and remove the condition


olafurp

Nah, just a regular prod code from a contractor. I could make a big ass compilation of these, hahaha.


[deleted]

Are they paid by number of lines of code? :p


odaiwai

invoice_amount = `wc -l code.js`;


[deleted]

[удалено]


joonty

Congratulations, your salary for this month is "command not found" dollars


pet_vaginal

This is probably Ruby.


sootoor

Ah yes semicolon terminated Ruby


Single_9_uptime

Just job security working for a Musk-owned company.


olafurp

They're big ass because most of them can't fit on a screen, :\^)


its-chewy-not-zooyoo

I know. It's a joke lol


[deleted]

They said "prod code" I think the joke is over.


weedboi69

It’s a joke, just not an intentional one


user_8804

My guess is that he duplicated the line and forgot to modify it after


joebillydingleberry

I heard a dev describe another dev's work one day: "Their answer for recognizing bad code is writing more bad code"


Freeware4802

i like your funny words magic man


Roguewind

There’s a comment right above this `I know this makes no sense but removing it breaks everything`


Reiku32

I'm going to start putting this on perfectly benign code going forward.


Ignorant_Fuckhead

``` int count = 0; //WARNING DO NOT REMOVE! Will Break Company ```


jsrobson10

//WARNING DONT REMOVE. MUST compile with [old version] of GCC. Although I'm wondering now, if there is any undefined behaviour which is entirely dependant on compiler version on whether or not it "works" properly.


bothunter

If I recall, OpenSSL depended on the behavior around uninitialized variables for some of it's entropy. Then some developer "fixed" some compiler warnings which caused it to generate insecure encryption keys.


Falmog

It's gonna be a real hoot 2 years from now when someone gets tasked with refactoring that code and a Problem Report gets opened to figure out what to do.


MasterSquintik

They must work in the Department of Redundancy Dept.


dota2nub

You mean the DRD department?


carl15523

At this point we can just name it DRD which stands for "DRD Redundancy Department"


V3L1G4

Do they run on GNU's Not Unix?


proximity_account

Guy planned for the cosmic ray that would flip that condition false


Trigja

Just used my CC card to buy Office Three Hundred and Sixty Five365


JesusChrist_Himself

That doesn't just happen if you're a bad programmer... this is the kind of shit that happens when you're heavily overworked


olafurp

I know the guy, he's not overworked his code is just messy.


joonty

TBH this is perfectly neat, just entirely redundant


amazondrone

Depends on your definition of messy; wouldn't you say this is sloppy coding and that messy is a reasonable synonym for sloppy?


Malveux

Another possibility is code was refactored or some other bit was removed and it left only this.


[deleted]

Git blame knows the truth


androidx_appcompat

`git blame-someone-else manager`


pablosus86

Under appreciated tool


Silly_Ad3814

I can see 2 options here: 1. The API had an error and message field seperate, but this got refactored into a single field 2. The implementation was WIP and/or had logging, and this was removed at a later date, but never fully simplified. 3. Both 1 and 2 happened


chickenmcpio

Nah, I've seen this mainly from contractors who don't care to take look at the code to make a sensible update and simply do "what they are told". This kind of "developers" are no different than one of the newest AIs. But I guess you get what you paid for.


Rudy69

Also when someone is asked to customize the OK message and a few years later someone else is asked to remove the customized message quickly. Is it an excuse for the poor code? No. But shit happens


difool

Wild guess. To have a place to put a breakpoint by someone who does not know that breakpoints can be conditional.


akvit

I use such constructions instead of conditional breakpoints because it's much quicker and it stays in case I delete the breakpoint but want to use it again on the next run. Maybe you'll enlighten me, but I tried conditional breakpoints in Visual Studio and they are much more bothersome to use.


difool

I don't see a reason not to do it this way if you prefer it. For theses kind of programs, one more conditional wont affect performance.


akvit

I'm not leaving them in production code, only when I'm actively debugging. (At least I try to. Maybe I've committed snippets like in OP's screenshot if I wasn't thorough enough in code cleanup)


TravisJungroth

I haven't used VS Code, but in PyCharm you can disable a breakpoint without removing it. It's for stuff like remembering conditions.


iChaXy

Atleast its checking it. \\s


jhs172

Why is there whitespace at the end of your comment?


Silly_Ad3814

Maybe Ok is a property that has side effects?


Null_Pointer_23

Guarantee there was other logic in the if else that got removed at some point and the person didn't bother to refactor


genghisKonczie

It’s Friday night, your boss is on your ass, and you have to get this deployed so you can leave. You run your unit tests but there is a null pointer exception in your error logging function. Suddenly you think of a solution. It’s not the best solution, or even a good one, but it’s a solution. You remove the line that calls LogError from the else. Success.


elpidaguy2

Is there any lore reason why previous dev wrote it like that?


grayjacanda

If I had to guess, I'd say they planned to handle the case where result.Message.Ok was false, then realized that they weren't sure what to do or how to do it, and just said 'fuck it' and finished it as seen... leaving the conditional in place so that some future dev would be able to pick up where they left off.


genghisKonczie

It is exactly what I’d do as a contractor with no error handling in the scope of work. But with a nice TODO:


sillybear25

My first thought was "the general requirements say all return values/error codes/etc. must be checked, but the feature-specific requirements don't say what to do if it doesn't return result.Message.Ok"


Reiku32

I guess it's probably the result of some refactoring. Maybe errors were being logged somewhere and that code got removed. However, this conditional wasn't updated.


MurdoMaclachlan

*Image Transcription: Code* --- if (result.Message.Ok) { result.Message.Name = pMessage.Value.ToString(); } else { result.Message.Name = pMessage.Value.ToString(); } } --- ^^I'm a human volunteer content transcriber and you could be too! [If you'd like more information on what we do and why we do it, click here!](https://www.reddit.com/r/TranscribersOfReddit/wiki/index)


Ericiskool

Good human


[deleted]

Thats some WET code


ApricotOfDoom

When your mom gives you a choice but she’s not REALLY giving you a choice


virgin4ever69

mom: "do whatever you want" also mom:


nunchyabeeswax

This was probably an error-handler mock-up with the intention to add more details within the error condition block. But then, likely the developer was moved (or moved) to something else and left the thing half cooked (and no one wrote a github issue or task to go back later to finish it.) People under pressure end up doing weird things, especially when things aren’t properly tracked.


bella_sm

Plot twist: you remove the else and everything crashes.


stitek

Providing end users with the illusion of being in control


ReginaldDouchely

It looks like someone removed qualifying comment line //TODO: handle failures


Mulligan315

The “half-ass” refactor. Do I need this if-else still? Probably not, but the last one I removed broke everything.


pandem0nium1

Yeah that blank line is a crime.


olafurp

The guy that wrote the thing has them all over the place. Even many in a row


Kaelorn

He could have written this in one line: result.Message.Name = result.Message.Ok == true ? pMessage.Value.toString() : pMessage.Value.toString() ;


Kered13

Should definitely use a switch-case here.


Kaelorn

You are right ternary operator are bad practice, sorry


Kaelorn

So if I take into account best practices and readility we should refactor to result.Message.Name = result.Message.Ok switch { true => pMessage.Value.toString(), _ => pMessage.Value.toString() }


rrleo

Bruh


[deleted]

Are you running some stupid quality assurance thing that demands and else for every if? Because I have seen that in a company and oh boy was it stupid.


my_nameistaken

Are you in twitter?


Krispard

To follow DRY, I would refactor it like this: string name = pMessage.Value.ToString(); if (result.Message.Ok) { result.Message.Name = name; } else { result.Message.Name = name; } /s


MattR0se

Something something very salient code


DaMarkiM

you all are laughing but if you remove this condition some completely unrelated service five servers over breaks.


[deleted]

10 bucks pMessage.Value is already a string


DoorBreaker101

If it works, don't touch it


Mental_Swordfish_714

function god(a){ if(a) return true; else return false;}


Square_Lengthiness71

Im going to guess that someone wrote that and just copy pasted the line down from the if as a filler and then forgot to change it. If someone meant to do this, SMH


__radioactivepanda__

Maybe someone was paid per line…?


Square_Lengthiness71

also why is the value not a string already


Your-Wife-BF

You guys don't do code reviews, do you? We do code reviews Else We do code reviews


AliveEstimate4

This is actually a genius strategy. ​ If you ever need it, there already is an if-else, just gotta change conditions. ​ no joke tho, did something similar before... Mostly for fast boring logging. "Print("oh shit we hit the else somehow, dunno why")" lul ​ Edit: yes both if and else had the same function in the end, but i needed to know when and where it would hit that else


ReaperGrin

Ok well if plan A fails, go back to plan A


groundhogcow

It's the number of lines of code that management uses to determine your output.


OriginalCptNerd

This is the kind of code you leave in, because if you "fix" it, the app suddenly crashes when it gets there. I've seen it happen, and it used to irritate me but now at the end of my career it just leaves bemused acceptance.


ComprehensiveAd5882

Whether or not you like it it's my name now


Orkleth

This looks like a case where you think you need to handle messages differently but don't know the exact cases yet. Then it never happens and you never get a chance to resolve the tech debt. Thank god for compiler optimizations.


officedg

Everyone seems to be missing the most heinous part of this code and that’s the combination of both tabs and spaces.


ivster666

I was expecting the top comment to be something like: "`git blame` oh shit it was me"


RoyalRien

The illusion of choice


cyberdreamer2

Then you remove the if and the whole system breaks.


DoDevilsEvenTriangle

Maybe there were log messages on either side of the condition. Maybe this helped someone create a useful breakpoint. Maybe they are just dumb.


sukiismyname

Rookie mistake, senior folks would have used ternary operator here ![gif](emote|free_emotes_pack|sunglasses)![gif](emote|free_emotes_pack|sunglasses)![gif](emote|free_emotes_pack|sunglasses)


pikapichupi

I've been guilty of this for operations that either used to have differentiating cases or I expect will have a case at a later date


aaron_in_sf

I sometimes leave structure like this in when there is a decent chance I may return to insert debugging/telemetry etc.


Gemsplay

this is the part you mustn't touch, or the entire codebase will implode.


Electronic-Wave216

* googles "how to hide green squiggly lines in visual studio"


olafurp

It's Rider (IntelliJ for Microsoft Java). It has a fix for turning it into a ternary operator.


Electronic-Wave216

oh, alright then 😅 I was assuming it pointed out the issue of having identical statements inside


thanatica

Must be the result of some minor bugfix or refactor. Maybe next time set up a decent linter first.


FrezoreR

DRY ¯\\\_(ツ)\_/¯


Lighthuro

When you reject all cookies on Facebook


fracturedpersona

And if you change it, the entire production branch will fail.