Skip to main content
Topic: Change the coding guidelines (Read 2765 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Change the coding guidelines

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.

Re: Change the coding guidelines

Reply #1

Brackets... Where? In which ways? It can help newbies to understand, ya know? ;)
~ SimplePortal Support Team ~

Re: Change the coding guidelines

Reply #2

Curly brackets { }

No offense but this is beyond the scope of newbie discussion

Re: Change the coding guidelines

Reply #3

Yes but where should they be used and they aren't being used, is what gets me :P They should be widely used already...
~ SimplePortal Support Team ~

Re: Change the coding guidelines

Reply #4

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.

Re: Change the coding guidelines

Reply #5

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.
~ SimplePortal Support Team ~

Re: Change the coding guidelines

Reply #6

Yeah, 2.0 is where I can break everything ;)

Re: Change the coding guidelines

Reply #7

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. :)
Bugs creator.
Features destroyer.
Template killer.

Re: Change the coding guidelines

Reply #8

Lol, just spotted a bug while reading your reply. Gonna post soon.
~ SimplePortal Support Team ~

Re: Change the coding guidelines

Reply #9

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.

Re: Change the coding guidelines

Reply #10

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.

Re: Change the coding guidelines

Reply #11

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.