HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Codestyle
Hello, me again
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;
andif (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)
0
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").
My shop | About Me
Well timed! We just had our first developer meeting in many moons on Wednesday and settled on a new unified coding style we'll be publishing in the docs and also creating a CodeSniffer for checking it.
The full-time dev team is up to 6 now so it was time to solve a few issues. Every dev can use what IDE they want but PhpStorm has indeed become the de facto standard in the office over the last year.
Fair warning: it's going to get worse before it gets better because we're changing a lot of our conventions to better match other PHP projects.
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
@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.
I like neither of these things!
Oh well, what happens in the Garden stays in the Garden.
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.
I like the python style of class names in CamelCase and function/method names being snake_case.
grep is your friend.
@x00 http://cplus.about.com/od/learnc/ss/csharpclasses_5.htm
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.
@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)
Some of the guys in the office call it StegoaurusCase which is my new favorite.
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.
StegosaurusCase for
ClassDefinitions
,ExceptionNames
camelCase for
functionNames
,methodNames
,$variableNames
ELEPHANT_CASE for
GLOBAL_CONSTANTS
,CLASS_CONSTANTS
I was against 4 spaces initially, but I converted all my repos (they're all internal), and now its actually a lot better. NetBeans seems to just work better with 4 space indents, so life is actually a bit smoother.
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.
Vanilla Forums COO [GitHub, Twitter, About.me]
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.