Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Woke Mind Virus
Aug 22, 2005

CPColin posted:

Reject it because it mixes tabs and spaces.

that was me trying to sanitize it for posts on public forums cause this one is worth it

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

synapse posted:

I just got a code review request and let's just say I don't exactly know what to do with this one. I am a junior developer relative to this man.

code:
#if DEBUG
        public static string Testing_BlockThreadAfterClearingValues;
        public static string Testing_BlockThreadBeforeProperty1ValueReturn;
        public static string Testing_BlockThreadBeforeProperty2ValueReturn;
        public static string Testing_BlockThreadBeforeProperty3ValueReturn;
#endif

#if DEBUG
            void LockThread(ref string threadName)
            {
                while (!string.IsNullOrEmpty(threadName) && threadName == Thread.CurrentThread.Name)
                {
                    Thread.Sleep(100);
                }
            }
#endif

            internal string Property1
            {
                get
                {
                    lock (syncLock)
                    {
                        EnsureConfigured();

#if DEBUG
                        LockThread(ref Testing_BlockThreadBeforeProperty1ValueReturn);
#endif

                        return property1;
                    }
                }
            }
            internal string Property2
            {
                get
                {
                    lock (syncLock)
                    {
                        EnsureConfigured();

#if DEBUG
                        LockThread(ref Testing_BlockThreadBeforeProperty2ValueReturn);
#endif

                        return property2;
                    }
                }
            }
            internal string Property3
            {
                get
                {
                    lock (syncLock)
                    {
                        EnsureConfigured();

#if DEBUG
                        LockThread(ref Testing_BlockThreadBeforeProperty3ValueReturn);
#endif
                        return property3;
                    }
                }
            }

            public void TestPropertiesAreThreadSafe()
		{
			SetupForThreadSageTesting();

			var property1WhenBlocked = string.Empty;
			var property1Current = "Pending...";

			var property2WhenBlocked = string.Empty;
			var property2Current = "Pending...";

			var property3WhenBlocked = string.Empty;
			var property3Current = "Pending...";

			using (var adminConnection = Db.NewAdminConnection())
			{
                    var reloadingThread = new Thread(new ThreadStart(() =>
                    {
                        using (Db.DisposableActionForDbConnection())
                        {
                            TestConfig.EnsureData();
                        }
                    }));
                    reloadingThread.Priority = ThreadPriority.Lowest;
                    reloadingThread.Name = "Reloading";
                    Testing_BlockThreadAfterClearingValues = reloadingThread.Name;

                    var readingProperty1Thread = new Thread(new ThreadStart(() =>
                    {
                        using (Db.DisposableActionForDbConnection())
                        {
                            property1Current = TestConfig.Property1;
                        }
                    }));
                    readingProperty1Thread.Priority = ThreadPriority.Lowest;
                    readingProperty1Thread.Name = "Reading Property1";
                    Testing_BlockThreadBeforeProperty1ValueReturn = readingProperty1Thread.Name;

                    var readingProperty2Thread = new Thread(new ThreadStart(() =>
                    {
                        using (Db.DisposableActionForDbConnection())
                        {
                            property2Current = TestConfig.Property2;
                        }
                    }));
                    readingProperty2Thread.Priority = ThreadPriority.Lowest;
                    readingProperty2Thread.Name = "Reading Property2";
                    Testing_BlockThreadBeforeProperty2ValueReturn = readingProperty2Thread.Name;

		var readingProperty3Thread = new Thread(new ThreadStart(() =>
		{
			using (Db.DisposableActionForDbConnection())
			{
				property3 = TestConfig.Property3;
			}
		}));
		readingProperty3Thread.Priority = ThreadPriority.Lowest;
		readingProperty3Thread.Name = "Reading Property 3";
		Testing_BlockThreadBeforeProperty3Return = readingProperty3Thread.Name;

                    try
                    {
                        readingProperty1Thread.Start();
                        Thread.Sleep(200);
                        readingProperty2.Start();
                        Thread.Sleep(200);
                        readingProperty3.Start();
                        Thread.Sleep(200);
                        reloadingThread.Start();
                        Thread.Sleep(200);

                        Testing_BlockThreadBeforeProperty1ValueReturn = string.Empty;
                        Thread.Sleep(200);
                        Testing_BlockThreadBeforeProperty2ValueReturn = string.Empty;
                        Thread.Sleep(200);
                        Testing_BlockThreadBeforeProperty3lueReturn = string.Empty;
                        Thread.Sleep(200);
                        property1WHenBlocked = property1CUrrent;
                        property2WhenBLocked = property2Current;
                        propert3WhenBlocked = property3Current;
                    }
                    finally
                    {
                        readingProperty1Thread.Join();
                        readingPRoperty2Thread.Join();
                        readingProeprty3Thread.Join();
                        Testing_BlockThreadAfterClearingValues = string.Empty;
                        reloadingThread.Join();
                    }
		AssertEquals("Property1 reading thread should block configuration loading thread and get correct Property1 code.", "Property1Blocked", property1WhenBlocked);
		AssertEquals("Property1 reading thread should get the correct Property1 code.", "Property1", property1WhenCurrent);

		AssertEquals("Property2 reading thread should block configuration loading thread and get correct Property2.", "Property2Blocked", property2WhenBlocked);
		AssertEquals("Property2 reading thread should get the correct name.", "Property2", property2Current);

		AssertEquals("Property3 reading thread should block configuration loading thread and get correct Property3.", "Property3Blocked", homePageWhenBlocked);
		AssertEquals("Property3 reading thread should get the correct Property3.", "Property3", property3Current);
	}
}

Just because you write a test to figure something out about the how the language works doesn't necessarily mean it should be part of the unit test suite for all time, especially if it sleeps for seconds...

FlapYoJacks
Feb 12, 2009

Hargrimm posted:

How fuckin big is that project for that much tech debt to be an A rating?

That was the first scan, so it’s a baseline.

boo_radley posted:

(Slides large stack of chips to "npm dependencies", rolls the dice)

Spatial posted:

I've seen plenty of codebases where people shamelessly copied and pasted huge chunks of code around.

Which then slowly mutated with slight differences, of course

This, and:

boo_radley posted:

(Slides large stack of chips to "npm dependencies", rolls the dice)

This

iospace
Jan 19, 2038


CPColin posted:

Reject it because it mixes tabs and spaces.

Spaces for life

redleader
Aug 18, 2005

Engage according to operational parameters

iospace posted:

Spaces for life

please don't start this again

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

redleader posted:

please don't start this again

Sounds like you need a




Safe space












(I'm sorry)

iospace
Jan 19, 2038


jit bull transpile posted:

Sounds like you need a




Safe (io)space












(I'm sorry)

I fixed that :v:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Vertical tabs and newlines: the only valid whitespace™

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Is caring a lot about white space a legitimate reason to call someone a nazi?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I mean it’s basically the definition!

Nude
Nov 16, 2014

I have no idea what I'm doing.

jit bull transpile posted:

Sounds like you need a




Safe space












(I'm sorry)

Hey I can get you a safe space no problem, and if they ask for money you can



put it on my tab









(I'm sorry too)

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

iospace posted:

Spaces for life

I really don't give a toss whether a codebase uses spaces or tabs, but a pet peeve I have with my current place is that there's no rule on which it is. So we end up with loads of files that are a mishmash of tab-indented and space-indented lines, because one person's VS is set up to use spaces and another person's is set up for tabs. I would bring it up to someone, but a previous foray in that direction gave me the impression that complaining about it would be seen as "making a fuss about tabs/spaces", i.e. that advocating for consistency would not be distinguished from advocating for one over the other. So I don't bring it up. I mean, it's a very minor thing, but it annoys me because it feels untidy.

(there is a company-wide policy that defines how many spaces a tab must be, so it doesn't affect the appearance of files on different machines.)

Magissima
Apr 15, 2013

I'd like to introduce you to some of the most special of our rocks and minerals.
Soiled Meat
At some point my company switched from tabs (or not having a policy) to spaces but just left all the tabs in place, so in older files you can use the distinct strata of tabs and spaces to tell which code is new and which code hasn't been touched since the 2000s

FlapYoJacks
Feb 12, 2009
It's just a find and replace to go from one to the other. :psyduck:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ratbert90 posted:

It's just a find and replace to go from one to the other. :psyduck:

... five weeks pass ...

“Hey ratbert weren’t you the one heading up our code reformatting initiative? Whatever happened to that?”

MononcQc
May 29, 2007

ratbert90 posted:

It's just a find and replace to go from one to the other. :psyduck:

I sometimes contribute to the Erlang standard library and it works that way for them. They basically have some tooling that handles blaming and diffs and don’t want indentation change to have an impact on file history when inspecting code.

So you are allowed to reindent code, but only if you are actively working on that bit.

EssOEss
Oct 23, 2006
128-bit approved
I used to use tabs for reasons but goddamn Visual Studio kept resetting my settings every 3 months, so eventually I gave up and said gently caress it, I'll use the defaults (spaces). This is how the tabs and spaces war is won.

TheBlackVegetable
Oct 29, 2006

MononcQc posted:

I sometimes contribute to the Erlang standard library and it works that way for them. They basically have some tooling that handles blaming and diffs and don’t want indentation change to have an impact on file history when inspecting code.

So you are allowed to reindent code, but only if you are actively working on that bit.

This to me is the most sensible solution. That or have a pre-commit that reformats (though I've never tried it). Tabs vs spaces is just bike shedding time waster (especially since they format their code all wrong, with tabs)

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


We settled on a standard style at work. I'm not wild about it, but I like having a style much better than I like having every file having a mix of styles, some of which might not be found anywhere else.

If you're using git, you can set up the formatter to run as a pre-commit hook, so you can write whatever you want and it goes in as the correct format.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Our blame tools ignore changesets that are marked as purely reformatting/cleanup, which seems like a way better solution than banning people from making cleanup changes.

redleader
Aug 18, 2005

Engage according to operational parameters

EssOEss posted:

gently caress it, I'll use the defaults (spaces)

This is the correct response whereever possible.

Note that for any people using VS2017: you can enforce a single style on a project using VS's editorconfig extensions.

FlapYoJacks
Feb 12, 2009
I used to be a huge spaces over tabs guy.
As I got older I stopped caring so much what the code formatting looked like, just so long as it was all consistent.

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED
The real argument is relative vs absolute indentation. And sometimes you need both :getin:

Pie Colony fucked around with this message at 23:48 on Nov 4, 2018

Absurd Alhazred
Mar 27, 2010

by Athanatos
Just go whole hogpython and make indentation part of the syntax of your language! :v:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
The real argument is :backtowork:

xtal
Jan 9, 2011

by Fluffdaddy

Jabor posted:

Our blame tools ignore changesets that are marked as purely reformatting/cleanup, which seems like a way better solution than banning people from making cleanup changes.

Try that in a language with significant whitespace!

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

xtal posted:

Try that in a language with significant whitespace!

It seems like that doesn't affect anything? Deciding which changes should be marked as "cleanup" is a human problem, not a technical one.

redleader
Aug 18, 2005

Engage according to operational parameters

CPColin posted:

Reject it because it mixes tabs and spaces.

iospace posted:

Spaces for life


Look at what you've done. Are you proud?

iospace
Jan 19, 2038


redleader posted:

Look at what you've done. Are you proud?

Very!

CPColin
Sep 9, 2003

Big ol' smile.

redleader posted:

Look at what you've done. Are you proud?

Hey I didn't take a stand on which was better; I just said they shouldn't be mixed!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
This subforum needs a CoC so we can do some call and response at meetups.

When I say CoC you say CoC
CoC (CoC)
CoC (CoC)

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Absurd Alhazred posted:

He's absolutely serious and really saddened that people think it's a joke:


I don't know, I think a code of conduct that says "you need to be this Christian to comply" is messed up, and "well, actually, you don't have to comply by all of it" is a lovely attitude towards a code of conduct.

Argh the Arabic letter "N" makes my chud-sense tingle (ISIS is said to paint that letter - for "Nazarene" - on the houses of Christians to mark them for ethnic cleansing. A very common "virtue signal" for conservatives on Twitter and a huge red flag)

hackbunny fucked around with this message at 18:21 on Nov 5, 2018

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

pokeyman posted:

This subforum needs a CoC so we can do some call and response at meetups.

When I say CoC you say CoC
CoC (CoC)
CoC (CoC)

Yeah, you know me!

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

EssOEss posted:

I used to use tabs for reasons but goddamn Visual Studio kept resetting my settings every 3 months, so eventually I gave up and said gently caress it, I'll use the defaults (spaces). This is how the tabs and spaces war is won.

Embrace. Indent. Extinguish.

feedmegin
Jul 30, 2008

Magissima posted:

At some point my company switched from tabs (or not having a policy) to spaces but just left all the tabs in place, so in older files you can use the distinct strata of tabs and spaces to tell which code is new and which code hasn't been touched since the 2000s

Lol if ur code base doesn't go back to the late 80s :getin:

JawnV6
Jul 4, 2004

So hot ...

feedmegin posted:

Lol if ur code base doesn't go back to the late 80s :getin:

Scars from multiple VCS migrations. Files that it's easier to build new parsers than to represent any other way. Comments that stylistically evolve from Jargon file to XKCD to HN.

General Emergency
Apr 2, 2009

Can we talk?
The true horror are languages that care about your tabs and spaces (you know the one).

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I can’t think of a language that truly never cares about whitespace. Brainfuck?

Sereri
Sep 30, 2008

awwwrigami

comedy option

Adbot
ADBOT LOVES YOU

Absurd Alhazred
Mar 27, 2010

by Athanatos

Oh, is that the language Gab is written in?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply