ElkArte Community

Title: Change the coding guidelines
Post by: Joshua Dickerson on August 29, 2015, 11:45:01 pm
I think we should change the coding guidelines to always use brackets.

I will gladly do this but it will result in every file being changed. This might break mods so I don't want to do this without @Spuds and @emanuele agreeing to it. It would also mean that already submited PRs and commits already made would break.
Title: Re: Change the coding guidelines
Post by: Flavio93Zena on August 30, 2015, 12:51:58 am
Brackets... Where? In which ways? It can help newbies to understand, ya know? ;)
Title: Re: Change the coding guidelines
Post by: Joshua Dickerson on August 30, 2015, 01:08:12 am
Curly brackets { }

No offense but this is beyond the scope of newbie discussion
Title: Re: Change the coding guidelines
Post by: Flavio93Zena on August 30, 2015, 01:43:29 am
Yes but where should they be used and they aren't being used, is what gets me :P They should be widely used already...
Title: Re: Change the coding guidelines
Post by: Joshua Dickerson on August 30, 2015, 02:22:13 am
When I wrote the coding guidelines for SMF way back when there were some people that were concerned about the size of the files and I was stupid. So it was written that a one-line block shouldn't use curly brackets. Most of the conditional blocks are a single line so there's tons of cases of not using curly brackets.
Title: Re: Change the coding guidelines
Post by: Flavio93Zena on August 30, 2015, 02:25:24 am
Now everything makes sense, thanks :)

To be honest I have no idea what to reply, you are talking about PHP, I know, but there's mostly the same thing in css. I code a lot in css and I found myself coding in one line or using brackets and lines properly, I guess it's not just me being messy ;D
However, if you really want to cleanup all the code, I figure it won't happen before 2.0ish.
Title: Re: Change the coding guidelines
Post by: Joshua Dickerson on August 30, 2015, 02:40:06 am
Yeah, 2.0 is where I can break everything ;)
Title: Re: Change the coding guidelines
Post by: emanuele on August 30, 2015, 04:43:39 am
From time to time I already use brackets on one-line conditionals. O:-)
No objections, of course for 1.1 it would be kind of a mess, so 2.0 would be fine. :)
Title: Re: Change the coding guidelines
Post by: Flavio93Zena on August 30, 2015, 05:28:43 am
Lol, just spotted a bug while reading your reply. Gonna post soon.
Title: Re: Change the coding guidelines
Post by: Spuds on August 30, 2015, 08:07:40 am
Its fine with me as well ... although I don't tend to {} the pure one liners I can get used to it and TBH I added a lot of {} in 1.0   It also helps with most ide's which add them automatically anyway.
Title: Re: Change the coding guidelines
Post by: Joshua Dickerson on August 30, 2015, 01:24:16 pm
Quote from: Spuds – Its fine with me as well ... although I don't tend to {} the pure one liners I can get used to it and TBH I added a lot of {} in 1.0   It also helps with most ide's which add them automatically anyway.
Main reason is that every time I commit it gives me 200+ warnings/errors and I really don't want to go through the mess of changing the inspections.
Title: Re: Change the coding guidelines
Post by: Spuds on August 30, 2015, 04:06:54 pm
I like them since it makes it easier to add a debug line anywhere with ease and improves any code folding that I may want to do.

I know I tweaked the inspections (Settings->editor->code style->inspections such as don't complain when a docblock does not have an @return statement and use of the silence operator like on all those chmod's etc ... I don't recall the {} being in there but must be as well.