HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Codestyle

lumiolumio New
edited May 2014 in Feedback

Hello, me again :smiley:

This is kind of critic but I don't mean it in a harsh way. For that (I guess it is) 7 days I'm working with Vanilla I'm quite happy how simple it is to handle.

But I also found a lot of disparity and mixtures of many code styles.
A little list:

  • Mixed indentations
  • Mixture of short and long conditions (if (condition): code; endif; and if (condition) { code; }) in the same file
  • One code line after an if-condition is sometimes not wrapped in braces.

How to fix this?
Using PHP CodeSniffer (phpcs) and an IDE or better Texteditor which makes a check of each file while coding.
PhpStorm is one of the better ones and it's even free for OpenSource projects.

I really encourage everyone to use this feature.

The only problem now is to find a global code style which everyone needs to use.
To check if the style is okay - we could use Jenkins for continues tests (which should be used anyway in combination with TDD)

«1

Comments

  • I agree this sucks. There are inconsistencies in the core install.

    On the other hand, I am sure this is because of how many people have touched the codebase and how long it has existed.

    I would be happy to submit a PR with consistent formatting in all the files (using NetBeans and spot checking all warnings), but the devs would still have to go through the compares with a fine tooth comb to make sure I didn't screw something up.

    This puts us in the awkward position of waiting for a large amount of work to be done that will not show any benefit at all. Perhaps in the long run, but definitely not in the short term.

    TDD is dead. Long live TDD!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • I think cleaning the old codebase should not be the primary goal but surely should be done when needed.

    But for new code TDD and a good Ruleset would be really nice. And that together with something like Jenkins (where developers should get a nice and friendly notification, that there are some ugly spots) - that would be a real win!

  • I would be quite happy if there were a method to run automated tests which everybody could use. I implemented my own framework rough one in the past, but I got too busy and I never managed to complete it (and it was completely reliant on a working installation of the Garden framework, as there would have been way too much stuff to "mock").

  • LincLinc Admin

    Spoilers: 4-space indents & camelCase are becoming the new law of the land.

  • Nice :) I'm not really happy with 4 spaces, but thats matter of tase ;)

  • LincLinc Admin

    @lumio I kinda feel the same way, but most things we compromised on pretty readily to reach an agreement faster.

    The only sticking point was whether opening braces go on a newline after class & function declarations - we had a small holy war over that. I will leave you in suspense how that one turned out for now. ;)

  • @Lincoln said:
    Spoilers: 4-space indents & camelCase are becoming the new law of the land.

    I like neither of these things!

    Oh well, what happens in the Garden stays in the Garden. :D

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • CamelCase!=camelBack

    4 space indent are pretty standard.

    grep is your friend.

  • x00x00 MVP
    edited May 2014

    I like the python style of class names in CamelCase and function/method names being snake_case.

    grep is your friend.

  • x00x00 MVP
    edited May 2014

    one of my first languages was pascal.

    I believe both are camel case, called lower and upper camel case, but nowadays, cammelBack and mixedCase is what I've heard used nowadays to differentiate the two. Definitely in Python CamelCase means upper camel case.

    grep is your friend.

  • what indent do you like two space, or tab?

    grep is your friend.

  • LincLinc Admin
    edited May 2014

    @x00 I prefer the 3-space indent we currently use, probably just because I'm used to it - been coding this way 4+ years now. I'd live with 2 or 4. A tab is the devil's work. :(

    (in all seriousness I find it really hard to care about this point; just pick one)

  • LincLinc Admin

    Some of the guys in the office call it StegoaurusCase which is my new favorite.

  • LincLinc Admin
    edited May 2014

    FYI, same-line condition/statements (like if(true) $x=1;) and no-braces conditions are going away too wherever they still exist.

    However, we will be exempting the view files from most rules. They will not be covered by the CodeSniffer rules. Everything gets funky in views, and we'll be vastly simplifying them as time goes on anyway.

  • I prefer 2 space indents and StegasaurusCase (sweet name).

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited May 2014

    Tim said:
    I will go to my grave in service of our Lord Brackos, protector of the same-line brackets, master of clear code, enemy of wasted newlines.

    I'm with you there. :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.