this post was submitted on 09 Feb 2024
878 points (100.0% liked)

Programmer Humor

24426 readers
338 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 125 points 1 year ago (4 children)

This wouldn't pass PR review and automated tests, unless they were a senior dev and used elevated privileges to mess with things behind the scenes.

[–] [email protected] 174 points 1 year ago (1 children)

It's bold to assume those exist. Maybe there's a reason the coworker left

[–] [email protected] 112 points 1 year ago (1 children)

rand() will be infrequent < 10 (at least ten in 2^15 times, if not exponentially more), so automated tests are likely to pass. If they don't, they're likely to pass on the second try, and then everyone shrugs and continues. If it's buried in 500 other lines, then it's likely the code reviewer will give it all a quick scan and say "it's fine". It's the three line diffs that get lots of scrutiny.

In other words, you seem to have a lot more faith in the process than I do.

[–] [email protected] 27 points 1 year ago (1 children)

rand will be called every time true is used, which could be hundreds of times for all we know

[–] [email protected] 26 points 1 year ago

If it's a 16-bit integer platform, it might hit every once in a while.

If it's a 32-bit integer platform, it'll hit very rarely.

If it's a 64-bit integer platform, someone would have to do the math with some reasonable assumptions, but I wouldn't be surprised if it would never hit before the universe becomes nothing but black holes.

[–] [email protected] 63 points 1 year ago* (last edited 1 year ago) (3 children)

Write a 5 line PR and receive 5 comments. Write a 500 line PR and receive no comments.

[–] [email protected] 10 points 1 year ago

Attn: security team

Hi,

I think someone on Lemmy has hacked into every work environment I've ever coded in

[–] [email protected] 2 points 1 year ago

It works on my machine, most of the time.

[–] [email protected] 18 points 1 year ago

you'd be surprised what slips through review