MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/114thfx/just_in_case/
r/badcode • u/sspecZ • Feb 17 '23
24 comments sorted by
95
You can never be too sure
10 u/jarfil Feb 18 '23 edited Dec 02 '23 CENSORED
10
CENSORED
82
Lines like these exist just to confuse juniors. Assert.Dominance()
6 u/[deleted] Feb 18 '23 Assert.Dominance(string deltamales, int dominancelevel) 2 u/adamski234 Feb 18 '23 deltamalesAre those above sigmas or are sigmas still the most desirable? 3 u/[deleted] Feb 18 '23 delta males are lower than beta males (it's the person you're asserting dominance over) 2 u/badapplecider Mar 03 '23 And it's a good reference to deltatime and other variables about intervals.
6
Assert.Dominance(string deltamales, int dominancelevel)
2 u/adamski234 Feb 18 '23 deltamalesAre those above sigmas or are sigmas still the most desirable? 3 u/[deleted] Feb 18 '23 delta males are lower than beta males (it's the person you're asserting dominance over) 2 u/badapplecider Mar 03 '23 And it's a good reference to deltatime and other variables about intervals.
2
deltamales
Are those above sigmas or are sigmas still the most desirable?
3 u/[deleted] Feb 18 '23 delta males are lower than beta males (it's the person you're asserting dominance over) 2 u/badapplecider Mar 03 '23 And it's a good reference to deltatime and other variables about intervals.
3
delta males are lower than beta males (it's the person you're asserting dominance over)
2 u/badapplecider Mar 03 '23 And it's a good reference to deltatime and other variables about intervals.
And it's a good reference to deltatime and other variables about intervals.
deltatime
Might actually be ok in the right context. If the condition was quite complex and you want to make sure someone hasn't dicked with it without understanding it.
2 u/sspecZ Feb 17 '23 It was just comparing a veritable to an enum 14 u/ooodummy Feb 17 '23 Just do assert(existing_project_type == whatever) 13 u/dabombnl Feb 17 '23 Oh shit, didn't even notice it wasn't the same condition as the IF. Nevermind. Is totally worthless.
It was just comparing a veritable to an enum
14
Just do assert(existing_project_type == whatever)
13 u/dabombnl Feb 17 '23 Oh shit, didn't even notice it wasn't the same condition as the IF. Nevermind. Is totally worthless.
13
Oh shit, didn't even notice it wasn't the same condition as the IF. Nevermind. Is totally worthless.
33
Assert.AreEqual(number, 1);
changes all occurrences of number to 1 by search and replace
Assert.AreEqual(1,1);
3 u/Pragalbhv Feb 18 '23 Good human
Good human
31
Someone wanted to set a breakpoint when a particular condition was true, and forgot to remove the code when they were done.
5
Looks like a placeholder I would leave. But I always obfuscate mine so it's obvious it doesn't belong.
Assert.aretrue(true, !false)
Might be a placeholder.
4
Image Transcription: Code
[The first line of the following code is cut off in the image.]
if (existingProjectType == (int)Ei { Assert.AreEqual(1, 1); }
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!
Better safe than sorry
You CBA Beger trudy Assert.Pass()…
9 u/MineKemot Feb 17 '23 I think dictation service had a stroke…
9
I think dictation service had a stroke…
This is for sonarqube. It would complain if your test has no assertions. See this every day.
3 u/darkflame91 Feb 18 '23 Why would you have a test with no assertions? 1 u/ReplacementAcademic8 Feb 18 '23 edited Feb 18 '23 For sonarqube, there's a rule that requires some percentage of code coverage.
Why would you have a test with no assertions?
1 u/ReplacementAcademic8 Feb 18 '23 edited Feb 18 '23 For sonarqube, there's a rule that requires some percentage of code coverage.
1
For sonarqube, there's a rule that requires some percentage of code coverage.
We had tests like these in my last project, I took great pleasure in removing them for being stupid
95
u/domtriestocode public static Feb 17 '23
You can never be too sure
82
u/[deleted] Feb 17 '23
Lines like these exist just to confuse juniors. Assert.Dominance()
6
u/dabombnl Feb 17 '23
Might actually be ok in the right context. If the condition was quite complex and you want to make sure someone hasn't dicked with it without understanding it.
33
u/anton____ Feb 18 '23
Assert.AreEqual(number, 1);changes all occurrences of number to 1 by search and replace
Assert.AreEqual(1,1);31
u/CandyCrisis Feb 18 '23
Someone wanted to set a breakpoint when a particular condition was true, and forgot to remove the code when they were done.
5
u/IsntDoingScience Feb 18 '23
Looks like a placeholder I would leave. But I always obfuscate mine so it's obvious it doesn't belong.
Assert.aretrue(true, !false)
5
u/redgiftbox Feb 18 '23
Might be a placeholder.
4
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 18 '23
Image Transcription: Code
[The first line of the following code is cut off in the image.]
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!
3
u/Tom1380 Feb 18 '23
Better safe than sorry
3
u/MineKemot Feb 17 '23
You CBA Beger trudy Assert.Pass()…
2
u/ReplacementAcademic8 Feb 18 '23
This is for sonarqube. It would complain if your test has no assertions. See this every day.
1
u/beclops Feb 18 '23
We had tests like these in my last project, I took great pleasure in removing them for being stupid