codeforbtv / live-music-venue-directory

Live Music Venue Directory
4 stars 6 forks source link

Code Indentation #33

Closed eflynn closed 11 years ago

eflynn commented 11 years ago

@afishnamedsquish @fringedgentian @billkeys @dimxasnewfrozen I have a tendency to want to get the small things out of the way first...

Well maybe not such a small thing. Should we use tabs or spaces for indenting? Personally, I prefer spaces. Two spaces, in particular, and barring that, four spaces. I don't like tabs.

As long as we can agree on the same thing and explicity note that, that's fine.

bradley-holt commented 11 years ago

If I can add my $0.02, I'd strongly encourage you to follow the PSR-2 Coding Style Guide (and thus the PSR-1 Basic Coding Standard and PSR-0 as well). These coding standards are used by many of the major frameworks and other libraries, bringing you consistency and interoperability benefits.

benglass commented 11 years ago

@bradley-holt I think that's a great idea, why not rely on an existing standard.

That being said none of the code really conforms to this right now so we will need to convert it over (mainly its an indentation thing since we don't have much PHP code at this point and what we have needs a rewrite). The gist of PSR for indentation is 4 spaces I believe.

PSR is specifically for PHP although we can apply to tab vs. spaces to javascript as well. For the javascript I'd like to adopt the Air BNB javascript coding guidelines

@foobarman do you have a recommendation on converting stuff over like your magic .gitattributes trick? I have used the php code sniffer tool for this before but not extensively.

https://github.com/airbnb/javascript

eflynn commented 11 years ago

@afishnamedsquish Recommendation? Use emacs ;)

I suppose gnu indent might work too, but I've never tried it. The emacs modes for JS and PHP should do a good job.

The text=auto attribute trick only works for new files. Existing files have to be recommitted. I did that part so it's not an issue anymore.

eflynn commented 11 years ago

How does Git know what a text file looks like? Simple, it checks the first 8000 bytes of a file, and if that doesn't contain a null then it's text. You can specify explicitly in .gitattributes like this:

*.txt           text
*.js            text
*.php           text
*.jpg           -text
benglass commented 11 years ago

Didn't meant to close the issue. I guess referencing an issue in a merge commit message closes the issue?

I converted the PHP code to PSR-2, which includes 4 spaces for indentation.

I ended up using the PHP Code Standards Fixer

 php-cs-fixer fix live-music-venue-directory/ --level=psr2